Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2003-11-13 17:10:25 -0500
committerJean Michel-Lemieux2003-11-13 17:10:25 -0500
commite13745ea6d654a16bf3915e59939fb04f997ccf9 (patch)
treef839ceadf08b27a257289fed56437799dd2e7b4b
parent24a854025428809f54541e75aa513653f13dec6f (diff)
downloadeclipse.platform.team-branch_20031113_jm_m5fixes.tar.gz
eclipse.platform.team-branch_20031113_jm_m5fixes.tar.xz
eclipse.platform.team-branch_20031113_jm_m5fixes.zip
*** empty log message ***branch_20031113_jm_m5fixes
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/BackgroundEventHandler.java68
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java27
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java15
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java7
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java14
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java26
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties1
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java390
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TeamSynchronizingPerspective.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/sets/SubscriberEventHandler.java25
15 files changed, 294 insertions, 303 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/BackgroundEventHandler.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/BackgroundEventHandler.java
index d6b645b1d..0eb3cd889 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/BackgroundEventHandler.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/BackgroundEventHandler.java
@@ -14,15 +14,10 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.team.internal.core.ExceptionCollector;
-import org.eclipse.team.internal.core.Policy;
-import org.eclipse.team.internal.core.TeamPlugin;
+import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.jobs.*;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.core.*;
/**
* Thsi class provides the infrastucture for processing events in the background
@@ -41,6 +36,11 @@ public abstract class BackgroundEventHandler {
// Accumulate exceptions that occur
private ExceptionCollector errors;
+ // time the last dispath took
+ private long processingEventsDuration = 0L;
+
+ private long DISPATCH_DELAY = 1500;
+
/**
* Resource event class. The type is specific to subclasses.
*/
@@ -112,10 +112,10 @@ public abstract class BackgroundEventHandler {
return processEvents(monitor);
}
public boolean shouldRun() {
- return hasUnprocessedEvents();
+ return ! isQueueEmpty();
}
public boolean shouldSchedule() {
- return hasUnprocessedEvents();
+ return ! isQueueEmpty();
}
};
eventHandlerJob.addJobChangeListener(new JobChangeAdapter() {
@@ -137,7 +137,7 @@ public abstract class BackgroundEventHandler {
synchronized(this) {
awaitingProcessing.clear();
}
- } else if (hasUnprocessedEvents()) {
+ } else if (! isQueueEmpty()) {
// An event squeaked in as the job was finishing. Reschedule the job.
schedule();
}
@@ -186,10 +186,12 @@ public abstract class BackgroundEventHandler {
System.out.println("Event queued on " + getName() + ":" + event.toString()); //$NON-NLS-1$ //$NON-NLS-2$
}
awaitingProcessing.add(event);
- if (!isShutdown()
- && eventHandlerJob != null
- && eventHandlerJob.getState() == Job.NONE) {
- schedule();
+ if (!isShutdown() && eventHandlerJob != null) {
+ if(eventHandlerJob.getState() == Job.NONE) {
+ schedule();
+ } else {
+ notify();
+ }
}
}
@@ -198,7 +200,7 @@ public abstract class BackgroundEventHandler {
* @return Event to be processed
*/
private synchronized Event nextElement() {
- if (isShutdown() || !hasUnprocessedEvents()) {
+ if (isShutdown() || isQueueEmpty()) {
return null;
}
return (Event) awaitingProcessing.remove(0);
@@ -208,8 +210,8 @@ public abstract class BackgroundEventHandler {
* Return whether there are unprocessed events on the event queue.
* @return whether there are unprocessed events on the queue
*/
- protected synchronized boolean hasUnprocessedEvents() {
- return !awaitingProcessing.isEmpty();
+ protected synchronized boolean isQueueEmpty() {
+ return awaitingProcessing.isEmpty();
}
/**
@@ -229,12 +231,17 @@ public abstract class BackgroundEventHandler {
subMonitor.beginTask(null, 1024);
Event event;
+ processingEventsDuration = System.currentTimeMillis();
while ((event = nextElement()) != null && ! isShutdown()) {
try {
processEvent(event, subMonitor);
if (Policy.DEBUG_BACKGROUND_EVENTS) {
System.out.println("Event processed on " + getName() + ":" + event.toString()); //$NON-NLS-1$ //$NON-NLS-2$
}
+ if(isReadyForDispath()) {
+ dispatchEvents();
+ processingEventsDuration = System.currentTimeMillis();
+ }
} catch (CoreException e) {
// handle exception but keep going
handleException(e);
@@ -247,6 +254,29 @@ public abstract class BackgroundEventHandler {
}
/**
+ * Notify clients of processed events.
+ */
+ protected abstract void dispatchEvents() throws TeamException;
+
+ private boolean isReadyForDispath() {
+ long duration = System.currentTimeMillis() - processingEventsDuration;
+ if(duration >= DISPATCH_DELAY) {
+ return true;
+ }
+ synchronized(this) {
+ if(! isQueueEmpty()) {
+ return false;
+ }
+ try {
+ wait(this.DISPATCH_DELAY);
+ } catch (InterruptedException e) {
+ // just continue
+ }
+ }
+ return isQueueEmpty();
+ }
+
+ /**
* Handle the exception by recording it in the errors list.
* @param e
*/
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java
index 96b24060c..4f921b0c2 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/DeferredResourceChangeHandler.java
@@ -10,18 +10,14 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.core.syncinfo;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
+import java.util.*;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.BackgroundEventHandler;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
import org.eclipse.team.internal.ccvs.core.Policy;
+import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
/**
* This class handles resources changes that are reported in deltas
@@ -33,8 +29,6 @@ public class DeferredResourceChangeHandler extends BackgroundEventHandler {
private Set changedIgnoreFiles = new HashSet();
- private int NOTIFICATION_BATCHING_NUMBER = 10;
-
/* (non-Javadoc)
* @see org.eclipse.team.core.subscribers.BackgroundEventHandler#getName()
*/
@@ -57,13 +51,7 @@ public class DeferredResourceChangeHandler extends BackgroundEventHandler {
switch (type) {
case IGNORE_FILE_CHANGED :
changedIgnoreFiles.add(event.getResource());
- }
-
- if (!hasUnprocessedEvents()
- || changedIgnoreFiles.size() > NOTIFICATION_BATCHING_NUMBER) {
- EclipseSynchronizer.getInstance().ignoreFilesChanged(getParents(changedIgnoreFiles));
- changedIgnoreFiles.clear();
- }
+ }
}
private IContainer[] getParents(Set files) {
@@ -79,4 +67,11 @@ public class DeferredResourceChangeHandler extends BackgroundEventHandler {
queueEvent(new Event(file, IGNORE_FILE_CHANGED, IResource.DEPTH_ZERO));
}
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.BackgroundEventHandler#dispatchEvents()
+ */
+ protected void dispatchEvents() throws TeamException {
+ EclipseSynchronizer.getInstance().ignoreFilesChanged(getParents(changedIgnoreFiles));
+ changedIgnoreFiles.clear();
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
index 0ce5eba22..362e32bb8 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
@@ -569,12 +569,6 @@ public class CVSUIPlugin extends AbstractUIPlugin {
// Get the plugin preferences for CVS Core
Preferences corePrefs = CVSProviderPlugin.getPlugin().getPluginPreferences();
- // work in progress START
- store.setDefault(ICVSUIConstants.BACKGROUND_REPOVIEW, true);
- store.setDefault(ICVSUIConstants.BACKGROUND_OPERATIONS, true);
- store.setDefault(ICVSUIConstants.USE_NEW_SYNCVIEW, true);
- // work in progress END
-
store.setDefault(ICVSUIConstants.PREF_REPOSITORIES_ARE_BINARY, false);
store.setDefault(ICVSUIConstants.PREF_SHOW_COMMENTS, true);
store.setDefault(ICVSUIConstants.PREF_SHOW_TAGS, true);
@@ -692,6 +686,15 @@ public class CVSUIPlugin extends AbstractUIPlugin {
}
/**
+ * Returns the system speed setting. This is mainly used to determine to enable/disable
+ * certain CVS features.
+ * @since 3.0
+ */
+ public static int getPlatformPerformance() {
+ return Platform.getPlugin(Platform.PI_RUNTIME).getPluginPreferences().getInt(Platform.PREF_PLATFORM_PERFORMANCE);
+ }
+
+ /**
* This is a convenience method to show the CVS workspace subscriber in the sync view.
* The working set of the workspace participant will be set to the provided working set
* and the provided resources will be refreshed.
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java
index f6c4d5a58..2bf8d1148 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java
@@ -135,11 +135,6 @@ public interface ICVSUIConstants {
// preference options
public final int OPTION_NEVER = 1; //$NON-NLS-1$
public final int OPTION_PROMPT = 2; //$NON-NLS-1$
- public final int OPTION_AUTOMATIC = 3;
-
- // work in progress preferences
- public final String BACKGROUND_REPOVIEW = PREFIX + "background_repoview"; //$NON-NLS-1$
- public final String BACKGROUND_OPERATIONS = PREFIX + "background_operations"; //$NON-NLS-1$
- public final String USE_NEW_SYNCVIEW = PREFIX + "old_sync_view"; //$NON-NLS-1$
+ public final int OPTION_AUTOMATIC = 3;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java
index edec1e568..5a89e817e 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkInProgressPreferencePage.java
@@ -39,9 +39,6 @@ public class WorkInProgressPreferencePage extends FieldEditorPreferencePage impl
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
public void createFieldEditors() {
- addField(new BooleanFieldEditor(ICVSUIConstants.BACKGROUND_REPOVIEW, Policy.bind("WorkInProgressPreferencePage.2"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
- addField(new BooleanFieldEditor(ICVSUIConstants.BACKGROUND_OPERATIONS, Policy.bind("WorkInProgressPreferencePage.3"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
- addField(new BooleanFieldEditor(ICVSUIConstants.USE_NEW_SYNCVIEW, Policy.bind("WorkInProgressPreferencePage.4"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
index e06029d6f..7af6fff06 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
@@ -28,15 +28,11 @@ import org.eclipse.ui.IWorkingSet;
public class SyncAction extends WorkspaceAction {
public void execute(IAction action) throws InvocationTargetException {
- if(CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.USE_NEW_SYNCVIEW)) {
- IResource[] resources = getResourcesToSync();
- if (resources == null || resources.length == 0) return;
-
- IWorkingSet workingSet = CVSUIPlugin.getWorkingSet(resources, Policy.bind("SyncAction.workingSetName")); //$NON-NLS-1$
- CVSUIPlugin.showInSyncView(getShell(), resources, workingSet, 0 /* no mode in particular */);
- } else {
- executeInOldSyncView(action);
- }
+ IResource[] resources = getResourcesToSync();
+ if (resources == null || resources.length == 0) return;
+
+ IWorkingSet workingSet = CVSUIPlugin.getWorkingSet(resources, Policy.bind("SyncAction.workingSetName")); //$NON-NLS-1$
+ CVSUIPlugin.showInSyncView(getShell(), resources, workingSet, 0 /* no mode in particular */);
}
public void executeInOldSyncView(IAction action) throws InvocationTargetException {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java
index d7cb29008..f98e4041b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.model;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
@@ -40,7 +41,7 @@ public class RemoteContentProvider extends WorkbenchContentProvider {
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (viewer instanceof AbstractTreeViewer) {
- if(CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.BACKGROUND_REPOVIEW)) {
+ if(CVSUIPlugin.getPlatformPerformance() != Platform.MIN_PERFORMANCE) {
manager = new DeferredTreeContentManager(this, (AbstractTreeViewer) viewer);
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java
index f42857510..41811f470 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java
@@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
@@ -81,7 +82,7 @@ public abstract class CVSOperation implements IRunnableWithProgress {
}
protected boolean areJobsEnabled() {
- return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.BACKGROUND_OPERATIONS);
+ return CVSUIPlugin.getPlatformPerformance() != Platform.MIN_PERFORMANCE;
}
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java
index 25335fb15..06ee22802 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSSubscriberAction.java
@@ -11,16 +11,10 @@
package org.eclipse.team.internal.ccvs.ui.subscriber;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.MultiRule;
import org.eclipse.jface.action.IAction;
@@ -28,20 +22,13 @@ import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.SyncInfo;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSSyncInfo;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
+import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.client.PruneFolderVisitor;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.operations.CVSBlockingRunnableContext;
-import org.eclipse.team.internal.ccvs.ui.operations.CVSSubscriberNonblockingContext;
-import org.eclipse.team.internal.ccvs.ui.operations.ICVSRunnableContext;
+import org.eclipse.team.internal.ccvs.ui.operations.*;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.ui.synchronize.actions.SubscriberAction;
import org.eclipse.team.ui.synchronize.actions.SyncInfoSet;
@@ -181,7 +168,8 @@ public abstract class CVSSubscriberAction extends SubscriberAction {
}
protected boolean areJobsEnabled() {
- return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.BACKGROUND_OPERATIONS);
+ int speed = CVSUIPlugin.getPlatformPerformance();
+ return speed != Platform.MIN_PERFORMANCE;
}
/**
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java
index a1f58e583..26270e433 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java
@@ -206,13 +206,12 @@ public class TeamUIPlugin extends AbstractUIPlugin implements IPropertyChangeLis
getPreferenceStore().addPropertyChangeListener(this);
// startup auto-refresh job if necessary
- refreshJob = new RefreshSubscriberInputJob(Policy.bind("ScheduledSyncViewRefresh.taskName")); //$NON-NLS-1$
+ refreshJob = new RefreshSubscriberInputJob(Policy.bind("ScheduledSyncViewRefresh.taskName")); //$NON-NLS-1$
refreshJob.setRefreshInterval(getPreferenceStore().getInt(IPreferenceIds.SYNCVIEW_DELAY) * 60);
if(getPreferenceStore().getBoolean(IPreferenceIds.SYNCVIEW_SCHEDULED_SYNC)) {
refreshJob.setRestartOnCancel(true);
refreshJob.setReschedule(true);
- // start once the platform has started and stabilized
- refreshJob.schedule(20000 /* 20 seconds */);
+ refreshJob.schedule(refreshJob.getScheduleDelay());
}
((SynchronizeManager)TeamUI.getSynchronizeManager()).initialize();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java
index 509a29e83..aff6f88c9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/jobs/RefreshSubscriberJob.java
@@ -53,7 +53,7 @@ public class RefreshSubscriberJob extends WorkspaceJob {
/**
* The schedule delay used when rescheduling a completed job
*/
- /* internal use only */ static long scheduleDelay = 20000; //5 /* minutes */ * (60 * 1000);
+ /* internal use only */ static long scheduleDelay = 20000;
/**
* Time the job was run last in milliseconds.
@@ -148,7 +148,7 @@ public class RefreshSubscriberJob extends WorkspaceJob {
return subscriber;
}
- protected long getScheduleDelay() {
+ public long getScheduleDelay() {
return scheduleDelay;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
index e653e889f..f0e4f5947 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
@@ -466,3 +466,4 @@ TeamSubscriberParticipantPage.8=In Folder
TeamSubscriberSyncPage.labelWithSyncKind={0} {1}
AbstractSynchronizeParticipant.4=Cannot initialize participant. Wrong descriptor type
+SynchronizeManager.11=Error creating participant instance
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java
index cd956ffd5..971427f71 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java
@@ -10,57 +10,23 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.synchronize;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.io.*;
+import java.util.*;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.ISaveContext;
-import org.eclipse.core.resources.ISaveParticipant;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.*;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ui.IPreferenceIds;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.internal.ui.*;
import org.eclipse.team.internal.ui.registry.SynchronizeParticipantDescriptor;
import org.eclipse.team.internal.ui.registry.SynchronizeParticipantRegistry;
import org.eclipse.team.ui.ITeamUIConstants;
-import org.eclipse.team.ui.synchronize.ISynchronizeManager;
-import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
-import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor;
-import org.eclipse.team.ui.synchronize.ISynchronizeParticipantListener;
-import org.eclipse.team.ui.synchronize.ISynchronizeView;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.XMLMemento;
+import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.ui.*;
/**
- * Manages the registered synchronize participants. It handles notification
- * of participant lifecycles, creation of <code>static</code> participants,
- * and the re-creation of persisted participants.
+ * Manages the registered synchronize participants. It handles notification of
+ * participant lifecycles, creation of <code>static</code> participants, and
+ * the re-creation of persisted participants.
*
* @see ISynchronizeView
* @see ISynchronizeParticipant
@@ -71,58 +37,51 @@ public class SynchronizeManager implements ISynchronizeManager {
* Synchronize participants listeners
*/
private ListenerList fListeners = null;
-
+
/**
- * List of registered synchronize view pages
- * {String id -> List participant instances}}
+ * List of registered synchronize view pages {String id -> List participant
+ * instances}}
*/
- private Map synchronizeParticipants = new HashMap(10);
+ private Map synchronizeParticipants = new HashMap(10);
private SynchronizeParticipantRegistry participantRegistry = new SynchronizeParticipantRegistry();
-
+
// change notification constants
private final static int ADDED = 1;
private final static int REMOVED = 2;
-
+
// save context constants
private final static String CTX_PARTICIPANTS = "syncparticipants"; //$NON-NLS-1$
private final static String CTX_PARTICIPANT = "participant"; //$NON-NLS-1$
private final static String CTX_ID = "id"; //$NON-NLS-1$
private final static String CTX_PARTICIPANT_DATA = "data"; //$NON-NLS-1$
private final static String FILENAME = "syncParticipants.xml"; //$NON-NLS-1$
-
+
/**
* Notifies a participant listeners of additions or removals
*/
class SynchronizeViewPageNotifier implements ISafeRunnable {
-
+
private ISynchronizeParticipantListener fListener;
private int fType;
private ISynchronizeParticipant[] fChanged;
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable)
- */
+
public void handleException(Throwable exception) {
TeamUIPlugin.log(IStatus.ERROR, Policy.bind("SynchronizeManager.7"), exception); //$NON-NLS-1$
}
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.ISafeRunnable#run()
- */
+
public void run() throws Exception {
switch (fType) {
- case ADDED:
+ case ADDED :
fListener.participantsAdded(fChanged);
break;
- case REMOVED:
+ case REMOVED :
fListener.participantsRemoved(fChanged);
break;
}
}
-
+
/**
* Notifies the given listener of the adds/removes
- *
* @param participants the participants that changed
* @param update the type of change
*/
@@ -132,42 +91,70 @@ public class SynchronizeManager implements ISynchronizeManager {
}
fChanged = participants;
fType = update;
- Object[] copiedListeners= fListeners.getListeners();
- for (int i= 0; i < copiedListeners.length; i++) {
- fListener = (ISynchronizeParticipantListener)copiedListeners[i];
+ Object[] copiedListeners = fListeners.getListeners();
+ for (int i = 0; i < copiedListeners.length; i++) {
+ fListener = (ISynchronizeParticipantListener) copiedListeners[i];
Platform.run(this);
- }
+ }
fChanged = null;
- fListener = null;
+ fListener = null;
}
- }
-
- class SaveParticipant implements ISaveParticipant {
+ }
- public void doneSaving(ISaveContext context) {
+ /**
+ * Represents a paticipant instance and allows lazy initialization of the instance
+ * only when the participant is required.
+ */
+ static class ParticipantInstance {
+ private ISynchronizeParticipant participant;
+ private IMemento savedState;
+ private SynchronizeParticipantDescriptor descriptor;
+
+ public ParticipantInstance(SynchronizeParticipantDescriptor descriptor, IMemento savedState) {
+ this.savedState = savedState;
+ this.descriptor = descriptor;
}
-
- public void prepareToSave(ISaveContext context) throws CoreException {
+
+ public void setParticipant(ISynchronizeParticipant participant) {
+ this.participant = participant;
}
-
- public void rollback(ISaveContext context) {
+
+ public ISynchronizeParticipant getParticipant() {
+ if (participant == null) {
+ try {
+ participant = (ISynchronizeParticipant) TeamUIPlugin.createExtension(descriptor.getConfigurationElement(), SynchronizeParticipantDescriptor.ATT_CLASS);
+ participant.setInitializationData(descriptor.getConfigurationElement(), null, null);
+ participant.restoreState(savedState);
+ } catch (PartInitException e2) {
+ TeamUIPlugin.log(IStatus.ERROR, Policy.bind("SynchronizeManager.11"), e2); //$NON-NLS-1$
+ } catch (CoreException e) {
+ TeamUIPlugin.log(IStatus.ERROR, Policy.bind("SynchronizeManager.11"), e); //$NON-NLS-1$
+ }
+ }
+ return participant;
}
-
- public void saving(ISaveContext context) throws CoreException {
- saveState();
- }
- }
-
- public SynchronizeManager() {
- super();
- try {
- ResourcesPlugin.getWorkspace().addSaveParticipant(TeamUIPlugin.getPlugin(), new SaveParticipant());
- } catch (CoreException e) {
- TeamUIPlugin.log(e);
+
+ public boolean equals(Object other) {
+ if(other == this) return true;
+ if (other instanceof ISynchronizeParticipant) {
+ return other == this.getParticipant();
+ } else if(other instanceof ParticipantInstance) {
+ return ((ParticipantInstance)other).getParticipant() == this.getParticipant();
+ }
+ return false;
+ }
+
+ public String getId() {
+ return descriptor.getId();
}
}
-
- /* (non-Javadoc)
+
+ public SynchronizeManager() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.team.ui.sync.ISynchronizeManager#addSynchronizeParticipantListener(org.eclipse.team.ui.sync.ISynchronizeParticipantListener)
*/
public void addSynchronizeParticipantListener(ISynchronizeParticipantListener listener) {
@@ -176,8 +163,10 @@ public class SynchronizeManager implements ISynchronizeManager {
}
fListeners.add(listener);
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.team.ui.sync.ISynchronizeManager#removeSynchronizeParticipantListener(org.eclipse.team.ui.sync.ISynchronizeParticipantListener)
*/
public void removeSynchronizeParticipantListener(ISynchronizeParticipantListener listener) {
@@ -185,36 +174,38 @@ public class SynchronizeManager implements ISynchronizeManager {
fListeners.remove(listener);
}
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.team.ui.synchronize.ISynchronizeManager#getParticipantDescriptor(java.lang.String)
+ */
+ public ISynchronizeParticipantDescriptor getParticipantDescriptor(String id) {
+ return participantRegistry.find(id);
+ }
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.team.ui.sync.ISynchronizeManager#addSynchronizeParticipants(org.eclipse.team.ui.sync.ISynchronizeParticipant[])
*/
public synchronized void addSynchronizeParticipants(ISynchronizeParticipant[] participants) {
List added = new ArrayList(participants.length);
for (int i = 0; i < participants.length; i++) {
ISynchronizeParticipant participant = participants[i];
- addParticipant(participant);
+ ParticipantInstance instance = new ParticipantInstance(participantRegistry.find(participant.getId()), null /* no saved state */);
+ instance.setParticipant(participant);
added.add(participant);
- }
+ }
if (!added.isEmpty()) {
saveState();
- fireUpdate((ISynchronizeParticipant[])added.toArray(new ISynchronizeParticipant[added.size()]), ADDED);
- }
- }
-
- private synchronized void addParticipant(ISynchronizeParticipant participant) {
- String id = participant.getId();
- List instances = (List)synchronizeParticipants.get(id);
- if(instances == null) {
- instances = new ArrayList(2);
- synchronizeParticipants.put(id, instances);
- }
- if(! instances.contains(participant)) {
- instances.add(participant);
+ fireUpdate((ISynchronizeParticipant[]) added.toArray(new ISynchronizeParticipant[added.size()]), ADDED);
}
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.team.ui.sync.ISynchronizeManager#removeSynchronizeParticipants(org.eclipse.team.ui.sync.ISynchronizeParticipant[])
*/
public synchronized void removeSynchronizeParticipants(ISynchronizeParticipant[] participants) {
@@ -227,66 +218,52 @@ public class SynchronizeManager implements ISynchronizeManager {
}
if (!removed.isEmpty()) {
saveState();
- fireUpdate((ISynchronizeParticipant[])removed.toArray(new ISynchronizeParticipant[removed.size()]), REMOVED);
+ fireUpdate((ISynchronizeParticipant[]) removed.toArray(new ISynchronizeParticipant[removed.size()]), REMOVED);
}
}
-
- private synchronized boolean removeParticipant(ISynchronizeParticipant participant) {
- boolean removed = false;
- String id = participant.getId();
- List instances = (List)synchronizeParticipants.get(id);
- if(instances != null) {
- removed = instances.remove(participant);
- if(instances.isEmpty()) {
- synchronizeParticipants.remove(id);
- }
- }
- return removed;
- }
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.team.ui.sync.ISynchronizeManager#getSynchronizeParticipants()
*/
public synchronized ISynchronizeParticipant[] getSynchronizeParticipants() {
List participants = new ArrayList();
- for (Iterator it = synchronizeParticipants.values().iterator(); it.hasNext();) {
- List instances = (List) it.next();
- participants.addAll(instances);
+ for (Iterator it = synchronizeParticipants.keySet().iterator(); it.hasNext(); ) {
+ String id = (String) it.next();
+ ISynchronizeParticipant[] instances = find(id);
+ participants.addAll(Arrays.asList(instances));
}
return (ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()]);
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.team.ui.sync.ISynchronizeManager#find(java.lang.String)
*/
public ISynchronizeParticipant[] find(String id) {
- List participants = (List)synchronizeParticipants.get(id);
- if(participants == null) {
- return null;
+ List instances = (List) synchronizeParticipants.get(id);
+ if (instances == null) {
+ return new ISynchronizeParticipant[0];
+ }
+ List participants = new ArrayList(instances.size());
+ for (Iterator it = instances.iterator(); it.hasNext(); ) {
+ ParticipantInstance instance = (ParticipantInstance) it.next();
+ participants.add(instance.getParticipant());
}
return (ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()]);
}
-
- /**
- * Fires notification.
- *
- * @param participants participants added/removed
- * @param type ADD or REMOVE
- */
- private void fireUpdate(ISynchronizeParticipant[] participants, int type) {
- new SynchronizeViewPageNotifier().notify(participants, type);
- }
-
+
/**
* Called to display the synchronize view in the given page. If the given
* page is <code>null</code> the synchronize view is shown in the default
* active workbench window.
*/
public ISynchronizeView showSynchronizeViewInActivePage(IWorkbenchPage activePage) {
- IWorkbench workbench= TeamUIPlugin.getPlugin().getWorkbench();
- IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
-
- if(! TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE).equals(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE_NONE)) {
+ IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench();
+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+
+ if (!TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE).equals(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE_NONE)) {
try {
String pId = TeamUIPlugin.getPlugin().getPreferenceStore().getString(IPreferenceIds.SYNCVIEW_DEFAULT_PERSPECTIVE);
activePage = workbench.showPerspective(pId, window);
@@ -297,53 +274,54 @@ public class SynchronizeManager implements ISynchronizeManager {
try {
if (activePage == null) {
activePage = TeamUIPlugin.getActivePage();
- if (activePage == null) return null;
+ if (activePage == null)
+ return null;
}
- return (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID);
+ return (ISynchronizeView) activePage.showView(ISynchronizeView.VIEW_ID);
} catch (PartInitException pe) {
Utils.handleError(window.getShell(), pe, Policy.bind("SynchronizeView.16"), pe.getMessage()); //$NON-NLS-1$
return null;
}
}
-
+
/**
- * Creates the participant registry and restore any saved participants. Will also instantiate
- * any static participants.
+ * Creates the participant registry and restore any saved participants.
+ * Will also instantiate any static participants.
*/
public void initialize() {
try {
- // Initialize the participant registry - reads all participant extension descriptions.
+ // Initialize the participant registry - reads all participant
+ // extension descriptions.
participantRegistry.readRegistry(Platform.getPluginRegistry(), TeamUIPlugin.ID, ITeamUIConstants.PT_SYNCPARTICIPANTS);
-
- // Instantiate and register any dynamic participants saved from a previous session.
+
+ // Instantiate and register any dynamic participants saved from a
+ // previous session.
restoreSavedParticipants();
-
- // Instantiate and register any static participant that has not already been created.
+
+ // Instantiate and register any static participant that has not
+ // already been created.
initializeStaticParticipants();
- } catch (CoreException e) {
+ } catch (CoreException e) {
TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("SynchronizeManager.8"), e)); //$NON-NLS-1$
}
}
-
+
private void initializeStaticParticipants() throws CoreException {
SynchronizeParticipantDescriptor[] desc = participantRegistry.getSynchronizeParticipants();
List participants = new ArrayList();
for (int i = 0; i < desc.length; i++) {
SynchronizeParticipantDescriptor descriptor = desc[i];
- if(descriptor.isStatic() && ! synchronizeParticipants.containsKey(descriptor.getId())) {
- participants.add(createParticipant(null, descriptor));
+ if (descriptor.isStatic() && !synchronizeParticipants.containsKey(descriptor.getId())) {
+ addParticipant(new ParticipantInstance(descriptor, null /* no saved state */));
}
- }
- if(! participants.isEmpty()) {
- addSynchronizeParticipants((ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()]));
}
}
-
+
/**
- * Restores participants that have been saved between sessions.
+ * Restores participants that have been saved between sessions.
*/
private void restoreSavedParticipants() throws TeamException, CoreException {
- File file = getStateFile();
+ File file = getStateFile();
Reader reader;
try {
reader = new BufferedReader(new FileReader(file));
@@ -354,43 +332,32 @@ public class SynchronizeManager implements ISynchronizeManager {
IMemento memento = XMLMemento.createReadRoot(reader);
IMemento[] participantNodes = memento.getChildren(CTX_PARTICIPANT);
for (int i = 0; i < participantNodes.length; i++) {
- IMemento memento2 = participantNodes[i];
+ IMemento memento2 = participantNodes[i];
String id = memento2.getString(CTX_ID);
- SynchronizeParticipantDescriptor desc = participantRegistry.find(id);
- if(desc != null) {
+ SynchronizeParticipantDescriptor desc = participantRegistry.find(id);
+ if (desc != null) {
IConfigurationElement cfgElement = desc.getConfigurationElement();
- participants.add(createParticipant(memento2.getChild(CTX_PARTICIPANT_DATA), desc));
+ addParticipant(new ParticipantInstance(desc, memento2.getChild(CTX_PARTICIPANT_DATA)));
} else {
TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("SynchronizeManager.9", id), null)); //$NON-NLS-1$
}
}
- if(! participants.isEmpty()) {
- addSynchronizeParticipants((ISynchronizeParticipant[]) participants.toArray(new ISynchronizeParticipant[participants.size()]));
- }
}
-
- /**
- * Creates a participant instance with the given id from the participant description
- */
- private ISynchronizeParticipant createParticipant(IMemento memento, SynchronizeParticipantDescriptor desc) throws CoreException {
- ISynchronizeParticipant participant = (ISynchronizeParticipant)TeamUIPlugin.createExtension(desc.getConfigurationElement(), SynchronizeParticipantDescriptor.ATT_CLASS);
- participant.setInitializationData(desc.getConfigurationElement(), null, null);
- participant.restoreState(memento);
- return participant;
- }
-
+
/**
- * Saves a file containing the list of participant ids that are registered with this
- * manager. Each participant is also given the chance to save it's state.
+ * Saves a file containing the list of participant ids that are registered
+ * with this manager. Each participant is also given the chance to save
+ * it's state.
*/
private void saveState() {
- XMLMemento xmlMemento = XMLMemento.createWriteRoot(CTX_PARTICIPANTS);
+ XMLMemento xmlMemento = XMLMemento.createWriteRoot(CTX_PARTICIPANTS);
List children = new ArrayList();
- for (Iterator it = synchronizeParticipants.keySet().iterator(); it.hasNext();) {
+ for (Iterator it = synchronizeParticipants.keySet().iterator(); it.hasNext(); ) {
String id = (String) it.next();
- List participants = (List)synchronizeParticipants.get(id);
+ List participants = (List) synchronizeParticipants.get(id);
for (Iterator it2 = participants.iterator(); it2.hasNext(); ) {
- ISynchronizeParticipant participant = (ISynchronizeParticipant) it2.next();
+ ParticipantInstance instance = (ParticipantInstance) it2.next();
+ ISynchronizeParticipant participant = instance.getParticipant();
IMemento participantNode = xmlMemento.createChild(CTX_PARTICIPANT);
participantNode.putString(CTX_ID, participant.getId());
participant.saveState(participantNode.createChild(CTX_PARTICIPANT_DATA));
@@ -405,18 +372,43 @@ public class SynchronizeManager implements ISynchronizeManager {
}
} catch (IOException e) {
TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("SynchronizeManager.10"), e)); //$NON-NLS-1$
- }
+ }
}
-
+
private File getStateFile() {
IPath pluginStateLocation = TeamUIPlugin.getPlugin().getStateLocation();
return pluginStateLocation.append(FILENAME).toFile(); //$NON-NLS-1$
}
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.ISynchronizeManager#getParticipantDescriptor(java.lang.String)
+ private synchronized void addParticipant(ParticipantInstance instance) {
+ String id = instance.getId();
+ List instances = (List) synchronizeParticipants.get(id);
+ if (instances == null) {
+ instances = new ArrayList(2);
+ synchronizeParticipants.put(id, instances);
+ }
+ instances.add(instance);
+ }
+
+ private synchronized boolean removeParticipant(ISynchronizeParticipant participant) {
+ boolean removed = false;
+ String id = participant.getId();
+ List instances = (List) synchronizeParticipants.get(id);
+ if (instances != null) {
+ removed = instances.remove(participant);
+ if (instances.isEmpty()) {
+ synchronizeParticipants.remove(id);
+ }
+ }
+ return removed;
+ }
+
+ /**
+ * Fires notification.
+ * @param participants participants added/removed
+ * @param type ADD or REMOVE
*/
- public ISynchronizeParticipantDescriptor getParticipantDescriptor(String id) {
- return participantRegistry.find(id);
+ private void fireUpdate(ISynchronizeParticipant[] participants, int type) {
+ new SynchronizeViewPageNotifier().notify(participants, type);
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TeamSynchronizingPerspective.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TeamSynchronizingPerspective.java
index 37516716c..b28617e0d 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TeamSynchronizingPerspective.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TeamSynchronizingPerspective.java
@@ -37,11 +37,11 @@ public class TeamSynchronizingPerspective implements IPerspectiveFactory {
layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file"); //$NON-NLS-1$
// Add "show views".
+ layout.addShowViewShortcut(SynchronizeView.VIEW_ID);
layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
- layout.addShowViewShortcut(SynchronizeView.VIEW_ID);
layout.addActionSet("org.eclipse.team.ui.actionSet"); //$NON-NLS-1$
}
@@ -53,8 +53,6 @@ public class TeamSynchronizingPerspective implements IPerspectiveFactory {
String editorArea = layout.getEditorArea();
IFolderLayout top = layout.createFolder("top", IPageLayout.LEFT, 0.25f, editorArea); //$NON-NLS-1$
top.addView(SynchronizeView.VIEW_ID);
- top.addView(IPageLayout.ID_RES_NAV);
- top.addView(IPageLayout.ID_OUTLINE);
layout.setEditorAreaVisible(true);
}
-}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/sets/SubscriberEventHandler.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/sets/SubscriberEventHandler.java
index ca164eb46..f57aaff96 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/sets/SubscriberEventHandler.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/sets/SubscriberEventHandler.java
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.synchronize.sets;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -34,9 +32,6 @@ import org.eclipse.team.ui.synchronize.actions.SubscriberAction;
* one.
*/
public class SubscriberEventHandler extends BackgroundEventHandler {
- // The number of events to process before feeding into the set.
- private static final int NOTIFICATION_BATCHING_NUMBER = 10;
-
// The set that receives notification when the resource synchronization state
// has been calculated by the job.
private SyncSetInputFromSubscriber set;
@@ -300,13 +295,13 @@ public class SubscriberEventHandler extends BackgroundEventHandler {
resultCache.addAll(Arrays.asList(events));
break;
}
-
- if (!hasUnprocessedEvents()
- || resultCache.size() > NOTIFICATION_BATCHING_NUMBER) {
- dispatchEvents(
- (SubscriberEvent[]) resultCache.toArray(
- new SubscriberEvent[resultCache.size()]));
- resultCache.clear();
- }
}
-}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.BackgroundEventHandler#dispatchEvents()
+ */
+ protected void dispatchEvents() {
+ dispatchEvents((SubscriberEvent[]) resultCache.toArray(new SubscriberEvent[resultCache.size()]));
+ resultCache.clear();
+ }
+} \ No newline at end of file

Back to the top