Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2003-10-14 19:14:52 +0000
committerJean Michel-Lemieux2003-10-14 19:14:52 +0000
commite48b69ed99cf4c7b2923bce0a76fed7ee2b10240 (patch)
tree2abae92c9f1e7f13096904602ce129e092e32ac7
parent5eb6420b3e29781b4784f79a5894945da01b830e (diff)
downloadeclipse.platform.team-e48b69ed99cf4c7b2923bce0a76fed7ee2b10240.tar.gz
eclipse.platform.team-e48b69ed99cf4c7b2923bce0a76fed7ee2b10240.tar.xz
eclipse.platform.team-e48b69ed99cf4c7b2923bce0a76fed7ee2b10240.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/AndSyncInfoFilter.java35
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/CompoundSyncInfoFilter.java19
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/SyncInfoDirectionFilter.java42
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/SyncInfoSet.java206
4 files changed, 302 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/AndSyncInfoFilter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/AndSyncInfoFilter.java
new file mode 100644
index 000000000..6c89ba7bb
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/AndSyncInfoFilter.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.ui.sync.actions;
+
+import org.eclipse.team.core.subscribers.SyncInfo;
+
+/**
+ * Selects SyncInfo which match all child filters
+ */
+public class AndSyncInfoFilter extends CompoundSyncInfoFilter {
+ public AndSyncInfoFilter(SyncInfoFilter[] filters) {
+ super(filters);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ccvs.syncviews.views.SyncSetFilter#select(org.eclipse.team.core.sync.SyncInfo)
+ */
+ public boolean select(SyncInfo info) {
+ for (int i = 0; i < filters.length; i++) {
+ SyncInfoFilter filter = filters[i];
+ if (!filter.select(info)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/CompoundSyncInfoFilter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/CompoundSyncInfoFilter.java
new file mode 100644
index 000000000..6432f18f6
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/CompoundSyncInfoFilter.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.ui.sync.actions;
+
+
+public abstract class CompoundSyncInfoFilter extends SyncInfoFilter {
+ protected SyncInfoFilter[] filters;
+ public CompoundSyncInfoFilter(SyncInfoFilter[] filters) {
+ this.filters = filters;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/SyncInfoDirectionFilter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/SyncInfoDirectionFilter.java
new file mode 100644
index 000000000..3bd4ac238
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/SyncInfoDirectionFilter.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.ui.sync.actions;
+
+import org.eclipse.team.core.subscribers.SyncInfo;
+
+/**
+ * Filter the SyncInfo by a set of directions (incoming, outgoing, conflict)
+ */
+public class SyncInfoDirectionFilter extends SyncInfoFilter {
+
+ int[] directionFilters = new int[] {SyncInfo.OUTGOING, SyncInfo.INCOMING, SyncInfo.CONFLICTING};
+
+ public SyncInfoDirectionFilter(int[] directionFilters) {
+ this.directionFilters = directionFilters;
+ }
+
+ public SyncInfoDirectionFilter(int direction) {
+ this(new int[] { direction });
+ }
+
+ /* (non-Javadoc)
+ * @see SyncSetFilter#select(org.eclipse.team.core.sync.SyncInfo)
+ */
+ public boolean select(SyncInfo info) {
+ int syncKind = info.getKind();
+ for (int i = 0; i < directionFilters.length; i++) {
+ int filter = directionFilters[i];
+ if ((syncKind & SyncInfo.DIRECTION_MASK) == filter)
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/SyncInfoSet.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/SyncInfoSet.java
new file mode 100644
index 000000000..aa3677cc0
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/actions/SyncInfoSet.java
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * 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.ui.sync.actions;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.team.core.subscribers.SyncInfo;
+
+public class SyncInfoSet {
+
+ Set set = new HashSet();
+
+ public SyncInfoSet(SyncInfo[] resources) {
+ set.addAll(Arrays.asList(resources));
+ }
+ /**
+ * Returns true if there are any conflicting nodes in the set, and
+ * false otherwise.
+ */
+ public boolean hasConflicts() {
+ return hasNodes(new SyncInfoDirectionFilter(SyncInfo.CONFLICTING));
+ }
+
+ /**
+ * Returns true if this sync set has incoming changes.
+ * Note that conflicts are not considered to be incoming changes.
+ */
+ public boolean hasIncomingChanges() {
+ return hasNodes(new SyncInfoDirectionFilter(SyncInfo.INCOMING));
+ }
+
+ /**
+ * Returns true if this sync set has outgoing changes.
+ * Note that conflicts are not considered to be outgoing changes.
+ */
+ public boolean hasOutgoingChanges() {
+ return hasNodes(new SyncInfoDirectionFilter(SyncInfo.OUTGOING));
+ }
+
+ /**
+ * Returns true if this sync set has auto-mergeable conflicts.
+ */
+ public boolean hasAutoMergeableConflicts() {
+ return hasNodes(new AutomergableFilter());
+ }
+
+ /**
+ * Removes all conflicting nodes from this set.
+ */
+ public void removeConflictingNodes() {
+ rejectNodes(new SyncInfoDirectionFilter(SyncInfo.CONFLICTING));
+ }
+ /**
+ * Removes all outgoing nodes from this set.
+ */
+ public void removeOutgoingNodes() {
+ rejectNodes(new SyncInfoDirectionFilter(SyncInfo.OUTGOING));
+ }
+ /**
+ * Removes all incoming nodes from this set.
+ */
+ public void removeIncomingNodes() {
+ rejectNodes(new SyncInfoDirectionFilter(SyncInfo.INCOMING));
+ }
+
+ /**
+ * Removes all nodes from this set that are not auto-mergeable conflicts
+ */
+ public void removeNonMergeableNodes() {
+ for (Iterator it = set.iterator(); it.hasNext();) {
+ SyncInfo node = (SyncInfo)it.next();
+ if ((node.getKind() & SyncInfo.MANUAL_CONFLICT) != 0) {
+ it.remove();
+ } else if ((node.getKind() & SyncInfo.DIRECTION_MASK) != SyncInfo.CONFLICTING) {
+ it.remove();
+ }
+ }
+ }
+
+ /**
+ * Indicate whether the set has nodes matching the given filter
+ */
+ public boolean hasNodes(SyncInfoFilter filter) {
+ for (Iterator it = set.iterator(); it.hasNext();) {
+ SyncInfo info = (SyncInfo)it.next();
+ if (info != null && filter.select(info)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Removes all nodes from this set that do not match the given filter
+ */
+ public void selectNodes(SyncInfoFilter filter) {
+ for (Iterator it = set.iterator(); it.hasNext();) {
+ SyncInfo info = (SyncInfo)it.next();
+ if (info == null || !filter.select(info)) {
+ it.remove();
+ }
+ }
+ }
+
+ /**
+ * Removes all nodes from this set that match the given filter
+ */
+ public void rejectNodes(SyncInfoFilter filter) {
+ for (Iterator it = set.iterator(); it.hasNext();) {
+ SyncInfo info = (SyncInfo)it.next();
+ if (info != null && filter.select(info)) {
+ it.remove();
+ }
+ }
+ }
+
+ /**
+ * Return all nodes in this set that match the given filter
+ */
+ public SyncInfo[] getNodes(SyncInfoFilter filter) {
+ List result = new ArrayList();
+ for (Iterator it = set.iterator(); it.hasNext();) {
+ SyncInfo info = (SyncInfo)it.next();
+ if (info != null && filter.select(info)) {
+ result.add(info);
+ }
+ }
+ return (SyncInfo[]) result.toArray(new SyncInfo[result.size()]);
+ }
+
+ public SyncInfo[] getSyncInfos() {
+ return (SyncInfo[]) set.toArray(new SyncInfo[set.size()]);
+ }
+
+ /**
+ * Returns the resources from all the nodes in this set.
+ */
+ public IResource[] getResources() {
+ SyncInfo[] changed = getSyncInfos();
+ IResource[] resources = new IResource[changed.length];
+ for (int i = 0; i < changed.length; i++) {
+ resources[i] = changed[i].getLocal();
+ }
+ return resources;
+ }
+
+ public boolean isEmpty() {
+ return set.isEmpty();
+ }
+
+ public void removeResources(IResource[] resources) {
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ removeResource(resource);
+ }
+ }
+
+ private void removeResource(IResource resource) {
+ for (Iterator it = set.iterator(); it.hasNext();) {
+ SyncInfo node = (SyncInfo)it.next();
+ if (node.getLocal().equals(resource)) {
+ it.remove();
+ // short-circuit the operation once a match is found
+ return;
+ }
+ }
+ }
+
+ public int size() {
+ return set.size();
+ }
+
+ public SyncInfo getNodeFor(IResource resource) {
+ for (Iterator it = set.iterator(); it.hasNext();) {
+ SyncInfo node = (SyncInfo)it.next();
+ if (node.getLocal().equals(resource)) {
+ return node;
+ }
+ }
+ return null;
+ }
+
+ public void addAll(SyncInfoSet set) {
+ SyncInfo[] resources = set.getSyncInfos();
+ for (int i = 0; i < resources.length; i++) {
+ SyncInfo resource = resources[i];
+ this.set.add(resource);
+ }
+
+ }
+}
+

Back to the top