Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-02-25 20:45:35 +0000
committerJean Michel-Lemieux2004-02-25 20:45:35 +0000
commit611f26b53dc8c8e03019aa05a42e7ed40ad2fa51 (patch)
treeda1a682b00dda95024364683fd6e75f19c4505fe /bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSyncSet.java
parent4a1ca77df6f4238416a8715a8c35819611d5992a (diff)
downloadeclipse.platform.team-611f26b53dc8c8e03019aa05a42e7ed40ad2fa51.tar.gz
eclipse.platform.team-611f26b53dc8c8e03019aa05a42e7ed40ad2fa51.tar.xz
eclipse.platform.team-611f26b53dc8c8e03019aa05a42e7ed40ad2fa51.zip
SyncView API released to HEAD.
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSyncSet.java')
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSyncSet.java117
1 files changed, 117 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSyncSet.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSyncSet.java
new file mode 100644
index 000000000..3d84b4532
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSyncSet.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.core.subscribers;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.ITeamStatus;
+import org.eclipse.team.core.synchronize.*;
+import org.eclipse.team.internal.core.Policy;
+
+/**
+ * Ths class uses the contents of one sync set as the input of another.
+ */
+public class SyncSetInputFromSyncSet extends SyncSetInput implements ISyncInfoSetChangeListener {
+
+ SubscriberSyncInfoSet inputSyncSet;
+
+ public SyncSetInputFromSyncSet(SubscriberSyncInfoSet set, SubscriberEventHandler handler) {
+ super(handler);
+ this.inputSyncSet = set;
+ inputSyncSet.addSyncSetChangedListener(this);
+ }
+
+ public SyncInfoSet getInputSyncSet() {
+ return inputSyncSet;
+ }
+
+ public void disconnect() {
+ if (inputSyncSet == null) return;
+ inputSyncSet.removeSyncSetChangedListener(this);
+ inputSyncSet = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ccvs.syncviews.views.AbstractSyncSet#initialize(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected void fetchInput(IProgressMonitor monitor) {
+ if (inputSyncSet == null) return;
+ SyncInfo[] infos = inputSyncSet.getSyncInfos();
+ for (int i = 0; i < infos.length; i++) {
+ collect(infos[i], monitor);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ccvs.syncviews.views.ISyncSetChangedListener#syncSetChanged(org.eclipse.team.ccvs.syncviews.views.SyncSetChangedEvent)
+ */
+ public void syncInfoChanged(ISyncInfoSetChangeEvent event, IProgressMonitor monitor) {
+ SyncInfoSet syncSet = getSyncSet();
+ try {
+ syncSet.beginInput();
+ monitor.beginTask(null, 105);
+ syncSetChanged(event.getChangedResources(), Policy.subMonitorFor(monitor, 50));
+ syncSetChanged(event.getAddedResources(), Policy.subMonitorFor(monitor, 50));
+ remove(event.getRemovedResources());
+ } finally {
+ syncSet.endInput(Policy.subMonitorFor(monitor, 5));
+ }
+ }
+
+ private void syncSetChanged(SyncInfo[] infos, IProgressMonitor monitor) {
+ for (int i = 0; i < infos.length; i++) {
+ collect(infos[i], monitor);
+ }
+ }
+
+ private void remove(IResource[] resources) {
+ for (int i = 0; i < resources.length; i++) {
+ remove(resources[i]);
+ }
+ }
+
+ public void reset() {
+ inputSyncSet.connect(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) {
+ SyncInfoSet syncSet = getSyncSet();
+ try {
+ syncSet.beginInput();
+ monitor.beginTask(null, 100);
+ syncSet.clear();
+ fetchInput(Policy.subMonitorFor(monitor, 95));
+ } finally {
+ syncSet.endInput(Policy.subMonitorFor(monitor, 5));
+ monitor.done();
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.ISyncInfoSetChangeListener#syncInfoSetError(org.eclipse.team.core.subscribers.SyncInfoSet, org.eclipse.team.core.ITeamStatus[], org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) {
+ SubscriberSyncInfoSet syncSet = getSyncSet();
+ try {
+ syncSet.beginInput();
+ for (int i = 0; i < errors.length; i++) {
+ ITeamStatus status = errors[i];
+ syncSet.addError(status);
+ }
+ } finally {
+ syncSet.endInput(monitor);
+ }
+ }
+}

Back to the top