summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilippe Roland2014-01-27 10:41:51 (EST)
committerPhilippe Roland2014-01-27 10:41:51 (EST)
commit683979844cf4e169dcb2521a0e2a779f89467f81 (patch)
tree824506b8afdbe95545a478a0793381f7d8ff59da
parent55135c9acd1d1013c0f77b1c10c75ce43dee26c0 (diff)
downloadorg.eclipse.papyrus-683979844cf4e169dcb2521a0e2a779f89467f81.zip
org.eclipse.papyrus-683979844cf4e169dcb2521a0e2a779f89467f81.tar.gz
org.eclipse.papyrus-683979844cf4e169dcb2521a0e2a779f89467f81.tar.bz2
Bug 425560 - [Collaborative] Migrate collaborative mode from Indigo to
Luna Backport to Luna
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.classpath7
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.gitignore3
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.options2
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.project28
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/META-INF/MANIFEST.MF24
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/about.html28
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/build.properties6
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/plugin.xml14
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/pom.xml26
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/AbstractExtendedURIBuilderForFile.java76
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/Activator.java62
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/CollabResourceSelector.java100
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/SVNCollabFactory.java151
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/AbstractSVNCollab.java67
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/SVNLocker.java104
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/SVNUnlocker.java107
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/tracing/ITracingConstant.java39
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/tracing/Tracer.java108
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/CommitActionUtilityWithProperties.java63
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/SVNUtils.java104
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/SetPropertyActionNow.java198
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/AbstractSVNVersionController.java86
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNCommitter.java120
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNReverter.java76
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNUpdater.java186
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNWorkOnModifiedFile.java85
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.classpath7
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.gitignore4
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.project28
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/META-INF/MANIFEST.MF30
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/about.html28
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/build.properties7
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/CreateCollabPartition_16x16.pngbin0 -> 468 bytes
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/CreateCollabPartition_64x64.pngbin0 -> 1055 bytes
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/PartialLock_16x16.pngbin0 -> 332 bytes
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/ShowPartition_16x16.pngbin0 -> 299 bytes
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/ShowPartition_64x64.pngbin0 -> 737 bytes
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/plugin.xml63
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/pom.xml26
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabCustomization.uiCustom11
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabFacet.facetSet14
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabQueries.querySet12
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/Activator.java81
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/commands/AddFileToCollabSVN.java147
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/commands/SaveCommand.java62
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/control/SVNControlModeParticipant.java133
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/handler/SVNCollabControlCommandHandler.java96
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/handler/ShowModelPartitionHandler.java47
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/queries/IsCollabQuery.java70
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/queries/IsPartialyLocked.java70
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/ui/CreateCollabModelFragmentDialog.java373
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/ui/IconsPath.java22
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.classpath7
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.gitignore3
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.project28
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/META-INF/MANIFEST.MF36
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/about.html28
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/build.properties6
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/TeamIcon.pngbin0 -> 726 bytes
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/commit.gifbin0 -> 222 bytes
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/lock.gifbin0 -> 334 bytes
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/revert.gifbin0 -> 150 bytes
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/unlock.gifbin0 -> 323 bytes
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/update.gifbin0 -> 230 bytes
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/plugin.xml125
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/pom.xml26
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/Activator.java64
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/IsCollabPropertyTest.java64
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/MatchingURIObject.java79
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/RefreshHelper.java182
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/security/CollabReadOnlyHandler.java95
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/security/PreCommitReadOnlyHandler.java141
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/AbstractResourceBaseStrategy.java43
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/PapyrusCurrentResource.java61
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/PapyrusSelectionAllContent.java83
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/ICollabColors.java20
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/AbstractCollabHandler.java55
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/CommitHandler.java154
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/LockAction.java163
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/RevertHandler.java140
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/UnlockAction.java179
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/UpdateHandler.java122
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/dialogs/CommitDialog.java135
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/dialogs/PreviewDialog.java270
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/items/LockStrategyItemProvider.java74
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/items/UnlockStrategyItemProvider.java73
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/providers/ExtensivePartitionNameLabelProvider.java226
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/utils/PapyrusResourceUtils.java30
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/utils/UIUtils.java307
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.classpath7
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.gitignore3
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.project28
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/META-INF/MANIFEST.MF25
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/about.html28
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/build.properties7
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/plugin.properties4
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/plugin.xml6
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/pom.xml26
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/schema/collaborative.exsd151
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/Activator.java64
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ExtendedURI.java175
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ICollabFactory.java33
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ICollaborativeManager.java120
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/IExtendedURI.java43
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/impl/CollaborativeManager.java290
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/AbstractExtendedURIBuilder.java162
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/ICollabParticipant.java20
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/IExtendedURISuperSet.java46
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/locker/ILocker.java42
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/locker/IUnlocker.java42
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/ICommitter.java40
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IReverter.java33
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IUpdater.java89
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IWorkOnModifiedElementParticipant.java38
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/CollabStatus.java94
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/LogHelper.java162
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/copy/CollabStatus.java94
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/copy/LogHelper.java162
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/strategy/AbstractLockingStrategy.java34
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/strategy/ILockingStrategy.java96
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/AbstractRunnableWithProgressWithResult.java33
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/CollabFunctionsFactory.java112
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/CollabUtils.java46
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ExtendedURIUtil.java62
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/IRunnableWithProgressWithResult.java32
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ModelsUtil.java354
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ResourceUtils.java83
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/URIUtils.java246
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/EObjectToExtendedURI.java63
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToEObjects.java66
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToIResource.java70
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToURI.java34
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/IFileToFile.java41
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/IResourceToExtendedURI.java61
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ResourceToIFile.java62
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ResourceToURI.java61
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/URIToExtendedURI.java58
-rw-r--r--extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/URIToExtendedURIWithContainment.java62
142 files changed, 9961 insertions, 0 deletions
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.classpath b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.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/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.gitignore b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.gitignore
new file mode 100644
index 0000000..19af0f1
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.gitignore
@@ -0,0 +1,3 @@
+*.class
+*.jar
+/target \ No newline at end of file
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.options b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.options
new file mode 100644
index 0000000..963a469
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.options
@@ -0,0 +1,2 @@
+org.eclipse.papyrus.team.collaborative.connector.svn/debug=true
+org.eclipse.papyrus.team.collaborative.connector.svn/debug/commit=true
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.project b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.project
new file mode 100644
index 0000000..2f1c7d8
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.team.collaborative.connector.svn</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/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.settings/org.eclipse.jdt.core.prefs b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..6bb8136
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.objectteams.otdt.compiler.option.pure_java=enabled
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/META-INF/MANIFEST.MF b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..255d9a0
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Svn Connector
+Bundle-SymbolicName: org.eclipse.papyrus.team.collaborative.connector.svn;singleton:=true
+Bundle-Version: 1.7.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.team.collaborative.connector.svn.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.team.collaborative,
+ org.eclipse.emf.ecore,
+ com.google.guava,
+ org.eclipse.core.resources,
+ org.eclipse.emf.workspace,
+ org.eclipse.team.core,
+ org.eclipse.team.ui,
+ org.eclipse.team.svn.core,
+ org.eclipse.team.svn.ui
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.eclipse.papyrus.team.collaborative.connector.svn,
+ org.eclipse.papyrus.team.collaborative.connector.svn.tracing,
+ org.eclipse.papyrus.team.collaborative.connector.svn.utils,
+ org.eclipse.papyrus.team.collaborative.connector.svn.versioncontroller
+Bundle-Vendor: Atos
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/about.html b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/about.html
new file mode 100644
index 0000000..d35d5ae
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/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>June 5, 2007</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>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/build.properties b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/build.properties
new file mode 100644
index 0000000..060a9e9
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ .options
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/plugin.xml b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/plugin.xml
new file mode 100644
index 0000000..faea148
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/plugin.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.team.collaborative.collaborative">
+ <ParticipantFactory
+ id="org.eclipse.papyrus.team.collaborative.connector.svn"
+ impl="org.eclipse.papyrus.team.collaborative.connector.svn.SVNCollabFactory"
+ priority="10">
+ </ParticipantFactory>
+ </extension>
+
+
+</plugin>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/pom.xml b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/pom.xml
new file mode 100644
index 0000000..3a58d6b
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/pom.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2013 Atos.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Arthur Daussy <a href="mailto:arthur.daussy@atos.net"> - initial API and implementation
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <relativePath>../../../Releng/org.topcased.fast.tycho.master/pom.xml</relativePath>
+ <groupId>org.topcased.fast</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.7.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.papyrus.team.collaborative.connector.svn</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>Svn Connector</name>
+</project>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/AbstractExtendedURIBuilderForFile.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/AbstractExtendedURIBuilderForFile.java
new file mode 100644
index 0000000..38aea3c
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/AbstractExtendedURIBuilderForFile.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.participants.AbstractExtendedURIBuilder;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+
+
+/**
+ * Extends {@link AbstractExtendedURIBuilder} adding some utilitary method to manipulate files
+ *
+ * @author adaussy
+ *
+ */
+public abstract class AbstractExtendedURIBuilderForFile extends AbstractExtendedURIBuilder {
+
+ public AbstractExtendedURIBuilderForFile(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ super(uris, resourceSet);
+ }
+
+ /**
+ * Transform resource to {@link IFile}
+ *
+ * @param r
+ * the r
+ * @return the i file
+ */
+ protected IFile toIFile(Resource r) {
+ if(r != null) {
+ return TO_FILE_FUNCTION.apply(r);
+ }
+ return null;
+ }
+
+ /** The Constant TO_FILE_FUNCTION. */
+ protected static final Function<Resource, IFile> TO_FILE_FUNCTION = new Function<Resource, IFile>() {
+
+ @Override
+ public IFile apply(Resource from) {
+
+ return WorkspaceSynchronizer.getFile(from);
+ }
+ };
+
+ /**
+ * Gets the target files.
+ *
+ * @param resourcesToLock
+ * the resources to lock
+ * @return the target files
+ */
+ protected static IFile[] getTargetFiles(Collection<Resource> resourcesToLock) {
+ Collection<IFile> iResourcesToLock = Collections2.transform(resourcesToLock, TO_FILE_FUNCTION);
+ return iResourcesToLock.toArray(new IFile[iResourcesToLock.size()]);
+ }
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/Activator.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/Activator.java
new file mode 100644
index 0000000..a2a850b
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/Activator.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn;
+
+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.team.collaborative.connector.svn"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/CollabResourceSelector.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/CollabResourceSelector.java
new file mode 100644
index 0000000..696b11e
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/CollabResourceSelector.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.svn.core.IStateFilter;
+import org.eclipse.team.svn.core.extension.CoreExtensionsManager;
+import org.eclipse.team.svn.core.operation.AbstractActionOperation;
+import org.eclipse.team.svn.core.operation.IActionOperation;
+import org.eclipse.team.svn.core.utility.FileUtility;
+import org.eclipse.team.svn.ui.SVNUIMessages;
+import org.eclipse.team.svn.ui.action.IResourceSelector;
+import org.eclipse.team.svn.ui.utility.UIMonitorUtility;
+
+
+/**
+ * The Class CollabResourceSelector.
+ * Implementation of {@link IResourceSelector} for use in collaboration
+ */
+public class CollabResourceSelector implements IResourceSelector {
+
+ /** The resources. */
+ private IResource[] resources;
+
+ /** The shell. */
+ private Shell shell;
+
+ /**
+ * Instantiates a new collab resource selector.
+ *
+ * @param resources
+ * the resources
+ * @param shell
+ * the shell
+ */
+ public CollabResourceSelector(IResource[] resources, Shell shell) {
+ super();
+ this.resources = resources;
+ this.shell = shell;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.svn.ui.action.IRecursiveResourceSelector#getSelectedResourcesRecursive(org.eclipse.team.svn.core.IStateFilter)
+ */
+ public IResource[] getSelectedResourcesRecursive(IStateFilter filter) {
+ return this.getSelectedResourcesRecursive(filter, IResource.DEPTH_INFINITE);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.svn.ui.action.IRecursiveResourceSelector#getSelectedResourcesRecursive(org.eclipse.team.svn.core.IStateFilter, int)
+ */
+ public IResource[] getSelectedResourcesRecursive(final IStateFilter filter, final int depth) {
+ final IResource[][] retVal = new IResource[][]{ new IResource[0] };
+ IActionOperation op = new AbstractActionOperation("Operation_CollectingResources", SVNUIMessages.class) { //$NON-NLS-1$
+
+ protected void runImpl(IProgressMonitor monitor) throws Exception {
+ retVal[0] = FileUtility.getResourcesRecursive(getSelectedResources(), filter, depth, this, monitor);
+ }
+ };
+ if(CoreExtensionsManager.instance().getOptionProvider().isSVNCacheEnabled()) {
+ UIMonitorUtility.doTaskBusyDefault(op);
+ } else {
+ UIMonitorUtility.doTaskNowDefault(shell, op, true);
+ }
+ return retVal[0];
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.svn.ui.action.IPlainResourceSelector#getSelectedResources()
+ */
+ public IResource[] getSelectedResources() {
+ return resources;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.svn.ui.action.IPlainResourceSelector#getSelectedResources(org.eclipse.team.svn.core.IStateFilter)
+ */
+ public IResource[] getSelectedResources(IStateFilter filter) {
+ return FileUtility.getResourcesRecursive(this.getSelectedResources(), filter, IResource.DEPTH_ZERO);
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/SVNCollabFactory.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/SVNCollabFactory.java
new file mode 100644
index 0000000..eb27a15
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/SVNCollabFactory.java
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ * Philippe Roland (Atos) philippe.roland@atos.net - added workaround for eclipse bug 385394
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.ICollabFactory;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.connector.svn.locker.SVNLocker;
+import org.eclipse.papyrus.team.collaborative.connector.svn.locker.SVNUnlocker;
+import org.eclipse.papyrus.team.collaborative.connector.svn.versioncontroller.SVNCommitter;
+import org.eclipse.papyrus.team.collaborative.connector.svn.versioncontroller.SVNReverter;
+import org.eclipse.papyrus.team.collaborative.connector.svn.versioncontroller.SVNUpdater;
+import org.eclipse.papyrus.team.collaborative.participants.locker.ILocker;
+import org.eclipse.papyrus.team.collaborative.participants.locker.IUnlocker;
+import org.eclipse.papyrus.team.collaborative.participants.version.ICommitter;
+import org.eclipse.papyrus.team.collaborative.participants.version.IReverter;
+import org.eclipse.papyrus.team.collaborative.participants.version.IUpdater;
+import org.eclipse.papyrus.team.collaborative.utils.CollabFunctionsFactory;
+import org.eclipse.team.svn.core.utility.FileUtility;
+
+import com.google.common.collect.Collections2;
+
+
+/**
+ * Factory to build element to do collaborative work with SVN.
+ *
+ * @author adaussy
+ */
+public class SVNCollabFactory implements ICollabFactory {
+
+ /** The Constant SVN_COLLAB_ID. */
+ public static final String SVN_COLLAB_ID = "org.eclipse.papyrus.team.collaborative.connector.svn";
+
+ /**
+ * Resource set svn status cache
+ */
+ private WeakHashMap<ResourceSet, Boolean> alreadyOnSvnCache = new WeakHashMap<ResourceSet, Boolean>();
+
+ /**
+ * Instantiates a new sVN collab factory.
+ */
+ public SVNCollabFactory() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollabFactory#provide(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public boolean provide(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ /**
+ * Workaround for eclipse bug 385394. This bug causes property testers to be called very frequently
+ * even if no activity is taking place, causing important slowdowns when a right-click on a model explorer element is performed.
+ * a cache prevents these calls (and the subsequent calls to FileUtility.alreadyOnSVN) from being too taxing on system resources.
+ *
+ * This bug was fixed on 16/01/2014 but its fix has not yet been released outside of integration builds. Remove this workaround when it is.
+ */
+ if(alreadyOnSvnCache.containsKey(resourceSet)) {
+ return alreadyOnSvnCache.get(resourceSet);
+ }
+ boolean result;
+ Set<IProject> projects = new HashSet<IProject>();
+ for(IResource iResource : Collections2.transform(uris, CollabFunctionsFactory.getExtendedURIToIResource(resourceSet))) {
+ if(iResource != null) {
+ projects.add(iResource.getProject());
+ }
+ }
+ if(projects.isEmpty()) {
+ result = false;
+ alreadyOnSvnCache.put(resourceSet, result);
+ return result;
+ }
+ for(IProject iProject : projects) {
+ if(!FileUtility.alreadyOnSVN(iProject)) {
+ result = false;
+ alreadyOnSvnCache.put(resourceSet, result);
+ return result;
+ }
+ }
+ result = true;
+ alreadyOnSvnCache.put(resourceSet, result);
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollabFactory#createLocker(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public ILocker createLocker(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ return new SVNLocker(uris, resourceSet);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollabFactory#createUnlocker(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public IUnlocker createUnlocker(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ return new SVNUnlocker(uris, resourceSet);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollabFactory#createReverter(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public IReverter createReverter(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ return new SVNReverter(uris, resourceSet);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollabFactory#createCommitter(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public ICommitter createCommitter(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ return new SVNCommitter(uris, resourceSet);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollabFactory#createUpdater(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public IUpdater createUpdater(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ return new SVNUpdater(uris, resourceSet);
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/AbstractSVNCollab.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/AbstractSVNCollab.java
new file mode 100644
index 0000000..8144658
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/AbstractSVNCollab.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.locker;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.connector.svn.AbstractExtendedURIBuilderForFile;
+import org.eclipse.papyrus.team.collaborative.participants.ICollabParticipant;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+import org.eclipse.team.svn.core.resource.ILocalResource;
+import org.eclipse.team.svn.core.svnstorage.SVNRemoteStorage;
+
+
+/**
+ * The Class AbstractSVNCollab.
+ * Abstract class used for {@link ICollabParticipant} for SVN
+ */
+public abstract class AbstractSVNCollab extends AbstractExtendedURIBuilderForFile {
+
+ public AbstractSVNCollab(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ super(uris, resourceSet);
+ }
+
+ /** The Constant NOT_LOCK_STATUS. */
+ public static final CollabStatus NOT_LOCK_STATUS = CollabStatus.createErrorStatus("Not locked");
+
+ /**
+ * Checks if is locked.
+ *
+ * @param uri
+ * the uri
+ * @return the i status
+ */
+ public IStatus isLocked(IExtendedURI uri) {
+ Resource resourceToLock = getResourceSet().getResource(uri.getUri(), false);
+ IFile iResourcesToLock = WorkspaceSynchronizer.getFile(resourceToLock);
+ if(iResourcesToLock != null) {
+ if(iResourcesToLock.exists()) {
+ ILocalResource local = SVNRemoteStorage.instance().asLocalResource(iResourcesToLock);
+ if(local.isLocked()) {
+ return Status.OK_STATUS;
+ } else {
+ return NOT_LOCK_STATUS;
+ }
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/SVNLocker.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/SVNLocker.java
new file mode 100644
index 0000000..e08d1a1
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/SVNLocker.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.locker;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.ITracingConstant;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.Tracer;
+import org.eclipse.papyrus.team.collaborative.connector.svn.utils.SVNUtils;
+import org.eclipse.papyrus.team.collaborative.participants.locker.ILocker;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+import org.eclipse.team.svn.core.operation.CompositeOperation;
+import org.eclipse.team.svn.core.operation.IActionOperation;
+import org.eclipse.team.svn.core.operation.local.LockOperation;
+import org.eclipse.team.svn.core.operation.local.RefreshResourcesOperation;
+import org.eclipse.team.svn.ui.utility.ICancellableOperationWrapper;
+import org.eclipse.team.svn.ui.utility.UIMonitorUtility;
+
+
+/**
+ * SVN implementation of {@link ILocker}
+ *
+ * @author adaussy
+ *
+ */
+public class SVNLocker extends AbstractSVNCollab implements ILocker {
+
+
+ public SVNLocker(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ super(uris, resourceSet);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.participants.locker.ILocker#lock()
+ */
+ public IStatus lock() {
+ IResource[] resourcesToProcess = getTargetFiles(getTargetResources());
+ //Check that every file is on repository
+ List<IResource> fileToAddToRepo = new ArrayList<IResource>();
+ for(int i = 0; i < resourcesToProcess.length; i++) {
+ IResource currentResource = resourcesToProcess[i];
+ if(!SVNUtils.isAddedToRepository(currentResource)) {
+ return CollabStatus.createErrorStatus(currentResource.getFullPath() + "is not in the repository");
+ }
+ }
+ //Add resource to repository
+ IStatus addStatus = SVNUtils.addToRepository("Adding new resource to repository", fileToAddToRepo);
+ if(!addStatus.isOK()) {
+ return addStatus;
+ }
+ if(ITracingConstant.LOCK_TRACING) {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("Locking: ").append("\n");
+ for(IResource r : resourcesToProcess) {
+ stringBuilder.append(r.getFullPath()).append("\n");
+ }
+ Tracer.logInfo(stringBuilder.toString());
+ }
+ //Lock operation
+ LockOperation mainOp = new LockOperation(resourcesToProcess, "Lock taken", false);
+ CompositeOperation op = new CompositeOperation(mainOp.getId(), mainOp.getMessagesClass());
+ op.add(mainOp);
+ op.add(new RefreshResourcesOperation(resourcesToProcess));
+ ICancellableOperationWrapper runnable = UIMonitorUtility.doTaskNowDefault(op, false);
+ IActionOperation resultStatus = runnable.getOperation();
+ return resultStatus.getStatus();
+ }
+
+
+
+ @Override
+ protected Set<IExtendedURI> doBuild() {
+ for(IExtendedURI extendedURI : getUris()) {
+ IExtendedURI resourceURI = getResourceURI(extendedURI);
+ if(resourceURI != null) {
+ if(!isLocked(resourceURI).isOK()) {
+ getExtendedSet().add(resourceURI);
+ }
+ }
+ }
+ return getExtendedSet();
+ }
+
+
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/SVNUnlocker.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/SVNUnlocker.java
new file mode 100644
index 0000000..5779b4a
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/locker/SVNUnlocker.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.locker;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.ITracingConstant;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.Tracer;
+import org.eclipse.papyrus.team.collaborative.participants.locker.IUnlocker;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+import org.eclipse.team.svn.core.operation.CompositeOperation;
+import org.eclipse.team.svn.core.operation.IActionOperation;
+import org.eclipse.team.svn.core.operation.local.RefreshResourcesOperation;
+import org.eclipse.team.svn.core.operation.local.UnlockOperation;
+import org.eclipse.team.svn.ui.utility.ICancellableOperationWrapper;
+import org.eclipse.team.svn.ui.utility.UIMonitorUtility;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * SVN implementation of {@link IUnlocker}.
+ *
+ * @author adaussy
+ */
+public class SVNUnlocker extends AbstractSVNCollab implements IUnlocker {
+
+ /**
+ * Instantiates a new SVN unlocker.
+ *
+ * @param uris
+ * the uris
+ * @param resourceSet
+ * the resource set
+ */
+ public SVNUnlocker(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ super(uris, resourceSet);
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.participants.locker.IUnlocker#unlock()
+ */
+ public IStatus unlock() {
+ IResource[] resourcesToProcess = getTargetFiles(getTargetResources());
+ if(ITracingConstant.UNLOCK_TRACING) {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("Unlocking: ").append("\n");
+ for(IResource r : resourcesToProcess) {
+ stringBuilder.append(r.getFullPath()).append("\n");
+ }
+ Tracer.logInfo(stringBuilder.toString());
+ }
+ //Unlock operation
+ UnlockOperation mainOp = new UnlockOperation(resourcesToProcess);
+ CompositeOperation op = new CompositeOperation(mainOp.getId(), mainOp.getMessagesClass());
+ op.add(mainOp);
+ op.add(new RefreshResourcesOperation(resourcesToProcess));
+ ICancellableOperationWrapper runnable = UIMonitorUtility.doTaskNowDefault(op, false);
+ IActionOperation resultStatus = runnable.getOperation();
+
+ IStatus status = resultStatus.getStatus();
+ if(status.isOK()) {
+ return Status.OK_STATUS;
+ }
+ return CollabStatus.createErrorStatus(status.getMessage(), status.getException());
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.participants.AbstractExtendedURIBuilder#doBuild()
+ */
+ @Override
+ protected Set<IExtendedURI> doBuild() {
+ for(IExtendedURI extendedURI : getUris()) {
+ IExtendedURI resourceURI = getResourceURI(extendedURI);
+ if(resourceURI != null) {
+ if(isLocked(resourceURI).isOK()) {
+ getExtendedSet().add(resourceURI);
+ }
+ }
+ }
+ return getExtendedSet();
+ }
+
+
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/tracing/ITracingConstant.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/tracing/ITracingConstant.java
new file mode 100644
index 0000000..949fdb6
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/tracing/ITracingConstant.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.tracing;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.team.collaborative.connector.svn.Activator;
+
+/**
+ * Constant use to trace.
+ *
+ * @author adaussy
+ */
+public interface ITracingConstant {
+
+ /** Trace everything related to commmit. */
+ public static final boolean COMMIT_TRACING = Activator.getDefault().isDebugging() && "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.papyrus.team.collaborative.connector.svn/debug/commit"));
+
+ /** Trace everything related to lock. */
+ public static final boolean LOCK_TRACING = Activator.getDefault().isDebugging() && "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.papyrus.team.collaborative.connector.svn/debug/lock"));
+
+ /** Trace everything related to unlock. */
+ public static final boolean UNLOCK_TRACING = Activator.getDefault().isDebugging() && "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.papyrus.team.collaborative.connector.svn/debug/unlock"));
+
+ /** Trace everything related to Update. */
+ public static final boolean UPDATE_TRACING = Activator.getDefault().isDebugging() && "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.papyrus.team.collaborative.connector.svn/debug/update"));
+
+ /** Trace everything related to Revert. */
+ public static final boolean REVERT_TRACING = Activator.getDefault().isDebugging() && "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.papyrus.team.collaborative.connector.svn/debug/revert"));
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/tracing/Tracer.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/tracing/Tracer.java
new file mode 100644
index 0000000..7dcbaf2
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/tracing/Tracer.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy <a href="mailto:arthur.daussy@atos.net"> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.tracing;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.papyrus.team.collaborative.connector.svn.Activator;
+
+/**
+ * Utils class used to trace element
+ *
+ * @author adaussy
+ *
+ */
+public final class Tracer {
+
+ private Tracer() {
+ }
+
+ /**
+ * Return true if the plugin is debugging
+ *
+ * @return
+ */
+ public static boolean isDebuging() {
+ return Activator.getDefault().isDebugging();
+ }
+
+ /**
+ * Log info if the plugin is tracing
+ *
+ * @param info
+ * Info you want to log
+ * @param raisedException
+ * if true the the trace raise an exception
+ */
+ public static void logInfo(String info, boolean raisedException) {
+ log(Status.OK, info, raisedException);
+ }
+
+ /**
+ * Log an info
+ *
+ * @param info
+ * Info you want to log
+ */
+ public static void logInfo(String info) {
+ logInfo(info, false);
+ }
+
+ // /**
+ // * Log an error
+ // * @param error Message you want to log
+ // * @param raisedException if true the the trace raise an exception
+ // */
+ // public static void logError(String error, boolean raisedException) {
+ // log(Status.ERROR, error, raisedException);
+ // }
+
+ /**
+ * Log something
+ *
+ * @param severity
+ * Severity of what is going to be logged see {@link IStatus} constants
+ * @param message
+ * Message to log
+ * @param raisedException
+ * if true raise an exception
+ */
+ public static void log(int severity, String message, boolean raisedException) {
+ if(Activator.getDefault() != null) {
+ if(raisedException) {
+ Activator.getDefault().getLog().log(new Status(severity, Activator.PLUGIN_ID, message, new Exception()));
+ } else {
+ Activator.getDefault().getLog().log(new Status(severity, Activator.PLUGIN_ID, message));
+ }
+ }
+ }
+
+ // /**
+ // * Log an error
+ // * @param message Message you want to log
+ // * @param raisedException the exception to raise
+ // */
+ // public static void logExceptionError(String message, Exception raisedException) {
+ // Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, raisedException));
+ // }
+
+ /**
+ * Log warning
+ *
+ * @param message
+ * Message you want to log
+ * @param raisedException
+ * the exception to raise
+ */
+ public static void logExceptionWarning(String message, Exception raisedException) {
+ Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, message, raisedException));
+ }
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/CommitActionUtilityWithProperties.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/CommitActionUtilityWithProperties.java
new file mode 100644
index 0000000..d044eef
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/CommitActionUtilityWithProperties.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy <a href="mailto:arthur.daussy@atos.net"> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.utils;
+
+import java.util.Arrays;
+import java.util.HashSet;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.team.svn.core.IStateFilter;
+import org.eclipse.team.svn.core.utility.FileUtility;
+import org.eclipse.team.svn.ui.action.IResourceSelector;
+import org.eclipse.team.svn.ui.utility.CommitActionUtility;
+
+
+/**
+ * Same as {@link CommitActionUtility} however it add to commit set if the file has SVN properties changes
+ *
+ * @author adaussy
+ *
+ */
+public class CommitActionUtilityWithProperties extends CommitActionUtility {
+
+ public CommitActionUtilityWithProperties(IResourceSelector selector) {
+ super(selector);
+ }
+
+ @Override
+ public void initialize(IResourceSelector selector) {
+ this.selector = selector;
+
+ this.allResourcesSet = new HashSet<IResource>();
+ this.allResourcesSet.addAll(Arrays.asList(this.selector.getSelectedResourcesRecursive(new IStateFilter.OrStateFilter(new IStateFilter[]{ IStateFilter.SF_COMMITABLE, IStateFilter.SF_CONFLICTING, IStateFilter.SF_TREE_CONFLICTING, IStateFilter.SF_NEW, IStateFilter.SF_HAS_PROPERTIES_CHANGES }))));
+
+ this.newNonRecursive = new HashSet<IResource>(Arrays.asList(this.selector.getSelectedResources(IStateFilter.SF_IGNORED_BUT_NOT_EXTERNAL)));
+ this.newRecursive = new HashSet<IResource>(Arrays.asList(FileUtility.getResourcesRecursive((IResource[])this.allResourcesSet.toArray(new IResource[this.allResourcesSet.size()]), IStateFilter.SF_NEW, IResource.DEPTH_ZERO)));
+
+ HashSet<IResource> fullSet = new HashSet<IResource>(this.newNonRecursive);
+ fullSet.addAll(this.newRecursive);
+ this.parents = new HashSet<IResource>(Arrays.asList(FileUtility.getOperableParents((IResource[])fullSet.toArray(new IResource[fullSet.size()]), IStateFilter.SF_UNVERSIONED)));
+ this.newNonRecursive.addAll(this.parents);
+ fullSet.addAll(this.parents);
+
+ this.allResourcesSet.addAll(fullSet);
+
+ this.allResources = (IResource[])this.allResourcesSet.toArray(new IResource[this.allResourcesSet.size()]);
+ this.allResourcesSet.addAll(Arrays.asList(FileUtility.addOperableParents(this.allResources, IStateFilter.SF_ADDED, true)));
+ this.allResources = (IResource[])this.allResourcesSet.toArray(new IResource[this.allResourcesSet.size()]);
+
+ this.canBeRecursiveCommit = FileUtility.getOperableParents(this.selector.getSelectedResources(), IStateFilter.SF_ADDED, false).length == 0;
+ if(this.canBeRecursiveCommit && FileUtility.checkForResourcesPresence(this.allResources, IStateFilter.SF_SWITCHED, IResource.DEPTH_ZERO)) {
+ this.canBeRecursiveCommit = false;
+ }
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/SVNUtils.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/SVNUtils.java
new file mode 100644
index 0000000..4dff948
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/SVNUtils.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.utils;
+
+import java.util.Collection;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.ITracingConstant;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.Tracer;
+import org.eclipse.papyrus.team.collaborative.connector.svn.versioncontroller.SVNCommitter;
+import org.eclipse.team.svn.core.connector.SVNChangeStatus;
+import org.eclipse.team.svn.core.extension.CoreExtensionsManager;
+import org.eclipse.team.svn.core.extension.factory.ISVNConnectorFactory;
+import org.eclipse.team.svn.core.utility.SVNUtility;
+
+/**
+ * The Class SVNUtils.
+ */
+public class SVNUtils {
+
+ /** The Constant SVN_NEEDS_LOCK. */
+ private static final String SVN_NEEDS_LOCK = "svn:needs-lock";
+
+ /** The SVN connector factory. */
+ static ISVNConnectorFactory svnConnectorFactory = CoreExtensionsManager.instance().getSVNConnectorFactory();
+
+
+ /**
+ * Gets the resource SVN info.
+ *
+ * @param resource
+ * the resource
+ * @return the SVN info
+ */
+ public static SVNChangeStatus getSVNInfo(IResource resource) {
+ return SVNUtility.getSVNInfoForNotConnected(resource);
+ }
+
+
+
+ /**
+ * Add resources to the SVN repository.
+ *
+ * @param message
+ * Message for the Add operation
+ * @param resources
+ * The resources to add
+ * @return the i status
+ */
+ public static IStatus addToRepository(String message, Collection<? extends IResource> resources) {
+ IResource[] iResources = new IResource[resources.size()];
+ resources.toArray(iResources);
+ IStatus status = SVNCommitter.doCommit(message, true, resources);
+ if(!status.isOK()) {
+ return status;
+ }
+
+ //Set need lock property
+ if(ITracingConstant.COMMIT_TRACING) {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("Set need lock property on: ").append("\n");
+ for(IResource r : iResources) {
+ stringBuilder.append(r).append("\n");
+ }
+ Tracer.logInfo(stringBuilder.toString());
+ }
+ SetPropertyActionNow.doSetPropertyNow(iResources, SVN_NEEDS_LOCK, "*", "", false, true, 0, false, "*", false, null);
+
+ //Commit the property change
+ status = SVNCommitter.doCommit(message, true, resources);
+ if(!status.isOK()) {
+ return status;
+ }
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * Test if a {@link IResource}.
+ *
+ * @param resource
+ * the resource
+ * @return true, if is added to repository
+ */
+ public static boolean isAddedToRepository(IResource resource) {
+ SVNChangeStatus svnInfo = getSVNInfo(resource);
+ if(svnInfo != null) {
+ String value = SVNUtility.getPropertyForNotConnected(resource, SVN_NEEDS_LOCK);
+ return value != null && !value.isEmpty();
+ }
+ return false;
+
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/SetPropertyActionNow.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/SetPropertyActionNow.java
new file mode 100644
index 0000000..d61e959
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/utils/SetPropertyActionNow.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.svn.core.IStateFilter;
+import org.eclipse.team.svn.core.connector.SVNProperty;
+import org.eclipse.team.svn.core.extension.CoreExtensionsManager;
+import org.eclipse.team.svn.core.extension.properties.IPredefinedPropertySet;
+import org.eclipse.team.svn.core.extension.properties.PredefinedProperty;
+import org.eclipse.team.svn.core.operation.AbstractActionOperation;
+import org.eclipse.team.svn.core.operation.CompositeOperation;
+import org.eclipse.team.svn.core.operation.IActionOperation;
+import org.eclipse.team.svn.core.operation.local.RefreshResourcesOperation;
+import org.eclipse.team.svn.core.operation.local.property.IPropertyProvider;
+import org.eclipse.team.svn.core.operation.local.property.SetMultiPropertiesOperation;
+import org.eclipse.team.svn.core.operation.local.property.SetPropertiesOperation;
+import org.eclipse.team.svn.core.resource.ILocalResource;
+import org.eclipse.team.svn.core.utility.FileUtility;
+import org.eclipse.team.svn.core.utility.StringMatcher;
+import org.eclipse.team.svn.ui.SVNUIMessages;
+import org.eclipse.team.svn.ui.action.local.SetPropertyAction;
+import org.eclipse.team.svn.ui.composite.PropertiesComposite;
+import org.eclipse.team.svn.ui.properties.ResourcePropertyEditPanel;
+import org.eclipse.team.svn.ui.utility.UIMonitorUtility;
+
+
+/**
+ * The Class SetPropertyActionNow.
+ * Util class used to set SVN property. This implementation set the property immediatly
+ */
+public class SetPropertyActionNow {
+
+ /**
+ * Do set property.
+ *
+ * @param resources
+ * the resources
+ * @param panel
+ * the panel
+ * @param addOn
+ * the add on
+ */
+ public static void doSetProperty(final IResource[] resources, ResourcePropertyEditPanel panel, IActionOperation addOn) {
+ SetPropertyAction.doSetProperty(resources, panel.getPropertyName(), panel.getPropertyValue(), panel.getPropertyFile(), panel.isFileSelected(), panel.isRecursiveSelected(), panel.getApplyMethod(), panel.useMask(), panel.getFilterMask(), panel.isStrict(), addOn);
+ }
+
+ /**
+ * Do set property now.
+ *
+ * @param resources
+ * the resources
+ * @param propertyName
+ * the property name
+ * @param value
+ * the value
+ * @param fileName
+ * the file name
+ * @param isFileSelected
+ * the is file selected
+ * @param isRecursive
+ * the is recursive
+ * @param applyMethod
+ * the apply method
+ * @param useMask
+ * the use mask
+ * @param filterMask
+ * the filter mask
+ * @param strict
+ * the strict
+ * @param addOn
+ * the add on
+ */
+ public static void doSetPropertyNow(final IResource[] resources, String propertyName, String value, String fileName, boolean isFileSelected, boolean isRecursive, final int applyMethod, boolean useMask, String filterMask, boolean strict, IActionOperation addOn) {
+ final SVNProperty[] data = new SVNProperty[]{ new SVNProperty(propertyName, value) };
+ IActionOperation loadOp = null;
+ if(isFileSelected) {
+ final File f = new File(fileName);
+ loadOp = new AbstractActionOperation("Operation_SLoadFileContent", SVNUIMessages.class) { //$NON-NLS-1$
+
+ protected void runImpl(IProgressMonitor monitor) throws Exception {
+ FileInputStream input = null;
+ try {
+ input = new FileInputStream(f);
+ byte[] binary = new byte[(int)f.length()];
+ input.read(binary);
+ data[0] = new SVNProperty(data[0].name, new String(binary));
+ } finally {
+ if(input != null) {
+ input.close();
+ }
+ }
+ }
+ };
+ }
+ doSetPropertyNow(resources, data, loadOp, isRecursive, applyMethod, useMask, filterMask, strict, addOn);
+ }
+
+ /**
+ * Do set property now.
+ *
+ * @param resources
+ * the resources
+ * @param data
+ * the data
+ * @param loadOp
+ * the load op
+ * @param isRecursive
+ * the is recursive
+ * @param applyMethod
+ * the apply method
+ * @param useMask
+ * the use mask
+ * @param filterMask
+ * the filter mask
+ * @param strict
+ * the strict
+ * @param addOn
+ * the add on
+ */
+ public static void doSetPropertyNow(final IResource[] resources, SVNProperty[] data, IActionOperation loadOp, boolean isRecursive, final int applyMethod, boolean useMask, String filterMask, boolean strict, IActionOperation addOn) {
+ ArrayList<SVNProperty> folderPropsList = new ArrayList<SVNProperty>();
+ ArrayList<SVNProperty> filePropsList = new ArrayList<SVNProperty>();
+ IPredefinedPropertySet set = CoreExtensionsManager.instance().getPredefinedPropertySet();
+ for(SVNProperty prop : data) {
+ int type = PredefinedProperty.TYPE_COMMON;
+ PredefinedProperty pProp = set.getPredefinedProperty(prop.name);
+ if(pProp != null) {
+ type = pProp.type;
+ }
+ if(type == PredefinedProperty.TYPE_FILE) {
+ filePropsList.add(prop);
+ } else if(type == PredefinedProperty.TYPE_FOLDER) {
+ folderPropsList.add(prop);
+ } else if(type == PredefinedProperty.TYPE_COMMON) {
+ filePropsList.add(prop);
+ folderPropsList.add(prop);
+ }
+ }
+ final SVNProperty[] folderProps = folderPropsList.toArray(new SVNProperty[folderPropsList.size()]);
+ final SVNProperty[] fileProps = filePropsList.toArray(new SVNProperty[filePropsList.size()]);
+
+ final StringMatcher matcher = useMask ? new StringMatcher(filterMask) : null;
+ IStateFilter filter = new IStateFilter.AbstractStateFilter() {
+
+ protected boolean allowsRecursionImpl(ILocalResource local, IResource resource, String state, int mask) {
+ return IStateFilter.SF_EXCLUDE_PREREPLACED_AND_DELETED.allowsRecursion(resource, state, mask) || state == IStateFilter.ST_ADDED;
+ }
+
+ protected boolean acceptImpl(ILocalResource local, IResource resource, String state, int mask) {
+ if(applyMethod == PropertiesComposite.APPLY_TO_FILES && resource.getType() != IResource.FILE || applyMethod == PropertiesComposite.APPLY_TO_FOLDERS && resource.getType() == IResource.FILE || !IStateFilter.SF_EXCLUDE_PREREPLACED_AND_DELETED.accept(resource, state, mask) || matcher != null && !matcher.match(resource.getName())) {
+ return false;
+ }
+ return true;
+ }
+ };
+
+ IActionOperation mainOp;
+ if((!isRecursive || applyMethod == PropertiesComposite.APPLY_TO_ALL && !useMask) && folderProps.length == fileProps.length) {
+ // use faster version
+ mainOp = new SetPropertiesOperation(FileUtility.getResourcesRecursive(resources, filter, IResource.DEPTH_ZERO), data, isRecursive & !strict);
+ } else {
+ IPropertyProvider propertyProvider = new IPropertyProvider() {
+
+ public SVNProperty[] getProperties(IResource resource) {
+ return resource.getType() == IResource.FILE ? fileProps : folderProps;
+ }
+ };
+ mainOp = new SetMultiPropertiesOperation(resources, propertyProvider, filter, isRecursive && !strict ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO);
+ }
+ CompositeOperation composite = new CompositeOperation(mainOp.getId(), mainOp.getMessagesClass());
+ if(loadOp != null) {
+ composite.add(loadOp);
+ composite.add(mainOp, new IActionOperation[]{ loadOp });
+ } else {
+ composite.add(mainOp);
+ }
+ if(addOn != null) {
+ composite.add(addOn);
+ }
+ composite.add(new RefreshResourcesOperation(resources, IResource.DEPTH_INFINITE, RefreshResourcesOperation.REFRESH_ALL), new IActionOperation[]{ mainOp });
+ UIMonitorUtility.doTaskNowDefault(composite, false);
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/AbstractSVNVersionController.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/AbstractSVNVersionController.java
new file mode 100644
index 0000000..6e41a8b
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/AbstractSVNVersionController.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.versioncontroller;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+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.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.connector.svn.AbstractExtendedURIBuilderForFile;
+import org.eclipse.papyrus.team.collaborative.connector.svn.utils.SVNUtils;
+import org.eclipse.papyrus.team.collaborative.participants.version.IWorkOnModifiedElementParticipant;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+import org.eclipse.team.svn.core.connector.SVNChangeStatus;
+import org.eclipse.team.svn.core.connector.SVNEntryStatus;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * Abstract class for action with version control (update, commit, revert etc..) on SVN.
+ *
+ * @author adaussy
+ *
+ */
+public abstract class AbstractSVNVersionController extends AbstractExtendedURIBuilderForFile implements IWorkOnModifiedElementParticipant {
+
+ /**
+ * Instantiates a new abstract SVN version controller.
+ *
+ * @param uris
+ * the uris
+ * @param resourceSet
+ * the resource set
+ */
+ public AbstractSVNVersionController(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ super(uris, resourceSet);
+ }
+
+ /**
+ * Check if the element pointed by the URI is modified.
+ *
+ * @param uri
+ * the uri
+ * @return the i status
+ * @throws CollabException
+ * the collab exception
+ */
+ public IStatus isModified(IExtendedURI uri) {
+ IExtendedURI resourceEURI = getResourceURI(uri);
+ if(resourceEURI == null) {
+ return Status.OK_STATUS;
+ }
+ URI resourceURI = resourceEURI.getUri();
+ Resource resource = toResource(resourceURI);
+ if(resource == null) {
+ return CollabStatus.createErrorStatus(resourceURI + " is not a URI pointing to a resource");
+ }
+ IFile file = toIFile(resource);
+ if(file == null || !file.exists()) {
+ return CollabStatus.createErrorStatus(resourceURI + " is not a URI pointing to a existing file");
+ }
+ SVNChangeStatus svnInfo = SVNUtils.getSVNInfo(file);
+ if(svnInfo == null) {
+ return CollabStatus.createErrorStatus("Can not retreive SVN info for " + resourceURI);
+ }
+ if(svnInfo.repositoryPropStatus == SVNEntryStatus.Kind.MODIFIED) {
+ return MODIFIED_STATUS;
+ }
+ return Status.OK_STATUS;
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNCommitter.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNCommitter.java
new file mode 100644
index 0000000..b8535cc
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNCommitter.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.versioncontroller;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.connector.svn.CollabResourceSelector;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.ITracingConstant;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.Tracer;
+import org.eclipse.papyrus.team.collaborative.connector.svn.utils.CommitActionUtilityWithProperties;
+import org.eclipse.papyrus.team.collaborative.participants.version.ICommitter;
+import org.eclipse.papyrus.team.collaborative.utils.ResourceUtils;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.team.svn.core.operation.CompositeOperation;
+import org.eclipse.team.svn.core.operation.IActionOperation;
+import org.eclipse.team.svn.ui.utility.ICancellableOperationWrapper;
+import org.eclipse.team.svn.ui.utility.UIMonitorUtility;
+import org.eclipse.ui.PlatformUI;
+
+import com.google.common.collect.Lists;
+
+
+/**
+ * SVN implementation for {@link ICommitter}.
+ *
+ * @author adaussy
+ */
+public class SVNCommitter extends SVNWorkOnModifiedFile implements ICommitter {
+
+
+ /**
+ * Instantiates a new SVN committer.
+ *
+ * @param uris
+ * the uris
+ * @param resourceSet
+ * the resource set
+ */
+ public SVNCommitter(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ super(uris, resourceSet);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.participants.version.ICommitter#commit(java.lang.String, boolean)
+ */
+ @Override
+ public IStatus commit(String message, boolean keepLock) {
+ IStatus status = doCommit(message, keepLock, getTargetResources());
+ return status;
+ }
+
+ /**
+ * Do commit.
+ *
+ * @param message
+ * the message for the commit action
+ * @param keepLock
+ * the keep lock set to true if the lock has to be kept
+ * @param resourceToCommit
+ * the resource to commit
+ * @return the i status
+ */
+ public static IStatus doCommit(String message, boolean keepLock, Set<Resource> resourceToCommit) {
+ if(resourceToCommit != null && !resourceToCommit.isEmpty()) {
+ List<IFile> targetIFileList = Lists.newArrayList(getTargetFiles(resourceToCommit));
+ return doCommit(message, keepLock, ResourceUtils.getListAncestors(targetIFileList));
+ }
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * Do commit.
+ *
+ * @param message
+ * the message for the commit action
+ * @param keepLock
+ * the keep lock set to true if the lock has to be kept
+ * @param filesToCommit
+ * the files to commit
+ * @return the i status
+ */
+ public static IStatus doCommit(String message, boolean keepLock, Collection<? extends IResource> filesToCommit) {
+ CommitActionUtilityWithProperties tt = new CommitActionUtilityWithProperties(new CollabResourceSelector(filesToCommit.toArray(new IResource[filesToCommit.size()]), Display.getDefault().getActiveShell()));
+ IResource[] allResources = tt.getAllResources();
+ if(ITracingConstant.COMMIT_TRACING) {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("Committing ").append(message).append("\n");
+ for(IResource r : allResources) {
+ stringBuilder.append(r).append("\n");
+ }
+ Tracer.logInfo(stringBuilder.toString());
+ }
+ CompositeOperation mainOp = tt.getCompositeCommitOperation(allResources, new IResource[0], message, keepLock, Display.getDefault().getActiveShell(), PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(), true);
+ ICancellableOperationWrapper runnable = UIMonitorUtility.doTaskNowDefault(mainOp, false);
+ IActionOperation resultStatus = runnable.getOperation();
+ return resultStatus.getStatus();
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNReverter.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNReverter.java
new file mode 100644
index 0000000..b42fdee
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNReverter.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.versioncontroller;
+
+/*******************************************************************************
+ * Copyright (c) 2013 Atos.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy <a href="mailto:arthur.daussy@atos.net"> - initial API and implementation
+ ******************************************************************************/
+import java.io.File;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.ITracingConstant;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.Tracer;
+import org.eclipse.papyrus.team.collaborative.participants.version.IReverter;
+import org.eclipse.team.svn.core.operation.CompositeOperation;
+import org.eclipse.team.svn.core.operation.IActionOperation;
+import org.eclipse.team.svn.core.operation.file.RevertOperation;
+import org.eclipse.team.svn.core.operation.local.RefreshResourcesOperation;
+import org.eclipse.team.svn.ui.utility.ICancellableOperationWrapper;
+import org.eclipse.team.svn.ui.utility.UIMonitorUtility;
+
+
+/**
+ * SVN Implementation for {@link IReverter}
+ *
+ * @author adaussy
+ *
+ */
+public class SVNReverter extends SVNWorkOnModifiedFile implements IReverter {
+
+
+ public SVNReverter(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ super(uris, resourceSet);
+ }
+
+ @Override
+ public IStatus revert() {
+ File[] modifiedFiles = getModifiedFile(getTargetResources());
+ if(ITracingConstant.REVERT_TRACING) {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("Reverting: ").append("\n");
+ for(File f : modifiedFiles) {
+ stringBuilder.append(f).append("\n");
+ }
+ Tracer.logInfo(stringBuilder.toString());
+ }
+ //Revert operation
+ RevertOperation mainOp = new RevertOperation(modifiedFiles, true);
+ CompositeOperation op = new CompositeOperation(mainOp.getId(), mainOp.getMessagesClass());
+ op.add(mainOp);
+ op.add(new RefreshResourcesOperation(getTargetFiles(getTargetResources())));
+ ICancellableOperationWrapper runnable = UIMonitorUtility.doTaskNowDefault(op, false);
+ IActionOperation resultStatus = runnable.getOperation();
+
+ return resultStatus.getStatus();
+ }
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNUpdater.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNUpdater.java
new file mode 100644
index 0000000..7acf706
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNUpdater.java
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.versioncontroller;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+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.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.ITracingConstant;
+import org.eclipse.papyrus.team.collaborative.connector.svn.tracing.Tracer;
+import org.eclipse.papyrus.team.collaborative.participants.version.IUpdater;
+import org.eclipse.team.svn.core.connector.SVNEntryInfo;
+import org.eclipse.team.svn.core.connector.SVNLogEntry;
+import org.eclipse.team.svn.core.connector.SVNRevision;
+import org.eclipse.team.svn.core.operation.CompositeOperation;
+import org.eclipse.team.svn.core.operation.IActionOperation;
+import org.eclipse.team.svn.core.operation.local.InfoOperation;
+import org.eclipse.team.svn.core.operation.remote.GetLogMessagesOperation;
+import org.eclipse.team.svn.core.resource.IRepositoryResource;
+import org.eclipse.team.svn.core.svnstorage.SVNRemoteStorage;
+import org.eclipse.team.svn.ui.action.local.UpdateAction;
+import org.eclipse.team.svn.ui.utility.ICancellableOperationWrapper;
+import org.eclipse.team.svn.ui.utility.UIMonitorUtility;
+
+
+/**
+ * SVN implementation of {@link IUpdater}
+ *
+ * @author adaussy
+ *
+ */
+public class SVNUpdater extends AbstractSVNVersionController implements IUpdater {
+
+ /**
+ * Instantiates a new sVN updater.
+ *
+ * @param uris
+ * the uris
+ * @param resourceSet
+ * the resource set
+ */
+ public SVNUpdater(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ super(uris, resourceSet);
+ }
+
+ @Override
+ public IStatus update() {
+ IFile[] resourcesToProcess = getTargetFiles(getTargetResources());
+ //The all project of each file shall be updated (In order to see if new files appeared (New control))
+ Set<IProject> projects = new HashSet<IProject>();
+ for(IFile f : resourcesToProcess) {
+ projects.add(f.getProject());
+ }
+
+ IProject[] projectsToUpdate = new IProject[projects.size()];
+ projects.toArray(projectsToUpdate);
+ if(ITracingConstant.UPDATE_TRACING) {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("Updating projects: ").append("\n");
+ for(IProject p : projectsToUpdate) {
+ stringBuilder.append(p.getFullPath()).append("\n");
+ }
+ Tracer.logInfo(stringBuilder.toString());
+ }
+ CompositeOperation op = UpdateAction.getUpdateOperation(projectsToUpdate, SVNRevision.HEAD);
+ ICancellableOperationWrapper runnable = UIMonitorUtility.doTaskNowDefault(op, false);
+ IActionOperation resultStatus = runnable.getOperation();
+
+ return resultStatus.getStatus();
+ }
+
+ @Override
+ protected Set<IExtendedURI> doBuild() {
+ for(IExtendedURI extendedURI : getUris()) {
+ IExtendedURI resourceURI = getResourceURI(extendedURI);
+ if(resourceURI != null) {
+ IFile file = toIFile(toResource(resourceURI.getUri()));
+ if(file != null && file.exists()) {
+ if(!isUpToDate(resourceURI).isUpToDate()) {
+ getExtendedSet().add(resourceURI);
+ }
+ }
+ }
+ }
+ return getExtendedSet();
+ }
+
+
+ /**
+ * Checks if is up to date.
+ *
+ * @param uri
+ * the uri
+ * @return the i status
+ */
+ public UpToDateStatus isUpToDate(IExtendedURI uri) {
+ IExtendedURI resourceEURI = getResourceURI(uri);
+ if(resourceEURI == null) {
+ return UpToDateStatus.createErrorDuringUpToDataStatus("The URI is null");
+ }
+ UpToDateStatus status = getCache().get(resourceEURI);
+ if(status == null) {
+ URI resourceURI = resourceEURI.getUri();
+ Resource resource = toResource(resourceURI);
+ if(resource == null) {
+ return UpToDateStatus.createErrorDuringUpToDataStatus(resourceURI + " is not a URI pointing to a resource");
+ }
+ IFile file = toIFile(resource);
+ if(file == null || !file.exists()) {
+ return UpToDateStatus.createErrorDuringUpToDataStatus(resourceURI + " is not a URI pointing to a existing file");
+ }
+
+ SVNLogEntry log = getRemoteHEADRevision(file);
+ if(log == null) {
+ return UpToDateStatus.createErrorDuringUpToDataStatus("Unable to get remote HEAD revision for file " + file.getFullPath());
+ }
+ InfoOperation refreshOperation = new InfoOperation(file);
+ refreshOperation.run(new NullProgressMonitor());
+ SVNEntryInfo info = refreshOperation.getInfo();
+ long localRevision = info.revision;
+ if(log.revision > localRevision) {
+ status = UpToDateStatus.createNotUpToDataStatus(log.author, log.date, log.revision);
+ getCache().put(resourceEURI, status);
+ return status;
+ } else {
+ status = UpToDateStatus.createUpToDataStatus(log.author, log.date, log.revision);
+ getCache().put(resourceEURI, status);
+ }
+ }
+ return status;
+ }
+
+
+
+
+ protected Map<IExtendedURI, UpToDateStatus> getCache() {
+ if(cache == null) {
+ cache = new HashMap<IExtendedURI, IUpdater.UpToDateStatus>();
+ }
+ return cache;
+ }
+
+
+
+ private Map<IExtendedURI, UpToDateStatus> cache = null;
+
+ public static final long INVALID_REVISION = -1;
+
+
+ public SVNLogEntry getRemoteHEADRevision(IResource resource) {
+ IRepositoryResource remote = SVNRemoteStorage.instance().asRepositoryResource(resource);
+ GetLogMessagesOperation logOp = new GetLogMessagesOperation(remote);
+ logOp.setLimit(1);
+ logOp.run(new NullProgressMonitor());
+ if(logOp.getExecutionState() == IActionOperation.OK && logOp.getMessages() != null) {
+ SVNLogEntry[] messages = logOp.getMessages();
+ if(messages.length > 0) {
+ return messages[0];
+ }
+ }
+ return null;
+ }
+
+
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNWorkOnModifiedFile.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNWorkOnModifiedFile.java
new file mode 100644
index 0000000..70aded9
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.connector.svn/src/org/eclipse/papyrus/team/collaborative/connector/svn/versioncontroller/SVNWorkOnModifiedFile.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.connector.svn.versioncontroller;
+
+
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.connector.svn.CollabResourceSelector;
+import org.eclipse.papyrus.team.collaborative.participants.IExtendedURISuperSet;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.team.svn.ui.utility.CommitActionUtility;
+
+/**
+ * Abstract class used to SVN action which used modified files ad {@link IExtendedURISuperSet#getExtendedSet()}
+ *
+ * @author adaussy
+ *
+ */
+public abstract class SVNWorkOnModifiedFile extends AbstractSVNVersionController {
+
+ public SVNWorkOnModifiedFile(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ super(uris, resourceSet);
+ }
+
+ /**
+ * Gets the modified file.
+ *
+ * @param input
+ * the input
+ * @return the modified file
+ */
+ protected static File[] getModifiedFile(Collection<Resource> input) {
+ IFile[] resourcesToProcess = getTargetFiles(input);
+ File[] result = new File[resourcesToProcess.length];
+ for(int i = 0; i < resourcesToProcess.length; i++) {
+ result[i] = resourcesToProcess[i].getRawLocation().makeAbsolute().toFile();
+ }
+ return result;
+ }
+
+ @Override
+ protected Set<IExtendedURI> doBuild() {
+ List<IResource> toCommit = new ArrayList<IResource>();
+ Map<IResource, IExtendedURI> cach = new HashMap<IResource, IExtendedURI>();
+ for(IExtendedURI extendedURI : getUris()) {
+ IExtendedURI resourceURI = getResourceURI(extendedURI);
+ if(resourceURI != null) {
+ IFile file = toIFile(toResource(resourceURI.getUri()));
+ if(file != null && file.exists()) {
+ if(isModified(resourceURI).isOK()) {
+ toCommit.add(file);
+ cach.put(file, resourceURI);
+ }
+ }
+ }
+ }
+ CommitActionUtility commitUtility = new CommitActionUtility(new CollabResourceSelector(toCommit.toArray(new IResource[toCommit.size()]), Display.getDefault().getActiveShell()));
+ IResource[] allResources = commitUtility.getAllResources();
+ for(int i = 0; i < allResources.length; i++) {
+ getExtendedSet().add(cach.get(allResources[i]));
+ }
+ return getExtendedSet();
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.classpath b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.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/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.gitignore b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.gitignore
new file mode 100644
index 0000000..58393d4
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.gitignore
@@ -0,0 +1,4 @@
+/bin
+/target
+*.class
+*.jar \ No newline at end of file
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.project b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.project
new file mode 100644
index 0000000..67cf052
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.team.collaborative.integration.papyrus.svn</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/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.settings/org.eclipse.jdt.core.prefs b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..c537b63
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/.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.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/META-INF/MANIFEST.MF b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..869d49e
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SVN Control
+Bundle-SymbolicName: org.eclipse.papyrus.team.collaborative.integration.papyrus.svn;singleton:=true
+Bundle-Version: 1.7.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.infra.services.controlmode,
+ org.eclipse.gmf.runtime.common.core,
+ org.eclipse.gmf.runtime.emf.commands.core;bundle-version="1.4.0",
+ org.eclipse.papyrus.editor,
+ org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.4.0",
+ org.eclipse.papyrus.team.collaborative;bundle-version="1.7.0",
+ com.google.guava,
+ org.eclipse.papyrus.infra.gmfdiag.modelexplorer,
+ org.eclipse.ui.navigator;bundle-version="3.5.101",
+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.1.2",
+ org.eclipse.papyrus.team.collaborative.integration.papyrus,
+ org.eclipse.papyrus.team.collaborative.connector.svn,
+ org.eclipse.papyrus.infra.gmfdiag.modelexplorer,
+ org.eclipse.papyrus.infra.widgets.toolbox,
+ org.eclipse.papyrus.infra.gmfdiag.commands,
+ org.eclipse.team.svn.core;bundle-version="1.1.0",
+ org.eclipse.emf.facet.infra.query.core,
+ org.eclipse.emf.facet.infra.browser.custom,
+ org.eclipse.emf.common.ui,
+ org.eclipse.papyrus.views.modelexplorer
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/about.html b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/about.html
new file mode 100644
index 0000000..d35d5ae
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/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>June 5, 2007</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>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/build.properties b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/build.properties
new file mode 100644
index 0000000..0f6e478
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/,\
+ resources/
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/CreateCollabPartition_16x16.png b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/CreateCollabPartition_16x16.png
new file mode 100644
index 0000000..76686bd
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/CreateCollabPartition_16x16.png
Binary files differ
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/CreateCollabPartition_64x64.png b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/CreateCollabPartition_64x64.png
new file mode 100644
index 0000000..b48f359
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/CreateCollabPartition_64x64.png
Binary files differ
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/PartialLock_16x16.png b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/PartialLock_16x16.png
new file mode 100644
index 0000000..ad73fdf
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/PartialLock_16x16.png
Binary files differ
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/ShowPartition_16x16.png b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/ShowPartition_16x16.png
new file mode 100644
index 0000000..ac5f5b9
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/ShowPartition_16x16.png
Binary files differ
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/ShowPartition_64x64.png b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/ShowPartition_64x64.png
new file mode 100644
index 0000000..fc2d786
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/ShowPartition_64x64.png
Binary files differ
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/plugin.xml b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/plugin.xml
new file mode 100644
index 0000000..5403d02
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/plugin.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.infra.services.controlmode.participant">
+ <participant
+ class="org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.control.SVNControlModeParticipant">
+ </participant>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.handler.SVNCollabControlCommandHandler"
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.createcollaborative fragment"
+ name="Create collaborative fragment">
+ </command>
+ <command
+ defaultHandler="org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.handler.ShowModelPartitionHandler"
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.showModelPartition"
+ name="Show model partition">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.papyrus.team.collaborative.ui.collab.menu">
+ <command
+ commandId="org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.createcollaborative fragment"
+ icon="icons/CreateCollabPartition_16x16.png"
+ label="Create partition"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.infra.services.controlmode.isFragmentModel"
+ value="false">
+ </test>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.showModelPartition"
+ icon="icons/ShowPartition_16x16.png"
+ label="Show partition"
+ style="push">
+ </command>
+ </menuContribution>
+ </extension>
+ <extension point="org.eclipse.emf.facet.infra.browser.custom.core.registration">
+ <browserCustomization file="resources/CollabCustomization.uiCustom" loadByDefault="true"/>
+ </extension>
+ <extension point="org.eclipse.emf.facet.infra.query.registration">
+ <modelqueryset file="resources/CollabQueries.querySet"/>
+ </extension>
+ <extension point="org.eclipse.emf.facet.infra.facet.registration">
+ <facetset file="resources/CollabFacet.facetSet">
+ </facetset>
+ </extension>
+</plugin>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/pom.xml b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/pom.xml
new file mode 100644
index 0000000..24fd918
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/pom.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2013 Atos.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Arthur Daussy <a href="mailto:arthur.daussy@atos.net"> - initial API and implementation
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <relativePath>../../../Releng/org.topcased.fast.tycho.master/pom.xml</relativePath>
+ <groupId>org.topcased.fast</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.7.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.papyrus.team.collaborative.integration.papyrus.svn</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>SVN Control</name>
+</project>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabCustomization.uiCustom b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabCustomization.uiCustom
new file mode 100644
index 0000000..4ad8038
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabCustomization.uiCustom
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="ASCII"?>
+<uicustom:MetamodelView xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:query="http://www.eclipse.org/EmfFacet/infra/query/0.8.incubation" xmlns:uicustom="http://www.eclipse.org/EmfFacet/infra/browser/custom/0.8" metamodelURI="http://www.eclipse.org/collab">
+ <types metaclassName="CollabFacet.CollabElement">
+ <customizedFeatures customizedFeature="facetOverlayIcon">
+ <valueCases>
+ <value xsi:type="uicustom:StaticFeatureValue" value="/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/PartialLock_16x16.png:TopRight"/>
+ <condition xsi:type="query:JavaModelQuery" href="CollabQueries.querySet#IsPartialyLocked"/>
+ </valueCases>
+ </customizedFeatures>
+ </types>
+</uicustom:MetamodelView>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabFacet.facetSet b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabFacet.facetSet
new file mode 100644
index 0000000..b4ec037
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabFacet.facetSet
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="ASCII"?>
+<facet:FacetSet xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:facet="http://www.eclipse.org/EmfFacet/infra/facet/0.8.incubation"
+ xmlns:query="http://www.eclipse.org/EmfFacet/infra/query/0.8.incubation"
+ name="CollabFacet"
+ nsURI="http://www.eclipse.org/collab"
+ nsPrefix="collab">
+ <eClassifiers xsi:type="facet:Facet" name="CollabElement" abstract="true">
+ <eSuperTypes href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ <conditionQuery xsi:type="query:JavaModelQuery" href="CollabQueries.querySet#IsCollabQuery"/>
+ </eClassifiers>
+ <extendedPackage href="http://www.eclipse.org/emf/2002/Ecore#/"/>
+</facet:FacetSet>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabQueries.querySet b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabQueries.querySet
new file mode 100644
index 0000000..fcb050c
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/resources/CollabQueries.querySet
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="ASCII"?>
+<query:ModelQuerySet 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" xmlns:query="http://www.eclipse.org/EmfFacet/infra/query/0.8.incubation" name="CollabQueries">
+ <associatedMetamodels href="http://www.eclipse.org/emf/2002/Ecore#/"/>
+ <queries xsi:type="query:JavaModelQuery" name="IsCollabQuery" description="If the elemnt is a collab element" implementationClassName="org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.queries.IsCollabQuery">
+ <returnType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
+ <scope href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="IsPartialyLocked" description="Return true is at least one of the Nuplet of linked resource is locked" implementationClassName="org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.queries.IsPartialyLocked">
+ <returnType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
+ <scope href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </queries>
+</query:ModelQuerySet>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/Activator.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/Activator.java
new file mode 100644
index 0000000..13fec00
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/Activator.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.svn;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+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.team.collaborative.integration.papyrus.svn"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ *
+ * This method returns an <code>org.eclipse.swt.graphics.Image</code> identified by its pluginId and iconPath.<BR>
+ */
+ public static Image getPluginIconImage(String pluginId, String iconPath) {
+ String key = pluginId + iconPath;
+ ImageRegistry registry = getDefault().getImageRegistry();
+ Image image = registry.get(key);
+ if(image == null) {
+ ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, iconPath);
+ registry.put(key, desc);
+ image = registry.get(key);
+ }
+ return image;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/commands/AddFileToCollabSVN.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/commands/AddFileToCollabSVN.java
new file mode 100644
index 0000000..b0fd1ee
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/commands/AddFileToCollabSVN.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.commands;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.connector.svn.utils.SVNUtils;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions.CommitHandler;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions.LockAction;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.team.collaborative.utils.CollabFunctionsFactory;
+
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Sets;
+
+
+/**
+ * The Class AddFileToCollabSVN.
+ * This command is used to add file to a SVN repository using a {@link ControlModeRequest}.
+ * The files shall be already serialized.
+ */
+public class AddFileToCollabSVN extends AbstractTransactionalCommand {
+
+ // private Collection<URI> uris;
+ /** The request. */
+ private ControlModeRequest request;
+
+ /**
+ * Instantiates a new adds the file to collab svn.
+ *
+ * @param domain
+ * the domain
+ * @param request
+ * the request
+ */
+ public AddFileToCollabSVN(TransactionalEditingDomain domain, ControlModeRequest request) {
+ super(domain, "Add fiel to collacb", null);
+ this.request = request;
+ }
+
+ /**
+ * Adds the source resource.
+ *
+ * @param extension
+ * the extension
+ * @param resources
+ * the resources
+ */
+ protected void addSourceResource(String extension, Collection<Resource> resources) {
+ Resource resource = request.getSourceResource(extension);
+ if(resource != null) {
+ resources.add(resource);
+ }
+ }
+
+ /**
+ * Adds the target resource.
+ *
+ * @param extension
+ * the extension
+ * @param resources
+ * the resources
+ */
+ protected void addTargetResource(String extension, Collection<Resource> resources) {
+ Resource resource = request.getTargetResource(extension);
+ if(resource != null) {
+ resources.add(resource);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ /*
+ * This part should be more generic
+ */
+ Set<Resource> targetResource = new HashSet<Resource>();
+ addTargetResource("uml", targetResource);
+ addTargetResource("di", targetResource);
+ addTargetResource("notation", targetResource);
+ Set<Resource> sourceResource = new HashSet<Resource>();
+ addSourceResource("uml", sourceResource);
+ addSourceResource("di", sourceResource);
+ addSourceResource("notation", sourceResource);
+
+ //Add target resource to repository
+ Collection<IFile> targetExtendedFiles = Collections2.transform(targetResource, CollabFunctionsFactory.getResourceToIFile());
+ IStatus status = SVNUtils.addToRepository(UIUtils.getLabel(request.getTargetObject()), targetExtendedFiles);
+ if(!status.isOK()) {
+ throw new ExecutionException(status.getMessage(), status.getException());
+ }
+ //Commit source resources
+ HashSet<IExtendedURI> sourceExtendedURIs = Sets.newHashSet(Collections2.transform(sourceResource, CollabFunctionsFactory.getResourceToExtendedURIWithContainment()));
+ ResourceSet resourceSet = request.getEditingDomain().getResourceSet();
+ StringBuilder commitMessage = new StringBuilder("Creation of new partition ");
+ commitMessage.append(getPartitionName());
+ status = CommitHandler.doCommit(sourceExtendedURIs, resourceSet, false, commitMessage.toString());
+ if(!status.isOK()) {
+ throw new ExecutionException(status.getMessage(), status.getException());
+ }
+ //Take lock in new resources
+ Set<IExtendedURI> targetExtendedURIs = Sets.newHashSet(Collections2.transform(targetResource, CollabFunctionsFactory.getResourceToExtendedURIWithContainment()));
+ status = LockAction.doSafeLock(resourceSet, targetExtendedURIs, false);
+ if(!status.isOK()) {
+ throw new ExecutionException(status.getMessage(), status.getException());
+ }
+ return CommandResult.newOKCommandResult();
+ }
+
+ /**
+ * Gets the partition name.
+ *
+ * @return the partition name
+ */
+ protected String getPartitionName() {
+ return request.getTargetResource("uml").getURI().trimFileExtension().segment(1);
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/commands/SaveCommand.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/commands/SaveCommand.java
new file mode 100644
index 0000000..9af1e6b
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/commands/SaveCommand.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.ui.ISaveablePart;
+
+
+/**
+ * The Class SaveCommand.
+ * Command to save an editor
+ */
+public class SaveCommand extends AbstractTransactionalCommand {
+
+ /** The editor. */
+ private ISaveablePart editor;
+
+ /**
+ * Instantiates a new save command.
+ *
+ * @param domain
+ * the domain
+ * @param editor
+ * the editor
+ */
+ public SaveCommand(TransactionalEditingDomain domain, ISaveablePart editor) {
+ //Set list command to null the save command is secure with read only
+ super(domain, "Save command", null);
+ this.editor = editor;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ try {
+ editor.doSave(monitor);
+ } catch (Exception e) {
+ return CommandResult.newErrorCommandResult(e);
+ }
+ return CommandResult.newOKCommandResult();
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/control/SVNControlModeParticipant.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/control/SVNControlModeParticipant.java
new file mode 100644
index 0000000..db7733e
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/control/SVNControlModeParticipant.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.control;
+
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant;
+import org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.commands.AddFileToCollabSVN;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.commands.SaveCommand;
+import org.eclipse.papyrus.team.collaborative.utils.CollabUtils;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.ISaveablePart;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * The Class SVNControlModeParticipant.
+ * This {@link IControlCommandParticipant} provide mean to automatically integrate file generated after a control into a SVN repository
+ * WARNING: The {@link IUncontrolCommandParticipant} is not implemented yet
+ */
+public class SVNControlModeParticipant implements IControlCommandParticipant, IUncontrolCommandParticipant {
+
+ /**
+ * Instantiates a new sVN control mode participant.
+ */
+ public SVNControlModeParticipant() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.controlmode.interfaces.IControlModeParticipant#getID()
+ */
+ @Override
+ public String getID() {
+ return "org.eclipse.papyrus.team.collaborative.integration.papyrus.control.SVNControlModeParticipant";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.controlmode.interfaces.IControlModeParticipant#getPriority()
+ */
+ @Override
+ public int getPriority() {
+ return 10000;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.controlmode.interfaces.IUncontrolCommandParticipant#provideUnControlCommand(org.eclipse.papyrus.controlmode.request.
+ * ControlModeRequest)
+ */
+ @Override
+ public boolean provideUnControlCommand(ControlModeRequest request) {
+ return CollabUtils.isCollab(request.getTargetObject());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.controlmode.interfaces.IUncontrolCommandParticipant#getPreUncontrolCommand(org.eclipse.papyrus.controlmode.request.
+ * ControlModeRequest)
+ */
+ @Override
+ public ICommand getPreUncontrolCommand(ControlModeRequest request) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.controlmode.interfaces.IUncontrolCommandParticipant#getPostUncontrolCommand(org.eclipse.papyrus.controlmode.request.
+ * ControlModeRequest)
+ */
+ @Override
+ public ICommand getPostUncontrolCommand(ControlModeRequest request) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.controlmode.interfaces.IControlCommandParticipant#provideControlCommand(org.eclipse.papyrus.controlmode.request.
+ * ControlModeRequest)
+ */
+ @Override
+ public boolean provideControlCommand(ControlModeRequest request) {
+ return CollabUtils.isCollab(request.getTargetObject());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.controlmode.interfaces.IControlCommandParticipant#getPreControlCommand(org.eclipse.papyrus.controlmode.request.
+ * ControlModeRequest)
+ */
+ @Override
+ public ICommand getPreControlCommand(ControlModeRequest request) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.controlmode.interfaces.IControlCommandParticipant#getPostControlCommand(org.eclipse.papyrus.controlmode.request.
+ * ControlModeRequest)
+ */
+ @Override
+ public ICommand getPostControlCommand(ControlModeRequest request) {
+ CompositeTransactionalCommand cc = new CompositeTransactionalCommand(request.getEditingDomain(), "Share file to SVN with need lock");
+ IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(editor instanceof ISaveablePart) {
+ cc.compose(new SaveCommand(request.getEditingDomain(), editor));
+ cc.compose(new AddFileToCollabSVN(request.getEditingDomain(), request));
+ }
+ return cc;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/handler/SVNCollabControlCommandHandler.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/handler/SVNCollabControlCommandHandler.java
new file mode 100644
index 0000000..a40d03a
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/handler/SVNCollabControlCommandHandler.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ * Philippe Roland (Atos) philippe.roland@atos.net - minor change to the
+ * default naming algorithm to ensure it suggests a valid name
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.handler;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeManager;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.infra.services.controlmode.IControlModeManager;
+import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.ui.CreateCollabModelFragmentDialog;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs.PreviewDialog;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.providers.ExtensivePartitionNameLabelProvider;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.views.modelexplorer.handler.AbstractModelExplorerHandler;
+import org.eclipse.swt.widgets.Display;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
+
+/**
+ * The Class SVNCollabControlCommandHandler.
+ * Specific handler for fragment creation.
+ * This handler retrict the {@link URI} of the new target {@link Resource}
+ */
+public class SVNCollabControlCommandHandler extends AbstractModelExplorerHandler {
+
+ private static final String PARTITION_PREFIX = "__Partition";
+
+ private static final String ILLEGAL_CHARACTERS = "[^a-zA-Z0-9_]";
+
+ private static final String EMPTY_STRING = "";
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ List<EObject> selection = getCurrentSelectionAdaptedToType(event, EObject.class);
+ if(selection == null || selection.isEmpty() || selection.size() > 1) {
+ NotificationBuilder.createInfoPopup("Nothing to control").run();
+ return null;
+ }
+ EObject eObjectToControl = selection.get(0);
+ Resource eResource = eObjectToControl.eResource();
+ CreateCollabModelFragmentDialog dialog = new CreateCollabModelFragmentDialog(Display.getDefault().getActiveShell(), eResource, getDefaultName(event));
+ if(dialog.open() == CreateCollabModelFragmentDialog.OK) {
+ ControlModeRequest controlRequest = ControlModeRequest.createUIControlModelRequest(getEditingDomain(), eObjectToControl, dialog.getURI());
+ IControlModeManager controlMng = ControlModeManager.getInstance();
+ ICommand controlCommand = controlMng.getControlCommand(controlRequest);
+ getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(controlCommand));
+ PreviewDialog partitionDialog = new PreviewDialog(Display.getDefault().getActiveShell(), new ExtensivePartitionNameLabelProvider( UIUtils.getModelExplorerLavelProvider()), "Model Partition", EMPTY_STRING);
+ if(selection != null && !selection.isEmpty()) {
+ partitionDialog.setObjectsToReveal(Collections.singleton(eObjectToControl));
+ }
+ partitionDialog.open();
+ }
+ return null;
+ }
+
+ /**
+ * Create the default resource name from the selected element
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ protected String getDefaultName(ExecutionEvent event) throws ExecutionException {
+ List<ModelElementItem> selection = getCurrentSelectionAdaptedToType(event, ModelElementItem.class);
+ if(selection != null && !selection.isEmpty()) {
+ String label = selection.get(0).getText().trim() + PARTITION_PREFIX;
+ label = label.replaceAll(ILLEGAL_CHARACTERS, "");
+ return label;
+ }
+ return EMPTY_STRING;
+ }
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/handler/ShowModelPartitionHandler.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/handler/ShowModelPartitionHandler.java
new file mode 100644
index 0000000..83f44d3
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/handler/ShowModelPartitionHandler.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs.PreviewDialog;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.providers.ExtensivePartitionNameLabelProvider;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.views.modelexplorer.handler.AbstractModelExplorerHandler;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * The Class ShowModelPartitionHandler.
+ * Handler use to display the current partitioning of a model. It will reveal the current selected element
+ */
+public class ShowModelPartitionHandler extends AbstractModelExplorerHandler {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ List<EObject> selection = getCurrentSelectionAdaptedToType(event, EObject.class);
+ PreviewDialog dialog = new PreviewDialog(Display.getDefault().getActiveShell(), new ExtensivePartitionNameLabelProvider( UIUtils.getModelExplorerLavelProvider()), "Model Partition", "The name of each partition appear between the [] before each element name");
+ if(selection != null && !selection.isEmpty()) {
+ dialog.setObjectsToReveal(selection);
+ }
+ dialog.open();
+ return null;
+ }
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/queries/IsCollabQuery.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/queries/IsCollabQuery.java
new file mode 100644
index 0000000..376d86c
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/queries/IsCollabQuery.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.queries;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
+import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
+import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.PapyrusResourceUtils;
+import org.eclipse.papyrus.team.collaborative.participants.locker.ILocker;
+import org.eclipse.papyrus.team.collaborative.utils.CollabFunctionsFactory;
+
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Sets;
+
+
+/**
+ * Return true if the element is a collab element
+ *
+ * @author adaussy
+ *
+ */
+public class IsCollabQuery implements IJavaModelQuery<EObject, Boolean> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery#evaluate(org.eclipse.emf.ecore.EObject,
+ * org.eclipse.emf.facet.infra.query.core.java.ParameterValueList)
+ */
+ @Override
+ public Boolean evaluate(EObject arg0, ParameterValueList arg1) throws ModelQueryExecutionException {
+ List<URI> uris = new ArrayList<URI>();
+ URI uri = arg0.eResource().getURI();
+ ResourceSet resourceSet = arg0.eResource().getResourceSet();
+ uris.add(uri);
+ PapyrusResourceUtils.addExtraResources(resourceSet, uris, uri);
+ Set<IExtendedURI> extendedURIS = Sets.newHashSet(Collections2.transform(uris, CollabFunctionsFactory.getURIToExtendedURIWithContainment()));
+ ILocker locker = ICollaborativeManager.INSTANCE.getLocker(extendedURIS, resourceSet);
+ if(locker == null) {
+ return false;
+ }
+ boolean result = false;
+ for(IExtendedURI extURI : extendedURIS) {
+ if(locker.isLocked(extURI).isOK()) {
+ result = true;
+ }
+ }
+ return result;
+
+
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/queries/IsPartialyLocked.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/queries/IsPartialyLocked.java
new file mode 100644
index 0000000..246ffab
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/queries/IsPartialyLocked.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.queries;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
+import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
+import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.PapyrusResourceUtils;
+import org.eclipse.papyrus.team.collaborative.participants.locker.ILocker;
+import org.eclipse.papyrus.team.collaborative.utils.CollabFunctionsFactory;
+
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Sets;
+
+
+/**
+ * The Class IsPartialyLocked.
+ * Return true if the element is partialy locked. Partialy locked mean that there is one of the di or uml or notation model that has not been locked
+ */
+public class IsPartialyLocked implements IJavaModelQuery<EObject, Boolean> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery#evaluate(org.eclipse.emf.ecore.EObject,
+ * org.eclipse.emf.facet.infra.query.core.java.ParameterValueList)
+ */
+ @Override
+ public Boolean evaluate(EObject arg0, ParameterValueList arg1) throws ModelQueryExecutionException {
+ List<URI> uris = new ArrayList<URI>();
+ URI uri = arg0.eResource().getURI();
+ ResourceSet resourceSet = arg0.eResource().getResourceSet();
+ uris.add(uri);
+ PapyrusResourceUtils.addExtraResources(resourceSet, uris, uri);
+ Set<IExtendedURI> extendedURIS = Sets.newHashSet(Collections2.transform(uris, CollabFunctionsFactory.getURIToExtendedURIWithContainment()));
+ ILocker locker = ICollaborativeManager.INSTANCE.getLocker(extendedURIS, resourceSet);
+ if(locker == null) {
+ return false;
+ }
+ boolean oneLocked = false;
+ boolean oneUnlocked = false;
+ for(IExtendedURI extURI : extendedURIS) {
+ if(locker.isLocked(extURI).isOK()) {
+ oneLocked = true;
+ } else {
+ oneUnlocked = true;
+ }
+ }
+ return oneUnlocked && oneLocked;
+
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/ui/CreateCollabModelFragmentDialog.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/ui/CreateCollabModelFragmentDialog.java
new file mode 100644
index 0000000..4a2d329
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/ui/CreateCollabModelFragmentDialog.java
@@ -0,0 +1,373 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Anyware Technologies. All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Jacques Lescot (Anyware Technologies) - initial API and
+ * implementation
+ ******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.ui;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.Activator;
+import org.eclipse.papyrus.team.collaborative.reports.LogHelper;
+import org.eclipse.papyrus.team.collaborative.utils.CollabFunctionsFactory;
+import org.eclipse.papyrus.team.collaborative.utils.URIUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Dialog that will ask the user the name of the new partition and create an {@link URI}
+ *
+ * @author adaussy
+ *
+ */
+public class CreateCollabModelFragmentDialog extends Dialog {
+
+ private URI uri;
+
+ private Resource currentResource;
+
+ private String defaultName;
+
+
+ private static final String COLLAB_FOLDER_PATH = ".collab/";
+
+ /**
+ * The constructor
+ *
+ * @param parent
+ * @param theDomain
+ * @param theCurrentResource
+ * @param defaultName
+ */
+ public CreateCollabModelFragmentDialog(Shell parent, Resource theCurrentResource, String defaultName) {
+ super(parent);
+ this.currentResource = theCurrentResource;
+ this.defaultName = defaultName;
+ this.title = "Create new partition";
+ this.style = SWT.SAVE;
+
+ normalizeStyle();
+ setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE);
+ }
+
+ private URI computetURI() {
+ IFile file = CollabFunctionsFactory.getResourceToIFile().apply(currentResource);
+ IProject project = file.getProject();
+ IFolder folder = project.getFolder(COLLAB_FOLDER_PATH);
+ if(!folder.exists()) {
+ try {
+ folder.create(true, true, null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ LogHelper.getInstance().logError("Unable to fragment the model", Activator.PLUGIN_ID, e);
+ return null;
+ }
+ }
+
+ return URIUtils.getURI(folder.getFullPath());
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Control result = super.createContents(parent);
+ this.uriField.setText(defaultName);
+ return result;
+ }
+
+ /**
+ * Creates and, if it already exists, loads the specified resource. This implementation verifies
+ * that a resource can be opened for that URI, that the resource is not the object's current
+ * container, and that it is not read-only in the editing domain. If there is an existing
+ * resource with that URI, it prompts before overriding or adding to it.
+ *
+ * @see org.eclipse.emf.common.ui.dialogs.ResourceDialog#processResources()
+ */
+ protected boolean processResources() {
+ String uriText = getURIText();
+ if("".equals(uriText)) {
+ ErrorDialog.openError(Display.getDefault().getActiveShell(), "Illegal partition name", "The name can not be empty", new Status(Status.ERROR, Activator.PLUGIN_ID, "Illegal name"));
+ return false;
+ }
+ Matcher matcher = LEGAL_NAME.matcher(uriText);
+ if(matcher.matches()) {
+ URI uri = computetURI().appendSegment(uriText).appendFileExtension("uml");
+ if(!alreadyExist(uri)) {
+ this.uri = uri;
+ return true;
+ } else {
+ ErrorDialog.openError(Display.getDefault().getActiveShell(), "Illegal partition name", "This name is already used", new Status(Status.ERROR, Activator.PLUGIN_ID, "Illegal name"));
+ return false;
+ }
+ }
+ ErrorDialog.openError(Display.getDefault().getActiveShell(), "Illegal partition name", "The partition name shoudl respect ^[a-zA-Z][a-zA-Z0-9]*?$ convention", new Status(Status.ERROR, Activator.PLUGIN_ID, "Illegal name"));
+ return false;
+ }
+
+ protected boolean alreadyExist(URI uri) {
+ for(Resource r : currentResource.getResourceSet().getResources()) {
+ if(r.getURI().equals(uri)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static final Pattern LEGAL_NAME = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_]*?$");
+
+ /**
+ * Return the created Resource
+ *
+ * @return the Resource
+ */
+ public URI getURI() {
+ return uri;
+ }
+
+
+ protected static final int CONTROL_OFFSET = 10;
+
+ protected String title;
+
+ protected int style;
+
+ protected Text uriField;
+
+ protected String uriText;
+
+ protected void normalizeStyle() {
+ // Ensure there are no extraneous style bits.
+ //
+ if((style & ~(SWT.MULTI | SWT.SINGLE | SWT.OPEN | SWT.SAVE)) != 0) {
+ throw new IllegalArgumentException("extraneous style bits specified (only SWT.MULTI, SWT.SINGLE, SWT.OPEN, SWT.SAVE allowed");
+ }
+
+ // Assign default style bits, if necessary, and ensure none conflict.
+ //
+ if((style & SWT.MULTI) == 0 && (style & SWT.SINGLE) == 0) {
+ style |= SWT.SINGLE;
+ } else if((style & SWT.MULTI) != 0 && (style & SWT.SINGLE) != 0) {
+ throw new IllegalArgumentException("conflicting style bits specified (sWT.MUTLI and SWT.SINGLE)");
+ }
+
+ if((style & SWT.OPEN) == 0 && (style & SWT.SAVE) == 0) {
+ style |= SWT.OPEN;
+ } else if((style & SWT.OPEN) != 0 && (style & SWT.SAVE) != 0) {
+ throw new IllegalArgumentException("conflicting style bits specified (sWT.OPEN and SWT.SAVE)");
+ }
+
+ if(isMulti() && isSave()) {
+ throw new IllegalArgumentException("conflicting style bits specified (sWT.MULTI and SWT.SAVE)");
+ }
+ }
+
+ protected boolean isSave() {
+ return (style & SWT.SAVE) != 0;
+ }
+
+ protected boolean isMulti() {
+ return (style & SWT.MULTI) != 0;
+ }
+
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(title);
+ }
+
+ /**
+ * Creates and returns the contents of the upper part of this dialog.
+ * This implementation creates a labeled text field for the URI(s) and buttons for browsing the
+ * file system and workspace. These buttons are configured (selection listeners are added) by calling {@link #prepareBrowseFileSystemButton} and
+ * {@link #prepareBrowseWorkspaceButton}, respectively.
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite)super.createDialogArea(parent);
+ {
+ FormLayout layout = new FormLayout();
+ composite.setLayout(layout);
+
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.grabExcessVerticalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ data.widthHint = 500;
+ composite.setLayoutData(data);
+ }
+
+ // buttonComposite has to be the first child of composite because subclasses are expecting this.
+ Composite buttonComposite = new Composite(composite, SWT.NONE);
+
+ Label resourceURILabel = new Label(composite, SWT.LEFT);
+ {
+ resourceURILabel.setText("Name of the new partition");
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, CONTROL_OFFSET);
+ data.top = new FormAttachment(0, CONTROL_OFFSET);
+ resourceURILabel.setLayoutData(data);
+ }
+
+ {
+ FormData data = new FormData();
+ data.top = new FormAttachment(resourceURILabel, CONTROL_OFFSET, SWT.CENTER);
+ data.left = new FormAttachment(resourceURILabel, CONTROL_OFFSET);
+ data.right = new FormAttachment(100, -CONTROL_OFFSET);
+ buttonComposite.setLayoutData(data);
+
+ buttonComposite.setLayout(new FormLayout());
+ }
+
+ uriField = new Text(composite, SWT.BORDER);
+ {
+ FormData data = new FormData();
+ data.top = new FormAttachment(buttonComposite, CONTROL_OFFSET);
+ data.left = new FormAttachment(0, CONTROL_OFFSET);
+ data.right = new FormAttachment(100, -CONTROL_OFFSET);
+ uriField.setLayoutData(data);
+ }
+
+ composite.setTabList(new Control[]{ uriField, buttonComposite });
+ return composite;
+ }
+
+ /**
+ * Called to prepare the Browse File System button, this implementation adds a selection listener
+ * that creates an appropriate {@link FileDialog}.
+ */
+ protected void prepareBrowseFileSystemButton(Button browseFileSystemButton) {
+ browseFileSystemButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ FileDialog fileDialog = new FileDialog(getShell(), style);
+ fileDialog.open();
+
+ String filterPath = fileDialog.getFilterPath();
+ if(isMulti()) {
+ String[] fileNames = fileDialog.getFileNames();
+ StringBuffer uris = new StringBuffer();
+
+ for(int i = 0, len = fileNames.length; i < len; i++) {
+ uris.append(URI.createFileURI(filterPath + File.separator + fileNames[i]).toString());
+ uris.append(" ");
+ }
+ uriField.setText((uriField.getText() + " " + uris.toString()).trim());
+ } else {
+ String fileName = fileDialog.getFileName();
+ if(fileName != null) {
+ uriField.setText(URI.createFileURI(filterPath + File.separator + fileName).toString());
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * Called to prepare the Browse Workspace button, this implementation adds a selection listener
+ * that creates an appropriate {@link WorkspaceResourceDialog}.
+ */
+ protected void prepareBrowseWorkspaceButton(Button browseWorkspaceButton) {
+ browseWorkspaceButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ if(isMulti()) {
+ StringBuffer uris = new StringBuffer();
+
+ IFile[] files = WorkspaceResourceDialog.openFileSelection(getShell(), null, null, true, null, null);
+ for(int i = 0, len = files.length; i < len; i++) {
+ uris.append(URI.createPlatformResourceURI(files[i].getFullPath().toString(), true));
+ uris.append(" ");
+ }
+ uriField.setText((uriField.getText() + " " + uris.toString()).trim());
+ } else {
+ IFile file = null;
+
+ if(isSave()) {
+ file = WorkspaceResourceDialog.openNewFile(getShell(), null, null, null, null);
+ } else {
+ IFile[] files = WorkspaceResourceDialog.openFileSelection(getShell(), null, null, false, null, null);
+ if(files.length != 0) {
+ file = files[0];
+ }
+ }
+
+ if(file != null) {
+ uriField.setText(URI.createPlatformResourceURI(file.getFullPath().toString(), true).toString());
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * Called when the OK button has been pressed, this method calls {@link #getURIText} to cache and return
+ * the URI text field's value (so that it may be retrieved even after the field has been disposed).
+ * It then calls {@link #processResources} to handle the specified URIs and optionally closes the dialog,
+ * based on its return value.
+ */
+ @Override
+ protected void okPressed() {
+ uriText = getURIText();
+ if(processResources()) {
+ super.okPressed();
+ } else {
+ uriField.selectAll();
+ uriField.setFocus();
+ }
+ }
+
+ /**
+ * Returns the value of the URI text field.
+ */
+ public String getURIText() {
+ return uriField != null && !uriField.isDisposed() ? uriField.getText() : uriText;
+ }
+
+ /**
+ * Returns the list of space-separated URIs from the URI text field.
+ */
+ public List<URI> getURIs() {
+ List<URI> uris = new ArrayList<URI>();
+ for(StringTokenizer stringTokenizer = new StringTokenizer(getURIText()); stringTokenizer.hasMoreTokens();) {
+ String uri = stringTokenizer.nextToken();
+ uris.add(URI.createURI(uri));
+ }
+ return uris;
+ }
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/ui/IconsPath.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/ui/IconsPath.java
new file mode 100644
index 0000000..8067086
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/svn/ui/IconsPath.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.svn.ui;
+
+
+/**
+ * The Interface IconsPath.
+ */
+public interface IconsPath {
+
+ /** The Constant PARTIAL_LOCKED_OVERLAY. */
+ public static final String PARTIAL_LOCKED_OVERLAY = "/org.eclipse.papyrus.team.collaborative.integration.papyrus.svn/icons/PartialLock_16x16.png";
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.classpath b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.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/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.gitignore b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.gitignore
new file mode 100644
index 0000000..19af0f1
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.gitignore
@@ -0,0 +1,3 @@
+*.class
+*.jar
+/target \ No newline at end of file
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.project b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.project
new file mode 100644
index 0000000..3567352
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.team.collaborative.integration.papyrus</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/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.settings/org.eclipse.jdt.core.prefs b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..6bb8136
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.objectteams.otdt.compiler.option.pure_java=enabled
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/META-INF/MANIFEST.MF b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..98c700e
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/META-INF/MANIFEST.MF
@@ -0,0 +1,36 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Team Ui
+Bundle-SymbolicName: org.eclipse.papyrus.team.collaborative.integration.papyrus;singleton:=true
+Bundle-Version: 1.7.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.team.collaborative.integration.papyrus.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.team.collaborative;bundle-version="1.0.0",
+ com.google.guava,
+ org.eclipse.emf.ecore;bundle-version="2.7.0",
+ org.eclipse.papyrus.infra.core,
+ org.eclipse.papyrus.infra.gmfdiag.modelexplorer,
+ org.eclipse.ui.navigator;bundle-version="3.5.101",
+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.1.2",
+ org.eclipse.papyrus.infra.emf.readonly,
+ org.eclipse.core.expressions,
+ org.eclipse.uml2.uml;bundle-version="3.2.100",
+ org.eclipse.emf.edit,
+ org.eclipse.gmf.runtime.common.ui,
+ org.eclipse.papyrus.uml.tools,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.views.properties.tabbed,
+ org.eclipse.emf.transaction,
+ org.eclipse.papyrus.infra.gmfdiag.common,
+ org.eclipse.papyrus.views.modelexplorer,
+ org.eclipse.papyrus.infra.emf,
+ org.eclipse.papyrus.infra.widgets,
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions,
+ org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs,
+ org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.providers,
+ org.eclipse.papyrus.team.collaborative.integration.papyrus.utils
+Bundle-Vendor: Atos
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/about.html b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/about.html
new file mode 100644
index 0000000..d35d5ae
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/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>June 5, 2007</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>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/build.properties b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/build.properties
new file mode 100644
index 0000000..6c480f3
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/TeamIcon.png b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/TeamIcon.png
new file mode 100644
index 0000000..bb1d469
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/TeamIcon.png
Binary files differ
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/commit.gif b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/commit.gif
new file mode 100644
index 0000000..b67692d
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/commit.gif
Binary files differ
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/lock.gif b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/lock.gif
new file mode 100644
index 0000000..1075ee4
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/lock.gif
Binary files differ
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/revert.gif b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/revert.gif
new file mode 100644
index 0000000..c01c384
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/revert.gif
Binary files differ
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/unlock.gif b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/unlock.gif
new file mode 100644
index 0000000..73f3c2d
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/unlock.gif
Binary files differ
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/update.gif b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/update.gif
new file mode 100644
index 0000000..8c76387
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/icons/update.gif
Binary files differ
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/plugin.xml b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/plugin.xml
new file mode 100644
index 0000000..6b66d5f
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/plugin.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup">
+ <menu
+ icon="icons/TeamIcon.png"
+ id="org.eclipse.papyrus.team.collaborative.ui.collab.menu"
+ label="Collaborative">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <test
+ property="org.eclipse.papyrus.team.collaborative.integration.papyrus.isCollab"
+ value="true">
+ </test>
+ </with>
+ </visibleWhen>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.papyrus.team.collaborative.ui.collab.menu">
+ <menu
+ icon="icons/lock.gif"
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.menu"
+ label="Lock">
+ <dynamic
+ class="org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.items.LockStrategyItemProvider"
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.lockItems">
+ </dynamic>
+ </menu>
+ <menu
+ icon="icons/unlock.gif"
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.unlock"
+ label="Unlock">
+ <dynamic
+ class="org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.items.UnlockStrategyItemProvider"
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.UnlockItem">
+ </dynamic>
+ </menu>
+ <command
+ commandId="org.eclipse.papyrus.team.collaborative.integration.papyrus.update"
+ icon="icons/update.gif"
+ label="Update"
+ style="push"
+ tooltip="Update the all model from the repository">
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.team.collaborative.integration.papyrus.commit"
+ icon="icons/commit.gif"
+ label="Commit"
+ style="push"
+ tooltip="Commit all modification to the repository">
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.team.collaborative.integration.papyrus.revert"
+ icon="icons/revert.gif"
+ label="Revert"
+ style="push"
+ tooltip="Revert all changes">
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.team.collaborative.collaborative">
+ <LockingStrategy
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.elementsandcontents"
+ impl="org.eclipse.papyrus.team.collaborative.integration.papyrus.stategies.PapyrusSelectionAllContent"
+ name="Selected element and content">
+ </LockingStrategy>
+ <LockingStrategy
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.papyrusResourceContent"
+ impl="org.eclipse.papyrus.team.collaborative.integration.papyrus.stategies.PapyrusCurrentResource"
+ name="Selected element">
+ </LockingStrategy>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions.UpdateHandler"
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.update"
+ name="Update">
+ </command>
+ <command
+ defaultHandler="org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions.CommitHandler"
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.commit"
+ name="Commit">
+ </command>
+ <command
+ defaultHandler="org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions.RevertHandler"
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.revert"
+ name="Revert">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.papyrus.team.collaborative.integration.papyrus.IsCollabPropertyTest"
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.iCollabID"
+ namespace="org.eclipse.papyrus.team.collaborative.integration.papyrus"
+ properties="isCollab"
+ type="org.eclipse.jface.viewers.ISelection">
+ </propertyTester>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.emf.readonly.readOnlyHandler">
+ <readOnlyHandler
+ class="org.eclipse.papyrus.team.collaborative.integration.papyrus.security.CollabReadOnlyHandler"
+ id="org.eclipse.papyrus.team.collaborative.integration.papyrus.CollabReadOnlyHandler"
+ priority="700">
+ </readOnlyHandler>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.core.model">
+ <modelSetSnippet
+ classname="org.eclipse.papyrus.team.collaborative.integration.papyrus.security.PreCommitReadOnlyHandler">
+ </modelSetSnippet>
+ </extension>
+
+</plugin>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/pom.xml b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/pom.xml
new file mode 100644
index 0000000..d070516
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/pom.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2013 Atos.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Arthur Daussy <a href="mailto:arthur.daussy@atos.net"> - initial API and implementation
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <relativePath>../../../Releng/org.topcased.fast.tycho.master/pom.xml</relativePath>
+ <groupId>org.topcased.fast</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.7.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.papyrus.team.collaborative.integration.papyrus</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>Team Ui</name>
+</project>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/Activator.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/Activator.java
new file mode 100644
index 0000000..cfdf6ae
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/Activator.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus;
+
+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
+ /** The Constant PLUGIN_ID. */
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.team.collaborative.integration.papyrus"; //$NON-NLS-1$
+
+ // The shared instance
+ /** The plugin. */
+ private static Activator plugin;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/IsCollabPropertyTest.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/IsCollabPropertyTest.java
new file mode 100644
index 0000000..0459c54
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/IsCollabPropertyTest.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.team.collaborative.utils.CollabUtils;
+
+
+/**
+ * Tester to check if the selection belong to a collaborative model.
+ *
+ * @author adaussy
+ */
+public class IsCollabPropertyTest extends PropertyTester {
+
+ /** The Constant IS_COLLAB_PROPERTY. */
+ private static final String IS_COLLAB_PROPERTY = "isCollab";
+
+ /**
+ * Instantiates a new checks if is collab property test.
+ */
+ public IsCollabPropertyTest() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if(IS_COLLAB_PROPERTY.equals(property)) {
+ if(receiver instanceof ISelection) {
+ ISelection selection = (ISelection)receiver;
+ if(selection instanceof IStructuredSelection) {
+ IStructuredSelection structurSelection = (IStructuredSelection)selection;
+ Object first = structurSelection.getFirstElement();
+ if(first instanceof IAdaptable) {
+ Object eObject = ((IAdaptable)first).getAdapter(EObject.class);
+ if(eObject != null) {
+ EObject eObject2 = (EObject)eObject;
+ return CollabUtils.isCollab(eObject2);
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/MatchingURIObject.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/MatchingURIObject.java
new file mode 100644
index 0000000..858b540
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/MatchingURIObject.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.utils.ExtendedURIUtil;
+import org.eclipse.uml2.uml.Element;
+
+import com.google.common.base.Predicate;
+
+
+/**
+ * The Class MatchingURIObject.
+ * Predicate that will return true if the EObject belong to the set of {@link IExtendedURI}
+ */
+public class MatchingURIObject implements Predicate<EObject> {
+
+ private Set<IExtendedURI> uris;
+
+ public MatchingURIObject(Set<IExtendedURI> uris) {
+ super();
+ this.uris = uris;
+ }
+
+ @Override
+ public boolean apply(EObject input) {
+ List<EObject> objectToTEObjects = new ArrayList<EObject>();
+ objectToTEObjects.add(input);
+ objectToTEObjects.addAll(NotationUtils.getLoadedAssociatedDiagrams(input));
+ for(IExtendedURI extendedURI : uris) {
+ for(EObject o : objectToTEObjects) {
+ boolean contained = ExtendedURIUtil.isIncluded(o, extendedURI);
+
+ if(contained) {
+ return contained;
+ }
+ }
+ }
+ return false;
+ }
+
+
+ protected EObject getSemanticObject(EObject eObject) {
+ EObject result = null;
+ if(eObject instanceof Element) {
+ result = eObject;
+ } else if(eObject instanceof View) {
+ //Handle view
+ result = ((View)eObject).getElement();
+ } else {
+ //Handle setereotype
+ Element baseElement = org.eclipse.uml2.uml.util.UMLUtil.getBaseElement(eObject);
+ if(baseElement != null) {
+ result = baseElement;
+ }
+ //TODO handle tab
+ }
+ return result;
+ }
+
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/RefreshHelper.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/RefreshHelper.java
new file mode 100644
index 0000000..f9a73a7
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/RefreshHelper.java
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Olivier Melois <a href="mailto:olivier.melois@atos.net"> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.AbstractCommand;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Helper used to store method for refreshin model explorer view
+ *
+ * @author omelois
+ *
+ */
+public final class RefreshHelper {
+
+
+ private RefreshHelper() {
+ }
+
+
+ /**
+ * Runnable that will be used to refresh the model explorer view
+ *
+ * @author adaussy
+ *
+ */
+ public static final class RefreshModelExplorerRunnable implements Runnable {
+
+ private final Collection<EObject> elementsToRefresh;
+
+ private static final int TIME_TO_REFRESH_MODEL_EXPLORER = 100;
+
+ /**
+ * @param elementsToRefresh
+ * Element to Refresh
+ */
+ public RefreshModelExplorerRunnable(Collection<EObject> elementsToRefresh) {
+ this.elementsToRefresh = elementsToRefresh;
+ }
+
+ @Override
+ public void run() {
+
+ try {
+ Thread.sleep(TIME_TO_REFRESH_MODEL_EXPLORER);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ if(elementsToRefresh != null) {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if(activePage != null) {
+ IViewReference viewRef = activePage.findViewReference(ModelExplorerPageBookView.VIEW_ID);
+ if(viewRef != null && viewRef.getView(false) instanceof ModelExplorerView) {
+ ModelExplorerView modelExplorerView = (ModelExplorerView)viewRef.getView(false);
+ modelExplorerView.refresh();
+// Set<Object> alreadyRefreshed = new HashSet<Object>();
+// if(view != null) {
+// for(EObject elementToRefresh : elementsToRefresh) {
+//
+// view.refreshObject(elementToRefresh, alreadyRefreshed);
+// alreadyRefreshed.add(elementToRefresh);
+// }
+// }
+ }
+ }
+// IViewReference[] viewReferences = activePage.getViewReferences();
+// for(IViewReference viewRef : viewReferences) {
+// if(viewRef.getId().equals(ModelExplorerPageBookView.VIEW_ID));
+// }
+
+ }
+ }
+ }
+
+ protected static final String ELEMENTS_TO_REFRESH_KEY = "elementsToRefresh"; //$NON-NLS-1$
+
+ /**
+ * Get the model explorer refresh command
+ *
+ * @param request
+ * IEditCommandRequest which implies refresh
+ * @return
+ */
+ public static ICommand getRefreshCommand(final IEditCommandRequest request) {
+ return new AbstractCommand("Refresh") //$NON-NLS-1$
+ {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ refreshPostMove(request);
+ return CommandResult.newOKCommandResult();
+ }
+
+ @Override
+ protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ refreshPostMove(request);
+ return CommandResult.newOKCommandResult();
+ }
+
+ @Override
+ protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ refreshPostMove(request);
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ }
+
+ /**
+ * Function to asynchronously refresh the model explorer after moving a breakdown element.
+ *
+ * @param request
+ */
+ private static void refreshPostMove(final IEditCommandRequest request) {
+ @SuppressWarnings("unchecked")
+ final Set<EObject> elementsToRefresh = (Set<EObject>)request.getParameter(ELEMENTS_TO_REFRESH_KEY);
+
+ refreshModelExplorer(elementsToRefresh);
+ }
+
+ public static void refreshModelExplorer(Collection<EObject> elementsToRefresh) {
+ if(elementsToRefresh != null && !(elementsToRefresh.isEmpty())) {
+ Display.getDefault().asyncExec(new RefreshModelExplorerRunnable(elementsToRefresh));
+ }
+ }
+
+ /**
+ * Adds an element to the list of elements that should be refreshed, in the request.
+ *
+ * @param element
+ * Element you want to refresh
+ * @param request
+ * Request in which the information about a refresh will be added
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public static void addElementToRefresh(EObject element, IEditCommandRequest request) {
+ Object elementsToRefresh = request.getParameter(ELEMENTS_TO_REFRESH_KEY);
+ if(elementsToRefresh == null) {
+ elementsToRefresh = new HashSet<EObject>();
+ request.getParameters().put(ELEMENTS_TO_REFRESH_KEY, elementsToRefresh);
+ }
+ if(elementsToRefresh instanceof Set<?>) {
+ ((Set)elementsToRefresh).add(element);
+ }
+ }
+
+ /**
+ * Checks whether a request has elements to refresh;
+ *
+ * @param request
+ * Request in which the information about a refresh will be added
+ * @return
+ */
+ public static boolean hasElementsToRefresh(IEditCommandRequest request) {
+ Object elementsToRefresh = request.getParameter(ELEMENTS_TO_REFRESH_KEY);
+ return elementsToRefresh instanceof Set<?> && (!((Set<?>)elementsToRefresh).isEmpty());
+ }
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/security/CollabReadOnlyHandler.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/security/CollabReadOnlyHandler.java
new file mode 100644
index 0000000..66f5887
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/security/CollabReadOnlyHandler.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.security;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.domain.EditingDomain;
+//import org.eclipse.papyrus.infra.emf.readonly.IReadOnlyHandler;
+import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler;
+import org.eclipse.papyrus.infra.emf.readonly.AbstractReadOnlyHandler;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions.LockAction;
+import org.eclipse.papyrus.team.collaborative.participants.locker.ILocker;
+import org.eclipse.papyrus.team.collaborative.utils.CollabFunctionsFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+
+/**
+ * The Class CollabReadOnlyHandler.
+ * This read only handler implement {@link IReadOnlyHandler} using the collaborative framework
+ */
+public class CollabReadOnlyHandler extends AbstractReadOnlyHandler {
+
+ public CollabReadOnlyHandler(EditingDomain editingDomain) {
+ super(editingDomain);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.readonly.IReadOnlyHandler#isReadOnly(org.eclipse.emf.common.util.URI[], org.eclipse.emf.edit.domain.EditingDomain)
+ */
+ @Override
+ public Optional<Boolean> anyReadOnly(URI[] uris) {
+ if(uris != null && uris.length > 0 && getEditingDomain() != null) {
+ ArrayList<URI> urisList = Lists.newArrayList(uris);
+ Collection<IExtendedURI> extendedURICollection = Collections2.transform(urisList, CollabFunctionsFactory.getURIToExtendedURIWithContainment());
+ HashSet<IExtendedURI> extendURISet = Sets.newHashSet(extendedURICollection);
+ ResourceSet resourceSet = getEditingDomain().getResourceSet();
+ if(ICollaborativeManager.INSTANCE.isCollab(extendURISet, resourceSet)) {
+ ILocker locker;
+ locker = ICollaborativeManager.INSTANCE.getLocker(extendURISet, resourceSet);
+ if(locker == null) {
+ return Optional.absent();
+ }
+ for(IExtendedURI extendURI : locker.getExtendedSet()) {
+ if(!locker.isLocked(extendURI).isOK()) {
+ return Optional.of(true);
+ }
+ }
+ }
+ }
+ return Optional.absent();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.readonly.IReadOnlyHandler#enableWrite(org.eclipse.emf.common.util.URI[], org.eclipse.emf.edit.domain.EditingDomain)
+ */
+ @Override
+ public Optional<Boolean> makeWritable(URI[] uris) {
+ ArrayList<URI> urisList = Lists.newArrayList(uris);
+ Collection<IExtendedURI> extendedURICollection = Collections2.transform(urisList, CollabFunctionsFactory.getURIToExtendedURIWithContainment());
+ HashSet<IExtendedURI> extendedURISet = Sets.newHashSet(extendedURICollection);
+ ResourceSet resourceSet = getEditingDomain().getResourceSet();
+ if(ICollaborativeManager.INSTANCE.isCollab(extendedURISet, resourceSet)) {
+ IStatus status = LockAction.doSafeLock(resourceSet, extendedURISet, true);
+ if(!status.isOK()) {
+ return Optional.absent();
+ }
+ return Optional.of(true);
+ }
+ return Optional.absent();
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/security/PreCommitReadOnlyHandler.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/security/PreCommitReadOnlyHandler.java
new file mode 100644
index 0000000..3593730
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/security/PreCommitReadOnlyHandler.java
@@ -0,0 +1,141 @@
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.security;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.Notification;
+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.NotificationFilter;
+import org.eclipse.emf.transaction.ResourceSetChangeEvent;
+import org.eclipse.emf.transaction.ResourceSetListenerImpl;
+import org.eclipse.emf.transaction.RollbackException;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.resource.IModelSetSnippet;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions.LockAction;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.team.collaborative.participants.locker.ILocker;
+import org.eclipse.papyrus.team.collaborative.utils.CollabFunctionsFactory;
+
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Sets;
+
+
+/**
+ * This model snippet will register a new {@link ResourceSetListener} that will provide a new security on modifed resources.
+ * Each time a resource will be set to modified this listener will check that the resources has been locked. If the resources is not lock then it will
+ * try to rollback the current transaction
+ *
+ * @author adaussy
+ *
+ */
+public class PreCommitReadOnlyHandler implements IModelSetSnippet {
+
+ /**
+ * This {@link ResourceSetListener} will listen each time a resource is modified to check that it has been locked or will ask for lock
+ *
+ * @author adaussy
+ *
+ */
+ private static class ResourceSetListener extends ResourceSetListenerImpl {
+
+ @Override
+ public boolean isPostcommitOnly() {
+ return false;
+ }
+
+ @Override
+ public boolean isPrecommitOnly() {
+ return true;
+ }
+
+ @Override
+ public boolean isAggregatePrecommitListener() {
+ return false;
+ }
+
+ /**
+ * Filter only IS_MODIFIED notification
+ */
+ private static NotificationFilter filter = NotificationFilter.createFeatureFilter(Resource.class, Resource.RESOURCE__IS_MODIFIED);
+
+ @Override
+ public NotificationFilter getFilter() {
+ return filter;
+ }
+
+
+ @Override
+ public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
+ final Set<Resource> resourceToTest = new HashSet<Resource>();
+ for(Notification n : event.getNotifications()) {
+ if(n.getNewBooleanValue()) {
+ Resource resource = (Resource)n.getNotifier();
+ //Filtered out any DI resource. Those resource are not collaborative resources
+ if(!DiModel.MODEL_FILE_EXTENSION.equals(resource.getURI().fileExtension())) {
+ resourceToTest.add(resource);
+ }
+ }
+ }
+ if(!resourceToTest.isEmpty()) {
+ TransactionalEditingDomain editingDomain = event.getEditingDomain();
+ ResourceSet resourceSet = editingDomain.getResourceSet();
+ HashSet<IExtendedURI> uriToTest = Sets.newHashSet(Collections2.transform(resourceToTest, CollabFunctionsFactory.getResourceToExtendedURIWithContainment()));
+ if(ICollaborativeManager.INSTANCE.isCollab(uriToTest, resourceSet)) {
+ Set<IExtendedURI> uriToLock = new HashSet<IExtendedURI>();
+ ILocker locker = ICollaborativeManager.INSTANCE.getLocker(uriToTest, resourceSet);
+ if(locker == null) {
+ return null;
+ }
+ for(IExtendedURI extendURI : locker.getExtendedSet()) {
+ if(!locker.isLocked(extendURI).isOK()) {
+ uriToLock.add(extendURI);
+ }
+ }
+ if(!uriToLock.isEmpty()) {
+ final IStatus status = LockAction.doSafeLock(resourceSet, uriToLock, true);
+ if(!status.isOK()) {
+ UIUtils.errorDialog(status, "Unable to lock");
+ throw new RollbackException(status);
+
+ }
+ }
+ }
+ }
+ return null;
+ }
+ }
+
+ public PreCommitReadOnlyHandler() {
+ }
+
+
+ private WeakHashMap<EditingDomain, ResourceSetListener> link = new WeakHashMap<EditingDomain, PreCommitReadOnlyHandler.ResourceSetListener>();
+
+ @Override
+ public void start(ModelSet modelsManager) {
+ TransactionalEditingDomain transactionalEditingDomain = modelsManager.getTransactionalEditingDomain();
+ ResourceSetListener listener = new ResourceSetListener();
+ link.put(transactionalEditingDomain, listener);
+ transactionalEditingDomain.addResourceSetListener(listener);
+
+ }
+
+ @Override
+ public void dispose(ModelSet modelsManager) {
+ TransactionalEditingDomain transactionalEditingDomain = modelsManager.getTransactionalEditingDomain();
+ transactionalEditingDomain.removeResourceSetListener(link.get(transactionalEditingDomain));
+
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/AbstractResourceBaseStrategy.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/AbstractResourceBaseStrategy.java
new file mode 100644
index 0000000..f32c9f7
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/AbstractResourceBaseStrategy.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.stategies;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.PapyrusResourceUtils;
+import org.eclipse.papyrus.team.collaborative.strategy.AbstractLockingStrategy;
+
+
+/**
+ * The Class AbstractResourceBaseStrategy.
+ * Abstract class for strategy based on resources
+ * TODO remove this class after release
+ */
+public abstract class AbstractResourceBaseStrategy extends AbstractLockingStrategy {
+
+
+
+ /**
+ * Add all satellite resources (uml,di,notation).
+ *
+ * @param ressourceSet
+ * the ressource set
+ * @param uris
+ * the uris
+ * @param uri
+ * the uri
+ */
+ protected void addExtraResources(ResourceSet ressourceSet, Collection<URI> uris, URI uri) {
+ PapyrusResourceUtils.addExtraResources(ressourceSet, uris, uri);
+ }
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/PapyrusCurrentResource.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/PapyrusCurrentResource.java
new file mode 100644
index 0000000..b59c189
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/PapyrusCurrentResource.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.stategies;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.utils.CollabFunctionsFactory;
+import org.eclipse.papyrus.team.collaborative.utils.ModelsUtil;
+
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Sets;
+
+
+/**
+ * Strategy that will lock the current triplet resource of the selection (uml,di,notation).
+ *
+ * @author adaussy
+ */
+public class PapyrusCurrentResource extends AbstractResourceBaseStrategy {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.strategy.ILockingStrategy#getBusinessObject(java.util.Collection)
+ */
+ @Override
+ public Set<IExtendedURI> getBusinessObject(Collection<EObject> eOjbects) {
+ if(!eOjbects.isEmpty()) {
+ ResourceSet ressourceSet = eOjbects.iterator().next().eResource().getResourceSet();
+ Collection<URI> uris = new HashSet<URI>();
+ for(EObject o : ModelsUtil.getRoots(eOjbects)) {
+ URI uri = o.eResource().getURI();
+ if(!uris.contains(uri)) {
+ uris.add(uri);
+ addExtraResources(ressourceSet, uris, uri);
+ }
+ }
+ return Sets.newHashSet(Collections2.transform(uris, CollabFunctionsFactory.getURIToExtendedURI()));
+ }
+ return Collections.emptySet();
+ }
+
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/PapyrusSelectionAllContent.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/PapyrusSelectionAllContent.java
new file mode 100644
index 0000000..2fee22d
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/stategies/PapyrusSelectionAllContent.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.stategies;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.utils.CollabFunctionsFactory;
+import org.eclipse.papyrus.team.collaborative.utils.ModelsUtil;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Sets;
+
+
+/**
+ * Locking strategy that will lock all resources which contains element contained by the selection.
+ *
+ * @author adaussy
+ */
+public class PapyrusSelectionAllContent extends AbstractResourceBaseStrategy {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.strategy.ILockingStrategy#getBusinessObject(java.util.Collection)
+ */
+ @Override
+ public Set<IExtendedURI> getBusinessObject(Collection<EObject> eOjbects) {
+ if(!eOjbects.isEmpty()) {
+ ResourceSet ressourceSet = eOjbects.iterator().next().eResource().getResourceSet();
+ Collection<URI> uris = new HashSet<URI>();
+ for(EObject o : ModelsUtil.getRoots(eOjbects)) {
+ URI uri = o.eResource().getURI();
+ if(!uris.contains(uri)) {
+ uris.add(uri);
+ addExtraResources(ressourceSet, uris, uri);
+ }
+ Predicate<Resource> semanticResourcePredicate = new Predicate<Resource>() {
+
+ @Override
+ public boolean apply(Resource input) {
+ return "uml".equals(input.getURI().fileExtension());
+ }
+ };
+ //Add all resource that contains at least one descendant of a selected resource
+ for(Resource r : Collections2.filter(ressourceSet.getResources(), semanticResourcePredicate)) {
+ for(EObject potentialDescedant : r.getContents()) {
+ if(EcoreUtil.isAncestor(o, potentialDescedant)) {
+ URI childResourceURI = r.getURI();
+ if(!uris.contains(childResourceURI)) {
+ uris.add(childResourceURI);
+ addExtraResources(ressourceSet, uris, childResourceURI);
+ continue;
+ }
+ }
+ }
+ }
+ }
+ return Sets.newHashSet(Collections2.transform(uris, CollabFunctionsFactory.getURIToExtendedURIWithContainment()));
+ }
+ return Collections.emptySet();
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/ICollabColors.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/ICollabColors.java
new file mode 100644
index 0000000..9342ee5
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/ICollabColors.java
@@ -0,0 +1,20 @@
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui;
+
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+
+
+public interface ICollabColors {
+
+ public static final Color COMMIT_COLLOR = UIUtils.RESOURCE_MANAGER.createColor(new RGB(255, 65, 72));
+
+ public static final Color UPDATE_COLLOR = UIUtils.RESOURCE_MANAGER.createColor(new RGB(133, 255, 161));
+
+ public static final Color REVERT_COLLOR = UIUtils.RESOURCE_MANAGER.createColor(new RGB(255, 215, 78));
+
+ public static final Color UNLOCK_COLLOR = UIUtils.RESOURCE_MANAGER.createColor(new RGB(172, 209, 62));
+
+ public static final Color LOCK_COLLOR = UIUtils.RESOURCE_MANAGER.createColor(new RGB(232, 132, 59));
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/AbstractCollabHandler.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/AbstractCollabHandler.java
new file mode 100644
index 0000000..b3528d0
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/AbstractCollabHandler.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.team.collaborative.utils.CollabUtils;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * Abstract class for Collaborative handler which are enable only if the project is collaborative.
+ *
+ * @author adaussy
+ */
+public abstract class AbstractCollabHandler extends AbstractHandler {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ EObject firstSelection = UIUtils.getFirstSelection();
+ if(firstSelection != null) {
+ return CollabUtils.isCollab(firstSelection);
+ }
+ return false;
+ }
+
+ protected ResourceSet getResourceSet() {
+ IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(editor instanceof CoreMultiDiagramEditor) {
+ CoreMultiDiagramEditor papyrusEditor = (CoreMultiDiagramEditor)editor;
+ return papyrusEditor.getEditingDomain().getResourceSet();
+ } else {
+ return null;
+ }
+ }
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/CommitHandler.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/CommitHandler.java
new file mode 100644
index 0000000..16beed3
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/CommitHandler.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.MatchingURIObject;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.ICollabColors;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs.CommitDialog;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs.PreviewDialog;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.providers.ExtensivePartitionNameLabelProvider;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.team.collaborative.participants.version.ICommitter;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * Handler use to deal with Commit action
+ * The commit action will be performed on all the current model
+ *
+ * @author adaussy
+ */
+public class CommitHandler extends AbstractCollabHandler {
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ //Check that everything is commit
+ if(!UIUtils.saveAllDirtyEditor().isOK()) {
+ return null;
+ }
+ ResourceSet resourceSet = getResourceSet();
+ if(resourceSet == null) {
+ UIUtils.errorDialog(CollabStatus.createErrorStatus("unable to retreive the resource set"), "Collaboratibe error");
+ return null;
+ }
+ Set<IExtendedURI> uris = new HashSet<IExtendedURI>();
+ for(Resource r : resourceSet.getResources()) {
+ IFile file = WorkspaceSynchronizer.getFile(r);
+ if(file != null && file.exists()) {
+ uris.add(new ExtendedURI(r.getURI()));
+ }
+ }
+ IStatus status = doCommit(uris, resourceSet, true, null);
+ if(!status.isOK() && status.getCode() == Status.ERROR) {
+ UIUtils.errorDialog(status, "Error");
+ }
+ return null;
+
+
+ }
+
+ /**
+ * Do commit action
+ *
+ * @param uris
+ * the uris to commit
+ * @param resourceSet
+ * the resource set
+ * @param isPreview
+ * Set to true if the used to be given preview
+ * @param message
+ * the message used for the commit operation
+ * @return the {@link IStatus} of the operation
+ */
+ public static IStatus doCommit(Set<IExtendedURI> uris, ResourceSet resourceSet, boolean isPreview, String message) {
+ ICommitter committer = ICollaborativeManager.INSTANCE.getCommitter(uris, resourceSet);
+ if(committer == null) {
+ return CollabStatus.createErrorStatus("Unable to get a ICommitter for uris\n" + uris);
+ }
+ Set<IExtendedURI> toBeCommitted = committer.getExtendedSet();
+ IStatus status = doCommitFromBuilder(resourceSet, committer, toBeCommitted, isPreview, message);
+ if(!status.isOK()) {
+ return status;
+ }
+ return Status.OK_STATUS;
+
+ }
+
+ /**
+ * Do commit from builder using a already created {@link ICommitter}
+ *
+ * @param resourceSet
+ * the resource set
+ * @param committer
+ * the {@link ICommitter} to use
+ * @param toBeCommitted
+ * {@link IExtendedURI} of what is about to be committed
+ * @param isPreview
+ * Set to true if the user has to be given preview
+ * @param message
+ * the message
+ * @return the i status
+ * @throws CollabException
+ * the collab exception
+ */
+ public static IStatus doCommitFromBuilder(ResourceSet resourceSet, ICommitter committer, Set<IExtendedURI> toBeCommitted, boolean isPreview, String message) {
+ if(isPreview || message == null) {
+ ExtensivePartitionNameLabelProvider labelProvider = new ExtensivePartitionNameLabelProvider(new MatchingURIObject(toBeCommitted),UIUtils.getModelExplorerLavelProvider());
+ labelProvider.setColor(ICollabColors.COMMIT_COLLOR);
+ CommitDialog commitDialog = new CommitDialog(Display.getDefault().getActiveShell(), labelProvider, "Commit Dialog", "Element in red will be committed");
+ Collection<EObject> objectsToReveal = UIUtils.getLeafSemanticElement(toBeCommitted, resourceSet);
+ if(objectsToReveal != null && !objectsToReveal.isEmpty()) {
+ commitDialog.setObjectsToReveal(objectsToReveal);
+ }
+ if(commitDialog.open() == PreviewDialog.OK) {
+ message = commitDialog.getCommitMessage();
+ } else {
+ return Status.CANCEL_STATUS;
+ }
+ }
+
+ //Keep lock force to true. This shall be improve later
+ IStatus commitStatus = committer.commit(message, true);
+ UIUtils.refreshModelExplorer(toBeCommitted, resourceSet);
+ if(!commitStatus.isOK()) {
+ return commitStatus;
+ }
+ return Status.OK_STATUS;
+ }
+
+
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/LockAction.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/LockAction.java
new file mode 100644
index 0000000..f43699a
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/LockAction.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.MatchingURIObject;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.ICollabColors;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs.PreviewDialog;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.providers.ExtensivePartitionNameLabelProvider;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.team.collaborative.participants.locker.ILocker;
+import org.eclipse.papyrus.team.collaborative.participants.version.IUpdater;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+import org.eclipse.papyrus.team.collaborative.strategy.ILockingStrategy;
+import org.eclipse.papyrus.team.collaborative.strategy.ILockingStrategy.Descriptor;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * The Class LockAction.
+ */
+public class LockAction extends Action {
+
+ /** The strategy. */
+ protected ILockingStrategy.Descriptor strategy;
+
+ /**
+ * Instantiates a new lock action.
+ *
+ * @param strategy
+ * the strategy
+ */
+ public LockAction(Descriptor strategy) {
+ super();
+ this.strategy = strategy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ super.run();
+ Collection<EObject> selection = UIUtils.getSelection();
+ if(!selection.isEmpty()) {
+ IStatus status = doLock(selection, strategy);
+ if(!status.isOK()) {
+ UIUtils.errorDialog(status, "Unable to lock");
+ }
+ }
+ return;
+ }
+
+
+ /**
+ * Do lock action
+ *
+ * @param selection
+ * the selection
+ * @param strategy
+ * the strategy the selected {@link ILockingStrategy.Descriptor}
+ * @return the i status
+ */
+ public static IStatus doLock(Collection<EObject> selection, ILockingStrategy.Descriptor strategy) {
+ EObject eObject = selection.iterator().next();
+ ResourceSet resourceSet = eObject.eResource().getResourceSet();
+ //Execute the strategy to define the functional object to lock
+ Set<IExtendedURI> objectToLock = strategy.getStrategy().getBusinessObject(selection);
+ return doSafeLock(resourceSet, objectToLock, true);
+ }
+
+
+ /**
+ * Do lock action
+ *
+ * @param resourceSet
+ * the resource set
+ * @param objectToLock
+ * the {@link IExtendedURI} about to be locked
+ * @param usePreview
+ * Set to true if the user has to be given preview
+ * @return the {@link IStatus} of the operation
+ */
+ public static IStatus doSafeLock(ResourceSet resourceSet, Set<IExtendedURI> objectToLock, boolean usePreview) {
+ //Check that everything is up to date
+ IUpdater updater = ICollaborativeManager.INSTANCE.getUpdater(objectToLock, resourceSet);
+ if(updater == null) {
+ UIUtils.errorDialog(CollabStatus.createErrorStatus("Unable to find a updater"), "Unable to find a updater");
+ return CollabStatus.createErrorStatus("Unable to find a updater");
+ }
+ if(!updater.getExtendedSet().isEmpty()) {
+ if(MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Need update", "You need to update those elements in order to perform a lock")) {
+ IStatus status = UpdateHandler.doUpdateFromUpdater(resourceSet, updater, true);
+ if(!status.isOK()) {
+ UIUtils.errorDialog(status, "Error");
+ }
+ resourceSet = UIUtils.getCurrentResourceSet();
+ } else {
+ return CollabStatus.CANCEL_STATUS;
+ }
+ }
+
+ return doUnlock(resourceSet, objectToLock, usePreview);
+
+ }
+
+ protected static IStatus doUnlock(ResourceSet resourceSet, Set<IExtendedURI> objectToLock, boolean usePreview) {
+ ILocker locker = ICollaborativeManager.INSTANCE.getLocker(objectToLock, resourceSet);
+ if(locker == null) {
+ UIUtils.errorDialog(CollabStatus.createErrorStatus("Unable to find a locker"), "Unable to lock");
+ return CollabStatus.createErrorStatus("Unable to find a locker");
+ }
+
+ Set<IExtendedURI> needsLock = locker.getExtendedSet();
+ if(usePreview) {
+ //Check if the lock can be taken
+ ExtensivePartitionNameLabelProvider labelProvider = new ExtensivePartitionNameLabelProvider(new MatchingURIObject(needsLock),UIUtils.getModelExplorerLavelProvider());
+ labelProvider.setColor(ICollabColors.LOCK_COLLOR);
+ PreviewDialog previewDialog = new PreviewDialog(Display.getDefault().getActiveShell(), labelProvider, "Lock Preview", "Element in orange will be locked");
+ Collection<EObject> objectsToReveal = UIUtils.getLeafSemanticElement(needsLock, resourceSet);
+ if(objectsToReveal != null && !objectsToReveal.isEmpty()) {
+ previewDialog.setObjectsToReveal(objectsToReveal);
+ }
+ if(previewDialog.open() != PreviewDialog.OK) {
+ return CollabStatus.CANCEL_STATUS;
+ }
+ }
+ IStatus status = locker.lock();
+ UIUtils.refreshModelExplorer(needsLock, resourceSet);
+ return status;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.action.Action#getText()
+ */
+ @Override
+ public String getText() {
+ return strategy.getName();
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/RevertHandler.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/RevertHandler.java
new file mode 100644
index 0000000..483aeb4
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/RevertHandler.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.MatchingURIObject;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.ICollabColors;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs.PreviewDialog;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.providers.ExtensivePartitionNameLabelProvider;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.team.collaborative.participants.version.IReverter;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+import org.eclipse.swt.widgets.Display;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * Handler use for Revert action
+ * The revert action will be performe on all the current model.
+ *
+ * @author adaussy
+ */
+public class RevertHandler extends AbstractCollabHandler {
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ //Check that everything is commit
+ if(!UIUtils.saveAllDirtyEditor().isOK()) {
+ return null;
+ }
+ ResourceSet resourceSet = getResourceSet();
+ if(resourceSet == null) {
+ UIUtils.errorDialog(CollabStatus.createErrorStatus("unable to retreive the resource set"), "Collaboratibe error");
+ return null;
+ }
+ Set<IExtendedURI> uris = new HashSet<IExtendedURI>();
+ for(Resource r : resourceSet.getResources()) {
+ IFile file = WorkspaceSynchronizer.getFile(r);
+ if(file != null && file.exists()) {
+ uris.add(new ExtendedURI(r.getURI()));
+ }
+ }
+ IStatus status = doRevert(uris, resourceSet);
+ if(!status.isOK() && status.getCode() == Status.ERROR) {
+ UIUtils.errorDialog(status, "Error");
+ }
+
+ return null;
+
+ }
+
+ /**
+ * Do revert action
+ *
+ * @param uris
+ * the uris about to be reverted
+ * @param resourceSet
+ * the resource set
+ * @return the {@link IStatus} of the operation
+ * @throws CollabException
+ * the collab exception
+ */
+ public static IStatus doRevert(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+
+ IReverter reverter = ICollaborativeManager.INSTANCE.getReverter(uris, resourceSet);
+ if(reverter == null) {
+ CollabStatus errorStatus = CollabStatus.createErrorStatus("Unable to find a reverter");
+ return errorStatus;
+ }
+
+ Set<IExtendedURI> toBeCommitted = reverter.getExtendedSet();
+ IStatus status = doRevertFromBuilder(resourceSet, reverter, toBeCommitted);
+ return status;
+
+ }
+
+ /**
+ * Do revert using an existing {@link IReverter}s
+ *
+ * @param resourceSet
+ * the resource set
+ * @param reverter
+ * the reverter
+ * @param toBeReverted
+ * the {@link IExtendedURI} about to be reverted
+ * @return the {@link IStatus} of the operation
+ * @throws CollabException
+ * the collab exception
+ */
+ public static IStatus doRevertFromBuilder(ResourceSet resourceSet, IReverter reverter, Set<IExtendedURI> toBeReverted) {
+ ExtensivePartitionNameLabelProvider labelProvider = new ExtensivePartitionNameLabelProvider(new MatchingURIObject(toBeReverted),UIUtils.getModelExplorerLavelProvider());
+ labelProvider.setColor(ICollabColors.REVERT_COLLOR);
+ PreviewDialog revertDialog = new PreviewDialog(Display.getDefault().getActiveShell(), labelProvider, "Revert Dialog", "Element in yellow will be reverted");
+ Collection<EObject> objectsToReveal = UIUtils.getLeafSemanticElement(toBeReverted, resourceSet);
+ if(objectsToReveal != null && !objectsToReveal.isEmpty()) {
+ revertDialog.setObjectsToReveal(objectsToReveal);
+ }
+ if(revertDialog.open() == PreviewDialog.OK) {
+
+ //Keep lock force to true. This shall be improve later
+ IStatus commitStatus = reverter.revert();
+ UIUtils.refreshModelExplorer(toBeReverted, resourceSet);
+ UIUtils.reloadEditor();
+ return commitStatus;
+ } else {
+ return Status.CANCEL_STATUS;
+ }
+ }
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/UnlockAction.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/UnlockAction.java
new file mode 100644
index 0000000..3fddcaf
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/UnlockAction.java
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.MatchingURIObject;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.ICollabColors;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs.PreviewDialog;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.providers.ExtensivePartitionNameLabelProvider;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.team.collaborative.participants.locker.IUnlocker;
+import org.eclipse.papyrus.team.collaborative.participants.version.ICommitter;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+import org.eclipse.papyrus.team.collaborative.strategy.ILockingStrategy;
+import org.eclipse.papyrus.team.collaborative.strategy.ILockingStrategy.Descriptor;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * Handler for the Unlock action in Papyrus
+ */
+public class UnlockAction extends Action {
+
+ /** The strategy. */
+ protected ILockingStrategy.Descriptor strategy;
+
+ /**
+ * Instantiates a new unlock action.
+ *
+ * @param strategy
+ * the strategy
+ */
+ public UnlockAction(Descriptor strategy) {
+ super();
+ this.strategy = strategy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ if(!UIUtils.saveAllDirtyEditor().isOK()) {
+ return;
+ }
+ Collection<EObject> selection = UIUtils.getSelection();
+ if(!selection.isEmpty()) {
+ IStatus status = doSafeUnlock(selection, strategy);
+ if(!status.isOK()) {
+ UIUtils.errorDialog(status, "Error during Unlock");
+ }
+ }
+ super.run();
+ }
+
+ /**
+ * Do unlock.
+ *
+ * @param selection
+ * The {@link EObject} selected by the user
+ * @param strategy
+ * the strategy use to compute the business object set to unlock
+ * @throws CollabException
+ * the collab exception
+ */
+ public static IStatus doSafeUnlock(Collection<EObject> selection, ILockingStrategy.Descriptor strategy) {
+ EObject firstSelectedObject = selection.iterator().next();
+ ResourceSet resourceSet = firstSelectedObject.eResource().getResourceSet();
+
+ //Execute the strategy to define the functional object to lock
+ Set<IExtendedURI> objectToLock = strategy.getStrategy().getBusinessObject(selection);
+ //First check there no modification uncommitted
+ ICommitter committer = ICollaborativeManager.INSTANCE.getCommitter(objectToLock, resourceSet);
+ if(committer == null) {
+ return CollabStatus.createErrorStatus("Unable to find an Committer");
+ }
+
+ IStatus preventUnlockingWithUntrackedModification = preventUnlockingWithUntrackedModification(resourceSet, objectToLock, committer, firstSelectedObject);
+ if(!preventUnlockingWithUntrackedModification.isOK()) {
+ return preventUnlockingWithUntrackedModification;
+ }
+ //Reset the resourceSet because the editor may have been reloaded
+ resourceSet = UIUtils.getCurrentResourceSet();
+
+ IUnlocker unlocker = ICollaborativeManager.INSTANCE.getUnlocker(objectToLock, resourceSet);
+ if(unlocker == null) {
+ return CollabStatus.createErrorStatus("Unable to find a unlocker for:\n " + objectToLock);
+ }
+ return doUnlock(resourceSet, unlocker);
+ }
+
+ protected static IStatus doUnlock(ResourceSet resourceSet, IUnlocker unlocker) {
+ Set<IExtendedURI> needUnlock = unlocker.getExtendedSet();
+ //Check if the lock can be taken
+ ExtensivePartitionNameLabelProvider labelProvider = new ExtensivePartitionNameLabelProvider(new MatchingURIObject(needUnlock),UIUtils.getModelExplorerLavelProvider());
+ labelProvider.setColor(ICollabColors.UNLOCK_COLLOR);
+ PreviewDialog unlockPreviewDialog = new PreviewDialog(Display.getDefault().getActiveShell(), labelProvider, "Unlock Preview", "Element in green will be unlocked");
+ Collection<EObject> objectsToReveal = UIUtils.getLeafSemanticElement(needUnlock, resourceSet);
+ if(objectsToReveal != null && !objectsToReveal.isEmpty()) {
+ unlockPreviewDialog.setObjectsToReveal(objectsToReveal);
+ }
+ if(unlockPreviewDialog.open() == PreviewDialog.OK) {
+ IStatus lockResult = unlocker.unlock();
+ UIUtils.refreshModelExplorer(needUnlock, resourceSet);
+ return lockResult;
+ } else {
+ return CollabStatus.CANCEL_STATUS;
+ }
+ }
+
+
+ /**
+ * Prevent unlocking with untracked modification.
+ *
+ * @param resourceSet
+ * the resource set
+ * @param objectToLock
+ * the object to lock
+ * @param committer
+ * the committer
+ * @param selected
+ * the selected
+ * @return the i status
+ */
+ private static IStatus preventUnlockingWithUntrackedModification(ResourceSet resourceSet, Set<IExtendedURI> objectToLock, ICommitter committer, EObject selected) {
+ Set<IExtendedURI> committableResource = committer.getExtendedSet();
+ if(!committableResource.isEmpty()) {
+ //The user shall either commit or revert it's changes
+ MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Modification in progess", null, "You have untrackted modification. You either have to commit it or revert it(Everything will be lost) to release the lock", MessageDialog.WARNING, new String[]{ "Commit", "Revert" }, 0);
+ int dialogResult = dialog.open();
+ if(dialogResult == 0) {
+ //then commit
+ return CommitHandler.doCommitFromBuilder(resourceSet, committer, committableResource, true, null);
+ } else if(dialogResult == 1) {
+ //then revert
+ return RevertHandler.doRevert(committableResource, resourceSet);
+ } else {
+ //cancel
+ return Status.CANCEL_STATUS;
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.action.Action#getText()
+ */
+ @Override
+ public String getText() {
+ return strategy.getName();
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/UpdateHandler.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/UpdateHandler.java
new file mode 100644
index 0000000..71639d3
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/actions/UpdateHandler.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.MatchingURIObject;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.ICollabColors;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs.PreviewDialog;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.providers.ExtensivePartitionNameLabelProvider;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.team.collaborative.participants.version.IUpdater;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * Handler for Update action in Papyrus
+ * The update will be performed in all the current model
+ */
+public class UpdateHandler extends AbstractCollabHandler {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if(!UIUtils.saveAllDirtyEditor().isOK()) {
+ return null;
+ }
+ ResourceSet resourceSet = getResourceSet();
+ if(resourceSet == null) {
+ UIUtils.errorDialog(CollabStatus.createErrorStatus("unable to retreive the resource set"), "Collaboratibe error");
+ return null;
+ }
+ Set<IExtendedURI> uris = new HashSet<IExtendedURI>();
+ for(Resource r : resourceSet.getResources()) {
+ IFile file = WorkspaceSynchronizer.getFile(r);
+ if(file != null && file.exists()) {
+ uris.add(new ExtendedURI(r.getURI()));
+ }
+ }
+ IStatus status = doUpdate(uris, resourceSet, true);
+ if(!status.isOK()) {
+ UIUtils.errorDialog(status, "Error");
+ }
+ return null;
+
+ }
+
+ /**
+ * Do update action
+ *
+ * @param uris
+ * the {@link IExtendedURI} to update
+ * @param resourceSet
+ * the resource set
+ * @throws CollabException
+ * the collab exception
+ */
+ public static IStatus doUpdate(Set<IExtendedURI> uris, ResourceSet resourceSet, boolean preview) {
+ IUpdater updater = ICollaborativeManager.INSTANCE.getUpdater(uris, resourceSet);
+ if(updater == null) {
+ return CollabStatus.createErrorStatus("Unable to find an Updater for: \n" + uris);
+ }
+ return doUpdateFromUpdater(resourceSet, updater, preview);
+
+ }
+
+ public static IStatus doUpdateFromUpdater(ResourceSet resourceSet, IUpdater updater, boolean preview) {
+ Set<IExtendedURI> toUpdate = updater.getExtendedSet();
+ if(!toUpdate.isEmpty()) {
+ if(preview) {
+ ExtensivePartitionNameLabelProvider labelProvider = new ExtensivePartitionNameLabelProvider(new MatchingURIObject(toUpdate),UIUtils.getModelExplorerLavelProvider());
+ labelProvider.setColor(ICollabColors.UPDATE_COLLOR);
+ PreviewDialog previewDialog = new PreviewDialog(Display.getDefault().getActiveShell(), labelProvider, "Update Preview", "Element in light green will be updated");
+ Collection<EObject> objectsToReveal = UIUtils.getLeafSemanticElement(toUpdate, resourceSet);
+ if(objectsToReveal != null && !objectsToReveal.isEmpty()) {
+ previewDialog.setObjectsToReveal(objectsToReveal);
+ }
+ if(previewDialog.open() != PreviewDialog.OK) {
+ return CollabStatus.createErrorStatus("Canceled by user");
+ }
+ }
+ IStatus updateStatus = updater.update();
+ UIUtils.reloadEditor();
+ return updateStatus;
+ } else {
+ MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Nothing to do", "Nothing to update");
+ return Status.OK_STATUS;
+ }
+ }
+
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/dialogs/CommitDialog.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/dialogs/CommitDialog.java
new file mode 100644
index 0000000..3f9a5d0
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/dialogs/CommitDialog.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+
+/**
+ * Dialog used to gather inforamtion before commit
+ */
+public class CommitDialog extends PreviewDialog {
+
+ /** The toolkit. */
+ private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
+
+ /** The message value text. */
+ private Text messageValueText;
+
+ /**
+ * Instantiates a new commit dialog.
+ *
+ * @param parentShell
+ * the parent shell
+ * @param labelProvider
+ * the label provider
+ * @param title
+ * the title
+ * @param message
+ * the message
+ */
+ public CommitDialog(Shell parentShell, ILabelProvider labelProvider, String title, String message) {
+ super(parentShell, labelProvider, title, message);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs.PreviewDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Control result = super.createDialogArea(parent);
+ commitComposite((Composite)result, SWT.BORDER);
+ return result;
+
+ }
+
+ /** The message. */
+ protected String message = "";
+
+ /** The keep lock. */
+ protected boolean keepLock = false;
+
+ /**
+ * Commit composite.
+ *
+ * @param parent
+ * the parent
+ * @param style
+ * the style
+ * @return the composite
+ */
+ public Composite commitComposite(Composite parent, int style) {
+ Composite commitComposite = new Composite(parent, style);
+ commitComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ toolkit.adapt(commitComposite);
+ toolkit.paintBordersFor(commitComposite);
+ commitComposite.setLayout(new GridLayout(1, false));
+
+ Label lblMessage = new Label(commitComposite, SWT.NONE);
+ toolkit.adapt(lblMessage, true, true);
+ lblMessage.setText("Message:");
+
+ messageValueText = new Text(commitComposite, SWT.BORDER);
+ messageValueText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ messageValueText.addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ message = messageValueText.getMessage();
+
+ }
+ });
+ toolkit.adapt(messageValueText, true, true);
+
+ Composite composite = new Composite(commitComposite, SWT.NONE);
+ toolkit.adapt(composite);
+ toolkit.paintBordersFor(composite);
+ composite.setLayout(new GridLayout(1, false));
+ return commitComposite;
+ }
+
+
+ /**
+ * Gets the commit message.
+ *
+ * @return the commit message
+ */
+ public String getCommitMessage() {
+ return message;
+ }
+
+
+ /**
+ * Checks if is keep lock.
+ *
+ * @return true, if is keep lock
+ */
+ public boolean isKeepLock() {
+ return keepLock;
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/dialogs/PreviewDialog.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/dialogs/PreviewDialog.java
new file mode 100644
index 0000000..2e1b3f8
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/dialogs/PreviewDialog.java
@@ -0,0 +1,270 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.emf.providers.MoDiscoContentProvider;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
+import org.eclipse.papyrus.uml.tools.model.UmlUtils;
+import org.eclipse.papyrus.views.modelexplorer.CustomCommonViewer;
+import org.eclipse.papyrus.views.modelexplorer.matching.IMatchingItem;
+import org.eclipse.papyrus.views.modelexplorer.matching.ModelElementItemMatchingItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+
+/**
+ * The Class PreviewDialog.
+ * The preview dialog is a generic dialog use to display feedback to the user using specific {@link ILabelProvider}
+ */
+public class PreviewDialog extends TitleAreaDialog {
+
+
+ /** The title. */
+ private String title;
+
+ /** The message. */
+ private String message;
+
+ /** The label provider. */
+ private ILabelProvider labelProvider;
+
+ /** The tree viewer. */
+ private TreeViewer treeViewer;
+
+ /** The objects to reveal. */
+ private Collection<EObject> objectsToReveal;
+
+
+
+ /**
+ * Sets the objects to reveal.
+ *
+ * @param objectToReveal
+ * the new objects to reveal
+ */
+ public void setObjectsToReveal(Collection<EObject> objectToReveal) {
+ this.objectsToReveal = objectToReveal;
+ }
+
+ /**
+ * Create contents of the dialog.
+ *
+ * @param parent
+ * the parent
+ * @return the control
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ setMessage(message);
+ setTitle(title);
+ Composite area = (Composite)super.createDialogArea(parent);
+ Composite container = new Composite(area, SWT.NONE);
+ container.setLayout(new FillLayout(SWT.HORIZONTAL));
+ container.setLayoutData(new GridData(GridData.FILL_BOTH));
+ treeViewer = new CustomCommonViewer("org.eclipse.papyrus.modelexplorer.modelexplorer", container, SWT.BORDER);
+ treeViewer.setContentProvider(new MoDiscoContentProvider() {
+
+ @Override
+ protected EObject[] getRootElements(ModelSet modelSet) {
+ UmlModel umlModel = (UmlUtils.getUmlModel(modelSet));
+
+ if(umlModel == null)
+ return null;
+
+ EList<EObject> contents = umlModel.getResource().getContents();
+ ArrayList<EObject> result = new ArrayList<EObject>();
+ Iterator<EObject> iterator = contents.iterator();
+ while(iterator.hasNext()) {
+ EObject eObject = (EObject)iterator.next();
+ //Shall be improved
+ if(eObject.eClass().getEPackage().getNsURI().contains("uml")) {
+ result.add(eObject);
+ }
+ }
+ return result.toArray(new EObject[result.size()]);
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ //Remove duplicate
+ Object[] superChildren = super.getChildren(parentElement);
+
+ List<Object> result = new ArrayList<Object>();
+ for(int i = 0; i < superChildren.length; i++) {
+ Object c = superChildren[i];
+ if(!result.contains(c)) {
+ result.add(c);
+ }
+ }
+ return result.toArray(new Object[result.size()]);
+ }
+ });
+ treeViewer.setLabelProvider(labelProvider);
+ treeViewer.setInput(((CoreMultiDiagramEditor)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getServicesRegistry());
+ if(objectsToReveal != null) {
+ reveal(objectsToReveal);
+ }
+ return area;
+ }
+
+ /**
+ * Create contents of the button bar.
+ *
+ * @param parent
+ * the parent
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ /**
+ * Return the initial size of the dialog.
+ *
+ * @return the initial size
+ */
+ @Override
+ protected Point getInitialSize() {
+ return new Point(600, 600);
+ }
+
+ /**
+ * Create the dialog.
+ *
+ * @param parentShell
+ * the parent shell
+ * @param labelProvider
+ * the label provider
+ * @param title
+ * the title
+ * @param message
+ * the message
+ */
+ public PreviewDialog(Shell parentShell, ILabelProvider labelProvider, String title, String message) {
+ super(parentShell);
+ setShellStyle(SWT.SHELL_TRIM);
+ setHelpAvailable(false);
+ this.title = title;
+ this.message = message;
+ this.labelProvider = labelProvider;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#open()
+ */
+ @Override
+ public int open() {
+ int result = super.open();
+ return result;
+ }
+
+
+
+ /**
+ * Reveal.
+ *
+ * @param elementList
+ * the element list
+ */
+ public void reveal(Iterable<?> elementList) {
+ ArrayList<IMatchingItem> matchingItemsToSelect = new ArrayList<IMatchingItem>();
+ // filter out non EMF objects
+ Iterable<EObject> list = Iterables.transform(Iterables.filter(elementList, EObject.class), new Function<Object, EObject>() {
+
+ public EObject apply(Object from) {
+ return (EObject)from;
+ }
+ });
+
+ for(EObject currentEObject : list) {
+ //TODO The custom ModelExplorer Revealer feature has not yet been backported.
+ //See bug 426360. For now, we only reveal the given EObjects.
+ //EObject itemToSelect = ModelExplorerRevealerManager.getTargetObjectToRegveal(currentEObject);
+ matchingItemsToSelect.add(new ModelElementItemMatchingItem(currentEObject));
+
+ // Does the content provider exist?
+ // if(treeViewer.getContentProvider() != null) {
+
+ /*
+ * reveal the ancestors tree using expandToLevel on each of them
+ * in the good order. This is a lot faster than going through the whole tree
+ * using getChildren of the ContentProvider since our Viewer uses a Hashtable
+ * to keep track of the revealed elements.
+ *
+ * However we need to use a dedicated MatchingItem to do the matching,
+ * and a specific comparer in our viewer so than the equals of MatchingItem is
+ * used in priority.
+ *
+ * Please refer to MatchingItem for more infos.
+ */
+ //for(IMatchingItem item : ModelExplorerRevealerManager.getChainToReveal(itemToSelect)) {
+ // treeViewer.expandToLevel(item, 1);
+ //}
+ //}
+ }
+ treeViewer.expandToLevel(new StructuredSelection(matchingItemsToSelect), TreeViewer.ALL_LEVELS);
+ }
+
+ /**
+ * Select reveal.
+ *
+ * @param selection
+ * the selection
+ */
+ public void selectReveal(ISelection selection) {
+ if(treeViewer != null) {
+ treeViewer.setSelection(selection, true);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.core.ui.IRevealSemanticElement#revealSemanticElement(java.util.List)
+ */
+ /**
+ * Reveal semantic element.
+ *
+ * @param elementList
+ * the element list
+ */
+ public void revealSemanticElement(List<?> elementList) {
+ reveal(elementList);
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/items/LockStrategyItemProvider.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/items/LockStrategyItemProvider.java
new file mode 100644
index 0000000..b1b023a
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/items/LockStrategyItemProvider.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.items;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions.LockAction;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.team.collaborative.strategy.ILockingStrategy;
+import org.eclipse.papyrus.team.collaborative.utils.CollabUtils;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+
+
+/**
+ * Item provider which fill the menu with all lock strategy.
+ *
+ * @author adaussy
+ */
+public class LockStrategyItemProvider extends org.eclipse.ui.actions.CompoundContributionItem {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
+ */
+ @Override
+ protected IContributionItem[] getContributionItems() {
+ if(isEnabled()) {
+ Collection<ActionContributionItem> contribution = Collections2.transform(ICollaborativeManager.INSTANCE.getStrategies().values(), new Function<ILockingStrategy.Descriptor, ActionContributionItem>() {
+
+ @Override
+ public ActionContributionItem apply(final ILockingStrategy.Descriptor from) {
+
+ Action action = new LockAction(from);
+ ActionContributionItem actionContributionItem = new ActionContributionItem(action);
+ return actionContributionItem;
+ }
+ });
+ return contribution.toArray(new IContributionItem[contribution.size()]);
+ }
+
+ return new IContributionItem[0];
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.action.ContributionItem#isEnabled()
+ */
+ public boolean isEnabled() {
+ EObject firstSelection = UIUtils.getFirstSelection();
+ if(firstSelection != null) {
+ return CollabUtils.isCollab(firstSelection);
+ }
+ return false;
+ }
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/items/UnlockStrategyItemProvider.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/items/UnlockStrategyItemProvider.java
new file mode 100644
index 0000000..e34e721
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/items/UnlockStrategyItemProvider.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.items;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.actions.UnlockAction;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.utils.UIUtils;
+import org.eclipse.papyrus.team.collaborative.strategy.ILockingStrategy;
+import org.eclipse.papyrus.team.collaborative.utils.CollabUtils;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+
+
+/**
+ * Item provider which fill the menu with all unlock strategy.
+ */
+public class UnlockStrategyItemProvider extends org.eclipse.ui.actions.CompoundContributionItem {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
+ */
+ @Override
+ protected IContributionItem[] getContributionItems() {
+ if(isEnabled()) {
+ Collection<ActionContributionItem> contribution = Collections2.transform(ICollaborativeManager.INSTANCE.getStrategies().values(), new Function<ILockingStrategy.Descriptor, ActionContributionItem>() {
+
+ @Override
+ public ActionContributionItem apply(final ILockingStrategy.Descriptor from) {
+
+ Action action = new UnlockAction(from);
+ ActionContributionItem actionContributionItem = new ActionContributionItem(action);
+ return actionContributionItem;
+ }
+ });
+
+
+ return contribution.toArray(new IContributionItem[contribution.size()]);
+ }
+
+ return new IContributionItem[0];
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.action.ContributionItem#isEnabled()
+ */
+ public boolean isEnabled() {
+ EObject firstSelection = UIUtils.getFirstSelection();
+ if(firstSelection != null) {
+ return CollabUtils.isCollab(firstSelection);
+ }
+ return false;
+ }
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/providers/ExtensivePartitionNameLabelProvider.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/providers/ExtensivePartitionNameLabelProvider.java
new file mode 100644
index 0000000..7cdbdee
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/ui/providers/ExtensivePartitionNameLabelProvider.java
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.ui.providers;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+
+import com.google.common.base.Predicate;
+
+
+/**
+ * The Class ExtensiveLabelProvider. {@link ILabelProvider} that extend the one use by the model explorer view.
+ * This label provider can customize label and color of display object using predicate
+ */
+public class ExtensivePartitionNameLabelProvider implements IFontProvider, IColorProvider, ILabelProvider {
+
+
+ private ILabelProvider internal;
+
+
+ /** The color. */
+ private Color color;
+
+ /** The font. */
+ private Font font;
+
+ /** The predicate. */
+ private Predicate<EObject> predicate;
+
+ /**
+ * Instantiates a new extensive label provider.
+ *
+ * @param predicate
+ * the predicate
+ */
+ public ExtensivePartitionNameLabelProvider(Predicate<EObject> predicate, ILabelProvider internal) {
+ super();
+ this.predicate = predicate;
+ this.internal = internal;
+ }
+
+ public ExtensivePartitionNameLabelProvider(ILabelProvider internal) {
+ super();
+ this.predicate = null;
+ this.internal = internal;
+ }
+
+
+ /**
+ * Sets the color.
+ *
+ * @param color
+ * the new color
+ */
+ public void setColor(Color color) {
+ this.color = color;
+ }
+
+
+ /**
+ * Sets the font.
+ *
+ * @param font
+ * the new font
+ */
+ public void setFont(Font font) {
+ this.font = font;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.modelexplorer.MoDiscoLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object element) {
+ String superText = internal.getText(element);
+ if(element instanceof ModelElementItem) {
+ ModelElementItem elem = (ModelElementItem)element;
+ EObject eObject = elem.getEObject();
+ if(eObject != null) {
+ String partitionName = getPartitionName(eObject);
+ if(partitionName != null) {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append(partitionName);
+ stringBuilder.append(superText);
+ superText = stringBuilder.toString();
+ }
+ }
+ }
+ return superText;
+ }
+
+ private static final String CLOSING_BRACKET = "] ";
+
+ private static final String OPEN_BRACKET = "[";
+
+
+ /**
+ * Gets the partition name.
+ *
+ * @param eObject
+ * the e object
+ * @return the partition name
+ */
+ protected String getPartitionName(EObject eObject) {
+ Resource resource = eObject.eResource();
+ if(resource != null) {
+ URI uri = resource.getURI().trimFileExtension();
+ String partitionName = uri.segment(uri.segmentCount() - 1);
+ StringBuilder builder = new StringBuilder(OPEN_BRACKET);
+ builder.append(partitionName);
+ builder.append(CLOSING_BRACKET);
+ return builder.toString();
+ }
+ return null;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelLabelProvider#getFont(java.lang.Object)
+ */
+ @SuppressWarnings("restriction")
+ @Override
+ public Font getFont(Object element) {
+ if(predicate != null) {
+ if(element instanceof ModelElementItem) {
+ ModelElementItem eObject = (ModelElementItem)element;
+ if(font != null) {
+ if(predicate.apply(eObject.getEObject())) {
+ return font;
+ }
+ }
+ }
+ }
+ if(internal instanceof IFontProvider) {
+ return ((IFontProvider)internal).getFont(element);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelLabelProvider#getForeground(java.lang.Object)
+ */
+ @SuppressWarnings("restriction")
+ @Override
+ public Color getForeground(Object element) {
+ if(predicate != null) {
+ if(element instanceof ModelElementItem) {
+ ModelElementItem eObject = (ModelElementItem)element;
+ if(color != null) {
+ if(predicate.apply(eObject.getEObject())) {
+ return color;
+ }
+ }
+ }
+ }
+ if(internal instanceof IColorProvider) {
+ return ((IColorProvider)internal).getForeground(element);
+ }
+ return null;
+ }
+
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ internal.addListener(listener);
+
+ }
+
+
+ @Override
+ public void dispose() {
+ internal.dispose();
+
+ }
+
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return internal.isLabelProperty(element, property);
+ }
+
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ internal.removeListener(listener);
+
+ }
+
+
+ @Override
+ public Image getImage(Object element) {
+ return internal.getImage(element);
+ }
+
+
+ @Override
+ public Color getBackground(Object element) {
+ if(internal instanceof IColorProvider) {
+ return ((IColorProvider)internal).getBackground(element);
+ }
+ return null;
+ }
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/utils/PapyrusResourceUtils.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/utils/PapyrusResourceUtils.java
new file mode 100644
index 0000000..4da408d
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/utils/PapyrusResourceUtils.java
@@ -0,0 +1,30 @@
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.utils;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
+import org.eclipse.papyrus.team.collaborative.utils.URIUtils;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
+
+
+public class PapyrusResourceUtils {
+
+ private static final String[] FILE_EXTENSIONS = new String[]{ UmlModel.UML_FILE_EXTENSION, NotationModel.NOTATION_FILE_EXTENSION, DiModel.MODEL_FILE_EXTENSION };
+
+
+ public static void addExtraResources(ResourceSet ressourceSet, Collection<URI> uris, URI uri) {
+ String currentExtension = uri.fileExtension();
+ for(String ext : FILE_EXTENSIONS) {
+ if(!ext.equals(currentExtension)) {
+ URI sateliteResource = URIUtils.getSateliteResource(uri, ext);
+ if(URIUtils.isResourceURI(sateliteResource, ressourceSet)) {
+ uris.add(sateliteResource);
+ }
+ }
+ }
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/utils/UIUtils.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/utils/UIUtils.java
new file mode 100644
index 0000000..f6c336b
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.integration.papyrus/src/org/eclipse/papyrus/team/collaborative/integration/papyrus/utils/UIUtils.java
@@ -0,0 +1,307 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.integration.papyrus.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+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.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.gmf.runtime.common.ui.dialogs.SaveAllDirtyEditorsDialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.Activator;
+import org.eclipse.papyrus.team.collaborative.integration.papyrus.RefreshHelper;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+import org.eclipse.papyrus.team.collaborative.reports.LogHelper;
+import org.eclipse.papyrus.team.collaborative.utils.CollabFunctionsFactory;
+import org.eclipse.papyrus.team.collaborative.utils.ModelsUtil;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+
+
+/**
+ * Utility class for User Interface interactions.
+ *
+ * @author adaussy
+ */
+public class UIUtils {
+
+ /** The resource manager. */
+ public static LocalResourceManager RESOURCE_MANAGER = new LocalResourceManager(JFaceResources.getResources());
+
+ /**
+ * Save all dirty editor.
+ *
+ * @return the {@link IStatus}
+ */
+ public static IStatus saveAllDirtyEditor() {
+ //Force save
+ IEditorPart[] dirtyEditors = SaveAllDirtyEditorsDialog.getDirtyEditors();
+ if(dirtyEditors.length > 0) {
+ SaveAllDirtyEditorsDialog dialog = new SaveAllDirtyEditorsDialog(Display.getDefault().getActiveShell());
+ if(dialog.open() == SaveAllDirtyEditorsDialog.CANCEL) {
+ return Status.CANCEL_STATUS;
+ } else {
+ for(int i = 0; i < dirtyEditors.length; i++) {
+ IEditorPart editorI = dirtyEditors[i];
+ editorI.doSave(new NullProgressMonitor());
+ }
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * Gets the current resource set.
+ *
+ * @return the current resource set
+ */
+ public static ResourceSet getCurrentResourceSet() {
+ IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(editor instanceof CoreMultiDiagramEditor) {
+ CoreMultiDiagramEditor papyrusEditor = (CoreMultiDiagramEditor)editor;
+ return papyrusEditor.getEditingDomain().getResourceSet();
+ }
+ return null;
+ }
+
+ /**
+ * Return all the leaf from the semantic meta model
+ *
+ * @param uris
+ * Input set for the search of leaf
+ * @param resourceSet
+ * @return
+ */
+ public static Collection<EObject> getLeafSemanticElement(Collection<IExtendedURI> uris, ResourceSet resourceSet) {
+ Collection<IExtendedURI> semanticURIS = Collections2.filter(uris, new Predicate<IExtendedURI>() {
+
+ @Override
+ public boolean apply(IExtendedURI arg0) {
+ return UmlModel.UML_FILE_EXTENSION.equals(arg0.getUri().fileExtension());
+ }
+ });
+ Collection<Collection<EObject>> eObjects = Collections2.transform(semanticURIS, CollabFunctionsFactory.getExtendedURIToEObjects(resourceSet));
+ Set<EObject> semanticElements = new HashSet<EObject>();
+ for(Collection<EObject> eos : eObjects) {
+ semanticElements.addAll(eos);
+ }
+ return ModelsUtil.getRoots(semanticElements);
+ }
+
+ /**
+ * Gets the first selection from the workbench
+ *
+ * @return the first selection
+ */
+ public static EObject getFirstSelection() {
+ Collection<EObject> selection = getSelection();
+ if(selection.isEmpty()) {
+ return null;
+ }
+ return selection.iterator().next();
+ }
+
+ /**
+ * Gets the selection from the workbench
+ *
+ * @return the selection
+ */
+ public static Collection<EObject> getSelection() {
+ ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
+ ISelection selection = selectionService.getSelection();
+ if(selection != null) {
+ if(selection instanceof IStructuredSelection) {
+ List<EObject> result = new ArrayList<EObject>();
+ Iterator<?> ite = ((IStructuredSelection)selection).iterator();
+ while(ite.hasNext()) {
+ Object next = ite.next();
+ EObject eObject = getEObject(next);
+ if(eObject != null) {
+ result.add(eObject);
+ }
+ }
+ return result;
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * Refresh elements in model explorer view.
+ *
+ * @param uris
+ * {@link IExtendedURI} to refresh
+ * @param resourceSet
+ * the resource set
+ */
+ public static void refreshModelExplorer(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ for(Collection<EObject> objects : Collections2.transform(uris, CollabFunctionsFactory.getExtendedURIToEObjects(resourceSet))) {
+ RefreshHelper.refreshModelExplorer(objects);
+ }
+ }
+
+ /**
+ * This reload the current editor
+ * WARNING : BE careful after this action the ancient resourceSet will deprecated you may use getCurrentResourceSet() to retrieve the new one.
+ */
+ public static void reloadEditor() {
+ Display.getCurrent().syncExec(new Runnable() {
+
+ public void run() {
+ IWorkbench wb = PlatformUI.getWorkbench();
+ IWorkbenchPage page = wb.getActiveWorkbenchWindow().getActivePage();
+ IEditorPart editor = page.getActiveEditor();
+ IEditorInput input = editor.getEditorInput();
+ page.closeEditor(editor, true);
+ try {
+ IEditorDescriptor desc = wb.getEditorRegistry().getDefaultEditor(input.getName());
+ page.openEditor(input, desc.getId(), false);
+ } catch (PartInitException e) {
+ LogHelper.getInstance().logError("Error during reloading", Activator.PLUGIN_ID, e);
+ }
+ }
+ });
+ }
+
+ /**
+ * Gets the e object.
+ *
+ * @param in
+ * the in
+ * @return the e object
+ */
+ protected static EObject getEObject(Object in) {
+ if(in instanceof EObject) {
+ return (EObject)in;
+ } else if(in instanceof IAdaptable) {
+ return (EObject)((IAdaptable)in).getAdapter(EObject.class);
+ } else {
+ IAdapterManager adapterService = (IAdapterManager)PlatformUI.getWorkbench().getService(IAdapterManager.class);
+ return (EObject)adapterService.getAdapter(in, EObject.class);
+ }
+ }
+
+
+ /**
+ * Display an error dialog using a status.
+ *
+ * @param errorStatus
+ * the error status
+ * @param title
+ * the title
+ */
+ public static void errorDialog(IStatus errorStatus, String title) {
+ ErrorDialog dialog = new ErrorDialog(Display.getDefault().getActiveShell(), title, errorStatus.getMessage(), errorStatus, Status.ERROR);
+ dialog.open();
+ LogHelper.getInstance().logError(errorStatus.getMessage(), Activator.PLUGIN_ID, errorStatus.getException());
+ }
+
+ /**
+ * Error dialog.
+ *
+ * @param throwable
+ * the throwable
+ * @param title
+ * the title
+ * @param message
+ * the message
+ */
+ public static void errorDialog(Throwable throwable, String title, String message) {
+ errorDialog(CollabStatus.createErrorStatus(message, throwable), title);
+ }
+
+ /** The adapter factory. */
+ private static ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ /**
+ * Try to get a correct label from a Object
+ * Handle: {@link EObject} {@link Resource}.
+ *
+ * @param object
+ * the object
+ * @return the label
+ */
+ public static String getLabel(Object object) {
+ if(object instanceof EObject) {
+ EObject eObject = (EObject)object;
+ IItemLabelProvider labelProvider = (IItemLabelProvider)adapterFactory.adapt(eObject, IItemLabelProvider.class);
+ return labelProvider.getText(eObject);
+ } else if(object instanceof Resource) {
+ return "Resouce " + ((Resource)object).getURI();
+ }
+ return object.toString();
+ }
+
+ public static ILabelProvider getModelExplorerLavelProvider(){
+ ILabelProvider labelProvider = getLabelProvider(ModelExplorerView.LABEL_PROVIDER_SERVICE_CONTEXT);
+ if(labelProvider == null){
+ labelProvider = getLabelProvider();
+ }
+ return labelProvider;
+ }
+ public static ILabelProvider getLabelProvider(){
+ return getLabelProvider(null);
+ }
+ public static ILabelProvider getLabelProvider(String context){
+ IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if (editor instanceof CoreMultiDiagramEditor) {
+ CoreMultiDiagramEditor coreEditor = (CoreMultiDiagramEditor) editor;
+ try {
+ LabelProviderService service = coreEditor.getServicesRegistry().getService(LabelProviderService.class);
+ if(context != null){
+ return service.getLabelProvider(context);
+ }else {
+ return service.getLabelProvider();
+ }
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.classpath b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.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/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.gitignore b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.gitignore
new file mode 100644
index 0000000..19af0f1
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.gitignore
@@ -0,0 +1,3 @@
+*.class
+*.jar
+/target \ No newline at end of file
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.project b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.project
new file mode 100644
index 0000000..c0e0c44
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.team.collaborative</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/team.collaborative/org.eclipse.papyrus.team.collaborative/.settings/org.eclipse.jdt.core.prefs b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..6bb8136
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.objectteams.otdt.compiler.option.pure_java=enabled
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/META-INF/MANIFEST.MF b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..d864e36
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/META-INF/MANIFEST.MF
@@ -0,0 +1,25 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.team.collaborative;singleton:=true
+Bundle-Version: 1.7.0.qualifier
+Bundle-ClassPath: .
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-Activator: org.eclipse.papyrus.team.collaborative.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.ecore,
+ com.google.guava,
+ org.eclipse.core.resources;bundle-version="3.7.101",
+ org.eclipse.emf.workspace
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.eclipse.papyrus.team.collaborative,
+ org.eclipse.papyrus.team.collaborative.participants,
+ org.eclipse.papyrus.team.collaborative.participants.locker,
+ org.eclipse.papyrus.team.collaborative.participants.version,
+ org.eclipse.papyrus.team.collaborative.reports,
+ org.eclipse.papyrus.team.collaborative.strategy,
+ org.eclipse.papyrus.team.collaborative.utils,
+ org.eclipse.papyrus.team.collaborative.utils.funtions;x-internal:=true
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/about.html b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/about.html
new file mode 100644
index 0000000..d35d5ae
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/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>June 5, 2007</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>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/build.properties b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/build.properties
new file mode 100644
index 0000000..308ebe6
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
+
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/plugin.properties b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/plugin.properties
new file mode 100644
index 0000000..006c983
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/plugin.properties
@@ -0,0 +1,4 @@
+#
+
+pluginName = CollabConfiguration Model
+providerName = Atos
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/plugin.xml b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/plugin.xml
new file mode 100644
index 0000000..016f4a1
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/plugin.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="collaborative" name="collaborative" schema="schema/collaborative.exsd"/>
+
+</plugin>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/pom.xml b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/pom.xml
new file mode 100644
index 0000000..901fbc6
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/pom.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2013 Atos.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Arthur Daussy <a href="mailto:arthur.daussy@atos.net"> - initial API and implementation
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <relativePath>../../../Releng/org.topcased.fast.tycho.master/pom.xml</relativePath>
+ <groupId>org.topcased.fast</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.7.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.papyrus.team.collaborative</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <name>Alfa Editor</name>
+</project>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/schema/collaborative.exsd b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/schema/collaborative.exsd
new file mode 100644
index 0000000..863d5ab
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/schema/collaborative.exsd
@@ -0,0 +1,151 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.team.collaborative" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.papyrus.team.collaborative" id="collaborative" name="collaborative"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <choice minOccurs="1" maxOccurs="unbounded">
+ <element ref="ParticipantFactory"/>
+ <element ref="LockingStrategy"/>
+ </choice>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="LockingStrategy">
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="impl" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.team.collaborative.ILockingStrategy"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="ParticipantFactory">
+ <annotation>
+ <documentation>
+ This extension aim to register participant to collaboration
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="impl" type="string" use="required">
+ <annotation>
+ <documentation>
+ This is an implentation of a participant for the collaboration mode. Depending on the feature that this participant provide it as to inherite from ILocker, IUnlocker, IUpdater, ICommitter
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.team.collaborative.ICollabFactory"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string" use="required">
+ <annotation>
+ <documentation>
+ Should be a int. The higher int is the most prioritary
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/Activator.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/Activator.java
new file mode 100644
index 0000000..3a6e9f6
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/Activator.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative;
+
+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
+ /** The Constant PLUGIN_ID. */
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.team.collaborative"; //$NON-NLS-1$
+
+ // The shared instance
+ /** The plugin. */
+ private static Activator plugin;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ExtendedURI.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ExtendedURI.java
new file mode 100644
index 0000000..88366e6
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ExtendedURI.java
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.common.util.URI;
+
+
+/**
+ * The Class ExtendedURI.
+ * The {@link ExtendedURI} uri is a wrapper for {@link URI}.
+ * However it add a way to express containment. This aim to be used for performance issues
+ */
+public class ExtendedURI implements IExtendedURI {
+
+ /** The Constant CONTAINMENT_PARAMETER_KEY. */
+ public static final String CONTAINMENT_PARAMETER_KEY = "Containment";
+
+ /** The uri. */
+ private URI uri;
+
+ /** The parameters. */
+ private Map<String, Object> parameters = new HashMap<String, Object>();
+
+ /**
+ * Instantiates a new extended uri.
+ *
+ * @param uri
+ * the uri
+ */
+ public ExtendedURI(URI uri) {
+ super();
+ this.uri = uri;
+ }
+
+
+ /**
+ * Sets the containment.
+ *
+ * @param containment
+ * the containment
+ * @return the extended uri
+ */
+ public ExtendedURI setContainment(boolean containment) {
+ return setParameter(CONTAINMENT_PARAMETER_KEY, containment);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.team.collaborative.IExtendedURI#isContainment()
+ */
+ @Override
+ public boolean isContainment() {
+ Object containment = getParameter(CONTAINMENT_PARAMETER_KEY);
+ if(containment != null) {
+ return (Boolean)containment;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.team.collaborative.IExtendedURI#setParameter(java.lang.String, java.lang.Object)
+ */
+ @Override
+ public ExtendedURI setParameter(String id, Object value) {
+ parameters.put(id, value);
+ return this;
+ }
+
+
+
+
+ /**
+ * Sets the uri.
+ *
+ * @param uri
+ * the uri
+ * @return the extended uri
+ */
+ public IExtendedURI setUri(URI uri) {
+ this.uri = uri;
+ return this;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.team.collaborative.IExtendedURI#getParameter(java.lang.String)
+ */
+ @Override
+ public Object getParameter(String id) {
+ return parameters.get(id);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.team.collaborative.IExtendedURI#getUri()
+ */
+ @Override
+ public URI getUri() {
+ return uri;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
+ result = prime * result + ((uri == null) ? 0 : uri.hashCode());
+ return result;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if(this == obj)
+ return true;
+ if(obj == null)
+ return false;
+ if(getClass() != obj.getClass())
+ return false;
+ ExtendedURI other = (ExtendedURI)obj;
+ if(parameters == null) {
+ if(other.parameters != null)
+ return false;
+ } else if(!parameters.equals(other.parameters))
+ return false;
+ if(uri == null) {
+ if(other.uri != null)
+ return false;
+ } else if(!uri.equals(other.uri))
+ return false;
+ return true;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append(uri.toString());
+ stringBuilder.append("[");
+ stringBuilder.append(isContainment());
+ stringBuilder.append("]");
+ return stringBuilder.toString();
+ }
+
+
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ICollabFactory.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ICollabFactory.java
new file mode 100644
index 0000000..54443ee
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ICollabFactory.java
@@ -0,0 +1,33 @@
+package org.eclipse.papyrus.team.collaborative;
+
+import java.util.Set;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.participants.locker.ILocker;
+import org.eclipse.papyrus.team.collaborative.participants.locker.IUnlocker;
+import org.eclipse.papyrus.team.collaborative.participants.version.ICommitter;
+import org.eclipse.papyrus.team.collaborative.participants.version.IReverter;
+import org.eclipse.papyrus.team.collaborative.participants.version.IUpdater;
+
+
+/**
+ * Factory for creating all necessary participant for collaborative actions
+ *
+ * @author adaussy
+ *
+ */
+public interface ICollabFactory {
+
+ ILocker createLocker(Set<IExtendedURI> uris, ResourceSet resourceSet);
+
+ IUnlocker createUnlocker(Set<IExtendedURI> uris, ResourceSet resourceSet);
+
+ IReverter createReverter(Set<IExtendedURI> uris, ResourceSet resourceSet);
+
+ ICommitter createCommitter(Set<IExtendedURI> uris, ResourceSet resourceSet);
+
+ IUpdater createUpdater(Set<IExtendedURI> uris, ResourceSet resourceSet);
+
+ boolean provide(Set<IExtendedURI> uris, ResourceSet resourceSet);
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ICollaborativeManager.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ICollaborativeManager.java
new file mode 100644
index 0000000..3ef8f37
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/ICollaborativeManager.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.impl.CollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.participants.ICollabParticipant;
+import org.eclipse.papyrus.team.collaborative.participants.locker.ILocker;
+import org.eclipse.papyrus.team.collaborative.participants.locker.IUnlocker;
+import org.eclipse.papyrus.team.collaborative.participants.version.ICommitter;
+import org.eclipse.papyrus.team.collaborative.participants.version.IReverter;
+import org.eclipse.papyrus.team.collaborative.participants.version.IUpdater;
+import org.eclipse.papyrus.team.collaborative.strategy.ILockingStrategy;
+
+/**
+ * The Interface ICollaborativeManager.
+ * Manager all {@link ICollabParticipant} such as {@link IUpdater}, {@link ICommitter}, {@link IReverter}, {@link ILocker}, {@link IUnlocker}.
+ * It also handle {@link ILockingStrategy} items
+ */
+public interface ICollaborativeManager {
+
+ /**
+ * Gets the strategies.
+ *
+ * @return the strategies or null if not found
+ */
+ public Map<String, ILockingStrategy.Descriptor> getStrategies();
+
+
+ /**
+ * Gets the locking strategy.
+ *
+ * @param id
+ * the id
+ * @return the locking strategy or null if not found
+ */
+ public ILockingStrategy getLockingStrategy(String id);
+
+ /**
+ * Gets the locker.
+ *
+ * @param objectToLock
+ * the object to lock
+ * @param resourceSet
+ * the resource set
+ * @return the locker or null if not found
+ */
+ public ILocker getLocker(Set<IExtendedURI> objectToLock, ResourceSet resourceSet);
+
+ /**
+ * Gets the unlocker.
+ *
+ * @param objectToLock
+ * the object to lock
+ * @param resourceSet
+ * the resource set
+ * @return the unlocker or null if not found
+ */
+ public IUnlocker getUnlocker(Set<IExtendedURI> objectToLock, ResourceSet resourceSet);
+
+ /**
+ * Gets the updater.
+ *
+ * @param objectToLock
+ * the object to lock
+ * @param resourceSet
+ * the resource set
+ * @return the updater or null if not found
+ */
+ public IUpdater getUpdater(Set<IExtendedURI> objectToLock, ResourceSet resourceSet);
+
+ /**
+ * Gets the committer.
+ *
+ * @param objectToLock
+ * the object to lock
+ * @param resourceSet
+ * the resource set
+ * @return the committer or null if not found
+ */
+ public ICommitter getCommitter(Set<IExtendedURI> objectToLock, ResourceSet resourceSet);
+
+ /**
+ * Gets the reverter.
+ *
+ * @param objectToLock
+ * the object to lock
+ * @param resourceSet
+ * the resource set
+ * @return the reverter or null if not found
+ */
+ public IReverter getReverter(Set<IExtendedURI> objectToLock, ResourceSet resourceSet);
+
+ /**
+ * Checks if is collab.
+ *
+ * @param objectToLock
+ * the object to lock
+ * @param resourceSet
+ * the resource set
+ * @return true, if is collab
+ */
+ public boolean isCollab(Set<IExtendedURI> objectToLock, ResourceSet resourceSet);
+
+ /** The instance. */
+ public static ICollaborativeManager INSTANCE = CollaborativeManager.getInstance();
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/IExtendedURI.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/IExtendedURI.java
new file mode 100644
index 0000000..3b4905a
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/IExtendedURI.java
@@ -0,0 +1,43 @@
+package org.eclipse.papyrus.team.collaborative;
+
+import org.eclipse.emf.common.util.URI;
+
+
+
+public interface IExtendedURI {
+
+ /**
+ * Checks if this {@link ExtendedURI} is express containment.
+ *
+ * @return true, if is containment
+ */
+ public abstract boolean isContainment();
+
+ /**
+ * Sets the parameter.
+ *
+ * @param id
+ * the id
+ * @param value
+ * the value
+ * @return the extended uri
+ */
+ public abstract IExtendedURI setParameter(String id, Object value);
+
+ /**
+ * Gets the parameter.
+ *
+ * @param id
+ * the id
+ * @return the parameter
+ */
+ public abstract Object getParameter(String id);
+
+ /**
+ * Gets the uri.
+ *
+ * @return the uri
+ */
+ public abstract URI getUri();
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/impl/CollaborativeManager.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/impl/CollaborativeManager.java
new file mode 100644
index 0000000..d82de14
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/impl/CollaborativeManager.java
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.Activator;
+import org.eclipse.papyrus.team.collaborative.ICollabFactory;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.participants.locker.ILocker;
+import org.eclipse.papyrus.team.collaborative.participants.locker.IUnlocker;
+import org.eclipse.papyrus.team.collaborative.participants.version.ICommitter;
+import org.eclipse.papyrus.team.collaborative.participants.version.IReverter;
+import org.eclipse.papyrus.team.collaborative.participants.version.IUpdater;
+import org.eclipse.papyrus.team.collaborative.strategy.ILockingStrategy;
+
+
+/**
+ * The Class CollaborativeManager.
+ * This the default implementation of {@link ICollaborativeManager}
+ *
+ * @author adaussy
+ */
+public class CollaborativeManager implements ICollaborativeManager {
+
+ /**
+ * The Class SingletonHolder.
+ */
+ private static class SingletonHolder {
+
+ /** The instance. */
+ private static ICollaborativeManager INSTANCE = new CollaborativeManager();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private CollaborativeManager() {
+ init();
+ }
+
+ /**
+ * Returns the Singleton instance.
+ * <p>
+ *
+ * @return The Singleton instance.
+ */
+ public static ICollaborativeManager getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+
+ /** The strategies. */
+ protected Map<String, ILockingStrategy.Descriptor> strategies;
+
+
+ /** The factories of all {@link ParticipantFactoryWrapper} */
+ List<ParticipantFactoryWrapper> factories = null;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollaborativeManager#getStrategies()
+ */
+ @Override
+ public Map<String, ILockingStrategy.Descriptor> getStrategies() {
+ return strategies;
+ }
+
+
+ /**
+ * Inits the manager.
+ */
+ protected void init() {
+ strategies = new HashMap<String, ILockingStrategy.Descriptor>();
+ factories = new ArrayList<CollaborativeManager.ParticipantFactoryWrapper>();
+ IConfigurationElement[] confs = Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.PLUGIN_ID, "collaborative");
+ for(IConfigurationElement conf : confs) {
+ if("LockingStrategy".equals(conf.getName())) {
+ try {
+ ILockingStrategy strategy = (ILockingStrategy)conf.createExecutableExtension("impl");
+ String id = conf.getAttribute("id");
+ String name = conf.getAttribute("name");
+ strategies.put(id, new ILockingStrategy.Descriptor(strategy, name));
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ } else if("ParticipantFactory".equals(conf.getName())) {
+ try {
+ ICollabFactory factory = (ICollabFactory)conf.createExecutableExtension("impl");
+ String id = conf.getAttribute("id");
+ Integer priority = Integer.parseInt(conf.getAttribute("priority"));
+ factories.add(new ParticipantFactoryWrapper(factory, priority, id));
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+ Collections.sort(factories);
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollaborativeManager#getLockingStrategy(java.lang.String)
+ */
+ @Override
+ public ILockingStrategy getLockingStrategy(String id) {
+ return getStrategies().get(id).getStrategy();
+ }
+
+ /**
+ * Gets the factory.
+ *
+ * @param objectToLock
+ * the object to lock
+ * @param resourceSet
+ * the resource set
+ * @return the factory
+ */
+ protected ICollabFactory getFactory(Set<IExtendedURI> objectToLock, ResourceSet resourceSet) {
+ for(ParticipantFactoryWrapper wrapper : factories) {
+ if(wrapper.factory.provide(objectToLock, resourceSet)) {
+ return wrapper.factory;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollaborativeManager#getLocker(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public ILocker getLocker(Set<IExtendedURI> objectToLock, ResourceSet resourceSet) {
+ ICollabFactory factory = getFactory(objectToLock, resourceSet);
+ if(factory == null) {
+ return null;
+ }
+ return factory.createLocker(objectToLock, resourceSet);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollaborativeManager#getUnlocker(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public IUnlocker getUnlocker(Set<IExtendedURI> objectToLock, ResourceSet resourceSet) {
+ ICollabFactory factory = getFactory(objectToLock, resourceSet);
+ if(factory == null) {
+ return null;
+ }
+ return factory.createUnlocker(objectToLock, resourceSet);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollaborativeManager#getUpdater(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public IUpdater getUpdater(Set<IExtendedURI> objectToLock, ResourceSet resourceSet) {
+ ICollabFactory factory = getFactory(objectToLock, resourceSet);
+ if(factory == null) {
+ return null;
+ }
+ return factory.createUpdater(objectToLock, resourceSet);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollaborativeManager#getCommitter(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public ICommitter getCommitter(Set<IExtendedURI> objectToLock, ResourceSet resourceSet) {
+ ICollabFactory factory = getFactory(objectToLock, resourceSet);
+ if(factory == null) {
+ return null;
+ }
+ return factory.createCommitter(objectToLock, resourceSet);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollaborativeManager#getReverter(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public IReverter getReverter(Set<IExtendedURI> objectToLock, ResourceSet resourceSet) {
+ ICollabFactory factory = getFactory(objectToLock, resourceSet);
+ if(factory == null) {
+ return null;
+ }
+ return factory.createReverter(objectToLock, resourceSet);
+ }
+
+
+ /** The resource set cash. */
+ protected Map<URI, ResourceSet> resourceSetCash = new HashMap<URI, ResourceSet>();
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.ICollaborativeManager#isCollab(java.util.Set, org.eclipse.emf.ecore.resource.ResourceSet)
+ */
+ @Override
+ public boolean isCollab(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ for(ParticipantFactoryWrapper wrapper : factories) {
+ if(wrapper.factory.provide(uris, resourceSet)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * The Class ParticipantFactoryWrapper.
+ */
+ private static class ParticipantFactoryWrapper implements Comparable<ParticipantFactoryWrapper> {
+
+ /** The factory. */
+ public ICollabFactory factory;
+
+ /** The priority. */
+ public Integer priority;
+
+ /** The id. */
+ public String id;
+
+ /**
+ * Instantiates a new participant factory wrapper.
+ *
+ * @param factory
+ * the factory
+ * @param priority
+ * the priority
+ * @param id
+ * the id
+ */
+ public ParticipantFactoryWrapper(ICollabFactory factory, Integer priority, String id) {
+ super();
+ this.factory = factory;
+ this.priority = priority;
+ this.id = id;
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(ParticipantFactoryWrapper o) {
+ return priority.compareTo(o.priority);
+ }
+
+
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/AbstractExtendedURIBuilder.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/AbstractExtendedURIBuilder.java
new file mode 100644
index 0000000..04bf8fa
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/AbstractExtendedURIBuilder.java
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.participants;
+
+import java.util.HashSet;
+import java.util.Set;
+
+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.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.utils.URIUtils;
+
+import com.google.common.base.Function;
+
+
+/**
+ * The Class AbstractExtendedURIBuilder.
+ * Abstract class for all element that implement {@link IExtendedURISuperSet}
+ */
+public abstract class AbstractExtendedURIBuilder implements IExtendedURISuperSet {
+
+ /** The uris. */
+ private Set<IExtendedURI> uris;
+
+ /** The resource set. */
+ private ResourceSet resourceSet;
+
+ /** The uri to handle. */
+ private Set<IExtendedURI> uriToHandle;
+
+ /** The to resouce function. */
+ private Function<URI, Resource> toResouceFunction = null;
+
+
+ /**
+ * Instantiates a new abstract extended uri builder.
+ *
+ * @param uris
+ * the uris
+ * @param resourceSet
+ * the resource set
+ */
+ public AbstractExtendedURIBuilder(Set<IExtendedURI> uris, ResourceSet resourceSet) {
+ this.uris = uris;
+ this.resourceSet = resourceSet;
+ this.toResouceFunction = new Function<URI, Resource>() {
+
+ @Override
+ public Resource apply(URI from) {
+ return getResourceSet().getResource(from, false);
+ }
+ };
+ uriToHandle = doBuild();
+
+ }
+
+
+ /**
+ * Do build.
+ *
+ * @return the sets the
+ */
+ protected abstract Set<IExtendedURI> doBuild();
+
+ /**
+ * Gets the uris.
+ *
+ * @return the uris
+ */
+ protected Set<IExtendedURI> getUris() {
+ return uris;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.participants.IExtendedURISuperSet#getResourceSet()
+ */
+ public ResourceSet getResourceSet() {
+ return resourceSet;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.participants.IExtendedURISuperSet#getExtendedSet()
+ */
+ public Set<IExtendedURI> getExtendedSet() {
+ if(uriToHandle == null) {
+ uriToHandle = new HashSet<IExtendedURI>();
+ }
+ return uriToHandle;
+ }
+
+ /**
+ * Gets the target resources.
+ *
+ * @return the target resources
+ */
+ protected Set<Resource> getTargetResources() {
+ Set<Resource> resourcesTolock = new HashSet<Resource>();
+ for(IExtendedURI toLock : getExtendedSet()) {
+ Resource resource = getResourceSet().getResource(toLock.getUri(), false);
+ if(resource != null) {
+ resourcesTolock.add(resource);
+ }
+ }
+ return resourcesTolock;
+ }
+
+ /**
+ * To resource.
+ *
+ * @param uri
+ * the uri
+ * @return the resource
+ */
+ protected Resource toResource(URI uri) {
+ if(uri != null) {
+ return toResouceFunction.apply(uri);
+ }
+ return null;
+
+ }
+
+
+
+ /**
+ * Gets the resource uri.
+ *
+ * @param extendedURI
+ * the extended uri
+ * @return the resource uri
+ */
+ protected IExtendedURI getResourceURI(IExtendedURI extendedURI) {
+ URI uri = extendedURI.getUri();
+ IExtendedURI resourceURI = null;
+ if(URIUtils.isResourceURI(uri, getResourceSet())) {
+ resourceURI = extendedURI;
+ } else if(URIUtils.isEObject(uri, getResourceSet())) {
+ resourceURI = new ExtendedURI(uri.trimFragment()).setContainment(extendedURI.isContainment());
+ }
+ return resourceURI;
+ }
+
+
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/ICollabParticipant.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/ICollabParticipant.java
new file mode 100644
index 0000000..fe7cddd
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/ICollabParticipant.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.participants;
+
+
+/**
+ * The Interface ICollabParticipant.
+ * All participant to collabaroration shall implement this interface
+ */
+public interface ICollabParticipant {
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/IExtendedURISuperSet.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/IExtendedURISuperSet.java
new file mode 100644
index 0000000..2616569
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/IExtendedURISuperSet.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.participants;
+
+import java.util.Set;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.participants.locker.ILocker;
+import org.eclipse.papyrus.team.collaborative.participants.locker.IUnlocker;
+import org.eclipse.papyrus.team.collaborative.participants.version.ICommitter;
+import org.eclipse.papyrus.team.collaborative.participants.version.IReverter;
+import org.eclipse.papyrus.team.collaborative.participants.version.IUpdater;
+
+
+/**
+ * Interface which return a super set of set using specific rules.
+ *
+ * @author adaussy
+ */
+public interface IExtendedURISuperSet extends ICollabParticipant {
+
+
+ /**
+ * Return set of {@link ExtendedURI} which as to be used for an operation (see {@link ILocker}, {@link IUnlocker}, {@link IReverter},.
+ *
+ * @return the extended set {@link ICommitter}, {@link IUpdater}
+ */
+ Set<IExtendedURI> getExtendedSet();
+
+ /**
+ * ResourceSet that is in use for those {@link ExtendedURI}.
+ *
+ * @return the resource set
+ */
+ ResourceSet getResourceSet();
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/locker/ILocker.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/locker/ILocker.java
new file mode 100644
index 0000000..5bf410a
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/locker/ILocker.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.participants.locker;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.participants.IExtendedURISuperSet;
+
+
+/**
+ * Object to perform a lock
+ *
+ * @author adaussy
+ */
+public interface ILocker extends IExtendedURISuperSet {
+
+
+ /**
+ * Lock the element of {@link IExtendedURISuperSet#getExtendedSet()}
+ *
+ * @return
+ * @throws CollabException
+ */
+ IStatus lock();
+
+ /**
+ * Return true if the {@link ExtendedURI} is locked
+ *
+ * @return
+ */
+ IStatus isLocked(IExtendedURI uri);
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/locker/IUnlocker.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/locker/IUnlocker.java
new file mode 100644
index 0000000..70a47af
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/locker/IUnlocker.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.participants.locker;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.participants.IExtendedURISuperSet;
+
+
+/**
+ * Object used to unlock Object.
+ *
+ * @author adaussy
+ *
+ */
+public interface IUnlocker extends IExtendedURISuperSet {
+
+ /**
+ * Unlock element in {@link IExtendedURISuperSet#getExtendedSet()}
+ *
+ * @return A success status is everything went well
+ * @throws CollabException
+ */
+ IStatus unlock();
+
+ /**
+ * Return true is at least one of {@link ExtendedURI} is locked
+ *
+ * @return
+ */
+ IStatus isLocked(IExtendedURI uri);
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/ICommitter.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/ICommitter.java
new file mode 100644
index 0000000..16aa25a
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/ICommitter.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.participants.version;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.papyrus.team.collaborative.participants.IExtendedURISuperSet;
+
+
+/**
+ * Object to commit elements
+ *
+ * @author adaussy
+ *
+ */
+public interface ICommitter extends IExtendedURISuperSet, IWorkOnModifiedElementParticipant {
+
+ /**
+ * Commit {@link IExtendedURISuperSet#getExtendedSet()}
+ *
+ * @param message
+ * Message for the commit
+ * @param keepLock
+ * If the lock has to be kept
+ * @return Success status is everything went fine
+ * @throws CollabException
+ */
+ IStatus commit(String message, boolean keepLock);
+
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IReverter.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IReverter.java
new file mode 100644
index 0000000..18d5bd3
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IReverter.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.participants.version;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.papyrus.team.collaborative.participants.IExtendedURISuperSet;
+
+
+/**
+ * Do a reverter action
+ *
+ * @author adaussy
+ *
+ */
+public interface IReverter extends IExtendedURISuperSet, IWorkOnModifiedElementParticipant {
+
+ /**
+ * Revert changes on {@link IExtendedURISuperSet#getExtendedSet()}
+ *
+ * @return
+ * @throws CollabException
+ */
+ IStatus revert();
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IUpdater.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IUpdater.java
new file mode 100644
index 0000000..22909a3
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IUpdater.java
@@ -0,0 +1,89 @@
+package org.eclipse.papyrus.team.collaborative.participants.version;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.papyrus.team.collaborative.Activator;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.participants.IExtendedURISuperSet;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+
+
+/**
+ * Do an update action
+ *
+ * @author adaussy
+ *
+ *
+ */
+public interface IUpdater extends IExtendedURISuperSet {
+
+ /** The Constant NOT_UP_TO_DATE. */
+ public static final CollabStatus NOT_UP_TO_DATE = CollabStatus.createErrorStatus("Not up to Date");
+
+
+ /**
+ * Update element of {@link IExtendedURISuperSet#getExtendedSet()}
+ *
+ * @return
+ * @throws CollabException
+ */
+ IStatus update();
+
+ /**
+ * Check if the elements has been modified
+ *
+ * @param uri
+ * @return
+ * @throws CollabException
+ */
+ UpToDateStatus isUpToDate(IExtendedURI uri);
+
+ public static class UpToDateStatus extends CollabStatus {
+
+ protected String author;
+
+ protected Long date;
+
+ protected Long revision;
+
+ private UpToDateStatus(int severity, String pluginId, int code, String message, Throwable exception, String author, Long date, Long revision) {
+ super(severity, pluginId, code, message, exception);
+ this.author = author;
+ this.date = date;
+ this.revision = revision;
+ }
+
+ public static int UP_TO_DATE_CODE = 578463;
+
+ public static int NOT_UP_TO_DATE_CODE = 578463;
+
+ public static int ERROR_DURING_OPERATION_CODE = 578462;
+
+ public boolean isUpToDate() {
+ return getSeverity() < IStatus.ERROR && getCode() == UP_TO_DATE_CODE;
+ }
+
+ public static UpToDateStatus createUpToDataStatus(String author, Long date, Long revision) {
+ return new UpToDateStatus(IStatus.OK, Activator.PLUGIN_ID, UP_TO_DATE_CODE, "Is up to date", null, author, date, revision);
+ }
+
+ public static UpToDateStatus createNotUpToDataStatus(String author, Long date, Long revision) {
+ return new UpToDateStatus(IStatus.ERROR, Activator.PLUGIN_ID, NOT_UP_TO_DATE_CODE, "Is noy up to date", null, author, date, revision);
+ }
+
+ public static UpToDateStatus createErrorDuringUpToDataStatus(String message, Throwable e) {
+ return new UpToDateStatus(IStatus.ERROR, Activator.PLUGIN_ID, ERROR_DURING_OPERATION_CODE, message, e, null, null, null);
+ }
+
+
+ public static UpToDateStatus createErrorDuringUpToDataStatus(String message) {
+ return createErrorDuringUpToDataStatus(message, null);
+ }
+
+
+
+
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IWorkOnModifiedElementParticipant.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IWorkOnModifiedElementParticipant.java
new file mode 100644
index 0000000..a4f0391
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/participants/version/IWorkOnModifiedElementParticipant.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.participants.version;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.reports.CollabStatus;
+
+
+/**
+ * The Interface IWorkOnModifiedElementParticipant.
+ * This kin of object are able to difference {@link ExtendedURI} which has been modified
+ */
+public interface IWorkOnModifiedElementParticipant {
+
+ public static final CollabStatus MODIFIED_STATUS = CollabStatus.createErrorStatus("Modified file");
+
+ /**
+ * Checks if the {@link ExtendedURI} has been modified.
+ *
+ * @param uri
+ * the uri
+ * @return the Istatus
+ * @throws CollabException
+ * the collab exception
+ */
+ IStatus isModified(IExtendedURI uri);
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/CollabStatus.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/CollabStatus.java
new file mode 100644
index 0000000..928fced
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/CollabStatus.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.reports;
+
+import org.eclipse.core.runtime.Status;
+
+/**
+ * The Class CollabStatus.
+ */
+public class CollabStatus extends Status {
+
+ /**
+ * Instantiates a new collab status.
+ *
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param code
+ * the code
+ * @param message
+ * the message
+ * @param exception
+ * the exception
+ */
+ public CollabStatus(int severity, String pluginId, int code, String message, Throwable exception) {
+ super(severity, pluginId, code, message, exception);
+ }
+
+ /**
+ * Instantiates a new collab status.
+ *
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ * @param exception
+ * the exception
+ */
+ public CollabStatus(int severity, String pluginId, String message, Throwable exception) {
+ super(severity, pluginId, message, exception);
+ }
+
+ /**
+ * Instantiates a new collab status.
+ *
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ */
+ public CollabStatus(int severity, String pluginId, String message) {
+ super(severity, pluginId, message);
+ }
+
+ /**
+ * Creates the error status.
+ *
+ * @param message
+ * the message
+ * @return the collab status
+ */
+ public static CollabStatus createErrorStatus(String message) {
+ return new CollabStatus(ERROR, org.eclipse.papyrus.team.collaborative.Activator.PLUGIN_ID, message);
+ }
+
+ /**
+ * Creates the error status.
+ *
+ * @param message
+ * the message
+ * @param e
+ * the e
+ * @return the collab status
+ */
+ public static CollabStatus createErrorStatus(String message, Throwable e) {
+ return new CollabStatus(ERROR, org.eclipse.papyrus.team.collaborative.Activator.PLUGIN_ID, message, e);
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/LogHelper.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/LogHelper.java
new file mode 100644
index 0000000..7e269c7
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/LogHelper.java
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.reports;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.papyrus.team.collaborative.Activator;
+
+
+/**
+ * The Class LogHelper.
+ * This class intend to help the user to log stuff
+ */
+public class LogHelper {
+
+ /**
+ * The Class SingletonHolder.
+ */
+ private static class SingletonHolder {
+
+ /** The Constant INSTANCE. */
+ private static final LogHelper INSTANCE = new LogHelper();
+ }
+
+ /**
+ * Gets the single instance of LogHelper.
+ *
+ * @return single instance of LogHelper
+ */
+ public static LogHelper getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+
+ /**
+ * Log info.
+ *
+ * @param message
+ * the message
+ * @param bundleId
+ * the bundle id
+ */
+ public void logInfo(String message, String bundleId) {
+ getLogger().log(createWarningStatus(bundleId, message));
+ }
+
+ /**
+ * Creates the warning status.
+ *
+ * @param bundleId
+ * the bundle id
+ * @param message
+ * the message
+ * @return the i status
+ */
+ protected IStatus createWarningStatus(String bundleId, String message) {
+ return createStatus(Status.WARNING, bundleId, message);
+ }
+
+ /**
+ * Log error.
+ *
+ * @param message
+ * the message
+ * @param bundleId
+ * the bundle id
+ * @param e
+ * the e
+ */
+ public void logError(String message, String bundleId, Throwable e) {
+ getLogger().log(createErrorStatus(bundleId, message, e));
+ }
+
+ /**
+ * Log error.
+ *
+ * @param message
+ * the message
+ * @param bundleId
+ * the bundle id
+ */
+ public void logError(String message, String bundleId) {
+ getLogger().log(createErrorStatus(bundleId, message));
+ }
+
+ /**
+ * Gets the logger.
+ *
+ * @return the logger
+ */
+ protected ILog getLogger() {
+ return Activator.getDefault().getLog();
+ }
+
+ /**
+ * Creates the error status.
+ *
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ * @return the i status
+ */
+ protected IStatus createErrorStatus(String pluginId, String message) {
+ return createStatus(Status.ERROR, pluginId, message);
+ }
+
+ /**
+ * Creates the error status.
+ *
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ * @param e
+ * the e
+ * @return the i status
+ */
+ protected IStatus createErrorStatus(String pluginId, String message, Throwable e) {
+ return createStatus(Status.ERROR, pluginId, message, e);
+ }
+
+ /**
+ * Creates the status.
+ *
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ * @param e
+ * the e
+ * @return the i status
+ */
+ protected IStatus createStatus(int severity, String pluginId, String message, Throwable e) {
+ return new Status(severity, pluginId, message, e);
+ }
+
+ /**
+ * Creates the status.
+ *
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ * @return the i status
+ */
+ protected IStatus createStatus(int severity, String pluginId, String message) {
+ return new Status(severity, pluginId, message);
+ }
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/copy/CollabStatus.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/copy/CollabStatus.java
new file mode 100644
index 0000000..90a4d1c
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/copy/CollabStatus.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.reports.copy;
+
+import org.eclipse.core.runtime.Status;
+
+/**
+ * The Class CollabStatus.
+ */
+public class CollabStatus extends Status {
+
+ /**
+ * Instantiates a new collab status.
+ *
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param code
+ * the code
+ * @param message
+ * the message
+ * @param exception
+ * the exception
+ */
+ public CollabStatus(int severity, String pluginId, int code, String message, Throwable exception) {
+ super(severity, pluginId, code, message, exception);
+ }
+
+ /**
+ * Instantiates a new collab status.
+ *
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ * @param exception
+ * the exception
+ */
+ public CollabStatus(int severity, String pluginId, String message, Throwable exception) {
+ super(severity, pluginId, message, exception);
+ }
+
+ /**
+ * Instantiates a new collab status.
+ *
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ */
+ public CollabStatus(int severity, String pluginId, String message) {
+ super(severity, pluginId, message);
+ }
+
+ /**
+ * Creates the error status.
+ *
+ * @param message
+ * the message
+ * @return the collab status
+ */
+ public static CollabStatus createErrorStatus(String message) {
+ return new CollabStatus(ERROR, org.eclipse.papyrus.team.collaborative.Activator.PLUGIN_ID, message);
+ }
+
+ /**
+ * Creates the error status.
+ *
+ * @param message
+ * the message
+ * @param e
+ * the e
+ * @return the collab status
+ */
+ public static CollabStatus createErrorStatus(String message, Throwable e) {
+ return new CollabStatus(ERROR, org.eclipse.papyrus.team.collaborative.Activator.PLUGIN_ID, message, e);
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/copy/LogHelper.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/copy/LogHelper.java
new file mode 100644
index 0000000..65f704d
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/reports/copy/LogHelper.java
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.reports.copy;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.papyrus.team.collaborative.Activator;
+
+
+/**
+ * The Class LogHelper.
+ * This class intend to help the user to log stuff
+ */
+public class LogHelper {
+
+ /**
+ * The Class SingletonHolder.
+ */
+ private static class SingletonHolder {
+
+ /** The Constant INSTANCE. */
+ private static final LogHelper INSTANCE = new LogHelper();
+ }
+
+ /**
+ * Gets the single instance of LogHelper.
+ *
+ * @return single instance of LogHelper
+ */
+ public static LogHelper getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+
+ /**
+ * Log info.
+ *
+ * @param message
+ * the message
+ * @param bundleId
+ * the bundle id
+ */
+ public void logInfo(String message, String bundleId) {
+ getLogger().log(createWarningStatus(bundleId, message));
+ }
+
+ /**
+ * Creates the warning status.
+ *
+ * @param bundleId
+ * the bundle id
+ * @param message
+ * the message
+ * @return the i status
+ */
+ protected IStatus createWarningStatus(String bundleId, String message) {
+ return createStatus(Status.WARNING, bundleId, message);
+ }
+
+ /**
+ * Log error.
+ *
+ * @param message
+ * the message
+ * @param bundleId
+ * the bundle id
+ * @param e
+ * the e
+ */
+ public void logError(String message, String bundleId, Throwable e) {
+ getLogger().log(createErrorStatus(bundleId, message, e));
+ }
+
+ /**
+ * Log error.
+ *
+ * @param message
+ * the message
+ * @param bundleId
+ * the bundle id
+ */
+ public void logError(String message, String bundleId) {
+ getLogger().log(createErrorStatus(bundleId, message));
+ }
+
+ /**
+ * Gets the logger.
+ *
+ * @return the logger
+ */
+ protected ILog getLogger() {
+ return Activator.getDefault().getLog();
+ }
+
+ /**
+ * Creates the error status.
+ *
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ * @return the i status
+ */
+ protected IStatus createErrorStatus(String pluginId, String message) {
+ return createStatus(Status.ERROR, pluginId, message);
+ }
+
+ /**
+ * Creates the error status.
+ *
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ * @param e
+ * the e
+ * @return the i status
+ */
+ protected IStatus createErrorStatus(String pluginId, String message, Throwable e) {
+ return createStatus(Status.ERROR, pluginId, message, e);
+ }
+
+ /**
+ * Creates the status.
+ *
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ * @param e
+ * the e
+ * @return the i status
+ */
+ protected IStatus createStatus(int severity, String pluginId, String message, Throwable e) {
+ return new Status(severity, pluginId, message, e);
+ }
+
+ /**
+ * Creates the status.
+ *
+ * @param severity
+ * the severity
+ * @param pluginId
+ * the plugin id
+ * @param message
+ * the message
+ * @return the i status
+ */
+ protected IStatus createStatus(int severity, String pluginId, String message) {
+ return new Status(severity, pluginId, message);
+ }
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/strategy/AbstractLockingStrategy.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/strategy/AbstractLockingStrategy.java
new file mode 100644
index 0000000..5c10d6a
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/strategy/AbstractLockingStrategy.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.strategy;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+
+
+/**
+ * The Class AbstractLockingStrategy.
+ * This only give a default implementation to {@link ILockingStrategy#applyOn(Collection)}
+ */
+public abstract class AbstractLockingStrategy implements ILockingStrategy {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.strategy.ILockingStrategy#applyOn(java.util.Collection)
+ */
+ @Override
+ public boolean applyOn(Collection<EObject> target) {
+ return !target.isEmpty();
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/strategy/ILockingStrategy.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/strategy/ILockingStrategy.java
new file mode 100644
index 0000000..72c90c3
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/strategy/ILockingStrategy.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.strategy;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+
+
+/**
+ * The Interface ILockingStrategy.
+ * A locking strategy is used to build a set of business object using the defined strategy
+ */
+public interface ILockingStrategy {
+
+ /**
+ * Get the business object define by this strategy
+ *
+ * @param eOjbect
+ * the e ojbect
+ * @return the object to lock
+ */
+ Set<IExtendedURI> getBusinessObject(Collection<EObject> eOjbect);
+
+ /**
+ * Return true if this strategy apply on the selected objects
+ *
+ * @param target
+ * the target
+ * @return true, if successful
+ */
+ public boolean applyOn(Collection<EObject> target);
+
+ /**
+ * The Class Descriptor.
+ */
+ public class Descriptor {
+
+ /** The strategy. */
+ private ILockingStrategy strategy;
+
+ /** The name. */
+ private String name;
+
+
+ /**
+ * Gets the strategy.
+ *
+ * @return the strategy
+ */
+ public ILockingStrategy getStrategy() {
+ return strategy;
+ }
+
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * Instantiates a new descriptor.
+ *
+ * @param strategy
+ * the strategy
+ * @param name
+ * the name
+ */
+ public Descriptor(ILockingStrategy strategy, String name) {
+ super();
+ this.strategy = strategy;
+ this.name = name;
+ }
+
+
+
+
+
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/AbstractRunnableWithProgressWithResult.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/AbstractRunnableWithProgressWithResult.java
new file mode 100644
index 0000000..eed22c0
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/AbstractRunnableWithProgressWithResult.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils;
+
+
+
+/**
+ * Default implementation for {@link IRunnableWithProgressWithResult}
+ */
+public abstract class AbstractRunnableWithProgressWithResult<T> implements IRunnableWithProgressWithResult<T> {
+
+ /** The result. */
+ protected T result;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.team.collaborative.utils.IRunnableWithProgressWithResult#getResult()
+ */
+ @Override
+ public T getResult() {
+ return result;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/CollabFunctionsFactory.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/CollabFunctionsFactory.java
new file mode 100644
index 0000000..a616207
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/CollabFunctionsFactory.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils;
+
+import java.util.Collection;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+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.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.utils.funtions.EObjectToExtendedURI;
+import org.eclipse.papyrus.team.collaborative.utils.funtions.ExtendedURIToEObjects;
+import org.eclipse.papyrus.team.collaborative.utils.funtions.ExtendedURIToIResource;
+import org.eclipse.papyrus.team.collaborative.utils.funtions.ResourceToIFile;
+import org.eclipse.papyrus.team.collaborative.utils.funtions.ResourceToURI;
+import org.eclipse.papyrus.team.collaborative.utils.funtions.URIToExtendedURI;
+import org.eclipse.papyrus.team.collaborative.utils.funtions.URIToExtendedURIWithContainment;
+
+import com.google.common.base.Function;
+import com.google.common.base.Functions;
+
+
+/**
+ * A factory for creating CollabFunctions objects.
+ * This a factory used to gather all function that are often use to collaboration function
+ */
+public class CollabFunctionsFactory {
+
+ /** The Constant RESOURCE__TO__URI. */
+ public static final ResourceToURI RESOURCE__TO__URI = ResourceToURI.getInstance();
+
+ /** The Constant URI__TO__EXTENDED_URI_CONTAINMENT. */
+ public static final URIToExtendedURIWithContainment URI__TO__EXTENDED_URI_CONTAINMENT = URIToExtendedURIWithContainment.getInstance();
+
+ /** The Constant RESOURCE__TO__EXTENDED_URI. */
+ public static final Function<Resource, IExtendedURI> RESOURCE__TO__EXTENDED_URI = Functions.compose(URI__TO__EXTENDED_URI_CONTAINMENT, RESOURCE__TO__URI);
+
+ /**
+ * Gets the {@link ExtendedURI} to {@link IResource}.
+ *
+ * @param resourceSet
+ * the resource set
+ * @return the extended uri to i resource
+ */
+ public static Function<IExtendedURI, IResource> getExtendedURIToIResource(ResourceSet resourceSet) {
+ return new ExtendedURIToIResource(resourceSet);
+ }
+
+ /**
+ * Gets the {@link Resource} to {@link IFile}.
+ *
+ * @return the resource to i file
+ */
+ public static Function<Resource, IFile> getResourceToIFile() {
+ return ResourceToIFile.getInstance();
+ }
+
+ /**
+ * Gets the {@link Resource} to {@link ExtendedURI} with containment.
+ *
+ * @return the resource to extended uri with containment
+ */
+ public static Function<Resource, IExtendedURI> getResourceToExtendedURIWithContainment() {
+ return RESOURCE__TO__EXTENDED_URI;
+ }
+
+ /**
+ * Gets the {@link URI} to {@link ExtendedURI} with containment.
+ *
+ * @return the uRI to extended uri with containment
+ */
+ public static Function<URI, IExtendedURI> getURIToExtendedURIWithContainment() {
+ return URIToExtendedURIWithContainment.getInstance();
+ }
+
+ public static Function<URI, IExtendedURI> getURIToExtendedURI() {
+ return URIToExtendedURI.getInstance();
+ }
+
+ /**
+ * Gets the {@link ExtendedURI} to Collection of {@link EObject}.
+ *
+ * @param resourceSet
+ * the resource set
+ * @return the extended uri to e objects
+ */
+ public static Function<IExtendedURI, Collection<EObject>> getExtendedURIToEObjects(ResourceSet resourceSet) {
+ return new ExtendedURIToEObjects(resourceSet);
+ }
+
+ /**
+ * Get the {@link IExtendedURI} from an {@link EObject}
+ *
+ * @return
+ */
+ public static Function<EObject, IExtendedURI> getEObjectToExtendedURI() {
+ return EObjectToExtendedURI.getInstance();
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/CollabUtils.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/CollabUtils.java
new file mode 100644
index 0000000..46ec466
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/CollabUtils.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils;
+
+import java.util.Collections;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.team.collaborative.ICollaborativeManager;
+import org.eclipse.papyrus.team.collaborative.utils.funtions.EObjectToExtendedURI;
+
+
+/**
+ * The Class CollabUtils.
+ * Util class for collaborative work
+ */
+public class CollabUtils {
+
+
+ /**
+ * Instantiates a new collab utils.
+ */
+ CollabUtils() {
+ }
+
+ /**
+ * Checks if an {@link EObject} can be used in the collaborative framework.
+ *
+ * @param input
+ * the input
+ * @return true, if is collab
+ */
+ public static boolean isCollab(EObject input) {
+ return ICollaborativeManager.INSTANCE.isCollab(Collections.singleton(EObjectToExtendedURI.getInstance().apply(input)), input.eResource().getResourceSet());
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ExtendedURIUtil.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ExtendedURIUtil.java
new file mode 100644
index 0000000..3d5de89
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ExtendedURIUtil.java
@@ -0,0 +1,62 @@
+package org.eclipse.papyrus.team.collaborative.utils;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+
+
+public class ExtendedURIUtil {
+
+
+ /**
+ * Return true if all
+ *
+ * @param input
+ * @param resourceExtendedURI
+ * @param resourceSet
+ * @return
+ */
+ protected static boolean isEObjectContainedResourceExtendedURI(EObject input, IExtendedURI resourceExtendedURI, ResourceSet resourceSet) {
+ URI uri = resourceExtendedURI.getUri();
+ if(resourceExtendedURI.isContainment()) {
+ Resource resource = resourceSet.getResource(uri, false);
+ for(EObject rootObject : resource.getContents()) {
+ if(EcoreUtil.isAncestor(rootObject, input)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isIncluded(EObject input, IExtendedURI extendedURI) {
+ if(input != null) {
+ Resource eResource = input.eResource();
+ if(eResource != null) {
+ ResourceSet resourceSet = eResource.getResourceSet();
+ URI uri = extendedURI.getUri();
+ //If same URI ok
+ if(uri.equals(input.eResource().getURI())) {
+ return true;
+ }
+ if(URIUtils.isResourceURI(uri, resourceSet)) {
+ //If resource
+ return ExtendedURIUtil.isEObjectContainedResourceExtendedURI(input, extendedURI, resourceSet);
+ } else if(URIUtils.isEObject(uri, resourceSet)) {
+ //If EObject
+ if(extendedURI.isContainment()) {
+ EObject eObject = resourceSet.getEObject(uri, false);
+ if(EcoreUtil.isAncestor(eObject, input)) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/IRunnableWithProgressWithResult.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/IRunnableWithProgressWithResult.java
new file mode 100644
index 0000000..0dba93f
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/IRunnableWithProgressWithResult.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils;
+
+import org.eclipse.jface.operation.IRunnableWithProgress;
+
+
+/**
+ * The Class AbstractRunnableWithProgressWithResult.
+ * Runnable used to return a result
+ *
+ * @param <T>
+ * the generic type
+ */
+public interface IRunnableWithProgressWithResult<T> extends IRunnableWithProgress {
+
+ /**
+ * Gets the result.
+ *
+ * @return the result
+ */
+ public T getResult();
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ModelsUtil.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ModelsUtil.java
new file mode 100644
index 0000000..97c765c
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ModelsUtil.java
@@ -0,0 +1,354 @@
+/**
+ * Copyright (c) 2010-2012 Thales Global Services S.A.S.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Thales Global Services S.A.S. - initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.team.collaborative.utils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+
+/**
+ * A utility class related to the structure of models.
+ *
+ * @author Olivier Constant
+ */
+public final class ModelsUtil {
+
+ /**
+ * An interface defining filters for model elements
+ */
+ public static interface IElementFilter {
+
+ /**
+ * Return whether the given element is accepted by this filter
+ *
+ * @param element_p
+ * a non-null element
+ */
+ boolean accepts(EObject element_p);
+ }
+
+
+ /**
+ * Constructor
+ */
+ private ModelsUtil() {
+ // Forbids instantiation
+ }
+
+ /**
+ * From a set of elements, return all the elements of their containment trees in
+ * depth-first order
+ * Postcondition: elements_p is not modified.
+ *
+ * @param elements_p
+ * a non-null collection
+ * @param filter_p
+ * an optional filter
+ * @return a non-null, modifiable list
+ */
+ private static List<EObject> getAllContentsDF(Collection<? extends EObject> elements_p, IElementFilter filter_p) {
+ List<EObject> result = new ArrayList<EObject>();
+ for(EObject element : elements_p) {
+ result.addAll(getAllContentsDF(element, filter_p));
+ }
+ return result;
+ }
+
+ /**
+ * Return all the elements of the containment tree of the given element in depth-first
+ * order
+ *
+ * @param element_p
+ * a non-null element
+ * @param filter_p
+ * an optional filter
+ * @return a non-null, modifiable list
+ */
+ private static List<EObject> getAllContentsDF(EObject element_p, IElementFilter filter_p) {
+ List<EObject> result = new ArrayList<EObject>();
+ if(filter_p == null || filter_p.accepts(element_p))
+ result.add(element_p);
+ TreeIterator<EObject> it = element_p.eAllContents();
+ while(it.hasNext()) {
+ EObject current = it.next();
+ if(filter_p == null || filter_p.accepts(current))
+ result.add(current);
+ }
+ return result;
+ }
+
+ /**
+ * From a set of elements, build a list of all the elements of their containment trees in
+ * breadth-first order
+ * Postcondition: elements_p is not modified.
+ * We use a LinkedList for queuing behavior.
+ *
+ * @param elements_p
+ * a non-null, modifiable, potentially empty queue of the roots
+ * @param result_p
+ * the non-null modifiable result being built
+ * @param filter_p
+ * an optional filter
+ */
+ private static void getAllContentsBF(LinkedList<EObject> elements_p, List<EObject> result_p, IElementFilter filter_p) {
+ if(!elements_p.isEmpty()) {
+ EObject current = elements_p.poll();
+ if(filter_p == null || filter_p.accepts(current)) {
+ result_p.add(current);
+ elements_p.addAll(current.eContents());
+ }
+ getAllContentsBF(elements_p, result_p, filter_p);
+ }
+ }
+
+ /**
+ * Return all the elements in the containment tree of the given element
+ *
+ * @param element_p
+ * a non-null element
+ * @param depthFirst_p
+ * whether the elements must be returned in breadth-first order or in
+ * depth-first order
+ * @param filter_p
+ * an optional filter
+ * @return a non-null, modifiable list
+ */
+ public static List<EObject> getAllContents(EObject element_p, boolean depthFirst_p, IElementFilter filter_p) {
+ return getAllContents(Collections.singletonList(element_p), depthFirst_p, filter_p);
+ }
+
+ /**
+ * From a set of elements, return all the elements in their containment trees
+ * Postcondition: elements_p is not modified.
+ *
+ * @param elements_p
+ * a non-null collection
+ * @param depthFirst_p
+ * whether the elements must be returned in breadth-first order or in
+ * depth-first order
+ * @param filter_p
+ * an optional filter
+ * @return a non-null, modifiable list
+ */
+ public static List<EObject> getAllContents(Collection<? extends EObject> elements_p, boolean depthFirst_p, IElementFilter filter_p) {
+ List<EObject> result;
+ if(depthFirst_p) {
+ result = getAllContentsDF(elements_p, filter_p);
+ } else {
+ result = new ArrayList<EObject>();
+ getAllContentsBF(new LinkedList<EObject>(elements_p), result, filter_p);
+ }
+ return result;
+ }
+
+ /**
+ * Return the list of ancestors including self, from higher to deeper.
+ * The result is not immutable but modifying it has no impact whatsoever.
+ *
+ * @param element_p
+ * a potentially null element
+ * @return a non-null, modifiable ordered set
+ */
+ public static List<EObject> getAncestors(EObject element_p) {
+ if(element_p == null)
+ return new ArrayList<EObject>();
+ List<EObject> containerList = getAncestors(element_p.eContainer());
+ containerList.add(element_p);
+ return containerList;
+ }
+
+ /**
+ * Return the lowest common ancestor in the containment hierarchy, if any,
+ * of the given set of elements
+ *
+ * @param acceptSelf_p
+ * whether the result can be any of the given elements
+ * @return a potentially null element
+ */
+ public static EObject getCommonAncestor(Collection<? extends EObject> elements_p, boolean acceptSelf_p) {
+ if(elements_p == null || elements_p.isEmpty())
+ return null;
+ Iterator<? extends EObject> it = elements_p.iterator();
+ List<EObject> commonHierarchy = getAncestors(it.next());
+ while(it.hasNext()) {
+ List<EObject> currentHierarchy = getAncestors(it.next());
+ // Compute intersection of ancestors
+ commonHierarchy.retainAll(currentHierarchy);
+ }
+ // Exclude the given elements
+ if(!acceptSelf_p)
+ commonHierarchy.removeAll(elements_p);
+ // Take lowest ancestor in common hierarchy
+ if(commonHierarchy.isEmpty())
+ return null;
+ return commonHierarchy.get(commonHierarchy.size() - 1);
+ }
+
+ /**
+ * Return the lowest common ancestor, in the containment hierarchy,
+ * of the two given elements (inclusive)
+ *
+ * @param first_p
+ * a non-null element
+ * @param second_p
+ * a non-null element
+ * @return a potentially null element
+ */
+ public static EObject getCommonAncestor(EObject first_p, EObject second_p) {
+ if(null == first_p || null == second_p)
+ return null;
+ return getCommonAncestor(Arrays.asList(new EObject[]{ first_p, second_p }), true);
+ }
+
+ /**
+ * Given a set of elements, find their lowest common meta-class
+ *
+ * @param elements_p
+ * a non-null collection of model elements
+ * @return a meta-class which is not null if elements_p is not empty
+ */
+ public static EClass getCommonType(Collection<? extends EObject> elements_p) {
+ EClass result = null;
+ if(!elements_p.isEmpty()) {
+ List<EClass> common = new ArrayList<EClass>(getSuperTypes(elements_p.iterator().next().eClass()));
+ for(EObject elt : elements_p) {
+ common.retainAll(getSuperTypes(elt.eClass()));
+ }
+ if(!common.isEmpty()) {
+ result = common.get(common.size() - 1);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return the depth in the containment tree of the given element
+ *
+ * @param element_p
+ * a potentially null element
+ * @return 0 if null, a strictly positive integer otherwise
+ */
+ public static int getDepth(EObject element_p) {
+ if(element_p == null)
+ return 0;
+ return 1 + getDepth(element_p.eContainer());
+ }
+
+ /**
+ * Return the overall depth in the containment tree of the given collection of elements,
+ * where overall means maximum if max_p is true, or minimum otherwise
+ *
+ * @param elements_p
+ * a non-null, potentially empty collection of elements
+ */
+ public static int getDepth(Iterable<? extends EObject> elements_p, boolean max_p) {
+ int result = max_p ? 0 : Integer.MAX_VALUE;
+ for(EObject element : elements_p) {
+ int depth = getDepth(element);
+ result = max_p ? Math.max(result, depth) : Math.min(result, depth);
+ }
+ return result;
+ }
+
+ /**
+ * From a set of elements, return all the leaves in their containment trees
+ *
+ * @param elements_p
+ * a non-null collection
+ * @return a non-null list
+ */
+ public static List<EObject> getLeaves(Collection<? extends EObject> elements_p) {
+ List<EObject> result = new ArrayList<EObject>();
+ for(EObject element : elements_p) {
+ result.addAll(getLeaves(element));
+ }
+ return result;
+ }
+
+ /**
+ * Return all the leaves in the containment tree of the given element
+ *
+ * @param element_p
+ * a non-null element
+ * @return a non-null list
+ */
+ public static List<EObject> getLeaves(EObject element_p) {
+ List<EObject> result;
+ if(element_p.eContents().isEmpty()) {
+ result = Collections.singletonList(element_p);
+ } else {
+ result = getLeaves(element_p.eContents());
+ }
+ return result;
+ }
+
+ /**
+ * From a set of elements, filter out those which are transitively contained
+ * in others
+ *
+ * @param elements_p
+ * a non-null collection
+ * @return a non-null list
+ */
+ public static <T extends EObject> List<T> getRoots(Collection<? extends T> elements_p) {
+ List<T> result = new ArrayList<T>();
+ Collection<T> elements = new HashSet<T>(elements_p);
+ for(T element : elements) {
+ if(!result.contains(element) && isRootAmong(element, elements))
+ result.add(element);
+ }
+ return result;
+ }
+
+ /**
+ * Return the super types of the given meta-class including the class itself,
+ * ordered from higher to lower in the hierarchy
+ *
+ * @param class_p
+ * a non-null meta-class
+ * @return a non-null, non-empty, unmodifiable list
+ */
+ private static List<EClass> getSuperTypes(EClass class_p) {
+ List<EClass> allButSelf = class_p.getEAllSuperTypes();
+ List<EClass> result = new ArrayList<EClass>(allButSelf.size() + 1);
+ result.addAll(allButSelf);
+ result.add(class_p);
+ return Collections.unmodifiableList(result);
+ }
+
+ /**
+ * Return whether the given element is not transitively contained by any
+ * of the given elements, unless it is one of the given elements
+ *
+ * @param element_p
+ * a non-null element
+ * @param elements_p
+ * a non-null collection
+ */
+ private static boolean isRootAmong(EObject element_p, Collection<? extends EObject> elements_p) {
+ Collection<EObject> filtered = new HashSet<EObject>(elements_p);
+ filtered.remove(element_p);
+ return !EcoreUtil.isAncestor(filtered, element_p);
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ResourceUtils.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ResourceUtils.java
new file mode 100644
index 0000000..2204ad8
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/ResourceUtils.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.emf.ecore.resource.Resource;
+
+
+/**
+ * The Class ResourceUtils.
+ * Utils class use to handle {@link Resource}
+ */
+public class ResourceUtils {
+
+
+ /**
+ * Instantiates a new resource utils.
+ */
+ protected ResourceUtils() {
+ }
+
+ // /**
+ // * Gets the list of non collab ancestor.
+ // *
+ // * @param inputResources
+ // * the input resources
+ // * @param resourceSet
+ // * the resource set
+ // * @return the list of non collab ancestor
+ // */
+ // public static List<IResource> getListOfNonCollabAncestor(Collection<? extends IResource> inputResources, ResourceSet resourceSet) {
+ // List<IResource> result = new ArrayList<IResource>();
+ // for(IResource f : inputResources) {
+ // if(!(f instanceof IProject) && (f instanceof IContainer || f instanceof IFile)) {
+ // getListOfNonCollabAncestor(Collections.singletonList(f.getParent()), resourceSet);
+ // if(!result.contains(f)) {
+ // if(!ICollaborativeManager.INSTANCE.isCollab(Collections.singleton(IResourceToExtendedURI.getInstance().apply(f)), resourceSet)) {
+ // result.add(f);
+ // }
+ // }
+ // }
+ // }
+ // return result;
+ // }
+
+
+ /**
+ * Gets the list ancestors.
+ *
+ * @param inputResources
+ * the input resources
+ * @return the list ancestors
+ */
+ public static List<IResource> getListAncestors(Collection<? extends IResource> inputResources) {
+ List<IResource> result = new ArrayList<IResource>();
+ for(IResource f : inputResources) {
+ if(!(f instanceof IProject) && (f instanceof IContainer || f instanceof IFile)) {
+ getListAncestors(Collections.singletonList(f.getParent()));
+ if(!result.contains(f)) {
+ result.add(f);
+ }
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/URIUtils.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/URIUtils.java
new file mode 100644
index 0000000..2320a26
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/URIUtils.java
@@ -0,0 +1,246 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+
+/**
+ * The Class URIUtils.
+ */
+public class URIUtils {
+
+ /**
+ * Checks if is {@link Resource} {@link URI}.
+ *
+ * @param uri
+ * the uri
+ * @param resourceSet
+ * the resource set
+ * @return true, if is resource uri
+ */
+ public static boolean isResourceURI(URI uri, ResourceSet resourceSet) {
+ return resourceSet.getResource(uri, false) != null;
+ }
+
+ /**
+ * Checks if an {@link URI} is an {@link EObject}.
+ *
+ * @param uri
+ * the uri
+ * @param resourceSet
+ * the resource set
+ * @return true, if is e object
+ */
+ public static boolean isEObject(URI uri, ResourceSet resourceSet) {
+ return uri.hasFragment() && resourceSet.getEObject(uri, false) != null;
+ }
+
+
+ /**
+ * Gets the satellite resource {@link URI}.
+ *
+ * @param uri
+ * the base uri
+ * @param fileExtension
+ * the file extension
+ * @return the satelite resource
+ */
+ public static URI getSateliteResource(URI uri, String fileExtension) {
+ return uri.trimFileExtension().appendFileExtension(fileExtension);
+ }
+
+
+
+ /**
+ * Convert EMF URI to Eclipse file
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param uri
+ * the uri
+ * @return the file
+ */
+ public static IFile getFile(URI uri) {
+ String platformString = uri.toPlatformString(true);
+ if(platformString != null) {
+ Path path = new Path(platformString);
+ return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ }
+ return null;
+ }
+
+ /**
+ * Convert EMF URI to Eclipse folder
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param uri
+ * the uri
+ * @return the folder
+ */
+ public static IFolder getFolder(URI uri) {
+ Path path = new Path(uri.toPlatformString(true));
+ return ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
+ }
+
+ /**
+ * Convert Eclipse resource to EMF URI
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param file
+ * the file
+ * @return the uri
+ */
+ public static URI getURI(IResource file) {
+ return getURI(file.getFullPath());
+ }
+
+ /**
+ * Create an EMF URI from an Eclipse path
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param path
+ * the path
+ * @return the uri
+ */
+ public static URI getURI(IPath path) {
+ return URI.createPlatformResourceURI(path.toString(), true);
+ }
+
+ /**
+ * Convert a file name to an EMF URI
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param fileName
+ * the file name
+ * @return EMF URI
+ */
+ public static URI getURI(String fileName) {
+ return getURI(new File(fileName));
+ }
+
+ /**
+ * Convert a file name to an EMF URI
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param file
+ * the file
+ * @return EMF URI
+ */
+ public static URI getURI(File file) {
+ return URI.createFileURI(file.getAbsolutePath());
+ }
+
+ /**
+ * Get Java URL from EMF URI
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param uri
+ * EMF URI
+ * @return Java URL
+ */
+ public static URL getURL(URI uri) {
+ try {
+ URL url = new URL(uri.toString());
+ return url;
+ } catch (MalformedURLException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Get EMF URI from Java URL
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param url
+ * Java URL
+ * @return EMF URI
+ */
+ public static URI getURI(URL url) {
+ return URI.createURI(url.toString());
+ }
+
+ /**
+ * Replace extension of a file
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param file
+ * File
+ * @param ext
+ * New extension
+ * @return New file
+ */
+ public static IFile replaceExtension(IFile file, String ext) {
+ IProject project = file.getProject();
+ return project.getFile(file.getProjectRelativePath().removeFileExtension().addFileExtension(ext));
+ }
+
+ /**
+ * Replace extension of a EMF URI
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param uri
+ * EMF URI
+ * @param ext
+ * New extension
+ * @return New EMF URI
+ */
+ public static URI replaceExtension(URI uri, String ext) {
+ return uri.trimFileExtension().appendFileExtension(ext);
+ }
+
+ /**
+ * Get the Java file for a URI
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param uri
+ * the uri
+ * @return Java file
+ */
+ public static File getJavaFile(URI uri) {
+ if(uri.isPlatform()) {
+ IFile file = getFile(uri);
+ IPath location = file.getLocation();
+ return location.toFile();
+ }
+ return new File(uri.toFileString());
+ }
+
+ /**
+ * Get the relative path of a {@link URI} w.r.t. another {@link URI}.
+ * Copied from org.eclipse.emf.edapt.common.URIUtils
+ *
+ * @param uri
+ * the uri
+ * @param relativeTo
+ * the relative to
+ * @return the relative path
+ */
+ public static URI getRelativePath(URI uri, URI relativeTo) {
+ return uri.deresolve(relativeTo, true, true, true);
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/EObjectToExtendedURI.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/EObjectToExtendedURI.java
new file mode 100644
index 0000000..b48c21a
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/EObjectToExtendedURI.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils.funtions;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+
+import com.google.common.base.Function;
+
+
+/**
+ * The Class EObjectToExtendedURI.
+ * Function to convert {@link EObject} to {@link ExtendedURI}
+ */
+public class EObjectToExtendedURI implements Function<EObject, IExtendedURI> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.common.base.Function#apply(java.lang.Object)
+ */
+ @Override
+ public IExtendedURI apply(EObject from) {
+ Resource resoure = from.eResource();
+ return new ExtendedURI(resoure.getURI().appendFragment(resoure.getURIFragment(from)));
+ }
+
+ /**
+ * The Class SingletonHolder.
+ */
+ private static class SingletonHolder {
+
+ /** The instance. */
+ private static EObjectToExtendedURI INSTANCE = new EObjectToExtendedURI();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private EObjectToExtendedURI() {
+ }
+
+ /**
+ * Returns the Singleton instance.
+ * <p>
+ *
+ * @return The Singleton instance.
+ */
+ public static EObjectToExtendedURI getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToEObjects.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToEObjects.java
new file mode 100644
index 0000000..08fa2fa
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToEObjects.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils.funtions;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.utils.URIUtils;
+
+import com.google.common.base.Function;
+
+
+/**
+ * The Class ExtendedURIToEObjects.
+ * Function used to convert {@link ExtendedURI} to {@link java.util.List} of {@link EObject}
+ */
+public class ExtendedURIToEObjects implements Function<IExtendedURI, Collection<EObject>> {
+
+ /** The resource set. */
+ private ResourceSet resourceSet;
+
+ /**
+ * Instantiates a new extended uri to e objects.
+ *
+ * @param resourceSet
+ * the resource set
+ */
+ public ExtendedURIToEObjects(ResourceSet resourceSet) {
+ super();
+ this.resourceSet = resourceSet;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.common.base.Function#apply(java.lang.Object)
+ */
+ @Override
+ public Collection<EObject> apply(IExtendedURI from) {
+ if(URIUtils.isEObject(from.getUri(), resourceSet)) {
+ return Collections.singleton(resourceSet.getEObject(from.getUri(), false));
+ } else if(URIUtils.isResourceURI(from.getUri(), resourceSet)) {
+ Resource resource = resourceSet.getResource(from.getUri(), false);
+ if(resource != null) {
+ return resource.getContents();
+ }
+ }
+ return Collections.emptyList();
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToIResource.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToIResource.java
new file mode 100644
index 0000000..5573646
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToIResource.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils.funtions;
+
+import org.eclipse.core.resources.IResource;
+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.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+import org.eclipse.papyrus.team.collaborative.utils.URIUtils;
+
+import com.google.common.base.Function;
+
+
+/**
+ * The Class ExtendedURIToIResource.
+ * Function used to convert {@link ExtendedURI} to {@link IResource}
+ */
+public class ExtendedURIToIResource implements Function<IExtendedURI, IResource> {
+
+ /** The resource set. */
+ private ResourceSet resourceSet;
+
+ /**
+ * Instantiates a new extended uri to i resource.
+ *
+ * @param resourceSet
+ * the resource set
+ */
+ public ExtendedURIToIResource(ResourceSet resourceSet) {
+ super();
+ this.resourceSet = resourceSet;
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.common.base.Function#apply(java.lang.Object)
+ */
+ @Override
+ public IResource apply(IExtendedURI from) {
+ URI uri = from.getUri();
+ IResource result = null;
+ if(URIUtils.isEObject(from.getUri(), resourceSet)) {
+ result = WorkspaceSynchronizer.getFile(resourceSet.getEObject(uri, false).eResource());
+ } else if(URIUtils.isResourceURI(from.getUri(), resourceSet)) {
+ Resource resource = resourceSet.getResource(from.getUri(), false);
+ result = WorkspaceSynchronizer.getFile(resource);
+ } else {
+ result = URIUtils.getFile(uri);
+ if(result == null) {
+ result = URIUtils.getFolder(uri);
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToURI.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToURI.java
new file mode 100644
index 0000000..683a8cf
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ExtendedURIToURI.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils.funtions;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+
+import com.google.common.base.Function;
+
+
+/**
+ * The Class ExtendedURIToURI.
+ * Function used to convert {@link ExtendedURI} to {@link URI}
+ */
+public class ExtendedURIToURI implements Function<ExtendedURI, URI> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.common.base.Function#apply(java.lang.Object)
+ */
+ public URI apply(ExtendedURI from) {
+ return from.getUri();
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/IFileToFile.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/IFileToFile.java
new file mode 100644
index 0000000..58b9388
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/IFileToFile.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils.funtions;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IResource;
+
+import com.google.common.base.Function;
+
+
+/**
+ * The Class IFileToFile.
+ * Function used to convert {@link IResource} to {@link File}
+ *
+ * @param <T>
+ * the generic type
+ */
+public class IFileToFile<T extends IResource> implements Function<T, File> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.common.base.Function#apply(java.lang.Object)
+ */
+ @Override
+ public File apply(T from) {
+ return from.getFullPath().toFile();
+ }
+
+
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/IResourceToExtendedURI.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/IResourceToExtendedURI.java
new file mode 100644
index 0000000..550b495
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/IResourceToExtendedURI.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils.funtions;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.utils.URIUtils;
+
+import com.google.common.base.Function;
+
+
+/**
+ * The Class IResourceToExtendedURI.
+ * Function used to convert {@link IResource} to {@link ExtendedURI}
+ */
+public class IResourceToExtendedURI implements Function<IResource, ExtendedURI> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.common.base.Function#apply(java.lang.Object)
+ */
+ @Override
+ public ExtendedURI apply(IResource from) {
+ return new ExtendedURI(URIUtils.getURI(from));
+ }
+
+ /**
+ * The Class SingletonHolder.
+ */
+ private static class SingletonHolder {
+
+ /** The instance. */
+ private static IResourceToExtendedURI INSTANCE = new IResourceToExtendedURI();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private IResourceToExtendedURI() {
+ }
+
+ /**
+ * Returns the Singleton instance.
+ * <p>
+ *
+ * @return The Singleton instance.
+ */
+ public static IResourceToExtendedURI getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ResourceToIFile.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ResourceToIFile.java
new file mode 100644
index 0000000..97350f4
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ResourceToIFile.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils.funtions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+
+import com.google.common.base.Function;
+
+
+/**
+ * The Class ResourceToIFile.
+ * Function used to convert {@link Resource} to {@link IFile}
+ */
+public class ResourceToIFile implements Function<Resource, IFile> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.common.base.Function#apply(java.lang.Object)
+ */
+ @Override
+ public IFile apply(Resource from) {
+ return WorkspaceSynchronizer.getFile(from);
+ }
+
+
+ /**
+ * The Class SingletonHolder.
+ */
+ private static class SingletonHolder {
+
+ /** The instance. */
+ private static ResourceToIFile INSTANCE = new ResourceToIFile();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private ResourceToIFile() {
+ // TODO auto-generated constructor
+ }
+
+ /**
+ * Returns the Singleton instance.
+ * <p>
+ *
+ * @return The Singleton instance.
+ */
+ public static ResourceToIFile getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ResourceToURI.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ResourceToURI.java
new file mode 100644
index 0000000..7f37343
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/ResourceToURI.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils.funtions;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+
+import com.google.common.base.Function;
+
+
+/**
+ * The Class ResourceToURI.
+ * Function used to convert {@link Resource} to {@link URI}
+ */
+public class ResourceToURI implements Function<Resource, URI> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.common.base.Function#apply(java.lang.Object)
+ */
+ @Override
+ public URI apply(Resource from) {
+ return from.getURI();
+ }
+
+ /**
+ * The Class SingletonHolder.
+ */
+ private static class SingletonHolder {
+
+ /** The instance. */
+ private static ResourceToURI INSTANCE = new ResourceToURI();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private ResourceToURI() {
+ // TODO auto-generated constructor
+ }
+
+ /**
+ * Returns the Singleton instance.
+ * <p>
+ *
+ * @return The Singleton instance.
+ */
+ public static ResourceToURI getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/URIToExtendedURI.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/URIToExtendedURI.java
new file mode 100644
index 0000000..4a40212
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/URIToExtendedURI.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils.funtions;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+
+import com.google.common.base.Function;
+
+
+/**
+ * The Class URIToExtendedURI.
+ * Function used to convert {@link URI} to {@link ExtendedURI} (No containment)
+ */
+public class URIToExtendedURI implements Function<URI, IExtendedURI> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.common.base.Function#apply(java.lang.Object)
+ */
+ @Override
+ public IExtendedURI apply(URI from) {
+ return new ExtendedURI(from);
+ }
+
+ private static class SingletonHolder {
+
+ private static URIToExtendedURI INSTANCE = new URIToExtendedURI();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private URIToExtendedURI() {
+ // TODO auto-generated constructor
+ }
+
+ /**
+ * Returns the Singleton instance.
+ * <p>
+ *
+ * @return The Singleton instance.
+ */
+ public static URIToExtendedURI getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+
+}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/URIToExtendedURIWithContainment.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/URIToExtendedURIWithContainment.java
new file mode 100644
index 0000000..d0c3ca5
--- /dev/null
+++ b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative/src/org/eclipse/papyrus/team/collaborative/utils/funtions/URIToExtendedURIWithContainment.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Atos
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Arthur Daussy - initial implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.team.collaborative.utils.funtions;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.team.collaborative.ExtendedURI;
+import org.eclipse.papyrus.team.collaborative.IExtendedURI;
+
+import com.google.common.base.Function;
+
+
+/**
+ * The Class URIToExtendedURIWithContainment.
+ * Function used to convert {@link URI} to {@link ExtendedURI} with containment
+ */
+public class URIToExtendedURIWithContainment implements Function<URI, IExtendedURI> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.common.base.Function#apply(java.lang.Object)
+ */
+ @Override
+ public ExtendedURI apply(URI from) {
+ return new ExtendedURI(from).setContainment(true);
+ }
+
+ /**
+ * The Class SingletonHolder.
+ */
+ private static class SingletonHolder {
+
+ /** The instance. */
+ private static URIToExtendedURIWithContainment INSTANCE = new URIToExtendedURIWithContainment();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private URIToExtendedURIWithContainment() {
+ // TODO auto-generated constructor
+ }
+
+ /**
+ * Returns the Singleton instance.
+ * <p>
+ *
+ * @return The Singleton instance.
+ */
+ public static URIToExtendedURIWithContainment getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+
+} \ No newline at end of file