Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-05-03 09:32:26 -0400
committerJean Michel-Lemieux2004-05-03 09:32:26 -0400
commit205b72690a34c256d9450fc2b4fbec31a3a984ce (patch)
treeb8d2feef59a18c9d0da38eb1c1faa597cf94c0cf
parent0e108e290996da2fd77de685bd4edb780049c3a3 (diff)
downloadeclipse.platform.team-205b72690a34c256d9450fc2b4fbec31a3a984ce.tar.gz
eclipse.platform.team-205b72690a34c256d9450fc2b4fbec31a3a984ce.tar.xz
eclipse.platform.team-205b72690a34c256d9450fc2b4fbec31a3a984ce.zip
Bug 60632 Navigation problems in a dialog
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/PartNavigator.java171
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java27
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java8
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java22
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java38
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java19
6 files changed, 248 insertions, 37 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/PartNavigator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/PartNavigator.java
new file mode 100644
index 000000000..3c34350f8
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/PartNavigator.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * 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 org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.CompareViewerSwitchingPane;
+import org.eclipse.compare.internal.*;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.team.internal.ui.synchronize.actions.NavigateAction;
+
+/**
+ * A navigator that coordinates navigation between several navigable
+ * objects. This is copied from the compare plugin and enhanced to
+ * support navigating adaptables.
+ * <p>
+ * This navigator can be used as input to the {@link NavigateAction}
+ * actions and should be passed to the actions via the
+ * {@link SynchronizePageConfiguration.P_NAVIGATOR}.
+ * </p>
+ * @since 3.0
+ */
+public class PartNavigator implements INavigatable {
+
+ private boolean fLastDirection= true;
+ private Object[] fPanes;
+ // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
+ private boolean fNextFirstTime= true;
+
+ public PartNavigator(Object[] panes) {
+ fPanes= panes;
+ }
+
+ public Object[] getPanes() {
+ return fPanes;
+ }
+
+ public boolean gotoDifference(boolean next) {
+
+ fLastDirection= next;
+
+ // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
+ if (next && fNextFirstTime && mustOpen()) {
+ fNextFirstTime= false;
+ openElement();
+ }
+
+ // find most down stream CompareViewerPane
+ int n= 0;
+ INavigatable[] navigators= new INavigatable[4];
+ for (int i= 0; i < fPanes.length; i++) {
+ navigators[n]= getNavigator(fPanes[i]);
+ if (navigators[n] != null)
+ n++;
+ }
+
+ while (n > 0) {
+ n--;
+ if (navigators[n].gotoDifference(next)) {
+ // at end of this navigator
+ continue;
+ } else // not at end
+ return false;
+ }
+ return true;
+ }
+
+ private static INavigatable getNavigator(Object p) {
+ if (p == null)
+ return null;
+ Control control = null;
+ if (p instanceof CompareViewerSwitchingPane) {
+ CompareViewerSwitchingPane pane = (CompareViewerSwitchingPane) p;
+ if (pane.isEmpty())
+ return null;
+ Viewer viewer = pane.getViewer();
+ if (viewer == null)
+ return null;
+ control = viewer.getControl();
+ if (control == null)
+ return null;
+ Object data = control.getData(INavigatable.NAVIGATOR_PROPERTY);
+ if (data instanceof INavigatable)
+ return (INavigatable) data;
+ } else if(p instanceof IAdaptable) {
+ return (INavigatable)((IAdaptable)p).getAdapter(INavigatable.class);
+ }
+ return null;
+ }
+
+ private static CompareNavigator findNavigator(Control c) {
+ while (c != null && !c.isDisposed()) { // PR 1GEUVV2
+ Object data= c.getData();
+ if (data instanceof CompareEditorInput) {
+ CompareEditorInput cei= (CompareEditorInput) data;
+ Object adapter= cei.getAdapter(CompareNavigator.class);
+ if (adapter instanceof CompareNavigator)
+ return (CompareNavigator)adapter;
+ }
+ c= c.getParent();
+ }
+ return null;
+ }
+
+ private boolean resetDirection() {
+ boolean last= fLastDirection;
+ fLastDirection= true;
+ return last;
+ }
+
+ /*
+ * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
+ */
+ private boolean mustOpen() {
+ if (fPanes == null || fPanes.length == 0)
+ return false;
+ for (int i= 1; i < fPanes.length; i++) {
+ Object p= fPanes[i];
+ if (p instanceof CompareViewerSwitchingPane) {
+ CompareViewerSwitchingPane pane = (CompareViewerSwitchingPane) p;
+ if (pane != null && pane.getInput() != null)
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /*
+ * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
+ */
+ private void openElement() {
+ if (fPanes == null || fPanes.length == 0)
+ return;
+ IOpenable openable= getOpenable(fPanes[0]);
+ if (openable != null) {
+ openable.openSelected();
+ }
+ }
+
+ /*
+ * Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106
+ */
+ private static IOpenable getOpenable(Object p) {
+ if (p instanceof CompareViewerSwitchingPane) {
+ CompareViewerSwitchingPane pane = (CompareViewerSwitchingPane) p;
+ if (pane == null)
+ return null;
+ if (pane.isEmpty())
+ return null;
+ Viewer viewer = pane.getViewer();
+ if (viewer == null)
+ return null;
+ Control control = viewer.getControl();
+ if (control == null)
+ return null;
+ Object data = control.getData(IOpenable.OPENABLE_PROPERTY);
+ if (data instanceof IOpenable)
+ return (IOpenable) data;
+ }
+ return null;
+ }
+}
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 5e9d1d3ff..5f5ee60fa 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
@@ -10,8 +10,11 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.synchronize;
+import org.eclipse.compare.internal.INavigatable;
+import org.eclipse.compare.internal.IOpenable;
import org.eclipse.compare.structuremergeviewer.*;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.*;
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -66,7 +69,7 @@ import org.eclipse.ui.model.BaseWorkbenchContentProvider;
* @see TreeViewerAdvisor
* @since 3.0
*/
-public abstract class StructuredViewerAdvisor {
+public abstract class StructuredViewerAdvisor implements IAdaptable {
// The physical model shown to the user in the provided viewer. The information in
// this set is transformed by the model provider into the actual logical model displayed
@@ -81,6 +84,9 @@ public abstract class StructuredViewerAdvisor {
private StatusLineContributionGroup statusLine;
private SynchronizeModelManager modelManager;
+ private INavigatable nav;
+ private IOpenable openable;
+
// Property change listener which reponds to:
// - working set selection by the user
// - decorator format change selected by the user
@@ -147,6 +153,25 @@ public abstract class StructuredViewerAdvisor {
hookContextMenu(viewer);
}
+ /* (non-Javadoc)
+ * Allow adding an advisor to the PartNavigator and support coordinated
+ * navigation between several objects.
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+ if(adapter == INavigatable.class) {
+ if(nav == null) {
+ nav = new INavigatable() {
+ public boolean gotoDifference(boolean next) {
+ return StructuredViewerAdvisor.this.navigate(next);
+ }
+ };
+ }
+ return nav;
+ }
+ return null;
+ }
+
/*
* Initializes actions that are contributed directly by the advisor.
* @param viewer the viewer being installed
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java
index 159c73033..997f51567 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java
@@ -52,6 +52,14 @@ public class SynchronizePageConfiguration extends SynchronizePageActionGroup imp
public static final String P_ADVISOR = TeamUIPlugin.ID + ".P_ADVISOR"; //$NON-NLS-1$
/**
+ * Property constant for the page's navigator
+ * an instance of <code>INavigable</code>.
+ * This property can be queried by clients and can be set. By default
+ * the advisors navigator will be used.
+ */
+ public static final String P_NAVIGATOR = TeamUIPlugin.ID + ".P_NAVIGATOR"; //$NON-NLS-1$
+
+ /**
* Property constant for the page's model manager which is
* an instance of <code>SynchronizeModelManager</code>.
* This property can be queried by clients but should not be
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java
index eb2523d1c..f0b430a15 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/TreeViewerAdvisor.java
@@ -72,15 +72,10 @@ public class TreeViewerAdvisor extends StructuredViewerAdvisor {
};
Utils.initAction(collapseAll, "action.collapseAll."); //$NON-NLS-1$
- INavigatable nav = new INavigatable() {
- public boolean gotoDifference(boolean next) {
- return TreeViewerAdvisor.this.navigate(next);
- }
- };
ISynchronizeParticipant participant = configuration.getParticipant();
ISynchronizePageSite site = configuration.getSite();
- gotoNext = new NavigateAction(site, participant.getName(), nav, true /*next*/);
- gotoPrevious = new NavigateAction(site, participant.getName(), nav, false /*previous*/);
+ gotoNext = new NavigateAction(site, participant.getName(), configuration, true /*next*/);
+ gotoPrevious = new NavigateAction(site, participant.getName(), configuration, false /*previous*/);
}
}
public void fillContextMenu(IMenuManager manager) {
@@ -128,9 +123,6 @@ public class TreeViewerAdvisor extends StructuredViewerAdvisor {
ISynchronizePageConfiguration configuration;
Map listeners = new HashMap();
- /**
- *
- */
public CheckboxSelectionProvider(ContainerCheckedTreeViewer viewer, ISynchronizePageConfiguration configuration) {
this.viewer = viewer;
this.configuration = configuration;
@@ -235,10 +227,12 @@ public class TreeViewerAdvisor extends StructuredViewerAdvisor {
* @param set the set of <code>SyncInfo</code> objects that are to be shown to the user.
*/
public TreeViewerAdvisor(Composite parent, ISynchronizePageConfiguration configuration) {
- super(configuration);
-
+ super(configuration);
+ INavigatable nav = (INavigatable)configuration.getProperty(SynchronizePageConfiguration.P_NAVIGATOR);
+ if (nav == null) {
+ configuration.setProperty(SynchronizePageConfiguration.P_NAVIGATOR, this);
+ }
configuration.addActionContribution(new NavigationActionGroup());
-
StructuredViewer viewer = TreeViewerAdvisor.createViewer(parent, configuration);
GridData data = new GridData(GridData.FILL_BOTH);
viewer.getControl().setLayoutData(data);
@@ -257,7 +251,7 @@ public class TreeViewerAdvisor extends StructuredViewerAdvisor {
* @see org.eclipse.team.ui.synchronize.viewers.StructuredViewerAdvisor#navigate(boolean)
*/
public boolean navigate(boolean next) {
- return TreeViewerAdvisor.navigate((TreeViewer)getViewer(), next, true, false);
+ return TreeViewerAdvisor.navigate((TreeViewer)getViewer(), next, false, false);
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
index 581de8f2e..2bce4624c 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
@@ -19,11 +19,10 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
+import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.*;
import org.eclipse.ui.actions.ActionFactory;
/**
@@ -35,20 +34,14 @@ import org.eclipse.ui.actions.ActionFactory;
*/
public class NavigateAction extends Action {
private final boolean next;
- private INavigatable navigator;
private ISynchronizePageSite site;
private String title;
+ private ISynchronizePageConfiguration configuration;
- /**
- * Direction to navigate
- */
- final public static int NEXT = 1;
- final public static int PREVIOUS = 2;
-
- public NavigateAction(ISynchronizePageSite site, String title, INavigatable navigator, boolean next) {
+ public NavigateAction(ISynchronizePageSite site, String title, ISynchronizePageConfiguration configuration, boolean next) {
this.site = site;
this.title = title;
- this.navigator = navigator;
+ this.configuration = configuration;
this.next = next;
IWorkbenchSite workbenchSite = site.getWorkbenchSite();
IViewSite viewSite = null;
@@ -66,19 +59,24 @@ public class NavigateAction extends Action {
}
}
+ /**
+ * Two types of navigation is supported: navigation that is specific to coordinating between a view
+ * and a compare editor and navigation simply using the configured navigator.
+ */
public void run() {
IWorkbenchSite ws = site.getWorkbenchSite();
- if (ws instanceof IWorkbenchPartSite) {
- navigate();
+ INavigatable nav = (INavigatable)configuration.getProperty(SynchronizePageConfiguration.P_NAVIGATOR);
+ if (nav != null && ws != null && ws instanceof IViewSite) {
+ navigate(nav);
} else {
- navigator.gotoDifference(next);
+ nav.gotoDifference(next);
}
}
- private void navigate() {
+ private void navigate(INavigatable nav) {
SyncInfo info = getSyncInfoFromSelection();
if(info == null) {
- if(navigator.gotoDifference(next)) {
+ if(nav.gotoDifference(next)) {
return;
} else {
info = getSyncInfoFromSelection();
@@ -87,7 +85,7 @@ public class NavigateAction extends Action {
}
if(info.getLocal().getType() != IResource.FILE) {
- if(! navigator.gotoDifference(next)) {
+ if(! nav.gotoDifference(next)) {
info = getSyncInfoFromSelection();
OpenInCompareAction.openCompareEditor(site, getTitle(), info, true /* keep focus */);
}
@@ -106,7 +104,7 @@ public class NavigateAction extends Action {
navigator = (ICompareNavigator)input.getAdapter(ICompareNavigator.class);
if(navigator != null) {
if(navigator.selectChange(next)) {
- if(! this.navigator.gotoDifference(next)) {
+ if(! nav.gotoDifference(next)) {
info = getSyncInfoFromSelection();
OpenInCompareAction.openCompareEditor(site, getTitle(), info, true /* keep focus */);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java
index 60dbd4c9b..f168f8672 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java
@@ -59,7 +59,6 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
// SWT controls
private CompareViewerSwitchingPane fContentPane;
- private CompareViewerPane fMemberPane;
private CompareViewerPane fEditionPane;
private CompareViewerSwitchingPane fStructuredComparePane;
private Viewer viewer;
@@ -224,7 +223,7 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
// we need two panes: the left for the elements, the right one for the structured diff
Splitter hsplitter = new Splitter(vsplitter, SWT.HORIZONTAL);
fEditionPane = new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT);
- fStructuredComparePane = new CompareViewerSwitchingPane(hsplitter, SWT.BORDER | SWT.FLAT, true) {
+ fStructuredComparePane = new CompareViewerSwitchingPane(hsplitter, SWT.BORDER | SWT.FLAT, false) {
protected Viewer getViewer(Viewer oldViewer, Object input) {
if (input instanceof ICompareInput)
return CompareUI.findStructureViewer(oldViewer, (ICompareInput) input, this, cc);
@@ -289,9 +288,25 @@ public class ParticipantPageSaveablePart extends SaveablePartAdapter implements
}
};
vsplitter.setWeights(new int[]{30, 70});
+ setNavigator(pageConfiguration);
control = parent;
}
+ /* (non Javadoc)
+ * TODO: using internal compare classes to support page navigation. This is required because
+ * we are building our own compare editor input that includes a participant page instead of a
+ * viewer.
+ */
+ public void setNavigator(ISynchronizePageConfiguration configuration) {
+ configuration.setProperty(SynchronizePageConfiguration.P_NAVIGATOR, new PartNavigator(
+ new Object[] {
+ configuration.getProperty(SynchronizePageConfiguration.P_ADVISOR),
+ fStructuredComparePane,
+ fContentPane
+ }
+ ));
+ }
+
/*
* Feeds input from the participant page into the content and structured viewers.
*/

Back to the top