Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2003-10-20 20:39:51 +0000
committerJean Michel-Lemieux2003-10-20 20:39:51 +0000
commit2f90738096233d38ea8dca3584b38e9b6be71b6b (patch)
tree38e4b8c2b0b0874ac6d686f1a9a0c12e455f8b7a /bundles/org.eclipse.team.ui/src
parent2eb555ca444ffd2c0e59c2eeba35c0d4fdb9cdfb (diff)
downloadeclipse.platform.team-2f90738096233d38ea8dca3584b38e9b6be71b6b.tar.gz
eclipse.platform.team-2f90738096233d38ea8dca3584b38e9b6be71b6b.tar.xz
eclipse.platform.team-2f90738096233d38ea8dca3584b38e9b6be71b6b.zip
*** empty log message ***
Diffstat (limited to 'bundles/org.eclipse.team.ui/src')
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/SynchronizeManager.java84
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/AbstractSynchronizeParticipant.java18
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/ISynchronizeParticipant.java28
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamSubscriberParticipant.java8
4 files changed, 92 insertions, 46 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/SynchronizeManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/SynchronizeManager.java
index 1b2350337..a7f0932cb 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/SynchronizeManager.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/pages/SynchronizeManager.java
@@ -12,6 +12,7 @@ package org.eclipse.team.internal.ui.sync.pages;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -23,7 +24,9 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.team.core.ISaveContext;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.core.SaveContext;
import org.eclipse.team.internal.core.SaveContextXMLWriter;
+import org.eclipse.team.internal.core.TeamPlugin;
import org.eclipse.team.internal.ui.IPreferenceIds;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.TeamUIPlugin;
@@ -61,6 +64,8 @@ public class SynchronizeManager implements ISynchronizeManager {
private final static String CTX_PARTICIPANTS = "syncparticipants";
private final static String CTX_PARTICIPANT = "participant";
private final static String CTX_ID = "id";
+ private final static String CTX_INSTANCE_ID = "instance_id";
+ private final static String FILENAME = "syncParticipants.xml";
/**
* Notifies a participant listeners of additions or removals
@@ -114,6 +119,10 @@ public class SynchronizeManager implements ISynchronizeManager {
}
}
+ public SynchronizeManager() {
+ super();
+ }
+
/* (non-Javadoc)
* @see org.eclipse.team.ui.sync.ISynchronizeManager#addSynchronizeParticipantListener(org.eclipse.team.ui.sync.ISynchronizeParticipantListener)
*/
@@ -146,6 +155,7 @@ public class SynchronizeManager implements ISynchronizeManager {
}
}
if (!added.isEmpty()) {
+ saveState();
fireUpdate((ISynchronizeParticipant[])added.toArray(new ISynchronizeParticipant[added.size()]), ADDED);
}
}
@@ -162,6 +172,7 @@ public class SynchronizeManager implements ISynchronizeManager {
}
}
if (!removed.isEmpty()) {
+ saveState();
fireUpdate((ISynchronizeParticipant[])removed.toArray(new ISynchronizeParticipant[removed.size()]), REMOVED);
}
}
@@ -216,50 +227,73 @@ public class SynchronizeManager implements ISynchronizeManager {
public void restoreParticipants() throws PartInitException, TeamException, CoreException {
participantRegistry.readRegistry(Platform.getPluginRegistry(), TeamUIPlugin.ID, ITeamUIConstants.PT_SYNCPARTICIPANTS);
- boolean firstTime = restoreSynchronizeParticipants();
- if(!firstTime) {
- SynchronizePartnerDescriptor[] desc = participantRegistry.getSynchronizeParticipants();
- for (int i = 0; i < desc.length; i++) {
- SynchronizePartnerDescriptor descriptor = desc[i];
- if(descriptor.isStatic()) {
- createParticipant(null, null, descriptor);
- }
+ restoreSynchronizeParticipants();
+ // Create any new participants that had previously not been added (e.g. new plugins being
+ // added.
+ SynchronizePartnerDescriptor[] desc = participantRegistry.getSynchronizeParticipants();
+ List participants = new ArrayList();
+ for (int i = 0; i < desc.length; i++) {
+ SynchronizePartnerDescriptor descriptor = desc[i];
+ if(descriptor.isStatic() && ! synchronizeParticipants.containsKey(descriptor.getId())) {
+ participants.add(createParticipant(descriptor.getId(), null, descriptor));
}
}
+ if(! participants.isEmpty()) {
+ addSynchronizeParticipants((ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()]));
+ }
}
- public void dispose() {
- }
-
- private boolean restoreSynchronizeParticipants() throws TeamException, PartInitException, CoreException {
- ISaveContext root = SaveContextXMLWriter.readXMLPluginMetaFile(TeamUIPlugin.getPlugin(), "subscribers"); //$NON-NLS-1$
+ private void restoreSynchronizeParticipants() throws TeamException, PartInitException, CoreException {
+ ISaveContext root = SaveContextXMLWriter.readXMLPluginMetaFile(TeamUIPlugin.getPlugin(), FILENAME); //$NON-NLS-1$
if(root != null && root.getName().equals(CTX_PARTICIPANTS)) {
+ List participants = new ArrayList();
ISaveContext[] contexts = root.getChildren();
for (int i = 0; i < contexts.length; i++) {
ISaveContext context = contexts[i];
if(context.getName().equals(CTX_PARTICIPANT)) {
String id = context.getAttribute(CTX_ID);
- ISaveContext[] children = context.getChildren();
+ String instance_id = context.getAttribute(CTX_INSTANCE_ID);
SynchronizePartnerDescriptor desc = participantRegistry.find(id);
if(desc != null) {
IConfigurationElement cfgElement = desc.getConfigurationElement();
- createParticipant(id, children, desc);
+ participants.add(createParticipant(id, instance_id, desc));
}
}
}
- return true;
+ if(! participants.isEmpty()) {
+ addSynchronizeParticipants((ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()]));
+ }
}
- return false;
}
-
- private void createParticipant(String id, ISaveContext[] children, SynchronizePartnerDescriptor desc) throws CoreException, PartInitException {
+
+ private ISynchronizeParticipant createParticipant(String id, String instance_id, SynchronizePartnerDescriptor desc) throws CoreException, PartInitException {
ISynchronizeParticipant participant = (ISynchronizeParticipant)TeamUIPlugin.createExtension(desc.getConfigurationElement(), SynchronizePartnerDescriptor.ATT_CLASS);
participant.setInitializationData(desc.getConfigurationElement(), id, null);
- if(children != null) {
- participant.init(children[0]);
- } else {
- participant.init(null);
- }
- addSynchronizeParticipants(new ISynchronizeParticipant[] {participant});
+ participant.init(instance_id);
+ return participant;
+ }
+
+ private void saveState() {
+ ISaveContext root = new SaveContext();
+ root.setName(CTX_PARTICIPANTS);
+ List children = new ArrayList();
+ try {
+ for (Iterator it = synchronizeParticipants.values().iterator(); it.hasNext();) {
+ ISynchronizeParticipant participant = (ISynchronizeParticipant) it.next();
+ String id = participant.getId();
+ ISaveContext item = new SaveContext();
+ item.setName(CTX_PARTICIPANT);
+ Map attributes = new HashMap();
+ attributes.put(CTX_ID, id);
+ attributes.put(CTX_INSTANCE_ID, participant.getInstanceId());
+ item.setAttributes(attributes);
+ children.add(item);
+ participant.saveState();
+ }
+ root.setChildren((SaveContext[])children.toArray(new SaveContext[children.size()]));
+ SaveContextXMLWriter.writeXMLPluginMetaFile(TeamUIPlugin.getPlugin(), FILENAME, (SaveContext)root); //$NON-NLS-1$
+ } catch (TeamException e) {
+ TeamPlugin.log(e);
+ }
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/AbstractSynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/AbstractSynchronizeParticipant.java
index fd66ab1ab..befc0ad49 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/AbstractSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/AbstractSynchronizeParticipant.java
@@ -29,8 +29,9 @@ public abstract class AbstractSynchronizeParticipant implements ISynchronizePart
private String fName;
private String fId;
+ private String fInstanceId;
private ImageDescriptor fImageDescriptor;
- private IConfigurationElement configElement;
+ protected IConfigurationElement configElement;
/**
* Used to notify this console of lifecycle methods <code>init()</code>
@@ -156,6 +157,21 @@ public abstract class AbstractSynchronizeParticipant implements ISynchronizePart
return fId;
}
+ protected void setId(String id) {
+ this.fId = id;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.sync.ISynchronizeParticipant#getId()
+ */
+ public String getInstanceId() {
+ return fInstanceId;
+ }
+
+ protected void setInstanceId(String id) {
+ this.fInstanceId = id;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.console.IConsole#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
*/
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/ISynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/ISynchronizeParticipant.java
index fb04047ec..00977935d 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/ISynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/ISynchronizeParticipant.java
@@ -13,7 +13,6 @@ package org.eclipse.team.ui.sync;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.team.core.ISaveContext;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.IPageBookViewPage;
@@ -26,13 +25,22 @@ import org.eclipse.ui.part.IPageBookViewPage;
*/
public interface ISynchronizeParticipant extends IExecutableExtension {
/**
- * Returns the unique id of this synchronize participant.
+ * Returns the unique id that identified the <i>type<i> of this synchronize participant.
*
- * @return the unique id of this synchronize participant
+ * @return the unique id that identified the <i>type<i> of this synchronize participant.
*/
public String getId();
/**
+ * Returns the dynamic instance id of this synchronize participant. For dynamic
+ * participants (e.g. participants that support multiple instance of the same
+ * type) this id is used to differentiate these dynamic instances.
+ *
+ * @return the dynamic instance id of this synchronize participant
+ */
+ public String getInstanceId();
+
+ /**
* Returns the name of this synchronize participant.
*
* @return the name of this synchronize participant
@@ -58,10 +66,8 @@ public interface ISynchronizeParticipant extends IExecutableExtension {
public IPageBookViewPage createPage(ISynchronizeView view);
/**
- * Initializes this participant with the given synchronize view. A save context is passed to
- * the participant which contains a snapshot of the participants state from a previous
- * session. Where possible, the participant should try to recreate that state
- * within the synchronize view.
+ * Initializes this participant with the given synchronize view. The instance id is
+ * passed to the participant.
* <p>
* This method is automatically called by the team plugin shortly after synchronize
* view construction. It marks the start of the views's lifecycle. Clients must
@@ -72,14 +78,12 @@ public interface ISynchronizeParticipant extends IExecutableExtension {
* @param saveContext the ISynchronizeParticipant state or null if there is no previous saved state
* @exception PartInitException if this participant was not initialized successfully
*/
- public void init(ISaveContext saveContext) throws PartInitException;
+ public void init(String instance_id) throws PartInitException;
/**
- * Saves the participants object state within a save context.
- *
- * @param memento a memento to receive the object state
+ * Saves the participants object state.
*/
- public void saveState(ISaveContext saveContext);
+ public void saveState();
/**
* Adds a listener for changes to properties of this synchronize participant.
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamSubscriberParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamSubscriberParticipant.java
index d3a9296c5..ccd6b0b39 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamSubscriberParticipant.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamSubscriberParticipant.java
@@ -1,7 +1,6 @@
package org.eclipse.team.ui.sync;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.team.core.subscribers.TeamSubscriber;
@@ -69,13 +68,6 @@ public abstract class TeamSubscriberParticipant extends AbstractSynchronizeParti
}
/* (non-Javadoc)
- * @see org.eclipse.team.ui.sync.ISynchronizeParticipant#getUniqueId()
- */
- public QualifiedName getUniqueId() {
- return input.getSubscriber().getId();
- }
-
- /* (non-Javadoc)
* @see org.eclipse.team.ui.sync.ISynchronizeViewPage#createPage(org.eclipse.team.ui.sync.ISynchronizeView)
*/
public IPageBookViewPage createPage(ISynchronizeView view) {

Back to the top