View | Details | Raw Unified | Return to bug 20106
Collapse All | Expand All

(-)compare/org/eclipse/compare/internal/CompareNavigator.java (+32 lines)
Lines 24-29 Link Here
24
	
24
	
25
	private boolean fLastDirection= true;
25
	private boolean fLastDirection= true;
26
	private CompareViewerSwitchingPane[] fPanes;
26
	private CompareViewerSwitchingPane[] fPanes;
27
	private boolean fNextFirstTime= true;
27
	
28
	
28
	public CompareNavigator(CompareViewerSwitchingPane[] panes) {
29
	public CompareNavigator(CompareViewerSwitchingPane[] panes) {
29
		fPanes= panes;
30
		fPanes= panes;
Lines 36-41 Link Here
36
	public void selectChange(boolean next) {
37
	public void selectChange(boolean next) {
37
		
38
		
38
		fLastDirection= next;
39
		fLastDirection= next;
40
41
		if (next && fNextFirstTime) {
42
			fNextFirstTime= false;
43
			openElement();
44
		}
39
		
45
		
40
		// find most down stream CompareViewerPane
46
		// find most down stream CompareViewerPane
41
		int n= 0;
47
		int n= 0;
Lines 119-122 Link Here
119
			return nav.resetDirection();
125
			return nav.resetDirection();
120
		return true;
126
		return true;
121
	}
127
	}
128
	
129
	private void openElement() {
130
		if (fPanes == null || fPanes.length == 0)
131
			return;
132
		IOpenable openable= getOpenable(fPanes[0]);
133
		if (openable != null) {
134
			openable.openSelected();
135
		}
136
	}
137
	
138
	private static IOpenable getOpenable(CompareViewerSwitchingPane pane) {
139
		if (pane == null)
140
			return null;
141
		if (pane.isEmpty())
142
			return null;
143
		Viewer viewer= pane.getViewer();
144
		if (viewer == null)
145
			return null;
146
		Control control= viewer.getControl();
147
		if (control == null)
148
			return null;
149
		Object data= control.getData(IOpenable.OPENABLE_PROPERTY);
150
		if (data instanceof IOpenable)
151
			return (IOpenable) data;
152
		return null;
153
	}	
122
}
154
}
(-)compare/org/eclipse/compare/internal/IOpenable.java (+21 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2002 International Business Machines Corp. and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v0.5 
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v05.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.compare.internal;
12
13
public interface IOpenable {
14
	
15
	static final String OPENABLE_PROPERTY= "org.eclipse.compare.internal.Openable"; //$NON-NLS-1$
16
	
17
	/**
18
	 * Opens the selected element
19
	 */
20
	void openSelected();
21
}
(-)compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java (-8 / +27 lines)
Lines 175-185 Link Here
175
		
175
		
176
		INavigatable nav= new INavigatable() {
176
		INavigatable nav= new INavigatable() {
177
			public boolean gotoDifference(boolean next) {
177
			public boolean gotoDifference(boolean next) {
178
				return internalNavigate(next);
178
				return internalNavigate(next, true);
179
			}
179
			}
180
		};
180
		};
181
		tree.setData(INavigatable.NAVIGATOR_PROPERTY, nav);
181
		tree.setData(INavigatable.NAVIGATOR_PROPERTY, nav);
182
		
182
		
183
		IOpenable openable= new IOpenable() {
184
			public void openSelected() {
185
				internalOpen();
186
			}
187
		};
188
		tree.setData(IOpenable.OPENABLE_PROPERTY, openable);
189
		
183
		fLeftIsLocal= Utilities.getBoolean(configuration, "LEFT_IS_LOCAL", false); //$NON-NLS-1$
190
		fLeftIsLocal= Utilities.getBoolean(configuration, "LEFT_IS_LOCAL", false); //$NON-NLS-1$
184
191
185
		tree.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());
192
		tree.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());
Lines 498-504 Link Here
498
	 * @param next if <code>true</code> the next node is selected, otherwise the previous node
505
	 * @param next if <code>true</code> the next node is selected, otherwise the previous node
499
	 */
506
	 */
500
	protected void navigate(boolean next) {	
507
	protected void navigate(boolean next) {	
501
		internalNavigate(next);
508
		internalNavigate(next, false);
502
	}
509
	}
503
	
510
	
504
	//---- private
511
	//---- private
Lines 512-518 Link Here
512
	 * @param next if <code>true</code> the next node is selected, otherwise the previous node
519
	 * @param next if <code>true</code> the next node is selected, otherwise the previous node
513
	 * @return <code>true</code> if at end (or beginning)
520
	 * @return <code>true</code> if at end (or beginning)
514
	 */
521
	 */
515
	private boolean internalNavigate(boolean next) {
522
	private boolean internalNavigate(boolean next, boolean open) {
516
		
523
		
517
		Control c= getControl();
524
		Control c= getControl();
518
		if (!(c instanceof Tree))
525
		if (!(c instanceof Tree))
Lines 528-534 Link Here
528
			if (children != null && children.length > 0) {
535
			if (children != null && children.length > 0) {
529
				item= children[0];
536
				item= children[0];
530
				if (item != null && item.getItemCount() <= 0) {
537
				if (item != null && item.getItemCount() <= 0) {
531
					internalSetSelection(item);
538
					internalSetSelection(item, open);
532
					return false;
539
					return false;
533
				}
540
				}
534
			}
541
			}
Lines 543-549 Link Here
543
		}
550
		}
544
		
551
		
545
		if (item != null) {
552
		if (item != null) {
546
			internalSetSelection(item);
553
			internalSetSelection(item, open);
547
			return false;
554
			return false;
548
		}
555
		}
549
		return true;
556
		return true;
Lines 632-642 Link Here
632
		return item;
639
		return item;
633
	}
640
	}
634
	
641
	
635
	private void internalSetSelection(TreeItem ti) {
642
	private void internalSetSelection(TreeItem ti, boolean open) {
636
		if (ti != null) {
643
		if (ti != null) {
637
			Object data= ti.getData();
644
			Object data= ti.getData();
638
			if (data != null)
645
			if (data != null) {
639
				setSelection(new StructuredSelection(data), true);
646
				ISelection selection= new StructuredSelection(data);
647
				setSelection(selection, true);
648
				if (open && selection.equals(getSelection())) {
649
					fireOpen(new OpenEvent(this, selection));
650
				}
651
			}
640
		}
652
		}
641
	}
653
	}
642
	
654
	
Lines 703-708 Link Here
703
			fCopyLeftToRightAction.setEnabled(leftToRight > 0);
715
			fCopyLeftToRightAction.setEnabled(leftToRight > 0);
704
		if (fCopyRightToLeftAction != null)
716
		if (fCopyRightToLeftAction != null)
705
			fCopyRightToLeftAction.setEnabled(rightToLeft > 0);
717
			fCopyRightToLeftAction.setEnabled(rightToLeft > 0);
718
	}
719
	
720
	private void internalOpen()  {
721
		ISelection selection= getSelection();
722
		if (selection != null && !selection.isEmpty()) {
723
			fireOpen(new OpenEvent(this, selection));
724
		}
706
	}
725
	}
707
}
726
}
708
727

Return to bug 20106