1 11 12 package org.eclipse.jface.viewers; 13 14 import org.eclipse.swt.SWT; 15 import org.eclipse.swt.widgets.Event; 16 17 28 public class CellNavigationStrategy { 29 38 public boolean isNavigationEvent(ColumnViewer viewer, Event event) { 39 switch (event.keyCode) { 40 case SWT.ARROW_UP: 41 case SWT.ARROW_DOWN: 42 case SWT.ARROW_LEFT: 43 case SWT.ARROW_RIGHT: 44 case SWT.HOME: 45 case SWT.PAGE_DOWN: 46 case SWT.PAGE_UP: 47 case SWT.END: 48 return true; 49 default: 50 return false; 51 } 52 } 53 54 63 public boolean isCollapseEvent(ColumnViewer viewer, 64 ViewerCell cellToCollapse, Event event) { 65 return false; 66 } 67 68 77 public boolean isExpandEvent(ColumnViewer viewer, ViewerCell cellToExpand, 78 Event event) { 79 return false; 80 } 81 82 90 public void expand(ColumnViewer viewer, ViewerCell cellToExpand, Event event) { 91 92 } 93 94 102 public void collapse(ColumnViewer viewer, ViewerCell cellToCollapse, 103 Event event) { 104 105 } 106 107 118 public ViewerCell findSelectedCell(ColumnViewer viewer, 119 ViewerCell currentSelectedCell, Event event) { 120 121 switch (event.keyCode) { 122 case SWT.ARROW_UP: 123 if (currentSelectedCell != null) { 124 return currentSelectedCell.getNeighbor(ViewerCell.ABOVE, false); 125 } 126 break; 127 case SWT.ARROW_DOWN: 128 if (currentSelectedCell != null) { 129 return currentSelectedCell.getNeighbor(ViewerCell.BELOW, false); 130 } 131 break; 132 case SWT.ARROW_LEFT: 133 if (currentSelectedCell != null) { 134 return currentSelectedCell.getNeighbor(ViewerCell.LEFT, true); 135 } 136 break; 137 case SWT.ARROW_RIGHT: 138 if (currentSelectedCell != null) { 139 return currentSelectedCell.getNeighbor(ViewerCell.RIGHT, true); 140 } 141 break; 142 } 143 144 return null; 145 } 146 147 157 public boolean shouldCancelEvent(ColumnViewer viewer, Event event) { 158 return event.keyCode == SWT.ARROW_LEFT 159 || event.keyCode == SWT.ARROW_RIGHT; 160 } 161 162 166 protected void init() { 167 } 168 } 169 | Popular Tags |