Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames2002-02-11 22:49:59 +0000
committerjames2002-02-11 22:49:59 +0000
commitc81af9eb0e5bb3b45012de5417a78a5b7790fbf0 (patch)
tree471879ec5721dcbebc967d46a948674c379bfe32
parent9ffc626a8b1a2f24b52cb76955e71f8deaa93e06 (diff)
downloadeclipse.platform.team-c81af9eb0e5bb3b45012de5417a78a5b7790fbf0.tar.gz
eclipse.platform.team-c81af9eb0e5bb3b45012de5417a78a5b7790fbf0.tar.xz
eclipse.platform.team-c81af9eb0e5bb3b45012de5417a78a5b7790fbf0.zip
Add Ignore action to sync viewer
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/IgnoreAction.java111
1 files changed, 111 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/IgnoreAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/IgnoreAction.java
new file mode 100644
index 000000000..033ac5b86
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/IgnoreAction.java
@@ -0,0 +1,111 @@
+package org.eclipse.team.internal.ccvs.ui.sync;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2002.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.compare.structuremergeviewer.IDiffContainer;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.sync.IRemoteSyncElement;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
+import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
+import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
+import org.eclipse.team.ui.sync.ChangedTeamContainer;
+import org.eclipse.team.ui.sync.ITeamNode;
+import org.eclipse.team.ui.sync.SyncSet;
+import org.eclipse.team.ui.sync.TeamFile;
+import org.eclipse.team.ui.sync.UnchangedTeamContainer;
+
+public class IgnoreAction extends Action {
+ Shell shell;
+ private CVSSyncCompareInput diffModel;
+ private ISelectionProvider selectionProvider;
+
+ public IgnoreAction(CVSSyncCompareInput model, ISelectionProvider sp, String label, Shell shell) {
+ super(label);
+ this.shell = shell;
+ this.diffModel = model;
+ this.selectionProvider = sp;
+ }
+ public void run() {
+ IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection();
+ if (selection.isEmpty()) return;
+ // Do the update
+ Object first = selection.getFirstElement();
+ ICVSResource cvsResource = null;
+ if (first instanceof TeamFile) {
+ IResource resource = ((TeamFile)first).getMergeResource().getResource();
+ cvsResource = new LocalFile(resource.getLocation().toFile());
+ } else if (first instanceof ChangedTeamContainer) {
+ IResource resource = ((ChangedTeamContainer)first).getMergeResource().getResource();
+ cvsResource = new LocalFolder(resource.getLocation().toFile());
+ }
+ if (cvsResource != null) {
+ try {
+ cvsResource.setIgnored();
+ } catch (CVSException e) {
+ ErrorDialog.openError(shell, null, null, e.getStatus());
+ return;
+ }
+ removeNodes(new SyncSet(selection).getChangedNodes());
+ diffModel.updateView();
+ }
+ }
+ /**
+ * Enabled if only one item is selected and it is an outgoing addition.
+ *
+ * This may be a folder or a single file, which will be handled differently.
+ */
+ protected boolean isEnabled(Object[] nodes) {
+ if (nodes.length != 1) return false;
+ if (!(nodes[0] instanceof ITeamNode)) return false;
+ ITeamNode node = (ITeamNode)nodes[0];
+ return node.getKind() == (ITeamNode.OUTGOING | IRemoteSyncElement.ADDITION);
+ }
+ public void update() {
+ IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection();
+ setEnabled(isEnabled(selection.toArray()));
+ }
+ /**
+ * The given nodes have been synchronized. Remove them from
+ * the sync set.
+ */
+ private void removeNodes(final ITeamNode[] nodes) {
+ // Update the model
+ for (int i = 0; i < nodes.length; i++) {
+ if (nodes[i].getClass() == UnchangedTeamContainer.class) {
+ // Unchanged containers get removed automatically when all
+ // children are removed
+ continue;
+ }
+ if (nodes[i].getClass() == ChangedTeamContainer.class) {
+ // If this node still has children, convert to an
+ // unchanged container, then it will disappear when
+ // all children have been removed.
+ ChangedTeamContainer container = (ChangedTeamContainer)nodes[i];
+ IDiffElement[] children = container.getChildren();
+ if (children.length > 0) {
+ IDiffContainer parent = container.getParent();
+ UnchangedTeamContainer unchanged = new UnchangedTeamContainer(parent, container.getResource());
+ for (int j = 0; j < children.length; j++) {
+ unchanged.add(children[j]);
+ }
+ parent.removeToRoot(container);
+ continue;
+ }
+ // No children, it will get removed below.
+ }
+ nodes[i].getParent().removeToRoot(nodes[i]);
+ }
+ }
+}

Back to the top