Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-09-30 19:47:28 +0000
committerMichael Valenta2004-09-30 19:47:28 +0000
commit06bfc3503f6bd4bb3a378aafb02ef4f7aca71e24 (patch)
tree4a0b24c8ba2b3732ad4ec43896c1f3a6b7671ba4
parentb5c30b9d1cb12a23ee66fbecbec7253cc237af56 (diff)
downloadeclipse.platform.team-06bfc3503f6bd4bb3a378aafb02ef4f7aca71e24.tar.gz
eclipse.platform.team-06bfc3503f6bd4bb3a378aafb02ef4f7aca71e24.tar.xz
eclipse.platform.team-06bfc3503f6bd4bb3a378aafb02ef4f7aca71e24.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeSetCollector.java63
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties31
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java24
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java152
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java173
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties15
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java261
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetActionGroup.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetDiffNode.java17
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelManager.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java195
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java1
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetChangeSetCollector.java17
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/launchConfigurations/One CVS Test.launch6
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java73
19 files changed, 810 insertions, 244 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeSetCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeSetCollector.java
index c1974e33d..46388a0b4 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeSetCollector.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeSetCollector.java
@@ -12,7 +12,6 @@ package org.eclipse.team.core.subscribers;
import java.util.*;
-import org.eclipse.core.internal.runtime.ListenerList;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.*;
@@ -36,8 +35,6 @@ public class SubscriberChangeSetCollector extends ChangeSetCollector implements
private static final int RESOURCE_REMOVAL = 1;
private static final int RESOURCE_CHANGE = 2;
- private List activeSets;
- private ListenerList listeners = new ListenerList();
private ActiveChangeSet defaultSet;
private EventHandler handler;
private ResourceCollector collector;
@@ -94,22 +91,24 @@ public class SubscriberChangeSetCollector extends ChangeSetCollector implements
}
private void beginDispath() {
- for (Iterator iter = activeSets.iterator(); iter.hasNext();) {
- ActiveChangeSet set = (ActiveChangeSet) iter.next();
+ ChangeSet[] sets = getSets();
+ for (int i = 0; i < sets.length; i++) {
+ ChangeSet set = sets[i];
set.getSyncInfoSet().beginInput();
}
}
private void endDispatch(IProgressMonitor monitor) {
- monitor.beginTask(null, 100 * activeSets.size());
- for (Iterator iter = activeSets.iterator(); iter.hasNext();) {
- ActiveChangeSet set = (ActiveChangeSet) iter.next();
+ ChangeSet[] sets = getSets();
+ monitor.beginTask(null, 100 * sets.length);
+ for (int i = 0; i < sets.length; i++) {
+ ChangeSet set = sets[i];
try {
set.getSyncInfoSet().endInput(Policy.subMonitorFor(monitor, 100));
} catch (RuntimeException e) {
// Don't worry about ending every set if an error occurs.
// Instead, log the error and suggest a restart.
- TeamPlugin.log(IStatus.ERROR, "An error occurred while reconciling change sets. Restarting the application is recommended.", e);
+ TeamPlugin.log(IStatus.ERROR, Policy.bind("SubscriberChangeSetCollector.0"), e); //$NON-NLS-1$
throw e;
}
}
@@ -128,8 +127,9 @@ public class SubscriberChangeSetCollector extends ChangeSetCollector implements
* Handle the removal
*/
private void handleRemove(IResource resource) {
- for (Iterator iter = activeSets.iterator(); iter.hasNext();) {
- ActiveChangeSet set = (ActiveChangeSet) iter.next();
+ ChangeSet[] sets = getSets();
+ for (int i = 0; i < sets.length; i++) {
+ ChangeSet set = sets[i];
// This will remove any descendants from the set and callback to
// resourcesChanged which will batch changes
if (!set.isEmpty()) {
@@ -175,8 +175,9 @@ public class SubscriberChangeSetCollector extends ChangeSetCollector implements
private void removeFromAllSets(IResource resource) {
List toRemove = new ArrayList();
- for (Iterator iter = activeSets.iterator(); iter.hasNext();) {
- ActiveChangeSet set = (ActiveChangeSet) iter.next();
+ ChangeSet[] sets = getSets();
+ for (int i = 0; i < sets.length; i++) {
+ ChangeSet set = sets[i];
if (set.contains(resource)) {
set.remove(resource);
if (set.isEmpty()) {
@@ -191,14 +192,15 @@ public class SubscriberChangeSetCollector extends ChangeSetCollector implements
}
private ActiveChangeSet[] getContainingSets(IResource resource) {
- Set sets = new HashSet();
- for (Iterator iter = activeSets.iterator(); iter.hasNext();) {
- ActiveChangeSet set = (ActiveChangeSet) iter.next();
+ Set result = new HashSet();
+ ChangeSet[] sets = getSets();
+ for (int i = 0; i < sets.length; i++) {
+ ChangeSet set = sets[i];
if (set.contains(resource)) {
- sets.add(set);
+ result.add(set);
}
}
- return (ActiveChangeSet[]) sets.toArray(new ActiveChangeSet[sets.size()]);
+ return (ActiveChangeSet[]) result.toArray(new ActiveChangeSet[result.size()]);
}
}
@@ -227,7 +229,7 @@ public class SubscriberChangeSetCollector extends ChangeSetCollector implements
public SubscriberChangeSetCollector(Subscriber subscriber) {
collector = new ResourceCollector(subscriber);
load();
- handler = new EventHandler("Updating Change Sets for {0}" + subscriber.getName(), "Errors occurred while updating the change sets for {0}" + subscriber.getName());
+ handler = new EventHandler(Policy.bind("SubscriberChangeSetCollector.1", subscriber.getName()), Policy.bind("SubscriberChangeSetCollector.2", subscriber.getName())); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -368,11 +370,12 @@ public class SubscriberChangeSetCollector extends ChangeSetCollector implements
private void save() {
Preferences prefs = getPreferences();
- for (Iterator it = activeSets.iterator(); it.hasNext(); ) {
- ActiveChangeSet set = (ActiveChangeSet) it.next();
- if (!set.isEmpty()) {
- Preferences child = prefs.node(set.getTitle());
- set.save(child);
+ ChangeSet[] sets = getSets();
+ for (int i = 0; i < sets.length; i++) {
+ ChangeSet set = sets[i];
+ if (set instanceof ActiveChangeSet && !set.isEmpty()) {
+ Preferences child = prefs.node(((ActiveChangeSet)set).getTitle());
+ ((ActiveChangeSet)set).save(child);
}
}
if (defaultSet != null) {
@@ -381,12 +384,11 @@ public class SubscriberChangeSetCollector extends ChangeSetCollector implements
try {
prefs.flush();
} catch (BackingStoreException e) {
- TeamPlugin.log(IStatus.ERROR, "An error occurred saving the change set state for {0}" + getSubscriber().getName(), e);
+ TeamPlugin.log(IStatus.ERROR, Policy.bind("SubscriberChangeSetCollector.3", getSubscriber().getName()), e); //$NON-NLS-1$
}
}
private void load() {
- activeSets = new ArrayList();
Preferences prefs = getPreferences();
String defaultSetTitle = prefs.get(CTX_DEFAULT_SET, null);
try {
@@ -398,10 +400,10 @@ public class SubscriberChangeSetCollector extends ChangeSetCollector implements
if (defaultSet == null && defaultSetTitle != null && set.getTitle().equals(defaultSetTitle)) {
defaultSet = set;
}
- activeSets.add(set);
+ add(set);
}
} catch (BackingStoreException e) {
- TeamPlugin.log(IStatus.ERROR, "An error occurred restoring the change set state for {0}" + getSubscriber().getName(), e);
+ TeamPlugin.log(IStatus.ERROR, Policy.bind("SubscriberChangeSetCollector.4", getSubscriber().getName()), e); //$NON-NLS-1$
}
}
@@ -478,8 +480,9 @@ public class SubscriberChangeSetCollector extends ChangeSetCollector implements
resources[i] = infos[i].getLocal();
}
// Remove the added files from any other set that contains them
- for (Iterator iter = activeSets.iterator(); iter.hasNext();) {
- ChangeSet otherSet = (ChangeSet) iter.next();
+ ChangeSet[] sets = getSets();
+ for (int i = 0; i < sets.length; i++) {
+ ChangeSet otherSet = sets[i];
if (otherSet != set) {
otherSet.remove(resources);
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties
index 5f74da69d..22dfa1eb2 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/messages.properties
@@ -102,6 +102,11 @@ ContentComparisonCriteria.3=\ ignoring whitespace
SubscriberEventHandler.2=Updating {0}.
SubscriberEventHandler.jobName=Updating {0}.
+SubscriberChangeSetCollector.0=An error occurred while reconciling change sets. Restarting the application is recommended.
+SubscriberChangeSetCollector.1=Updating Change Sets for {0}
+SubscriberChangeSetCollector.2=Errors occurred while updating the change sets for {0}
+SubscriberChangeSetCollector.3=An error occurred saving the change set state for {0}
+SubscriberChangeSetCollector.4=An error occurred restoring the change set state for {0}
SubscriberEventHandler.errors=Errors have occured while calculating the synchronization state for {0}.
RemoteContentsCacheEntry.3=Cache entry in {0} for {1} has been disposed
SynchronizationCacheRefreshOperation.0=Processing {0}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index 58ce8069a..17a91da54 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -1027,28 +1027,15 @@ CheckoutIntoWizard.title=Checkout Into
CheckoutIntoWizard.projectSelectionPageTitle=Select local folder
CheckoutIntoWizard.projectSelectionPageDescription=Select the local folder that is the target of the checkout operation.
CheckoutIntoWizard.error=Checkout Error
-ChangeLogModelProvider.0a=Sort &Comments By
-ChangeLogModelProvider.0=&New Commit Set...
-ChangeLogModelProvider.1a=&Comment
-ChangeLogModelProvider.1=New Set
-ChangeLogModelProvider.10=Could not add files
-ChangeLogModelProvider.11=A problem occurred while rying to add the files to the commit set
-ChangeLogModelProvider.12=Add &To
-ChangeLogModelProvider.2a=&Date
-ChangeLogModelProvider.20=Open Change in Compare Editor
-ChangeLogModelProvider.21=Could not determine the repository location of the selected resources
-ChangeLogModelProvider.2=New Commit Set
-ChangeLogModelProvider.3a=&User
-ChangeLogModelProvider.3=Enter the name and comment for the new commit set
-ChangeLogModelProvider.4=Retrieving revision histories
-ChangeLogModelProvider.4a=Could not create set
-ChangeLogModelProvider.5=Commit &Sets
-ChangeLogModelProvider.5a=A problem occurred while trying to create the commit set
-ChangeLogModelProvider.6=Ed&it Comment...
-ChangeLogModelProvider.7=Edit Commit Set Comment
-ChangeLogModelProvider.8=Edit the name and comment for the new commit set
-ChangeLogModelProvider.9=Make De&fault
-ChangeLogModelManager.0=Show Commit Sets
+
+WorkspaceChangeSetCapability.1=New Set
+OpenCommitSetAction.20=Open Change in Compare Editor
+OpenCommitSetAction.21=Could not determine the repository location of the selected resources
+WorkspaceChangeSetCapability.2=New Change Set
+WorkspaceChangeSetCapability.3=Enter the name and comment for the new change set
+CVSChangeSetCollector.4=Retrieving revision histories
+WorkspaceChangeSetCapability.7=Edit Change Set Comment
+WorkspaceChangeSetCapability.8=Edit the name and comment for the change set
CheckoutIntoWizard.thisResourceExists=The resource ''{0}'' already exists in the workspace. Overwrite?
CheckoutIntoWizard.confirmOverwrite=Confirm Overwrite
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 4b96f439e..d2ae65f7b 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
@@ -73,7 +73,7 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector {
private class FetchLogEntriesJob extends Job {
private Set syncSets = new HashSet();
public FetchLogEntriesJob() {
- super(Policy.bind("ChangeLogModelProvider.4")); //$NON-NLS-1$
+ super(Policy.bind("CVSChangeSetCollector.4")); //$NON-NLS-1$
setUser(false);
}
public boolean belongsTo(Object family) {
@@ -584,7 +584,9 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector {
ChangeSet[] sets = getSets();
for (int i = 0; i < sets.length; i++) {
ChangeSet set = sets[i];
- if (set.getComment().equals(logEntry.getComment())) {
+ if (set instanceof CheckedInChangeSet &&
+ set.getComment().equals(logEntry.getComment()) &&
+ ((CheckedInChangeSet)set).getAuthor().equals(logEntry.getAuthor())) {
return set;
}
}
@@ -610,4 +612,22 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector {
defaultSet = null;
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SyncInfoSetChangeSetCollector#waitUntilDone(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void waitUntilDone(IProgressMonitor monitor) {
+ super.waitUntilDone(monitor);
+ monitor.worked(1);
+ // wait for the event handler to process changes.
+ while(fetchLogEntriesJob.getState() != Job.NONE) {
+ monitor.worked(1);
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ }
+ Policy.checkCanceled(monitor);
+ }
+ monitor.worked(1);
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java
index e6559dab2..840a6239b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/ChangeLogModelProvider.java
@@ -79,161 +79,13 @@ public class ChangeLogModelProvider extends CompositeModelProvider implements IC
private ViewerSorter embeddedSorter;
/* *****************************************************************************
- * Action that will open a commit set in a compare editor.
- * It provides a comparison between the files in the
- * commit set and their immediate predecessors.
- */
- private class OpenCommitSetAction extends SynchronizeModelAction {
-
- protected OpenCommitSetAction(ISynchronizePageConfiguration configuration) {
- super(Policy.bind("ChangeLogModelProvider.20"), configuration); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSyncInfoFilter()
- */
- protected FastSyncInfoFilter getSyncInfoFilter() {
- return new AndSyncInfoFilter(new FastSyncInfoFilter[] {
- new FastSyncInfoFilter() {
- public boolean select(SyncInfo info) {
- return info.getLocal().getType() == IResource.FILE;
- }
- },
- new OrSyncInfoFilter(new FastSyncInfoFilter[] {
- new SyncInfoDirectionFilter(new int[] { SyncInfo.INCOMING, SyncInfo.CONFLICTING }),
- new FastSyncInfoFilter() {
- public boolean select(SyncInfo info) {
- return !info.getComparator().isThreeWay();
- }
- }
- })
- });
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
- */
- protected boolean updateSelection(IStructuredSelection selection) {
- boolean enabled = super.updateSelection(selection);
- if (enabled) {
- // The selection only contains appropriate files
- // only enable if there is only one item selected and
- // it is a file or a commit set
- if (selection.size() == 1) {
- Object o = selection.getFirstElement();
- if (o instanceof ChangeLogDiffNode) return true;
- if (o instanceof ISynchronizeModelElement) {
- ISynchronizeModelElement element = (ISynchronizeModelElement)o;
- IResource resource = element.getResource();
- return (resource != null && resource.getType() == IResource.FILE);
- }
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSubscriberOperation(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration, org.eclipse.compare.structuremergeviewer.IDiffElement[])
- */
- protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
- return new SynchronizeModelOperation(configuration, elements) {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- SyncInfoSet set = getSyncInfoSet();
- SyncInfo[] infos = set.getSyncInfos();
- if (infos.length > 0) {
- ICVSRepositoryLocation location = getLocation(infos[0]);
- if (location == null) {
- handle(new CVSException(Policy.bind("ChangeLogModelProvider.21"))); //$NON-NLS-1$
- return;
- }
- CompareTreeBuilder builder = new CompareTreeBuilder(location, null, null);
- if (buildTrees(builder, infos)) {
- try {
- builder.cacheContents(monitor);
- builder.openCompareEditor(getConfiguration().getSite().getPart().getSite().getPage(), getCompareTitle(), getCompareToolTip());
- } catch (CVSException e) {
- handle(e);
- return;
- }
- }
- }
- }
-
- private String getCompareToolTip() {
- IDiffElement[] elements = getSelectedDiffElements();
- for (int i = 0; i < elements.length; i++) {
- IDiffElement element = elements[i];
- while (element != null) {
- if (element instanceof ChangeLogDiffNode) {
- return ((ChangeLogDiffNode)element).getName();
- }
- element = element.getParent();
- }
- }
- return null;
- }
-
- private String getCompareTitle() {
- IDiffElement[] elements = getSelectedDiffElements();
- for (int i = 0; i < elements.length; i++) {
- IDiffElement element = elements[i];
- while (element != null) {
- if (element instanceof ChangeLogDiffNode) {
- return ((ChangeLogDiffNode)element).getShortName();
- }
- element = element.getParent();
- }
- }
- return null;
- }
-
- private ICVSRepositoryLocation getLocation(SyncInfo info) {
- IResourceVariant remote = info.getRemote();
- if (remote == null) {
- remote = info.getBase();
- }
- if (remote != null) {
- return ((ICVSRemoteResource)remote).getRepository();
- }
- return null;
- }
-
- /*
- * Build the trees that will be compared
- */
- private boolean buildTrees(CompareTreeBuilder builder, SyncInfo[] infos) {
- for (int i = 0; i < infos.length; i++) {
- SyncInfo info = infos[i];
- IResourceVariant remote = info.getRemote();
- if (remote == null) {
- IResourceVariant predecessor = info.getBase();
- if (predecessor instanceof ICVSRemoteFile) {
- builder.addToTrees((ICVSRemoteFile)predecessor, null);
- }
- } else if (remote instanceof ICVSRemoteFile) {
- try {
- ICVSRemoteFile predecessor = logs.getImmediatePredecessor((ICVSRemoteFile)remote);
- builder.addToTrees(predecessor, (ICVSRemoteFile)remote);
- } catch (TeamException e) {
- handle(e);
- return false;
- }
- }
- }
- return true;
- }
- };
- }
- }
-
- /* *****************************************************************************
* Action group for this layout. It is added and removed for this layout only.
*/
public class ChangeLogActionGroup extends ChangeSetActionGroup {
- private OpenCommitSetAction openCommitSet;
+ private OpenChangeSetAction openCommitSet;
public void initialize(ISynchronizePageConfiguration configuration) {
super.initialize(configuration);
- openCommitSet = new OpenCommitSetAction(configuration);
+ openCommitSet = new OpenChangeSetAction(ChangeLogModelProvider.this, configuration);
appendToGroup(
ISynchronizePageConfiguration.P_CONTEXT_MENU,
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java
new file mode 100644
index 000000000..31b84f3fe
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 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.ccvs.ui.subscriber;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.synchronize.*;
+import org.eclipse.team.core.synchronize.FastSyncInfoFilter.*;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.internal.ccvs.core.*;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.operations.RemoteCompareOperation.CompareTreeBuilder;
+import org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode;
+import org.eclipse.team.ui.synchronize.*;
+
+class OpenChangeSetAction extends SynchronizeModelAction {
+
+ private final ChangeLogModelProvider provider;
+
+ protected OpenChangeSetAction(ChangeLogModelProvider provider, ISynchronizePageConfiguration configuration) {
+ super(Policy.bind("OpenCommitSetAction.20"), configuration); //$NON-NLS-1$
+ this.provider = provider;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSyncInfoFilter()
+ */
+ protected FastSyncInfoFilter getSyncInfoFilter() {
+ return new AndSyncInfoFilter(new FastSyncInfoFilter[] {
+ new FastSyncInfoFilter() {
+ public boolean select(SyncInfo info) {
+ return info.getLocal().getType() == IResource.FILE;
+ }
+ },
+ new OrSyncInfoFilter(new FastSyncInfoFilter[] {
+ new SyncInfoDirectionFilter(new int[] { SyncInfo.INCOMING, SyncInfo.CONFLICTING }),
+ new FastSyncInfoFilter() {
+ public boolean select(SyncInfo info) {
+ return !info.getComparator().isThreeWay();
+ }
+ }
+ })
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ boolean enabled = super.updateSelection(selection);
+ if (enabled) {
+ // The selection only contains appropriate files
+ // only enable if there is only one item selected and
+ // it is a file or a commit set
+ if (selection.size() == 1) {
+ Object o = selection.getFirstElement();
+ if (o instanceof ChangeSetDiffNode) return true;
+ if (o instanceof ISynchronizeModelElement) {
+ ISynchronizeModelElement element = (ISynchronizeModelElement)o;
+ IResource resource = element.getResource();
+ return (resource != null && resource.getType() == IResource.FILE);
+ }
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#getSubscriberOperation(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration, org.eclipse.compare.structuremergeviewer.IDiffElement[])
+ */
+ protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
+ return new SynchronizeModelOperation(configuration, elements) {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ SyncInfoSet set = getSyncInfoSet();
+ SyncInfo[] infos = set.getSyncInfos();
+ if (infos.length > 0) {
+ ICVSRepositoryLocation location = getLocation(infos[0]);
+ if (location == null) {
+ handle(new CVSException(Policy.bind("OpenCommitSetAction.21"))); //$NON-NLS-1$
+ return;
+ }
+ CompareTreeBuilder builder = new CompareTreeBuilder(location, null, null);
+ if (buildTrees(builder, infos)) {
+ try {
+ builder.cacheContents(monitor);
+ builder.openCompareEditor(getConfiguration().getSite().getPart().getSite().getPage(), getCompareTitle(), getCompareToolTip());
+ } catch (CVSException e) {
+ handle(e);
+ return;
+ }
+ }
+ }
+ }
+
+ private String getCompareToolTip() {
+ IDiffElement[] elements = getSelectedDiffElements();
+ for (int i = 0; i < elements.length; i++) {
+ IDiffElement element = elements[i];
+ while (element != null) {
+ if (element instanceof ChangeSetDiffNode) {
+ return ((ChangeSetDiffNode)element).getName();
+ }
+ element = element.getParent();
+ }
+ }
+ return null;
+ }
+
+ private String getCompareTitle() {
+ IDiffElement[] elements = getSelectedDiffElements();
+ for (int i = 0; i < elements.length; i++) {
+ IDiffElement element = elements[i];
+ while (element != null) {
+ if (element instanceof ChangeSetDiffNode) {
+ return ((ChangeSetDiffNode)element).getShortName();
+ }
+ element = element.getParent();
+ }
+ }
+ return null;
+ }
+
+ private ICVSRepositoryLocation getLocation(SyncInfo info) {
+ IResourceVariant remote = info.getRemote();
+ if (remote == null) {
+ remote = info.getBase();
+ }
+ if (remote != null) {
+ return ((ICVSRemoteResource)remote).getRepository();
+ }
+ return null;
+ }
+
+ /*
+ * Build the trees that will be compared
+ */
+ private boolean buildTrees(CompareTreeBuilder builder, SyncInfo[] infos) {
+ for (int i = 0; i < infos.length; i++) {
+ SyncInfo info = infos[i];
+ IResourceVariant remote = info.getRemote();
+ if (remote == null) {
+ IResourceVariant predecessor = info.getBase();
+ if (predecessor instanceof ICVSRemoteFile) {
+ builder.addToTrees((ICVSRemoteFile)predecessor, null);
+ }
+ } else if (remote instanceof ICVSRemoteFile) {
+ try {
+ ICVSRemoteFile predecessor = OpenChangeSetAction.this.provider.logs.getImmediatePredecessor((ICVSRemoteFile)remote);
+ builder.addToTrees(predecessor, (ICVSRemoteFile)remote);
+ } catch (TeamException e) {
+ handle(e);
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ };
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
index 1e7d0415b..64ae79696 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java
@@ -145,9 +145,9 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa
* @see org.eclipse.team.ui.synchronize.ChangeSetCapability#createChangeSet(org.eclipse.team.core.synchronize.SyncInfo[])
*/
public ActiveChangeSet createChangeSet(ISynchronizePageConfiguration configuration, SyncInfo[] infos) {
- ActiveChangeSet set = getActiveChangeSetManager().createSet(Policy.bind("ChangeLogModelProvider.1"), new SyncInfo[0]); //$NON-NLS-1$
+ ActiveChangeSet set = getActiveChangeSetManager().createSet(Policy.bind("WorkspaceChangeSetCapability.1"), new SyncInfo[0]); //$NON-NLS-1$
CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, getResources(infos),
- Policy.bind("ChangeLogModelProvider.2"), Policy.bind("ChangeLogModelProvider.3")); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.bind("WorkspaceChangeSetCapability.2"), Policy.bind("WorkspaceChangeSetCapability.3")); //$NON-NLS-1$ //$NON-NLS-2$
dialog.open();
if (dialog.getReturnCode() != InputDialog.OK) return null;
set.add(infos);
@@ -167,7 +167,7 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa
*/
public void editChangeSet(ISynchronizePageConfiguration configuration, ActiveChangeSet set) {
CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, set.getResources(),
- Policy.bind("ChangeLogModelProvider.7"), Policy.bind("ChangeLogModelProvider.8")); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.bind("WorkspaceChangeSetCapability.7"), Policy.bind("WorkspaceChangeSetCapability.8")); //$NON-NLS-1$ //$NON-NLS-2$
dialog.open();
if (dialog.getReturnCode() != InputDialog.OK) return;
// Nothing to do here as the set was updated by the dialog
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 fc048ab76..1654c9a8a 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
@@ -473,3 +473,18 @@ FlatModelProvider.7=&Name
FlatModelProvider.8=&Path
FlatModelProvider.9=&Parent Name
FlatModelProvider.0=Flat
+
+ChangeLogModelProvider.0a=Sort &Comments By
+ChangeLogModelProvider.1a=&Comment
+ChangeLogModelProvider.2a=&Date
+ChangeLogModelProvider.3a=&User
+ChangeLogModelProvider.0=&New Change Set...
+ChangeLogModelProvider.10=Could not add files
+ChangeLogModelProvider.11=A problem occurred while trying to add resources to the change set.
+ChangeLogModelProvider.12=Add &To
+ChangeLogModelProvider.4a=Could not create set.
+ChangeLogModelProvider.5=Commit &Sets
+ChangeLogModelProvider.5a=A problem occurred while trying to create the change set.
+ChangeLogModelProvider.6=Ed&it Change Set...
+ChangeLogModelProvider.9=Make De&fault
+ChangeLogModelManager.0=Show Change Sets
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
index 8b9bbaa71..b3d9c9bae 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
@@ -756,10 +756,11 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo
}
/**
- * Wait until the update handler is not processing any events.
+ * Wait until the provider is done processing any events and
+ * the page conent are up-to-date.
* This method is for testing purposes only.
*/
- public void waitForUpdateHandler(IProgressMonitor monitor) {
+ public void waitUntilDone(IProgressMonitor monitor) {
monitor.worked(1);
// wait for the event handler to process changes.
while(updateHandler.getEventHandlerJob().getState() != Job.NONE) {
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
new file mode 100644
index 000000000..23842d2c3
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 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.ui.synchronize;
+
+import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.ITeamStatus;
+import org.eclipse.team.core.subscribers.ChangeSet;
+import org.eclipse.team.core.subscribers.SubscriberChangeSetCollector;
+import org.eclipse.team.core.synchronize.*;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+
+/**
+ * Group incoming changes according to the active change set thet are
+ * located in
+ */
+public class ActiveChangeSetCollector implements ISyncInfoSetChangeListener {
+
+ private final ISynchronizePageConfiguration configuration;
+
+ /*
+ * Map active change sets to infos displayed by the particpant
+ */
+ private final Map activeSets = new HashMap();
+
+ /*
+ * Set which contains those changes that are not part of an active set
+ */
+ private SyncInfoTree rootSet = new SyncInfoTree();
+
+ private final ChangeSetModelProvider provider;
+
+ public ActiveChangeSetCollector(ISynchronizePageConfiguration configuration, ChangeSetModelProvider provider) {
+ this.configuration = configuration;
+ this.provider = provider;
+ }
+
+ public ISynchronizePageConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ public SubscriberChangeSetCollector getActiveChangeSetManager() {
+ return getConfiguration().getParticipant().getChangeSetCapability().getActiveChangeSetManager();
+ }
+
+ /**
+ * Repopulate the change sets from the seed set.
+ * If <code>null</code> is passed, the state
+ * of the collector is cleared but the set is not
+ * repopulated.
+ *
+ */
+ 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);
+ }
+ activeSets.clear();
+
+ // Now repopulate
+ if (seedSet != null) {
+ provider.createActiveChangeSetModelElements();
+ add(seedSet.getSyncInfos());
+ }
+ }
+
+ public void handleChange(ISyncInfoSetChangeEvent event) {
+ List removals = new ArrayList();
+ List additions = new ArrayList();
+ removals.addAll(Arrays.asList(event.getRemovedResources()));
+ additions.addAll(Arrays.asList(event.getAddedResources()));
+ SyncInfo[] changed = event.getChangedResources();
+ for (int i = 0; i < changed.length; i++) {
+ SyncInfo info = changed[i];
+ additions.add(info);
+ removals.add(info.getLocal());
+ }
+ if (!removals.isEmpty()) {
+ remove((IResource[]) removals.toArray(new IResource[removals.size()]));
+ }
+ if (!additions.isEmpty()) {
+ add((SyncInfo[]) additions.toArray(new SyncInfo[additions.size()]));
+ }
+ }
+
+ /**
+ * Remove the given resources from all sets of this collector.
+ * @param resources the resources to be removed
+ */
+ protected void remove(IResource[] resources) {
+ for (Iterator iter = activeSets.values().iterator(); iter.hasNext();) {
+ SyncInfoSet set = (SyncInfoSet) iter.next();
+ set.removeAll(resources);
+ }
+ rootSet.removeAll(resources);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SyncInfoSetChangeSetCollector#add(org.eclipse.team.core.synchronize.SyncInfo[])
+ */
+ protected void add(SyncInfo[] infos) {
+ for (int i = 0; i < infos.length; i++) {
+ SyncInfo info = infos[i];
+ if (isLocalChange(info) && select(info)) {
+ ChangeSet[] sets = findChangeSets(info);
+ if (sets.length == 0) {
+ rootSet.add(info);
+ } else {
+ for (int j = 0; j < sets.length; j++) {
+ ChangeSet set = sets[j];
+ SyncInfoSet targetSet = (SyncInfoSet)activeSets.get(set);
+ if (targetSet == null) {
+ provider.createActiveChangeSetModelElement(set);
+ targetSet = (SyncInfoSet)activeSets.get(set);
+ }
+ if (targetSet != null) {
+ targetSet.add(info);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private ChangeSet[] findChangeSets(SyncInfo info) {
+ SubscriberChangeSetCollector manager = getActiveChangeSetManager();
+ ChangeSet[] sets = manager.getSets();
+ List result = new ArrayList();
+ for (int i = 0; i < sets.length; i++) {
+ ChangeSet set = sets[i];
+ if (set.contains(info.getLocal())) {
+ result.add(set);
+ }
+ }
+ return (ChangeSet[]) result.toArray(new ChangeSet[result.size()]);
+ }
+
+ /*
+ * Return if this sync info is an outgoing change.
+ */
+ private boolean isLocalChange(SyncInfo info) {
+ return (info.getComparator().isThreeWay()
+ && ((info.getKind() & SyncInfo.DIRECTION_MASK) == SyncInfo.OUTGOING ||
+ (info.getKind() & SyncInfo.DIRECTION_MASK) == SyncInfo.CONFLICTING));
+ }
+
+ public SyncInfoTree getRootSet() {
+ return rootSet;
+ }
+
+ /*
+ * emove the set from the collector. This should
+ * only be caleed after the node for the set
+ * has been removed from the view.
+ */
+ public void remove(ChangeSet set) {
+ set.getSyncInfoSet().removeSyncSetChangedListener(this);
+ activeSets.remove(set);
+ }
+
+ /*
+ * Return the sync info set for the given active change set.
+ * Create one if one doesn't already exist.
+ */
+ public SyncInfoTree getSyncInfoSet(ChangeSet set) {
+ SyncInfoTree sis = (SyncInfoTree)activeSets.get(set);
+ if (sis == null) {
+ sis = new SyncInfoTree();
+ set.getSyncInfoSet().addSyncSetChangedListener(this);
+ activeSets.put(set, sis);
+ }
+ return sis;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void syncInfoSetReset(final SyncInfoSet set, IProgressMonitor monitor) {
+ provider.runViewUpdate(new Runnable() {
+ public void run() {
+ ChangeSet changeSet = getChangeSet(set);
+ if (changeSet != null) {
+ SyncInfoSet targetSet = (SyncInfoSet)activeSets.get(changeSet);
+ if (targetSet != null) {
+ targetSet.clear();
+ targetSet.addAll(select(set.getSyncInfos()));
+ }
+ }
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoChanged(org.eclipse.team.core.synchronize.ISyncInfoSetChangeEvent, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void syncInfoChanged(final ISyncInfoSetChangeEvent event, IProgressMonitor monitor) {
+ provider.runViewUpdate(new Runnable() {
+ public void run() {
+ ChangeSet changeSet = getChangeSet(event.getSet());
+ if (changeSet != null) {
+ SyncInfoSet targetSet = (SyncInfoSet)activeSets.get(changeSet);
+ if (targetSet != null) {
+ targetSet.removeAll(event.getRemovedResources());
+ targetSet.addAll(select(event.getChangedResources()));
+ targetSet.addAll(select(event.getAddedResources()));
+ }
+ }
+ }
+ });
+ }
+
+ private ChangeSet getChangeSet(SyncInfoSet set) {
+ for (Iterator iter = activeSets.keySet().iterator(); iter.hasNext();) {
+ ChangeSet changeSet = (ChangeSet) iter.next();
+ if (changeSet.getSyncInfoSet() == set) {
+ return changeSet;
+ }
+ }
+ return null;
+ }
+
+ private boolean select(SyncInfo info) {
+ return getSeedSet().getSyncInfo(info.getLocal()) != null;
+ }
+
+ private SyncInfoSet select(SyncInfo[] syncInfos) {
+ SyncInfoSet result = new SyncInfoSet();
+ for (int i = 0; i < syncInfos.length; i++) {
+ SyncInfo info = syncInfos[i];
+ if (getSeedSet().getSyncInfo(info.getLocal()) != null) {
+ result.add(info);
+ }
+ }
+ return result;
+ }
+
+ private SyncInfoSet getSeedSet() {
+ return provider.getSyncInfoSet();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetErrors(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.team.core.ITeamStatus[], org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMonitor monitor) {
+ // Errors are not injected into the active change sets
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetActionGroup.java
index 1b29033fb..80f897a78 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetActionGroup.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetActionGroup.java
@@ -24,7 +24,7 @@ import org.eclipse.team.core.synchronize.FastSyncInfoFilter;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.AndSyncInfoFilter;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter;
-import org.eclipse.team.internal.core.Policy;
+import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.actions.TeamAction;
import org.eclipse.team.ui.synchronize.*;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetDiffNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetDiffNode.java
index b05f5feb7..8c39fb40e 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetDiffNode.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetDiffNode.java
@@ -60,4 +60,21 @@ public class ChangeSetDiffNode extends SynchronizeModelElement {
public String toString() {
return getName();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement#hashCode()
+ */
+ public int hashCode() {
+ return set.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement#equals(java.lang.Object)
+ */
+ public boolean equals(Object object) {
+ if (object instanceof ChangeSetDiffNode) {
+ return((ChangeSetDiffNode)object).getSet() == set;
+ }
+ return super.equals(object);
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelManager.java
index 447940c4c..2a1bc969a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelManager.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelManager.java
@@ -27,7 +27,7 @@ public class ChangeSetModelManager extends HierarchicalModelManager implements I
private static final String P_COMMIT_SET_ENABLED = TeamUIPlugin.ID + ".P_COMMIT_SET_ENABLED"; //$NON-NLS-1$
- public static final String COMMIT_SET_GROUP = "CommitSet"; //$NON-NLS-1$
+ public static final String CHANGE_SET_GROUP = "ChangeSet"; //$NON-NLS-1$
boolean enabled = false;
@@ -52,7 +52,7 @@ public class ChangeSetModelManager extends HierarchicalModelManager implements I
appendToGroup(
ISynchronizePageConfiguration.P_TOOLBAR_MENU,
- COMMIT_SET_GROUP,
+ CHANGE_SET_GROUP,
new ToggleCommitSetAction());
}
}
@@ -60,7 +60,7 @@ public class ChangeSetModelManager extends HierarchicalModelManager implements I
public ChangeSetModelManager(ISynchronizePageConfiguration configuration) {
super(configuration);
configuration.addPropertyChangeListener(this);
- configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, COMMIT_SET_GROUP);
+ configuration.addMenuGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, CHANGE_SET_GROUP);
configuration.addActionContribution(new CommitSetActionContribution());
if (configuration.getParticipant().getChangeSetCapability().supportsActiveChangeSets()) {
configuration.addLabelDecorator(new ChangeSetLabelDecorator(configuration));
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 990eb4428..b05c1958d 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,6 +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.ChangeSet;
import org.eclipse.team.core.subscribers.IChangeSetChangeListener;
import org.eclipse.team.core.synchronize.*;
@@ -40,9 +41,9 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
private ViewerSorter embeddedSorter;
- SyncInfoSetChangeSetCollector collector;
+ private SyncInfoSetChangeSetCollector checkedInCollector;
- IChangeSetChangeListener collectorListener = new IChangeSetChangeListener() {
+ private IChangeSetChangeListener checkedInCollectorListener = new IChangeSetChangeListener() {
/* (non-Javadoc)
* @see org.eclipse.team.core.subscribers.IChangeSetChangeListener#setAdded(org.eclipse.team.core.subscribers.ChangeSet)
@@ -70,12 +71,7 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
* @see org.eclipse.team.core.subscribers.IChangeSetChangeListener#setRemoved(org.eclipse.team.core.subscribers.ChangeSet)
*/
public void setRemoved(ChangeSet set) {
- ISynchronizeModelElement node = getModelElement(set);
- if (node != null) {
- ISynchronizeModelProvider provider = getProviderRootedAt(node);
- clearModelObjects(node);
- removeProvider(provider);
- }
+ removeModelElementForSet(set);
}
/* (non-Javadoc)
@@ -94,6 +90,60 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
}
};
+ private ActiveChangeSetCollector activeCollector;
+
+ private IChangeSetChangeListener activeChangeSetListener = new IChangeSetChangeListener() {
+
+ public void setAdded(final ChangeSet set) {
+ syncExec(new Runnable() {
+ public void run() {
+ // Remove any resources that are in the new set
+ activeCollector.remove(set.getResources());
+ createActiveChangeSetModelElement(set);
+ }
+ });
+
+ }
+
+ public void defaultSetChanged(final ChangeSet previousDefault, final ChangeSet set) {
+ syncExec(new Runnable() {
+ public void run() {
+ // Refresh the label for both of the sets involved
+ refreshLabel(getModelElement(previousDefault));
+ refreshLabel(getModelElement(set));
+ }
+ });
+ }
+
+ private void refreshLabel(final ISynchronizeModelElement node) {
+ if (node != null) {
+ getViewer().refresh(node);
+ }
+ }
+
+ public void setRemoved(final ChangeSet set) {
+ syncExec(new Runnable() {
+ public void run() {
+ removeModelElementForSet(set);
+ activeCollector.remove(set);
+ }
+ });
+ }
+
+ public void nameChanged(final ChangeSet set) {
+ syncExec(new Runnable() {
+ public void run() {
+ refreshLabel(getModelElement(set));
+ }
+ });
+ }
+
+ public void resourcesChanged(final ChangeSet set, final IResource[] resources) {
+ // Changes are handled by the sets themselves.
+ }
+
+ };
+
/* *****************************************************************************
* Descriptor for this model provider
*/
@@ -114,24 +164,41 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
protected ChangeSetModelProvider(ISynchronizePageConfiguration configuration, SyncInfoSet set, String subProvierId) {
super(configuration, set);
this.subProvierId = subProvierId;
- collector = getChangeSetCapability().createCheckedInChangeSetCollector(configuration);
- collector.setProvider(this);
- collector.addListener(collectorListener);
+ ChangeSetCapability changeSetCapability = getChangeSetCapability();
+ if (changeSetCapability.supportsCheckedInChangeSets()) {
+ checkedInCollector = changeSetCapability.createCheckedInChangeSetCollector(configuration);
+ checkedInCollector.setProvider(this);
+ checkedInCollector.addListener(checkedInCollectorListener);
+ }
+ if (changeSetCapability.supportsActiveChangeSets()) {
+ activeCollector = new ActiveChangeSetCollector(configuration, this);
+ activeCollector.getActiveChangeSetManager().addListener(activeChangeSetListener);
+ configuration.addMenuGroup(ISynchronizePageConfiguration.P_CONTEXT_MENU, ChangeSetActionGroup.CHANGE_SET_GROUP);
+ }
}
/* (non-Javadoc)
* @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) {
- collector.handleChange(event);
- // super.handleChanges(event, monitor); TODO Handle outgoing changes
+ if (checkedInCollector != null && getConfiguration().getMode() == ISynchronizePageConfiguration.INCOMING_MODE) {
+ checkedInCollector.handleChange(event);
+ } else if (activeCollector != null && getConfiguration().getMode() == ISynchronizePageConfiguration.OUTGOING_MODE) {
+ activeCollector.handleChange(event);
+ } else {
+ // Forward the event to the root provider
+ ISynchronizeModelProvider provider = getProviderRootedAt(getModelRoot());
+ if (provider != null) {
+ ((SynchronizeModelProvider)provider).syncInfoChanged(event, monitor);
+ }
+ }
}
/* (non-Javadoc)
* @see org.eclipse.team.internal.ui.synchronize.CompositeModelProvider#handleAddition(org.eclipse.team.core.synchronize.SyncInfo)
*/
protected void handleAddition(SyncInfo info) {
- // TODO: Nothing to do since change handling was bypassed
+ // Nothing to do since change handling was bypassed
}
/* (non-Javadoc)
@@ -139,9 +206,31 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
*/
protected IDiffElement[] buildModelObjects(ISynchronizeModelElement node) {
// This method is invoked on a reset after the provider state has been cleared.
- // Reseting the collector will rebuild the model
+ // Resetting the collector will rebuild the model
+
if (node == getModelRoot()) {
- collector.reset(getSyncInfoSet());
+
+ // First, disable the collectors
+ checkedInCollector.reset(null);
+ checkedInCollector.removeListener(checkedInCollectorListener);
+ activeCollector.reset(null);
+ activeCollector.getActiveChangeSetManager().removeListener(activeChangeSetListener);
+
+ // Then, re-enable the proper collection method
+ if (checkedInCollector != null && getConfiguration().getMode() == ISynchronizePageConfiguration.INCOMING_MODE) {
+ checkedInCollector.addListener(checkedInCollectorListener);
+ checkedInCollector.reset(getSyncInfoSet());
+
+ } else if (activeCollector != null && getConfiguration().getMode() == ISynchronizePageConfiguration.OUTGOING_MODE) {
+ activeCollector.getActiveChangeSetManager().addListener(activeChangeSetListener);
+ activeCollector.reset(getSyncInfoSet());
+ } else {
+ // Forward the sync info to the root provider and trigger a build
+ ISynchronizeModelProvider provider = getProviderRootedAt(getModelRoot());
+ if (provider != null) {
+ ((SynchronizeModelProvider)provider).getSyncInfoSet().addAll(getSyncInfoSet());
+ }
+ }
}
return new IDiffElement[0];
}
@@ -238,7 +327,14 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
*/
private void createRootProvider() {
// Recreate the sub-provider at the root and use it's viewer sorter and action group
- final ISynchronizeModelProvider provider = createProviderRootedAt(getModelRoot(), new SyncInfoTree());
+ SyncInfoTree tree;
+ if (activeCollector != null && getConfiguration().getMode() == ISynchronizePageConfiguration.OUTGOING_MODE) {
+ // When in outgoing mode, use the root set of the active change set collector at the root
+ tree = activeCollector.getRootSet();
+ } else {
+ tree = new SyncInfoTree();
+ }
+ final ISynchronizeModelProvider provider = createProviderRootedAt(getModelRoot(), tree);
embeddedSorter = provider.getViewerSorter();
if (provider instanceof AbstractSynchronizeModelProvider) {
SynchronizePageActionGroup actionGroup = ((AbstractSynchronizeModelProvider)provider).getActionGroup();
@@ -267,7 +363,7 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
/*
* Find the root element for the given change set.
- * A linear searhc is used,
+ * A linear search is used.
*/
protected ISynchronizeModelElement getModelElement(ChangeSet set) {
IDiffElement[] children = getModelRoot().getChildren();
@@ -288,8 +384,67 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
}
public void dispose() {
- collector.removeListener(collectorListener);
- collector.dispose();
+ if (checkedInCollector != null) {
+ checkedInCollector.removeListener(checkedInCollectorListener);
+ checkedInCollector.dispose();
+ }
+ if (activeCollector != null) {
+ activeCollector.getActiveChangeSetManager().removeListener(activeChangeSetListener);
+ }
super.dispose();
}
+
+
+ public void waitUntilDone(IProgressMonitor monitor) {
+ super.waitUntilDone(monitor);
+ 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();
+ }
+ }
+ });
+ }
+ }
+
+ private void removeModelElementForSet(final ChangeSet set) {
+ ISynchronizeModelElement node = getModelElement(set);
+ if (node != null) {
+ ISynchronizeModelProvider provider = getProviderRootedAt(node);
+ clearModelObjects(node);
+ removeProvider(provider);
+ }
+ }
+
+ public void createActiveChangeSetModelElements() {
+ ChangeSet[] sets = activeCollector.getActiveChangeSetManager().getSets();
+ for (int i = 0; i < sets.length; i++) {
+ ChangeSet set = sets[i];
+ createActiveChangeSetModelElement(set);
+ }
+ }
+
+ public void createActiveChangeSetModelElement(final ChangeSet set) {
+ // Add the model element and provider for the set
+ ISynchronizeModelElement node = getModelElement(set);
+ ISynchronizeModelProvider provider = null;
+ if (node != null) {
+ provider = getProviderRootedAt(node);
+ }
+ if (provider == null) {
+ provider = createActiveChangeSetProvider(set, activeCollector.getSyncInfoSet(set));
+ }
+ provider.prepareInput(null);
+ }
+
+ private ISynchronizeModelProvider createActiveChangeSetProvider(ChangeSet set, SyncInfoTree tree) {
+ ChangeSetDiffNode node = new ChangeSetDiffNode(getModelRoot(), set);
+ return createProviderRootedAt(node, tree);
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java
index ede09be78..6c3220788 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java
@@ -148,6 +148,7 @@ public abstract class StructuredViewerAdvisor implements IAdaptable {
modelManager = (SynchronizeModelManager)configuration.getProperty(SynchronizePageConfiguration.P_MODEL_MANAGER);
if(modelManager == null) {
modelManager = createModelManager(configuration);
+ configuration.setProperty(SynchronizePageConfiguration.P_MODEL_MANAGER, modelManager);
}
Assert.isNotNull(modelManager, "model manager must be set"); //$NON-NLS-1$
modelManager.setViewerAdvisor(this);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java
index 24571fa8a..c5ee46202 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java
@@ -189,7 +189,7 @@ public abstract class SynchronizeModelManager extends SynchronizePageActionGroup
*/
public ISelection getSelection(Object[] objects) {
if (modelProvider != null && modelProvider instanceof SynchronizeModelProvider) {
- ((SynchronizeModelProvider)modelProvider).waitForUpdateHandler(new IProgressMonitor() {
+ ((SynchronizeModelProvider)modelProvider).waitUntilDone(new IProgressMonitor() {
public void beginTask(String name, int totalWork) {
}
public void done() {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetChangeSetCollector.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetChangeSetCollector.java
index a34aa6054..ce7e0b7c1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetChangeSetCollector.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetChangeSetCollector.java
@@ -74,7 +74,6 @@ public abstract class SyncInfoSetChangeSetCollector extends ChangeSetCollector {
}
};
-
/**
* Create a collector that contains the sync info from the given seed set
* @param seedSet the set used to determine which sync info
@@ -119,6 +118,8 @@ public abstract class SyncInfoSetChangeSetCollector extends ChangeSetCollector {
/**
* Repopulate the change sets from the seed set.
+ * If <code>null</code> is passed, clear any state
+ * but do not repopulate.
*
*/
public void reset(SyncInfoSet seedSet) {
@@ -128,7 +129,9 @@ public abstract class SyncInfoSetChangeSetCollector extends ChangeSetCollector {
ChangeSet set2 = sets[i];
remove(set2);
}
- add(seedSet.getSyncInfos());
+ if (seedSet != null) {
+ add(seedSet.getSyncInfos());
+ }
}
public void handleChange(ISyncInfoSetChangeEvent event) {
@@ -164,4 +167,14 @@ public abstract class SyncInfoSetChangeSetCollector extends ChangeSetCollector {
public void setProvider(ChangeSetModelProvider provider) {
this.provider = provider;
}
+
+ /**
+ * This method should wait unti any background processing is
+ * completed. It is for testing purposes. By default, it does not wait at all.
+ * Subclasses that perform work in the background should override.
+ * @param monitor a progress monitor
+ */
+ public void waitUntilDone(IProgressMonitor monitor) {
+ // Do nothing, by default
+ }
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/One CVS Test.launch b/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/One CVS Test.launch
index b0ab96d21..9828795a9 100644
--- a/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/One CVS Test.launch
+++ b/tests/org.eclipse.team.tests.cvs.core/launchConfigurations/One CVS Test.launch
@@ -3,14 +3,14 @@
<stringAttribute key="product" value="org.eclipse.platform.ide"/>
<booleanAttribute key="clearws" value="true"/>
<stringAttribute key="bootstrap" value=""/>
-<booleanAttribute key="useProduct" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.team.tests.ccvs.core.subscriber.CVSChangeSetTests"/>
+<booleanAttribute key="useProduct" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<stringAttribute key="location1" value="C:\Eclipse\Latest-Eclipse-Drop\eclipse\runtime-test-workspace"/>
+<stringAttribute key="vmargs" value="-Declipse.cvs.properties=c:\eclipse\repository.properties -Declipse.cvs.testName=testSimpleCommit"/>
<booleanAttribute key="default" value="true"/>
-<stringAttribute key="vmargs" value="-Declipse.cvs.properties=c:\eclipse\repository.properties -Declipse.cvs.testName2=testIncomingChanges"/>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="clearConfig" value="true"/>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java
index 215deb038..5d9ecd8fc 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java
@@ -11,6 +11,7 @@
package org.eclipse.team.tests.ccvs.core.subscriber;
import java.io.ByteArrayInputStream;
+import java.util.*;
import java.util.ArrayList;
import java.util.List;
@@ -19,7 +20,8 @@ import junit.framework.Test;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.*;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.*;
import org.eclipse.team.core.synchronize.SyncInfo;
@@ -50,9 +52,11 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
private void assertIncomingChangesInSets(IFile[][] files, String[] messages) throws CoreException {
// Get the workspace subscriber which also creates a participant and page in the sync view
Subscriber workspaceSubscriber = getWorkspaceSubscriber();
- enableChangeSets(workspaceSubscriber);
refresh(workspaceSubscriber);
ISynchronizeModelElement root = getModelRoot(workspaceSubscriber);
+ ChangeSetDiffNode[] nodes = getCheckedInChangeSetNodes(root);
+ assertNodesInViewer(workspaceSubscriber, nodes);
+ assertEquals("The number of change sets in the sync view do not match the expected number", messages.length, nodes.length);
for (int i = 0; i < messages.length; i++) {
String message = messages[i];
ChangeSetDiffNode node = getCommitSetFor(root, message);
@@ -66,7 +70,43 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
}
}
}
-
+
+ private void assertNodesInViewer(Subscriber workspaceSubscriber, ChangeSetDiffNode[] nodes) throws PartInitException {
+ ISynchronizeParticipant participant = SynchronizeViewTestAdapter.getParticipant(workspaceSubscriber);
+ SubscriberParticipantPage page = (SubscriberParticipantPage)SynchronizeViewTestAdapter.getSyncViewPage(participant);
+ TreeViewer viewer = (TreeViewer)page.getViewer();
+ Tree tree = viewer.getTree();
+ List nodeList = new ArrayList();
+ nodeList.addAll(Arrays.asList(nodes));
+ TreeItem[] items = tree.getItems();
+ removeTreeItemsFromList(nodeList, items);
+ assertTrue("Not all nodes are visible in the view", nodeList.isEmpty());
+ }
+
+ private void removeTreeItemsFromList(List nodeList, TreeItem[] items) {
+ for (int i = 0; i < items.length; i++) {
+ TreeItem item = items[i];
+ nodeList.remove(item.getData());
+ TreeItem[] children = item.getItems();
+ removeTreeItemsFromList(nodeList, children);
+ }
+ }
+
+ private ChangeSetDiffNode[] getCheckedInChangeSetNodes(ISynchronizeModelElement root) {
+ List result = new ArrayList();
+ IDiffElement[] children = root.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ IDiffElement element = children[i];
+ if (element instanceof ChangeSetDiffNode) {
+ ChangeSetDiffNode node = (ChangeSetDiffNode)element;
+ if (node.getSet() instanceof CheckedInChangeSet) {
+ result.add(node);
+ }
+ }
+ }
+ return (ChangeSetDiffNode[]) result.toArray(new ChangeSetDiffNode[result.size()]);
+ }
+
/**
* Adds IFiles to the list
*/
@@ -109,6 +149,20 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
page.getConfiguration().setMode(ISynchronizePageConfiguration.BOTH_MODE);
}
+ private void enableCheckedInChangeSets(Subscriber workspaceSubscriber) throws PartInitException {
+ enableChangeSets(workspaceSubscriber);
+ ISynchronizeParticipant participant = SynchronizeViewTestAdapter.getParticipant(workspaceSubscriber);
+ SubscriberParticipantPage page = (SubscriberParticipantPage)SynchronizeViewTestAdapter.getSyncViewPage(participant);
+ page.getConfiguration().setMode(ISynchronizePageConfiguration.INCOMING_MODE);
+ }
+
+ private void enableActiveChangeSets(Subscriber workspaceSubscriber) throws PartInitException {
+ enableChangeSets(workspaceSubscriber);
+ ISynchronizeParticipant participant = SynchronizeViewTestAdapter.getParticipant(workspaceSubscriber);
+ SubscriberParticipantPage page = (SubscriberParticipantPage)SynchronizeViewTestAdapter.getSyncViewPage(participant);
+ page.getConfiguration().setMode(ISynchronizePageConfiguration.OUTGOING_MODE);
+ }
+
/*
* Wait until all the background handlers have settled and then return the root element in the sync view
*/
@@ -118,7 +172,7 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
SubscriberParticipantPage page = (SubscriberParticipantPage)SynchronizeViewTestAdapter.getSyncViewPage(participant);
ChangeSetModelManager manager = (ChangeSetModelManager)page.getConfiguration().getProperty(SynchronizePageConfiguration.P_MODEL_MANAGER);
AbstractSynchronizeModelProvider provider = (AbstractSynchronizeModelProvider)manager.getActiveModelProvider();
- provider.waitForUpdateHandler(new IProgressMonitor() {
+ provider.waitUntilDone(new IProgressMonitor() {
public void beginTask(String name, int totalWork) {
}
public void done() {
@@ -254,6 +308,8 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
}
public void testSimpleCommit() throws CoreException {
+ enableCheckedInChangeSets(getWorkspaceSubscriber());
+
IProject project = createProject(new String[] { "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
// Modify a file in a copy
@@ -282,12 +338,19 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
{ project.getFile("folder1/a.txt") },
{ project.getFile("file2.txt")}
}, new String[] {message1, message2, message3});
+
+ // Now commit the files in one of the sets and ensure it is removed from the view
+ updateResources(new IResource[] { project.getFile("file1.txt")}, false);
+ assertIncomingChangesInSets(new IFile[][] {
+ { project.getFile("folder1/a.txt") },
+ { project.getFile("file2.txt")}
+ }, new String[] {message2, message3});
}
public void testSimpleActiveChangeSet() throws CoreException {
IProject project = createProject(new String[] { "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
// Enable Change Sets
- enableChangeSets(getWorkspaceSubscriber());
+ enableActiveChangeSets(getWorkspaceSubscriber());
// Add a folder and file
IFolder newFolder = project.getFolder("folder2");
newFolder.create(false, true, null);

Back to the top