Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-02-03 21:32:58 +0000
committerMichael Valenta2003-02-03 21:32:58 +0000
commitfbd5263a666c822e6870352019157a687ed44393 (patch)
tree36e5e0869606a2135f8387fa2259253e552bb631
parente6104e4231ec6181ae64b44a37a9a1cd2517315e (diff)
downloadeclipse.platform.team-fbd5263a666c822e6870352019157a687ed44393.tar.gz
eclipse.platform.team-fbd5263a666c822e6870352019157a687ed44393.tar.xz
eclipse.platform.team-fbd5263a666c822e6870352019157a687ed44393.zip
30683: Need API to know if project is shared
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java19
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTests.java8
2 files changed, 27 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java
index 38d67518b..2c7bb4522 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java
@@ -444,6 +444,25 @@ public abstract class RepositoryProvider implements IProjectNature {
}
/**
+ * Returns whether the given project is shared or not. This is a lightweight
+ * method in that it will not instantiate a provider instance (as
+ * <code>getProvider</code> would) if one is not already instantiated.
+ * @param project the project being tested.
+ * @return boolean
+ *
+ * @see getProvider(IProject)
+ */
+ public static boolean isShared(IProject project) {
+ try {
+ if (lookupProviderProp(project) != null) return true;
+ return project.getPersistentProperty(PROVIDER_PROP_KEY) != null;
+ } catch (CoreException e) {
+ TeamPlugin.log(e.getStatus());
+ return false;
+ }
+ }
+
+ /**
* Provisional non-API method.
*
* This method is here to allow experimentation with 3rd party tools
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTests.java
index 3b22db842..d26e5cc34 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RepositoryProviderTests.java
@@ -367,4 +367,12 @@ public class RepositoryProviderTests extends TeamTest {
fail("Link should be disallowed");
}
+ public void testIsShared() throws CoreException, TeamException {
+ IProject project1 = getUniqueTestProject("testGetProviderById_1");
+ RepositoryProvider.map(project1, RepositoryProviderBic.NATURE_ID);
+ assertTrue(RepositoryProvider.isShared(project1));
+ RepositoryProvider.unmap(project1);
+ assertTrue(!RepositoryProvider.isShared(project1));
+ }
+
} \ No newline at end of file

Back to the top