Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/team')
-rw-r--r--plugins/team/org.eclipse.papyrus.team.svn/META-INF/MANIFEST.MF3
-rw-r--r--plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/team/svn/SVNLockHandler.java48
2 files changed, 44 insertions, 7 deletions
diff --git a/plugins/team/org.eclipse.papyrus.team.svn/META-INF/MANIFEST.MF b/plugins/team/org.eclipse.papyrus.team.svn/META-INF/MANIFEST.MF
index ccbb19289aa..a01439adc4d 100644
--- a/plugins/team/org.eclipse.papyrus.team.svn/META-INF/MANIFEST.MF
+++ b/plugins/team/org.eclipse.papyrus.team.svn/META-INF/MANIFEST.MF
@@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.papyrus.infra.onefile;bundle-version="1.0.0",
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.0",
org.eclipse.emf.edit,
org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
- com.google.guava;bundle-version="11.0.0"
+ com.google.guava;bundle-version="11.0.0",
+ org.eclipse.team.core;bundle-version="3.7.0"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.0.0.qualifier
diff --git a/plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/team/svn/SVNLockHandler.java b/plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/team/svn/SVNLockHandler.java
index f40ac894de2..3c91cb81f08 100644
--- a/plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/team/svn/SVNLockHandler.java
+++ b/plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/team/svn/SVNLockHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 Atos Origin.
+ * Copyright (c) 2011, 2014 Atos Origin, CEA, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,13 +9,17 @@
*
* Contributors:
* Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 429826
*
*****************************************************************************/
package org.eclipse.papyrus.team.svn;
import java.util.HashSet;
+import java.util.Iterator;
+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.resources.ResourcesPlugin;
import org.eclipse.core.resources.team.FileModificationValidationContext;
@@ -24,16 +28,27 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.infra.emf.readonly.AbstractReadOnlyHandler;
+import org.eclipse.papyrus.infra.core.resource.AbstractReadOnlyHandler;
+import org.eclipse.papyrus.infra.core.resource.ReadOnlyAxis;
+import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.svn.core.IStateFilter;
import org.eclipse.team.svn.core.svnstorage.SVNRemoteStorage;
import org.eclipse.team.svn.core.utility.FileUtility;
import org.eclipse.team.svn.ui.SVNTeamModificationValidator;
import com.google.common.base.Optional;
+import com.google.common.collect.Sets;
+/**
+ * The Subversion file read-only handler is permission-based.
+ */
public class SVNLockHandler extends AbstractReadOnlyHandler {
+ // This is defined by SVNTeamPlugin.NATURE_ID constant, but we don't want a dependency
+ // on that class (although, technically, it should be compiled into this class's constant
+ // pool, let's be explicit about it)
+ private static final String SVN_NATURE_ID = "org.eclipse.team.svn.core.nature"; //$NON-NLS-1$
+
FileModificationValidator validator = null;
public SVNLockHandler(EditingDomain editingDomain) {
@@ -44,9 +59,9 @@ public class SVNLockHandler extends AbstractReadOnlyHandler {
}
}
- public Optional<Boolean> anyReadOnly(URI[] uris) {
+ public Optional<Boolean> anyReadOnly(Set<ReadOnlyAxis> axes, URI[] uris) {
- if (validator != null) {
+ if ((validator != null) && axes.contains(ReadOnlyAxis.PERMISSION)) {
IResource[] needsLockResources = FileUtility.filterResources(getIFiles(uris), IStateFilter.SF_NEEDS_LOCK, IResource.DEPTH_ZERO);
for(IResource needsLockResource : needsLockResources) {
if(!SVNRemoteStorage.instance().asLocalResource(needsLockResource).isLocked()) {
@@ -57,9 +72,30 @@ public class SVNLockHandler extends AbstractReadOnlyHandler {
return Optional.absent();
}
+
+ @Override
+ public Optional<Boolean> canMakeWritable(Set<ReadOnlyAxis> axes, URI[] uris) {
+ if((validator != null) && axes.contains(ReadOnlyAxis.PERMISSION)) {
+ // get the unique set of projects to check for SVN team provider
+ IFile[] files = getIFiles(uris);
+ Set<IProject> projects = Sets.newHashSet();
+ for(int i = 0; i < files.length; i++) {
+ projects.add(files[i].getProject());
+ }
+
+ boolean result = false;
+ for(Iterator<IProject> iter = projects.iterator(); !result && iter.hasNext();) {
+ result = RepositoryProvider.getProvider(iter.next(), SVN_NATURE_ID) != null;
+ }
+
+ return Optional.of(result);
+ }
+
+ return Optional.absent();
+ }
- public Optional<Boolean> makeWritable(URI[] uris) {
- if (validator != null) {
+ public Optional<Boolean> makeWritable(Set<ReadOnlyAxis> axes, URI[] uris) {
+ if ((validator != null) && axes.contains(ReadOnlyAxis.PERMISSION)) {
IStatus result = validator.validateEdit(getIFiles(uris), FileModificationValidationContext.VALIDATE_PROMPT);
return Optional.of(result.isOK());
}

Back to the top