Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-01-23 15:24:50 -0500
committerMichael Valenta2004-01-23 15:24:50 -0500
commite3a74a1c79508e1a80fd16441b3ca73c02a94a2b (patch)
tree9e2e40d39d12dd04ef4e67489317635b6206ac9e
parentc1b1fed64fb06e62086ebaaf6e81bcba8e047a2f (diff)
downloadeclipse.platform.team-e3a74a1c79508e1a80fd16441b3ca73c02a94a2b.tar.gz
eclipse.platform.team-e3a74a1c79508e1a80fd16441b3ca73c02a94a2b.tar.xz
eclipse.platform.team-e3a74a1c79508e1a80fd16441b3ca73c02a94a2b.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/ExpandAllAction.java55
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/SyncInfoDiffTreeNavigator.java83
2 files changed, 85 insertions, 53 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/ExpandAllAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/ExpandAllAction.java
new file mode 100644
index 000000000..5a61bfe40
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/ExpandAllAction.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.synchronize.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.*;
+
+
+public class ExpandAllAction extends Action implements ISelectionChangedListener {
+
+ private final AbstractTreeViewer viewer;
+
+ public ExpandAllAction(AbstractTreeViewer viewer) {
+ this.viewer = viewer;
+ viewer.addSelectionChangedListener(this);
+ }
+ public void run() {
+ expandAllFromSelection();
+ }
+
+ protected void expandAllFromSelection() {
+ AbstractTreeViewer tree = viewer;
+ if (tree == null) return;
+ ISelection selection = tree.getSelection();
+ if(! selection.isEmpty()) {
+ Iterator elements = ((IStructuredSelection)selection).iterator();
+ while (elements.hasNext()) {
+ Object next = elements.next();
+ tree.expandToLevel(next, AbstractTreeViewer.ALL_LEVELS);
+ }
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ setEnabled(!ss.isEmpty());
+ return;
+ }
+ setEnabled(false);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/SyncInfoDiffTreeNavigator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/SyncInfoDiffTreeNavigator.java
index 3a24b9048..9da7d78f1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/SyncInfoDiffTreeNavigator.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/actions/SyncInfoDiffTreeNavigator.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.team.ui.synchronize.actions;
-import java.util.Iterator;
-
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.NavigationAction;
import org.eclipse.core.resources.IResource;
@@ -31,14 +29,35 @@ import org.eclipse.team.ui.synchronize.SyncInfoDiffNode;
*/
public class SyncInfoDiffTreeNavigator {
+ private final class OpenAction extends Action {
+ public void run() {
+ target.openSelection();
+ }
+ public void update() {
+ ISelection selection = target.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ if (ss.size() == 1) {
+ Object element = ss.getFirstElement();
+ if (element instanceof SyncInfoDiffNode) {
+ IResource resource = ((SyncInfoDiffNode)element).getResource();
+ setEnabled(resource != null && resource.getType() == IResource.FILE);
+ return;
+ }
+ }
+ }
+ setEnabled(false);
+ }
+ }
+
/**
* Direction to navigate
*/
final public static int NEXT = 1;
final public static int PREVIOUS = 2;
- private Action expandAll;
- private Action open;
+ private ExpandAllAction expandAll;
+ private OpenAction open;
private NavigationAction nextAction;
private NavigationAction previousAction;
@@ -222,68 +241,26 @@ public class SyncInfoDiffTreeNavigator {
}
public void createActions(final StructuredViewer viewer) {
- expandAll = new Action() {
- public void run() {
- expandAllFromSelection(viewer);
- }
- // TODO: needs to be invoked when the selection changes
- public void update() {
- ISelection selection = target.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection)selection;
- setEnabled(!ss.isEmpty());
- }
- setEnabled(false);
- }
- };
- Utils.initAction(expandAll, "action.expandAll."); //$NON-NLS-1$
+ AbstractTreeViewer abstractTreeViewer = getAbstractTreeViewer(viewer);
+ if (abstractTreeViewer != null) {
+ expandAll = new ExpandAllAction(abstractTreeViewer);
+ Utils.initAction(expandAll, "action.expandAll."); //$NON-NLS-1$
+ }
- open = new Action() {
- public void run() {
- target.openSelection();
- }
- // TODO: needs to be invoked when the selection changes
- public void update() {
- ISelection selection = target.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection)selection;
- if (ss.size() == 1) {
- Object element = ss.getFirstElement();
- if (element instanceof SyncInfoDiffNode) {
- IResource resource = ((SyncInfoDiffNode)element).getResource();
- setEnabled(resource != null && resource.getType() == IResource.FILE);
- return;
- }
- }
- }
- setEnabled(false);
- }
- };
+ open = new OpenAction();
Utils.initAction(open, "action.open."); //$NON-NLS-1$
}
public void fillContextMenu(StructuredViewer viewer, IMenuManager manager) {
AbstractTreeViewer tree = getAbstractTreeViewer(viewer);
if (isShowOpenAction()) {
+ open.update();
manager.add(open);
}
if (tree != null) {
manager.add(expandAll);
}
}
-
- protected void expandAllFromSelection(StructuredViewer viewer) {
- AbstractTreeViewer tree = getAbstractTreeViewer(viewer);
- if (tree == null) return;
- ISelection selection = tree.getSelection();
- if(! selection.isEmpty()) {
- Iterator elements = ((IStructuredSelection)selection).iterator();
- while (elements.hasNext()) {
- Object next = elements.next();
- tree.expandToLevel(next, AbstractTreeViewer.ALL_LEVELS);
- }
- }
- }
private AbstractTreeViewer getAbstractTreeViewer(StructuredViewer viewer) {
if (viewer instanceof AbstractTreeViewer) {

Back to the top