1 11 package org.eclipse.compare.internal; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.compare.*; 17 18 23 public class CompareEditorInputNavigator extends CompareNavigator { 24 25 private boolean fNextFirstTime= true; 27 private Object [] fPanes; 28 29 33 public CompareEditorInputNavigator(Object [] panes) { 34 fPanes= panes; 35 } 36 37 43 public Object [] getPanes() { 44 return fPanes; 45 } 46 47 protected INavigatable[] getNavigatables() { 48 List result = new ArrayList (); 49 Object [] panes = getPanes(); 50 for (int i = 0; i < panes.length; i++) { 51 Object pane = panes[i]; 52 INavigatable navigator= getNavigator(pane); 53 if (navigator != null) 54 result.add(navigator); 55 } 56 return (INavigatable[]) result.toArray(new INavigatable[result.size()]); 57 } 58 59 62 public boolean selectChange(boolean next) { 63 if (next && fNextFirstTime && mustOpen()) { 65 fNextFirstTime= false; 66 if (openElement()) 67 return false; 68 } 69 return super.selectChange(next); 70 } 71 72 75 private boolean mustOpen() { 76 Object [] panes = getPanes(); 77 if (panes == null || panes.length == 0) 78 return false; 79 for (int i= 1; i < panes.length; i++) { 80 Object pane= panes[i]; 81 INavigatable nav = getNavigator(pane); 82 if (nav != null && nav.getInput() != null) 83 return false; 84 } 85 return true; 86 } 87 88 91 private boolean openElement() { 92 Object [] panes = getPanes(); 93 if (panes == null || panes.length == 0) 94 return false; 95 INavigatable nav = getNavigator(panes[0]); 96 if (nav != null) 97 return nav.openSelectedChange(); 98 return false; 99 } 100 } 101 | Popular Tags |