Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2003-09-05 17:58:52 +0000
committerJean Michel-Lemieux2003-09-05 17:58:52 +0000
commitebe068fe99dbae9e62c616486c82564d30b3b5fe (patch)
tree5b829911290b8581e8d8e0d8cef61fe23858a055
parentfcca72471a2f112d2ed32c33618411c6c4c07b97 (diff)
downloadeclipse.platform.team-ebe068fe99dbae9e62c616486c82564d30b3b5fe.tar.gz
eclipse.platform.team-ebe068fe99dbae9e62c616486c82564d30b3b5fe.tar.xz
eclipse.platform.team-ebe068fe99dbae9e62c616486c82564d30b3b5fe.zip
Support for navigating next/previous with compare editors.
Compare editors can now be re-used.
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/clcl16/flatLayout.gifbin0 -> 100 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/clcl16/hierarchicalLayout.gifbin0 -> 106 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/clcl16/next_nav.gifbin0 -> 105 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/clcl16/prev_nav.gifbin0 -> 132 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/dlcl16/flatLayout.gifbin0 -> 71 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/dlcl16/hierarchicalLayout.gifbin0 -> 75 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/dlcl16/next_nav.gifbin0 -> 82 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/dlcl16/prev_nav.gifbin0 -> 82 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/elcl16/flatLayout.gifbin0 -> 82 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/elcl16/hierarchicalLayout.gifbin0 -> 103 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/elcl16/next_nav.gifbin0 -> 101 bytes
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/elcl16/prev_nav.gifbin0 -> 102 bytes
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties29
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/NavigateAction.java124
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/OpenInCompareAction.java139
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerActions.java57
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/ToggleViewAction.java35
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeView.java12
18 files changed, 273 insertions, 123 deletions
diff --git a/bundles/org.eclipse.team.ui/icons/full/clcl16/flatLayout.gif b/bundles/org.eclipse.team.ui/icons/full/clcl16/flatLayout.gif
new file mode 100644
index 000000000..b84df084f
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/clcl16/flatLayout.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/clcl16/hierarchicalLayout.gif b/bundles/org.eclipse.team.ui/icons/full/clcl16/hierarchicalLayout.gif
new file mode 100644
index 000000000..e597c3d16
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/clcl16/hierarchicalLayout.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/clcl16/next_nav.gif b/bundles/org.eclipse.team.ui/icons/full/clcl16/next_nav.gif
new file mode 100644
index 000000000..8392f3345
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/clcl16/next_nav.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/clcl16/prev_nav.gif b/bundles/org.eclipse.team.ui/icons/full/clcl16/prev_nav.gif
new file mode 100644
index 000000000..9b278e6fa
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/clcl16/prev_nav.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/dlcl16/flatLayout.gif b/bundles/org.eclipse.team.ui/icons/full/dlcl16/flatLayout.gif
new file mode 100644
index 000000000..aa0160d1c
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/dlcl16/flatLayout.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/dlcl16/hierarchicalLayout.gif b/bundles/org.eclipse.team.ui/icons/full/dlcl16/hierarchicalLayout.gif
new file mode 100644
index 000000000..76f336003
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/dlcl16/hierarchicalLayout.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/dlcl16/next_nav.gif b/bundles/org.eclipse.team.ui/icons/full/dlcl16/next_nav.gif
new file mode 100644
index 000000000..6cbeced26
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/dlcl16/next_nav.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/dlcl16/prev_nav.gif b/bundles/org.eclipse.team.ui/icons/full/dlcl16/prev_nav.gif
new file mode 100644
index 000000000..a3441a062
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/dlcl16/prev_nav.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/elcl16/flatLayout.gif b/bundles/org.eclipse.team.ui/icons/full/elcl16/flatLayout.gif
new file mode 100644
index 000000000..9f9ca4876
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/elcl16/flatLayout.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/elcl16/hierarchicalLayout.gif b/bundles/org.eclipse.team.ui/icons/full/elcl16/hierarchicalLayout.gif
new file mode 100644
index 000000000..b50b2c38a
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/elcl16/hierarchicalLayout.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/elcl16/next_nav.gif b/bundles/org.eclipse.team.ui/icons/full/elcl16/next_nav.gif
new file mode 100644
index 000000000..03b7af342
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/elcl16/next_nav.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/icons/full/elcl16/prev_nav.gif b/bundles/org.eclipse.team.ui/icons/full/elcl16/prev_nav.gif
new file mode 100644
index 000000000..dd65c5235
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/elcl16/prev_nav.gif
Binary files differ
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 d80011663..5018560c6 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
@@ -328,17 +328,18 @@ SyncViewPreferencePage.lastRefreshRunNever=Never
# Sync view actions
###############################################
-action.toggleView.label=Toggle layout between a tree and table
-action.toggleView.tooltip=Toggle layout between a tree and table
-action.toggleView.descrioption=Toggle layout between a tree and table
-action.toggleView.image=toggle_layout.gif
+action.toggleViewFlat.label=Flat
+action.toggleViewFlat.image=flatLayout.gif
+
+action.toggleViewHierarchical.label=Hierarchical
+action.toggleViewHierarchical.image=hierarchicalLayout.gif
action.collapseAll.label=Collapse All
action.collapseAll.tooltip=Collapse All
action.collapseAll.description=Collapse All
action.collapseAll.image=collapseall.gif
-action.changeFilters.label=Select change filters
+action.changeFilters.label=Filters...
action.changeFilters.tooltip=Select change filters
action.changeFilters.description=Select which change filters to apply in Synchronize view
action.changeFilters.image=filter_change.gif
@@ -373,16 +374,30 @@ action.refreshSubscriber.tooltip=Refresh the current synchronization target with
action.refreshSubscriber.description=Refresh the current synchronization target with Remote
action.refreshSubscriber.image=refresh_remote.gif
+action.navigateNext.label=Go to Next Difference
+action.navigateNext.tooltip=Go to Next Difference
+action.navigateNext.description=Go to Next Difference
+action.navigateNext.image=next_nav.gif
+
+action.navigatePrevious.label=Go to Previous Difference
+action.navigatePrevious.tooltip=Go to Previous Difference
+action.navigatePrevious.description=Go to Next Difference
+action.navigatePrevious.image=prev_nav.gif
+
action.expandAll.label=Expand All
action.openInCompareEditor.label=Open In Compare Editor
action.cancelSubscriber.label=Cancel
-action.selectNextChange.label=Select Next Change
-action.selectPreviousChange.label=Select Previous Change
+
action.syncViewPreferences.label=Preferences...
action.refreshViewContents.label=Refresh View Contents
action.changeFilterShowAdditions.label=Show Additions
action.changeFilterShowDeletions.label=Show Deletions
action.changeFilterShowChanges.label=Show Changes
+action.layout.label=Layout
+
+###############################################
+# Misc
+###############################################
SynchronizeView.12=One item selected
SynchronizeView.13=\ items selected
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/NavigateAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/NavigateAction.java
new file mode 100644
index 000000000..0a4509f89
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/NavigateAction.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.internal.ui.sync.actions;
+
+import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.ICompareNavigator;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.team.core.subscribers.SyncInfo;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.internal.ui.sync.views.INavigableControl;
+import org.eclipse.team.internal.ui.sync.views.SynchronizeView;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IKeyBindingService;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.actions.ActionContext;
+
+/**
+ * Action to navigate the changes shown in the Synchronize View. This
+ * will coordinate change browsing between the view and the compare
+ * editors.
+ *
+ * @since 3.0
+ */
+class NavigateAction extends Action {
+ private final SyncViewerActions actions;
+ private final SynchronizeView synchronizeView;
+ private final int direction;
+
+ public NavigateAction(SyncViewerActions actions, int direction) {
+ this.actions = actions;
+ this.synchronizeView = actions.getSyncView();
+ this.direction = direction;
+
+ IKeyBindingService kbs = synchronizeView.getSite().getKeyBindingService();
+ if(direction == INavigableControl.NEXT) {
+ Utils.initAction(this, "action.navigateNext."); //$NON-NLS-1$
+ Utils.registerAction(kbs, this, "org.eclipse.team.ui.syncview.selectNextChange"); //$NON-NLS-1$
+ synchronizeView.getViewSite().getActionBars().setGlobalActionHandler(IWorkbenchActionConstants.NEXT, this);
+ } else {
+ Utils.initAction(this, "action.navigatePrevious."); //$NON-NLS-1$
+ Utils.registerAction(kbs, this, "org.eclipse.team.ui.syncview.selectPreviousChange"); //$NON-NLS-1$
+ synchronizeView.getViewSite().getActionBars().setGlobalActionHandler(IWorkbenchActionConstants.PREVIOUS, this);
+ }
+ }
+
+ public void run() {
+ navigate();
+ }
+
+ private ISelection getSelection() {
+ ActionContext context = actions.getContext();
+ if (context == null) return null;
+ return actions.getContext().getSelection();
+ }
+
+ private void navigate() {
+ Viewer viewer = synchronizeView.getViewer();
+
+ if(viewer instanceof INavigableControl) {
+ SyncInfo info = getSyncInfoFromSelection();
+
+ if(info == null) {
+ if(((INavigableControl)viewer).gotoDifference(direction)) {
+ return;
+ } else {
+ info = getSyncInfoFromSelection();
+ if(info == null) return;
+ }
+ }
+
+ if(info.getLocal().getType() != IResource.FILE) {
+ if(! ((INavigableControl)viewer).gotoDifference(direction)) {
+ info = getSyncInfoFromSelection();
+ OpenInCompareAction.openCompareEditor(synchronizeView, info, true /* keep focus */);
+ }
+ return;
+ }
+
+ IEditorPart editor = OpenInCompareAction.findOpenCompareEditor(synchronizeView.getSite(), info.getLocal());
+ boolean atEnd = false;
+ CompareEditorInput input;
+ ICompareNavigator navigator;
+
+ if(editor != null) {
+ // if an existing editor is open on the current selection, use it
+ input = (CompareEditorInput)editor.getEditorInput();
+ navigator = (ICompareNavigator)input.getAdapter(ICompareNavigator.class);
+ if(navigator != null) {
+ if(navigator.selectChange(direction == INavigableControl.NEXT)) {
+ if(! ((INavigableControl)viewer).gotoDifference(direction)) {
+ info = getSyncInfoFromSelection();
+ OpenInCompareAction.openCompareEditor(synchronizeView, info, true /* keep focus */);
+ }
+ }
+ }
+ } else {
+ // otherwise, select the next change and open a compare editor which will automatically
+ // show the first change.
+ OpenInCompareAction.openCompareEditor(synchronizeView, info, true /* keep focus */);
+ }
+ }
+ return;
+ }
+
+ private SyncInfo getSyncInfoFromSelection() {
+ IStructuredSelection selection = ((IStructuredSelection)getSelection());
+ if(selection == null) return null;
+ Object obj = selection.getFirstElement();
+ SyncInfo info = OpenInCompareAction.getSyncInfo(obj);
+ return info;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/OpenInCompareAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/OpenInCompareAction.java
index 364d12b96..791f12ce7 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/OpenInCompareAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/OpenInCompareAction.java
@@ -12,7 +12,6 @@ package org.eclipse.team.internal.ui.sync.actions;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.CompareUI;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@@ -34,9 +33,13 @@ import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IReusableEditor;
import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
/**
- * Opens a compare editor on a selected SyncInfo object
+ * Action to open a compare editor from a SyncInfo object.
+ *
+ * @see SyncInfoCompareInput
+ * @since 3.0
*/
public class OpenInCompareAction extends Action {
@@ -47,34 +50,38 @@ public class OpenInCompareAction extends Action {
Utils.initAction(this, "action.openInCompareEditor."); //$NON-NLS-1$
}
- public void run() {
- openEditor();
+ public void run() {
+ ISelection selection = viewer.getViewer().getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ SyncInfo info = getSyncInfo(obj);
+ openCompareEditor(viewer, info, true /* keep focus */);
}
- private void openEditor() {
- CompareEditorInput input = getCompareInput();
+ public static SyncInfoCompareInput openCompareEditor(SynchronizeView viewer, SyncInfo info, boolean keepFocus) {
+ SyncInfoCompareInput input = getCompareInput(info);
if(input != null) {
- if (!prefetchFileContents()) return;
- IEditorPart editor = reuseCompareEditor((SyncInfoCompareInput)input);
+ if (!prefetchFileContents(viewer, info)) return null;
+ IEditorPart editor = findReusableCompareEditor(viewer.getSite().getPage());
if(editor != null && editor instanceof IReusableEditor) {
- CompareUI.openCompareEditor(input);
- // should be enabled once Bug 38770 is fixed
- //((IReusableEditor)editor).setInput(input);
+ CompareUI.reuseCompareEditor(input, (IReusableEditor)editor);
} else {
CompareUI.openCompareEditor(input);
}
- // This could be a user preference.
- //SynchronizeView.showInActivePage(viewer.getSite().getPage());
- }
+
+ if(keepFocus) {
+ SynchronizeView.showInActivePage(viewer.getSite().getPage());
+ }
+ return input;
+ }
+ return null;
}
-
- /*
+
+ /**
* Prefetching the file contents will cache them for use by the compare editor
+ * so that the compare editor doesn't have to perform file transfers. This will
+ * make the transfer cancellable.
*/
- private boolean prefetchFileContents() {
- ISelection selection = viewer.getViewer().getSelection();
- Object obj = ((IStructuredSelection)selection).getFirstElement();
- SyncInfo info = getSyncInfo(obj);
+ private static boolean prefetchFileContents(SynchronizeView viewer, SyncInfo info) {
final IRemoteResource remote = info.getRemote();
final IRemoteResource base = info.getBase();
if (remote != null || base != null) {
@@ -100,58 +107,78 @@ public class OpenInCompareAction extends Action {
return true;
}
- private CompareEditorInput getCompareInput() {
- ISelection selection = viewer.getViewer().getSelection();
- Object obj = ((IStructuredSelection)selection).getFirstElement();
- SyncInfo info = getSyncInfo(obj);
+ /**
+ * Returns a SyncInfoCompareInput instance for the current selection.
+ */
+ private static SyncInfoCompareInput getCompareInput(SyncInfo info) {
if (info != null && info.getLocal() instanceof IFile) {
return new SyncInfoCompareInput(info);
}
return null;
}
- private SyncInfo getSyncInfo(Object obj) {
- return (SyncInfo)TeamAction.getAdapter(obj, SyncInfo.class);
- }
-
- private IEditorPart reuseCompareEditor(SyncInfoCompareInput input) {
- IWorkbenchPage page = viewer.getSite().getPage();
+ /**
+ * Returns an editor that can be re-used. An open compare editor that
+ * has un-saved changes cannot be re-used.
+ */
+ public static IEditorPart findReusableCompareEditor(IWorkbenchPage page) {
IEditorReference[] editorRefs = page.getEditorReferences();
- IEditorPart editor = page.findEditor(input);
- if(editor == null) {
- for (int i = 0; i < editorRefs.length; i++) {
- IEditorPart part = editorRefs[i].getEditor(true);
- if(part != null && part.getEditorInput() instanceof SyncInfoCompareInput) {
- if(! part.isDirty()) {
- // should be removed once Bug 38770 is fixed
- page.closeEditor(part, true /*save changes if required */);
- }
+ for (int i = 0; i < editorRefs.length; i++) {
+ IEditorPart part = editorRefs[i].getEditor(true);
+ if(part != null && part.getEditorInput() instanceof SyncInfoCompareInput) {
+ if(! part.isDirty()) {
+ return part;
}
}
}
- return editor;
+ return null;
}
- public static void closeCompareEditorFor(final SynchronizeView viewer, final IResource resource) {
- viewer.getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ /**
+ * Close a compare editor that is opened on the given IResource.
+ *
+ * @param site the view site in which to close the editors
+ * @param resource the resource to use to find the compare editor
+ */
+ public static void closeCompareEditorFor(final IWorkbenchPartSite site, final IResource resource) {
+ site.getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
- IWorkbenchPage page = viewer.getSite().getPage();
- IEditorReference[] editorRefs = page.getEditorReferences();
-
- for (int i = 0; i < editorRefs.length; i++) {
- final IEditorPart part = editorRefs[i].getEditor(false /* don't restore editor */);
- if(part != null) {
- IEditorInput input = part.getEditorInput();
- if(part != null && input instanceof SyncInfoCompareInput) {
- SyncInfo inputInfo = ((SyncInfoCompareInput)input).getSyncInfo();
- if(inputInfo.getLocal().equals(resource)) {
- page.closeEditor(part, true /*save changes if required */);
- }
- }
+ IEditorPart editor = findOpenCompareEditor(site, resource);
+ if(editor != null) {
+ site.getPage().closeEditor(editor, true /*save changes if required */);
+ }
+ }
+ });
+ }
+
+ /**
+ * Returns an editor handle if a SyncInfoCompareInput compare editor is opened on
+ * the given IResource.
+ *
+ * @param site the view site in which to search for editors
+ * @param resource the resource to use to find the compare editor
+ * @return an editor handle if found and <code>null</code> otherwise
+ */
+ public static IEditorPart findOpenCompareEditor(IWorkbenchPartSite site, IResource resource) {
+ IWorkbenchPage page = site.getPage();
+ IEditorReference[] editorRefs = page.getEditorReferences();
+ for (int i = 0; i < editorRefs.length; i++) {
+ final IEditorPart part = editorRefs[i].getEditor(false /* don't restore editor */);
+ if(part != null) {
+ IEditorInput input = part.getEditorInput();
+ if(part != null && input instanceof SyncInfoCompareInput) {
+ SyncInfo inputInfo = ((SyncInfoCompareInput)input).getSyncInfo();
+ if(inputInfo.getLocal().equals(resource)) {
+ return part;
}
}
}
- });
+ }
+ return null;
+ }
+
+ public static SyncInfo getSyncInfo(Object obj) {
+ return (SyncInfo)TeamAction.getAdapter(obj, SyncInfo.class);
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerActions.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerActions.java
index 4f0eaa6b9..575ae0118 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerActions.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/SyncViewerActions.java
@@ -11,22 +11,22 @@
package org.eclipse.team.internal.ui.sync.actions;
import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.sync.sets.SubscriberInput;
import org.eclipse.team.internal.ui.sync.views.INavigableControl;
import org.eclipse.team.internal.ui.sync.views.SynchronizeView;
+import org.eclipse.team.ui.sync.ISynchronizeView;
import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IKeyBindingService;
import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext;
@@ -55,10 +55,14 @@ public class SyncViewerActions extends SyncViewerActionGroup {
// other view actions
private Action collapseAll;
private Action refreshSelectionAction;
- private Action toggleViewerType;
private Action refreshViewContents;
+
+ private Action toggleLayoutFlatAction;
+ private Action toggleLayoutHierarchicalAction;
private ExpandAllAction expandAll;
private SelectAllAction selectAllAction;
+ private NavigateAction gotoNext;
+ private NavigateAction gotoPrevious;
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
@@ -101,24 +105,11 @@ public class SyncViewerActions extends SyncViewerActionGroup {
expandAll = new ExpandAllAction(this);
- IKeyBindingService kbs = getSyncView().getSite().getKeyBindingService();
- IAction a= new Action() {
- public void run() {
- getSyncView().gotoDifference(INavigableControl.NEXT);
- }
- };
- Utils.initAction(a, "action.selectNextChange."); //$NON-NLS-1$
- Utils.registerAction(kbs, a, "org.eclipse.team.ui.syncview.selectNextChange"); //$NON-NLS-1$
- getSyncView().getViewSite().getActionBars().setGlobalActionHandler(IWorkbenchActionConstants.NEXT, a);
+ gotoNext = new NavigateAction(this, INavigableControl.NEXT);
+ gotoPrevious = new NavigateAction(this, INavigableControl.PREVIOUS);
- a= new Action() {
- public void run() {
- getSyncView().gotoDifference(INavigableControl.PREVIOUS);
- }
- };
- Utils.initAction(a, "action.selectPreviousChange."); //$NON-NLS-1$
- Utils.registerAction(kbs, a, "org.eclipse.team.ui.syncview.selectPreviousChange"); //$NON-NLS-1$
- getSyncView().getViewSite().getActionBars().setGlobalActionHandler(IWorkbenchActionConstants.PREVIOUS, a);
+ toggleLayoutFlatAction = new ToggleViewAction(getSyncView(), ISynchronizeView.TABLE_VIEW);
+ toggleLayoutHierarchicalAction = new ToggleViewAction(getSyncView(), ISynchronizeView.TREE_VIEW);
collapseAll = new Action() {
public void run() {
@@ -140,9 +131,6 @@ public class SyncViewerActions extends SyncViewerActionGroup {
}
};
Utils.initAction(refreshViewContents, "action.refreshViewContents."); //$NON-NLS-1$
-
-
- toggleViewerType = new ToggleViewAction(getSyncView(), getSyncView().getCurrentViewType());
IPropertyChangeListener workingSetUpdater = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
@@ -172,21 +160,33 @@ public class SyncViewerActions extends SyncViewerActionGroup {
public void fillActionBars(IActionBars actionBars) {
super.fillActionBars(actionBars);
+ // Setup toolbars
IToolBarManager manager = actionBars.getToolBarManager();
manager.add(chooseSubscriberAction);
manager.add(new Separator());
directionsFilters.fillActionBars(actionBars);
manager.add(new Separator());
- manager.add(chooseChangeFilterAction);
manager.add(collapseAll);
- manager.add(toggleViewerType);
+ manager.add(new Separator());
+ manager.add(gotoNext);
+ manager.add(gotoPrevious);
+ // Setup drop down menu
IMenuManager dropDownMenu = actionBars.getMenuManager();
workingSetGroup.fillActionBars(actionBars);
dropDownMenu.add(refreshViewContents);
dropDownMenu.add(new Separator());
+
+ MenuManager layoutMenu = new MenuManager(Policy.bind("action.layout.label")); //$NON-NLS-1$
+ layoutMenu.add(toggleLayoutFlatAction);
+ layoutMenu.add(toggleLayoutHierarchicalAction);
+ dropDownMenu.add(layoutMenu);
+ dropDownMenu.add(new Separator());
dropDownMenu.add(new SyncViewerShowPreferencesAction(getSyncView().getSite().getShell()));
+ dropDownMenu.add(gotoNext);
+ dropDownMenu.add(gotoPrevious);
+
refactoringActions.fillActionBars(actionBars);
}
@@ -253,11 +253,12 @@ public class SyncViewerActions extends SyncViewerActionGroup {
*/
protected void initializeActions() {
SubscriberInput input = getSubscriberContext();
- refreshSelectionAction.setEnabled(input != null);
- toggleViewerType.setEnabled(input != null);
+ refreshSelectionAction.setEnabled(input != null);
chooseSubscriberAction.setEnabled(input != null);
chooseChangeFilterAction.setEnabled(input != null);
collapseAll.setEnabled(input != null);
+ toggleLayoutFlatAction.setEnabled(input != null);
+ toggleLayoutHierarchicalAction.setEnabled(input != null);
// refresh the selected filter
refreshFilters();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/ToggleViewAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/ToggleViewAction.java
index d60f9ad3e..3387e8ae2 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/ToggleViewAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/ToggleViewAction.java
@@ -11,43 +11,34 @@
package org.eclipse.team.internal.ui.sync.actions;
import org.eclipse.jface.action.Action;
+import org.eclipse.swt.SWT;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.sync.views.SynchronizeView;
-import org.eclipse.ui.IKeyBindingService;
import org.eclipse.ui.IPropertyListener;
class ToggleViewAction extends Action implements IPropertyListener {
private SynchronizeView viewer;
+ private int layout;
- public ToggleViewAction(SynchronizeView viewer, int initialState) {
+ public ToggleViewAction(SynchronizeView viewer, int layout) {
+ super(null, SWT.RADIO);
this.viewer = viewer;
- Utils.initAction(this, "action.toggleView."); //$NON-NLS-1$
- Action a = new Action() {
- public void run() {
- ToggleViewAction.this.setChecked(! ToggleViewAction.this.isChecked());
- ToggleViewAction.this.run();
- }
- };
- IKeyBindingService kbs = viewer.getSite().getKeyBindingService();
- Utils.registerAction(kbs, a, "org.eclipse.team.ui.syncview.toggleView"); //$NON-NLS-1$
-
- setChecked(initialState == SynchronizeView.TREE_VIEW);
- viewer.addPropertyListener(this);
+ this.layout = layout;
+ if(layout == SynchronizeView.TABLE_VIEW) {
+ Utils.initAction(this, "action.toggleViewFlat."); //$NON-NLS-1$
+ } else {
+ Utils.initAction(this, "action.toggleViewHierarchical."); //$NON-NLS-1$
+ }
+ viewer.addPropertyListener(this);
}
public void run() {
- int viewerType;
- if(isChecked()) {
- viewerType = SynchronizeView.TREE_VIEW;
- } else {
- viewerType = SynchronizeView.TABLE_VIEW;
- }
- viewer.switchViewerType(viewerType);
+ viewer.switchViewerType(layout);
}
public void propertyChanged(Object source, int propId) {
if(propId == SynchronizeView.PROP_VIEWTYPE) {
- setChecked(viewer.getCurrentViewType() == SynchronizeView.TREE_VIEW);
+ setChecked(viewer.getCurrentViewType() == layout);
}
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeView.java
index 06c54cb88..cac599459 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SynchronizeView.java
@@ -222,7 +222,6 @@ public class SynchronizeView extends ViewPart implements ITeamResourceChangeList
RefreshSubscriberInputJob refreshJob = TeamUIPlugin.getPlugin().getRefreshJob();
refreshJob.setSubscriberInput(input);
- gotoDifference(INavigableControl.NEXT);
}
});
updateTitle();
@@ -250,7 +249,7 @@ public class SynchronizeView extends ViewPart implements ITeamResourceChangeList
createViewer(composite);
composite.layout();
if(oldSelection == null || oldSelection.size() == 0) {
- gotoDifference(INavigableControl.NEXT);
+ //gotoDifference(INavigableControl.NEXT);
} else {
viewer.setSelection(oldSelection, true);
}
@@ -764,7 +763,7 @@ public class SynchronizeView extends ViewPart implements ITeamResourceChangeList
IResource[] resources =event.getRemovedResources();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
- OpenInCompareAction.closeCompareEditorFor(this, resource);
+ OpenInCompareAction.closeCompareEditorFor(this.getSite(), resource);
}
}
@@ -831,13 +830,6 @@ public class SynchronizeView extends ViewPart implements ITeamResourceChangeList
}
}
- public boolean gotoDifference(int direction) {
- if(viewer instanceof INavigableControl) {
- return ((INavigableControl)viewer).gotoDifference(direction);
- }
- return false;
- }
-
private IPreferenceStore getStore() {
return TeamUIPlugin.getPlugin().getPreferenceStore();
}

Back to the top