Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Macguire2002-05-13 06:37:45 +0000
committerKevin Macguire2002-05-13 06:37:45 +0000
commit37e1913b25012b08d7fd830b1c3feb206e3906ff (patch)
tree4dc2a1ebaf8b7131d0e92f734c20041d6c3dffd3 /bundles
parent854072ef398e85722eb4bb6ddfbfb4d9f54ac7b5 (diff)
downloadeclipse.platform.team-37e1913b25012b08d7fd830b1c3feb206e3906ff.tar.gz
eclipse.platform.team-37e1913b25012b08d7fd830b1c3feb206e3906ff.tar.xz
eclipse.platform.team-37e1913b25012b08d7fd830b1c3feb206e3906ff.zip
Targets extension point
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.team.core/plugin.properties3
-rw-r--r--bundles/org.eclipse.team.core/plugin.xml1
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamPlugin.java6
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/ITargetFactory.java19
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetLocation.java19
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetManager.java150
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java (renamed from bundles/org.eclipse.team.core/src/org/eclipse/team/core/TargetProvider.java)3
7 files changed, 199 insertions, 2 deletions
diff --git a/bundles/org.eclipse.team.core/plugin.properties b/bundles/org.eclipse.team.core/plugin.properties
index b6888863d..045bc3486 100644
--- a/bundles/org.eclipse.team.core/plugin.properties
+++ b/bundles/org.eclipse.team.core/plugin.properties
@@ -1,4 +1,5 @@
pluginName = Team Support Core
FileTypesRegistry=File Types Registry
GlobalIgnoreRegistry=Global Ignore Registry
-TeamProjectSets=Team Project Sets \ No newline at end of file
+TeamProjectSets=Team Project Sets
+Targets=Target Provider and Location Factories \ No newline at end of file
diff --git a/bundles/org.eclipse.team.core/plugin.xml b/bundles/org.eclipse.team.core/plugin.xml
index cf1475485..3826b708d 100644
--- a/bundles/org.eclipse.team.core/plugin.xml
+++ b/bundles/org.eclipse.team.core/plugin.xml
@@ -20,6 +20,7 @@
<extension-point id="fileTypes" name="%FileTypesRegistry"/>
<extension-point id="ignore" name="%GlobalIgnoreRegistry"/>
<extension-point id="projectSets" name="%TeamProjectSets"/>
+<extension-point id="targets" name="%Targets"/>
<!-- Define some example text extensions. This will be done
by other plugins later. -->
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamPlugin.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamPlugin.java
index 7032f2bd2..9c6d87e7d 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamPlugin.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TeamPlugin.java
@@ -15,6 +15,7 @@ import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.team.core.target.TargetManager;
import org.eclipse.team.internal.core.Policy;
/**
@@ -42,6 +43,10 @@ final public class TeamPlugin extends Plugin {
public static final String IGNORE_EXTENSION = "ignore"; //$NON-NLS-1$
// The id of the project set extension point
public static final String PROJECT_SET_EXTENSION = "projectSets"; //$NON-NLS-1$
+ // The id of the targets extension point
+ public static final String TARGETS_EXTENSION = "targets"; //$NON-NLS-1$
+
+
// The one and only plug-in instance
private static TeamPlugin plugin;
@@ -59,6 +64,7 @@ final public class TeamPlugin extends Plugin {
public void startup() throws CoreException {
Policy.localize("org.eclipse.team.internal.core.messages"); //$NON-NLS-1$
Team.startup();
+ TargetManager.startup();
}
/**
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/ITargetFactory.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/ITargetFactory.java
new file mode 100644
index 000000000..bb88affa7
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/ITargetFactory.java
@@ -0,0 +1,19 @@
+package org.eclipse.team.core.target;
+
+/**
+ * @version 1.0
+ * @author
+ */
+public interface ITargetFactory {
+
+ /**
+ * Return a new target location for the given encoded description.
+ */
+ public TargetLocation decode(String serializedLocation);
+
+ /**
+ * Return a new target provider for the given location.
+ */
+ public TargetProvider newTarget(TargetLocation location);
+
+}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetLocation.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetLocation.java
new file mode 100644
index 000000000..eae2440e2
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetLocation.java
@@ -0,0 +1,19 @@
+package org.eclipse.team.core.target;
+
+/**
+ * @version 1.0
+ * @author
+ */
+public abstract class TargetLocation {
+
+ /*
+ * Initialize a new TargetLocation of the given type.
+ */
+
+ public TargetLocation() {
+ super();
+ }
+
+ public abstract String getType();
+ public abstract String encode();
+}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetManager.java
new file mode 100644
index 000000000..856e37b76
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetManager.java
@@ -0,0 +1,150 @@
+package org.eclipse.team.core.target;
+
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.team.core.*;
+import org.eclipse.team.internal.core.*;
+import org.eclipse.team.core.target.*;
+
+/**
+ * @version 1.0
+ * @author
+ */
+public class TargetManager {
+ private static final String TARGET_LOCATIONS_FILE = ".targetLocations";
+
+ private static Map factories = new Hashtable();
+ private static List locations = new ArrayList();
+
+
+ public static ITargetFactory getFactory(String id) {
+ ITargetFactory factory = (ITargetFactory) factories.get(id);
+ if(factory == null) {
+ factory = getTargetFactory(id);
+ if(factory != null) {
+ factories.put(id, factory);
+ return factory;
+ }
+ }
+ return null;
+ }
+
+ public static void startup() {
+ readLocations();
+ }
+
+ public static void save() {
+ writeLocations();
+ }
+
+ public static TargetLocation[] getLocations() {
+ return (TargetLocation[]) locations.toArray(new TargetLocation[locations.size()]);
+ }
+
+ public static void add(TargetLocation location) {
+ locations.add(location);
+ }
+
+ private static void readLocations() {
+ // read saved locations list from disk, only if the file exists
+ IPath pluginStateLocation = TeamPlugin.getPlugin().getStateLocation().append(TARGET_LOCATIONS_FILE);
+ File f = pluginStateLocation.toFile();
+ if( f.exists() ) {
+ try {
+ DataInputStream dis = new DataInputStream(new FileInputStream(f));
+ readLocations(dis);
+ } catch (IOException e) {
+ TeamPlugin.log(new Status(Status.ERROR, TeamPlugin.ID, 0, Policy.bind("Config.error"), e)); //$NON-NLS-1$
+ }
+ }
+ }
+
+ private static void writeLocations() {
+ // save repositories to disk
+ IPath pluginStateLocation = TeamPlugin.getPlugin().getStateLocation();
+ File tempFile = pluginStateLocation.append(TARGET_LOCATIONS_FILE + ".tmp").toFile(); //$NON-NLS-1$
+ File stateFile = pluginStateLocation.append(TARGET_LOCATIONS_FILE).toFile();
+ try {
+ DataOutputStream dos = new DataOutputStream(new FileOutputStream(tempFile));
+ writeLocations(dos);
+ dos.close();
+ if (stateFile.exists())
+ stateFile.delete();
+ boolean renamed = tempFile.renameTo(stateFile);
+ if (!renamed) {
+ //todo: log the error
+ }
+ } catch (IOException e) {
+ TeamPlugin.log(new Status(Status.ERROR, TeamPlugin.ID, 0, Policy.bind("Config.error"), e)); //$NON-NLS-1$
+ }
+ }
+
+ private static void readLocations(DataInputStream dis) throws IOException {
+ int repoCount = dis.readInt();
+ for (int i = 0; i < repoCount; i++) {
+ String type = dis.readUTF();
+ String locationData = dis.readUTF();
+ ITargetFactory factory = getFactory(type);
+ if(factory == null) {
+ //todo: log error
+ return;
+ }
+ TargetLocation loc = factory.decode(locationData);
+ locations.add(loc);
+ }
+ }
+
+ private static void writeLocations(DataOutputStream dos) throws IOException {
+ dos.writeInt(locations.size());
+ Iterator iter = locations.iterator();
+ while(iter.hasNext()) {
+ TargetLocation loc = (TargetLocation) iter.next();
+ dos.writeUTF(loc.getType());
+ dos.writeUTF(loc.encode());
+ }
+ }
+
+ private static ITargetFactory getTargetFactory(String id) {
+ TeamPlugin plugin = TeamPlugin.getPlugin();
+ if (plugin != null) {
+ IExtensionPoint extension = plugin.getDescriptor().getExtensionPoint(TeamPlugin.TARGETS_EXTENSION);
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+ String extensionId = configElements[j].getAttribute("id"); //$NON-NLS-1$
+ if (extensionId != null && extensionId.equals(id)) {
+ try {
+ return (ITargetFactory) configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
+ } catch (CoreException e) {
+ TeamPlugin.log(e.getStatus());
+ return null;
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+
+}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TargetProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java
index 1a65577ab..f2004b022 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/TargetProvider.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java
@@ -1,9 +1,10 @@
-package org.eclipse.team.core;
+package org.eclipse.team.core.target;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.team.core.TeamException;
public abstract class TargetProvider {

Back to the top