Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-10-06 20:14:34 +0000
committerMichael Valenta2004-10-06 20:14:34 +0000
commit96322cf9e74b203aedd4cf7ad5e83457084a0a1e (patch)
tree9cbd43657920efd05a8ac739f9f062a8412fc3f3
parenteae4dea4cdde1675d5488962fe0cecfe5520e0e9 (diff)
downloadeclipse.platform.team-96322cf9e74b203aedd4cf7ad5e83457084a0a1e.tar.gz
eclipse.platform.team-96322cf9e74b203aedd4cf7ad5e83457084a0a1e.tar.xz
eclipse.platform.team-96322cf9e74b203aedd4cf7ad5e83457084a0a1e.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java67
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java133
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java113
3 files changed, 158 insertions, 155 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java
index db315d6ab..0639ae5ad 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java
@@ -11,56 +11,28 @@
package org.eclipse.team.internal.ccvs.ui.subscriber;
import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.ChangeSet;
-import org.eclipse.team.core.subscribers.CheckedInChangeSet;
-import org.eclipse.team.core.subscribers.Subscriber;
+import org.eclipse.team.core.subscribers.*;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.SyncInfoSet;
import org.eclipse.team.core.variants.IResourceVariant;
-import org.eclipse.team.internal.ccvs.core.CVSCompareSubscriber;
-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.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.ILogEntry;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
+import org.eclipse.team.internal.ccvs.core.*;
+import org.eclipse.team.internal.ccvs.core.resources.*;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Util;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.HistoryView;
+import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation;
import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation.LogEntryCache;
import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.team.ui.synchronize.ISynchronizeManager;
-import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
-import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
-import org.eclipse.team.ui.synchronize.SyncInfoSetChangeSetCollector;
+import org.eclipse.team.ui.synchronize.*;
/**
* Collector that fetches the log for incoming CVS change sets
@@ -212,31 +184,6 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector {
*/
protected void add(SyncInfo[] infos) {
startUpdateJob(new SyncInfoSet(infos));
- // Add any outgoing changes to the root set
- for (int i = 0; i < infos.length; i++) {
- SyncInfo info = infos[i];
- if (isOutgoingChange(info)) {
- addLocalChange(info);
- }
- }
- }
-
- private void addLocalChange(SyncInfo info) {
- addToDefaultSet(DEFAULT_OUTGOING_SET_NAME, info);
- }
-
- private boolean isOutgoingChange(SyncInfo info) {
- try {
- SyncInfo threeWayInfo = info;
- if (!threeWayInfo.getComparator().isThreeWay())
- threeWayInfo = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().getSyncInfo(info.getLocal());
- if (threeWayInfo == null) return false;
- int direction = threeWayInfo.getKind() & SyncInfo.DIRECTION_MASK;
- return (direction == SyncInfo.OUTGOING || direction == SyncInfo.CONFLICTING);
- } catch (TeamException e) {
- CVSUIPlugin.log(e);
- return false;
- }
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java
index 35ada8c6f..6d434dfe9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java
@@ -50,51 +50,39 @@ public class ActiveChangeSetCollector implements ISyncInfoSetChangeListener {
private final ChangeSetModelProvider provider;
+ /**
+ * Listener registered with active change set manager
+ */
private IChangeSetChangeListener activeChangeSetListener = new IChangeSetChangeListener() {
public void setAdded(final ChangeSet set) {
- provider.runViewUpdate(new Runnable() {
- public void run() {
- // Remove any resources that are in the new set
- remove(set.getResources());
- provider.createActiveChangeSetModelElement(set);
- }
- });
-
+ // Remove any resources that are in the new set
+ remove(set.getResources());
+ createSyncInfoSet(set);
}
public void defaultSetChanged(final ChangeSet previousDefault, final ChangeSet set) {
- provider.runViewUpdate(new Runnable() {
- public void run() {
- // Refresh the label for both of the sets involved
- provider.refreshLabel(previousDefault);
- provider.refreshLabel(set);
- }
- });
+ listener.defaultSetChanged(previousDefault, set);
}
public void setRemoved(final ChangeSet set) {
- provider.runViewUpdate(new Runnable() {
- public void run() {
- provider.removeModelElementForSet(set);
- remove(set);
- }
- });
+ remove(set);
}
public void nameChanged(final ChangeSet set) {
- provider.runViewUpdate(new Runnable() {
- public void run() {
- provider.refreshLabel(set);
- }
- });
+ listener.nameChanged(set);
}
public void resourcesChanged(final ChangeSet set, final IResource[] resources) {
- // Changes are handled by the sets themselves.
+ listener.resourcesChanged(set, resources);
}
};
+
+ /**
+ * Listener that wants to recieve change events from this collector
+ */
+ private IChangeSetChangeListener listener;
public ActiveChangeSetCollector(ISynchronizePageConfiguration configuration, ChangeSetModelProvider provider) {
this.configuration = configuration;
@@ -120,19 +108,33 @@ public class ActiveChangeSetCollector implements ISyncInfoSetChangeListener {
public void reset(SyncInfoSet seedSet) {
// First, clean up
rootSet.clear();
- for (Iterator iter = activeSets.keySet().iterator(); iter.hasNext();) {
- ChangeSet set = (ChangeSet) iter.next();
- set.getSyncInfoSet().removeSyncSetChangedListener(this);
+ ChangeSet[] sets = (ChangeSet[]) activeSets.keySet().toArray(new ChangeSet[activeSets.size()]);
+ for (int i = 0; i < sets.length; i++) {
+ ChangeSet set = sets[i];
+ remove(set);
}
activeSets.clear();
// Now repopulate
- if (seedSet == null) {
- getActiveChangeSetManager().removeListener(activeChangeSetListener);
- } else {
- getActiveChangeSetManager().addListener(activeChangeSetListener);
- provider.createActiveChangeSetModelElements();
- add(seedSet.getSyncInfos());
+ if (seedSet != null) {
+ // Show all active change sets even if they are empty
+ sets = getActiveChangeSetManager().getSets();
+ for (int i = 0; i < sets.length; i++) {
+ ChangeSet set = sets[i];
+ add(set);
+ }
+ // The above will add all sync info that are contained in sets.
+ // We still need to add uncontained infos to the root set
+ SyncInfo[] syncInfos = seedSet.getSyncInfos();
+ for (int i = 0; i < syncInfos.length; i++) {
+ SyncInfo info = syncInfos[i];
+ if (isLocalChange(info)) {
+ ChangeSet[] containingSets = findChangeSets(info);
+ if (containingSets.length == 0) {
+ rootSet.add(info);
+ }
+ }
+ }
}
}
@@ -182,10 +184,9 @@ public class ActiveChangeSetCollector implements ISyncInfoSetChangeListener {
ChangeSet set = sets[j];
SyncInfoSet targetSet = (SyncInfoSet)activeSets.get(set);
if (targetSet == null) {
- provider.createActiveChangeSetModelElement(set);
- targetSet = (SyncInfoSet)activeSets.get(set);
- }
- if (targetSet != null) {
+ // This will add all the appropriate sync info to the set
+ createSyncInfoSet(set);
+ } else {
targetSet.add(info);
}
}
@@ -221,13 +222,45 @@ public class ActiveChangeSetCollector implements ISyncInfoSetChangeListener {
}
/*
- * emove the set from the collector. This should
- * only be caleed after the node for the set
- * has been removed from the view.
+ * Add the set from the collector.
+ */
+ public void add(ChangeSet set) {
+ SyncInfoSet targetSet = (SyncInfoSet)activeSets.get(set);
+ if (targetSet == null) {
+ createSyncInfoSet(set);
+ }
+ if (listener != null) {
+ listener.setAdded(set);
+ }
+ }
+
+ private SyncInfoTree createSyncInfoSet(ChangeSet set) {
+ SyncInfoTree sis = (SyncInfoTree)activeSets.get(set);
+ // Register the listener last since the add will
+ // look for new elements
+ boolean listen = false;
+ if (sis == null) {
+ sis = new SyncInfoTree();
+ activeSets.put(set, sis);
+ listen = true;
+ } else {
+ sis.clear();
+ }
+ sis.addAll(select(set.getSyncInfoSet().getSyncInfos()));
+ if (listen)
+ set.getSyncInfoSet().addSyncSetChangedListener(this);
+ return sis;
+ }
+
+ /*
+ * Remove the set from the collector.
*/
public void remove(ChangeSet set) {
set.getSyncInfoSet().removeSyncSetChangedListener(this);
activeSets.remove(set);
+ if (listener != null) {
+ listener.setRemoved(set);
+ }
}
/*
@@ -324,4 +357,18 @@ public class ActiveChangeSetCollector implements ISyncInfoSetChangeListener {
public void dispose() {
getActiveChangeSetManager().removeListener(activeChangeSetListener);
}
+
+ /**
+ * Set the change set listener for this collector. There is
+ * only one for this type of collector.
+ * @param listener change set change listener
+ */
+ public void setChangeSetChangeListener(IChangeSetChangeListener listener) {
+ this.listener = listener;
+ if (listener == null) {
+ getActiveChangeSetManager().removeListener(activeChangeSetListener);
+ } else {
+ getActiveChangeSetManager().addListener(activeChangeSetListener);
+ }
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java
index 15be300f6..8e5ef14d1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java
@@ -20,7 +20,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.widgets.Control;
+import org.eclipse.team.core.subscribers.*;
import org.eclipse.team.core.subscribers.ChangeSet;
import org.eclipse.team.core.subscribers.IChangeSetChangeListener;
import org.eclipse.team.core.synchronize.*;
@@ -44,42 +44,58 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
private SyncInfoSetChangeSetCollector checkedInCollector;
- private IChangeSetChangeListener checkedInCollectorListener = new IChangeSetChangeListener() {
+ private IChangeSetChangeListener changeSetListener = new IChangeSetChangeListener() {
/* (non-Javadoc)
* @see org.eclipse.team.core.subscribers.IChangeSetChangeListener#setAdded(org.eclipse.team.core.subscribers.ChangeSet)
*/
- public void setAdded(ChangeSet set) {
- ISynchronizeModelElement node = getModelElement(set);
- ISynchronizeModelProvider provider = null;
- if (node != null) {
- provider = getProviderRootedAt(node);
+ public void setAdded(final ChangeSet set) {
+ final SyncInfoTree syncInfoSet;
+ // TODO: May need to be modified to work with two-way
+ if (set instanceof CheckedInChangeSet) {
+ syncInfoSet = set.getSyncInfoSet();
+ } else {
+ syncInfoSet = activeCollector.getSyncInfoSet(set);
}
- if (provider == null) {
- provider = createProvider(set);
- }
- provider.prepareInput(null);
+ runViewUpdate(new Runnable() {
+ public void run() {
+ createChangeSetModelElement(set, syncInfoSet);
+ }
+ });
}
/* (non-Javadoc)
* @see org.eclipse.team.core.subscribers.IChangeSetChangeListener#defaultSetChanged(org.eclipse.team.core.subscribers.ChangeSet, org.eclipse.team.core.subscribers.ChangeSet)
*/
- public void defaultSetChanged(ChangeSet previousDefault, ChangeSet set) {
- // There is no default set for checked-in change sets
+ public void defaultSetChanged(final ChangeSet previousDefault, final ChangeSet set) {
+ runViewUpdate(new Runnable() {
+ public void run() {
+ refreshLabel(previousDefault);
+ refreshLabel(set);
+ }
+ });
}
/* (non-Javadoc)
* @see org.eclipse.team.core.subscribers.IChangeSetChangeListener#setRemoved(org.eclipse.team.core.subscribers.ChangeSet)
*/
- public void setRemoved(ChangeSet set) {
- removeModelElementForSet(set);
+ public void setRemoved(final ChangeSet set) {
+ runViewUpdate(new Runnable() {
+ public void run() {
+ removeModelElementForSet(set);
+ }
+ });
}
/* (non-Javadoc)
* @see org.eclipse.team.core.subscribers.IChangeSetChangeListener#nameChanged(org.eclipse.team.core.subscribers.ChangeSet)
*/
- public void nameChanged(ChangeSet set) {
- // The name of checked-in change sets should not change
+ public void nameChanged(final ChangeSet set) {
+ runViewUpdate(new Runnable() {
+ public void run() {
+ refreshLabel(set);
+ }
+ });
}
/* (non-Javadoc)
@@ -117,10 +133,11 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
if (changeSetCapability.supportsCheckedInChangeSets()) {
checkedInCollector = changeSetCapability.createCheckedInChangeSetCollector(configuration);
checkedInCollector.setProvider(this);
- checkedInCollector.addListener(checkedInCollectorListener);
+ checkedInCollector.addListener(changeSetListener);
}
if (changeSetCapability.supportsActiveChangeSets()) {
activeCollector = new ActiveChangeSetCollector(configuration, this);
+ activeCollector.setChangeSetChangeListener(changeSetListener);
configuration.addMenuGroup(ISynchronizePageConfiguration.P_CONTEXT_MENU, ChangeSetActionGroup.CHANGE_SET_GROUP);
}
}
@@ -129,11 +146,16 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
* @see org.eclipse.team.internal.ui.synchronize.AbstractSynchronizeModelProvider#handleChanges(org.eclipse.team.core.synchronize.ISyncInfoTreeChangeEvent, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void handleChanges(ISyncInfoTreeChangeEvent event, IProgressMonitor monitor) {
+ boolean handled = false;
if (checkedInCollector != null && getChangeSetCapability().enableCheckedInChangeSetsFor(getConfiguration())) {
checkedInCollector.handleChange(event);
- } else if (activeCollector != null && getChangeSetCapability().enableActiveChangeSetsFor(getConfiguration())) {
+ handled = true;
+ }
+ if (activeCollector != null && getChangeSetCapability().enableActiveChangeSetsFor(getConfiguration())) {
activeCollector.handleChange(event);
- } else {
+ handled = true;
+ }
+ if (!handled) {
// Forward the event to the root provider
ISynchronizeModelProvider provider = getProviderRootedAt(getModelRoot());
if (provider != null) {
@@ -177,20 +199,26 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
// First, disable the collectors
if (checkedInCollector != null) {
checkedInCollector.reset(null);
- checkedInCollector.removeListener(checkedInCollectorListener);
+ checkedInCollector.removeListener(changeSetListener);
}
- if (activeCollector != null) {
+ if (activeCollector != null) {
+ activeCollector.setChangeSetChangeListener(null);
activeCollector.reset(null);
}
- // Then, re-enable the proper collection method
+ // Then, re-enable the proper collection method
+ boolean handled = false;
if (checkedInCollector != null && getChangeSetCapability().enableCheckedInChangeSetsFor(getConfiguration())) {
- checkedInCollector.addListener(checkedInCollectorListener);
+ checkedInCollector.addListener(changeSetListener);
checkedInCollector.reset(getSyncInfoSet());
-
- } else if (activeCollector != null && getChangeSetCapability().enableActiveChangeSetsFor(getConfiguration())) {
+ handled = true;
+ }
+ if (activeCollector != null && getChangeSetCapability().enableActiveChangeSetsFor(getConfiguration())) {
+ activeCollector.setChangeSetChangeListener(changeSetListener);
activeCollector.reset(getSyncInfoSet());
- } else {
+ handled = true;
+ }
+ if (!handled) {
// Forward the sync info to the root provider and trigger a build
ISynchronizeModelProvider provider = getProviderRootedAt(getModelRoot());
if (provider != null) {
@@ -303,7 +331,7 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
private void createRootProvider() {
// Recreate the sub-provider at the root and use it's viewer sorter and action group
SyncInfoTree tree;
- if (activeCollector != null && getConfiguration().getMode() == ISynchronizePageConfiguration.OUTGOING_MODE) {
+ if (activeCollector != null && getChangeSetCapability().enableActiveChangeSetsFor(getConfiguration())) {
// When in outgoing mode, use the root set of the active change set collector at the root
tree = activeCollector.getRootSet();
} else {
@@ -329,13 +357,6 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
}
/*
- * Create a provider and node for the given change set
- */
- private ISynchronizeModelProvider createProvider(ChangeSet set) {
- return createProvider(set, set.getSyncInfoSet());
- }
-
- /*
* Find the root element for the given change set.
* A linear search is used.
*/
@@ -359,10 +380,11 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
public void dispose() {
if (checkedInCollector != null) {
- checkedInCollector.removeListener(checkedInCollectorListener);
+ checkedInCollector.removeListener(changeSetListener);
checkedInCollector.dispose();
}
if (activeCollector != null) {
+ activeCollector.setChangeSetChangeListener(null);
activeCollector.dispose();
}
super.dispose();
@@ -374,19 +396,6 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
if (checkedInCollector != null) checkedInCollector.waitUntilDone(monitor);
}
- private void syncExec(final Runnable runnable) {
- final Control ctrl = getViewer().getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ctrl.getDisplay().syncExec(new Runnable() {
- public void run() {
- if (!ctrl.isDisposed()) {
- runnable.run();
- }
- }
- });
- }
- }
-
void removeModelElementForSet(final ChangeSet set) {
ISynchronizeModelElement node = getModelElement(set);
if (node != null) {
@@ -400,11 +409,11 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
ChangeSet[] sets = activeCollector.getActiveChangeSetManager().getSets();
for (int i = 0; i < sets.length; i++) {
ChangeSet set = sets[i];
- createActiveChangeSetModelElement(set);
+ createChangeSetModelElement(set, activeCollector.getSyncInfoSet(set));
}
}
- public void createActiveChangeSetModelElement(final ChangeSet set) {
+ public void createChangeSetModelElement(ChangeSet set, SyncInfoTree tree) {
// Add the model element and provider for the set
ISynchronizeModelElement node = getModelElement(set);
ISynchronizeModelProvider provider = null;
@@ -412,7 +421,7 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
provider = getProviderRootedAt(node);
}
if (provider == null) {
- provider = createProvider(set, activeCollector.getSyncInfoSet(set));
+ provider = createProvider(set, tree);
}
provider.prepareInput(null);
}

Back to the top