Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/team/org.eclipse.papyrus.team.svn/src/org')
-rw-r--r--plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/svn/Activator.java45
-rw-r--r--plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/svn/SVNLockHandler.java48
2 files changed, 93 insertions, 0 deletions
diff --git a/plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/svn/Activator.java b/plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/svn/Activator.java
new file mode 100644
index 00000000000..74536d136fa
--- /dev/null
+++ b/plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/svn/Activator.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.svn;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
diff --git a/plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/svn/SVNLockHandler.java b/plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/svn/SVNLockHandler.java
new file mode 100644
index 00000000000..d909cae3f15
--- /dev/null
+++ b/plugins/team/org.eclipse.papyrus.team.svn/src/org/eclipse/papyrus/svn/SVNLockHandler.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.svn;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.team.FileModificationValidationContext;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.papyrus.readonly.IReadOnlyHandler;
+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;
+
+public class SVNLockHandler implements IReadOnlyHandler {
+
+ SVNTeamModificationValidator validator = new SVNTeamModificationValidator();
+
+ public boolean isReadOnly(IFile[] files) {
+
+ IResource[] needsLockResources = FileUtility.filterResources(files, IStateFilter.SF_NEEDS_LOCK, IResource.DEPTH_ZERO);
+ for(IResource needsLockResource : needsLockResources) {
+ if(!SVNRemoteStorage.instance().asLocalResource(needsLockResource).isLocked()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public boolean enableWrite(IFile[] files) {
+
+ IStatus result = validator.validateEdit(files, FileModificationValidationContext.VALIDATE_PROMPT);
+
+ return result.isOK();
+ }
+}

Back to the top