Index: compare/org/eclipse/compare/internal/CompareNavigator.java
===================================================================
RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareNavigator.java,v
retrieving revision 1.12
diff -u -r1.12 CompareNavigator.java
--- compare/org/eclipse/compare/internal/CompareNavigator.java 31 May 2002 12:54:00 -0000 1.12
+++ compare/org/eclipse/compare/internal/CompareNavigator.java 17 Jun 2002 09:03:03 -0000
@@ -24,6 +24,7 @@
private boolean fLastDirection= true;
private CompareViewerSwitchingPane[] fPanes;
+ private boolean fNextFirstTime= true;
public CompareNavigator(CompareViewerSwitchingPane[] panes) {
fPanes= panes;
@@ -36,6 +37,11 @@
public void selectChange(boolean next) {
fLastDirection= next;
+
+ if (next && fNextFirstTime) {
+ fNextFirstTime= false;
+ openElement();
+ }
// find most down stream CompareViewerPane
int n= 0;
@@ -119,4 +125,30 @@
return nav.resetDirection();
return true;
}
+
+ private void openElement() {
+ if (fPanes == null || fPanes.length == 0)
+ return;
+ IOpenable openable= getOpenable(fPanes[0]);
+ if (openable != null) {
+ openable.openSelected();
+ }
+ }
+
+ private static IOpenable getOpenable(CompareViewerSwitchingPane pane) {
+ 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;
+ }
}
Index: compare/org/eclipse/compare/internal/IOpenable.java
===================================================================
RCS file: compare/org/eclipse/compare/internal/IOpenable.java
diff -N compare/org/eclipse/compare/internal/IOpenable.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ compare/org/eclipse/compare/internal/IOpenable.java 17 Jun 2002 09:03:03 -0000
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2002 International Business Machines Corp. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.compare.internal;
+
+public interface IOpenable {
+
+ static final String OPENABLE_PROPERTY= "org.eclipse.compare.internal.Openable"; //$NON-NLS-1$
+
+ /**
+ * Opens the selected element
+ */
+ void openSelected();
+}
Index: compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java
===================================================================
RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java,v
retrieving revision 1.26
diff -u -r1.26 DiffTreeViewer.java
--- compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java 1 Jun 2002 10:00:00 -0000 1.26
+++ compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java 17 Jun 2002 09:03:03 -0000
@@ -175,11 +175,18 @@
INavigatable nav= new INavigatable() {
public boolean gotoDifference(boolean next) {
- return internalNavigate(next);
+ return internalNavigate(next, true);
}
};
tree.setData(INavigatable.NAVIGATOR_PROPERTY, nav);
+ IOpenable openable= new IOpenable() {
+ public void openSelected() {
+ internalOpen();
+ }
+ };
+ tree.setData(IOpenable.OPENABLE_PROPERTY, openable);
+
fLeftIsLocal= Utilities.getBoolean(configuration, "LEFT_IS_LOCAL", false); //$NON-NLS-1$
tree.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());
@@ -498,7 +505,7 @@
* @param next if true
the next node is selected, otherwise the previous node
*/
protected void navigate(boolean next) {
- internalNavigate(next);
+ internalNavigate(next, false);
}
//---- private
@@ -512,7 +519,7 @@
* @param next if true
the next node is selected, otherwise the previous node
* @return true
if at end (or beginning)
*/
- private boolean internalNavigate(boolean next) {
+ private boolean internalNavigate(boolean next, boolean open) {
Control c= getControl();
if (!(c instanceof Tree))
@@ -528,7 +535,7 @@
if (children != null && children.length > 0) {
item= children[0];
if (item != null && item.getItemCount() <= 0) {
- internalSetSelection(item);
+ internalSetSelection(item, open);
return false;
}
}
@@ -543,7 +550,7 @@
}
if (item != null) {
- internalSetSelection(item);
+ internalSetSelection(item, open);
return false;
}
return true;
@@ -632,11 +639,16 @@
return item;
}
- private void internalSetSelection(TreeItem ti) {
+ private void internalSetSelection(TreeItem ti, boolean open) {
if (ti != null) {
Object data= ti.getData();
- if (data != null)
- setSelection(new StructuredSelection(data), true);
+ if (data != null) {
+ ISelection selection= new StructuredSelection(data);
+ setSelection(selection, true);
+ if (open && selection.equals(getSelection())) {
+ fireOpen(new OpenEvent(this, selection));
+ }
+ }
}
}
@@ -703,6 +715,13 @@
fCopyLeftToRightAction.setEnabled(leftToRight > 0);
if (fCopyRightToLeftAction != null)
fCopyRightToLeftAction.setEnabled(rightToLeft > 0);
+ }
+
+ private void internalOpen() {
+ ISelection selection= getSelection();
+ if (selection != null && !selection.isEmpty()) {
+ fireOpen(new OpenEvent(this, selection));
+ }
}
}