1 14 15 package org.eclipse.jface.viewers; 16 17 import org.eclipse.swt.graphics.Color; 18 import org.eclipse.swt.graphics.Font; 19 import org.eclipse.swt.graphics.Image; 20 import org.eclipse.swt.graphics.Point; 21 import org.eclipse.swt.graphics.Rectangle; 22 import org.eclipse.swt.widgets.Control; 23 import org.eclipse.swt.widgets.Widget; 24 25 33 public abstract class ViewerRow implements Cloneable { 34 35 40 public static final int ABOVE = 1; 41 42 47 public static final int BELOW = 2; 48 49 55 public abstract Rectangle getBounds(int columnIndex); 56 57 62 public abstract Rectangle getBounds(); 63 64 69 public abstract Widget getItem(); 70 71 76 public abstract int getColumnCount(); 77 78 84 public abstract Image getImage(int columnIndex); 85 86 92 public abstract void setImage(int columnIndex, Image image); 93 94 100 public abstract String getText(int columnIndex); 101 102 108 public abstract void setText(int columnIndex, String text); 109 110 116 public abstract Color getBackground(int columnIndex); 117 118 124 public abstract void setBackground(int columnIndex, Color color); 125 126 132 public abstract Color getForeground(int columnIndex); 133 134 140 public abstract void setForeground(int columnIndex, Color color); 141 142 148 public abstract Font getFont(int columnIndex); 149 150 156 public abstract void setFont(int columnIndex, Font font); 157 158 164 public ViewerCell getCell(Point point) { 165 int index = getColumnIndex(point); 166 return getCell(index); 167 } 168 169 175 public int getColumnIndex(Point point) { 176 int count = getColumnCount(); 177 178 if (count == 0) { 180 return 0; 181 } 182 183 for (int i = 0; i < count; i++) { 184 if (getBounds(i).contains(point)) { 185 return i; 186 } 187 } 188 189 return -1; 190 } 191 192 199 public ViewerCell getCell(int column) { 200 if (column >= 0) 201 return new ViewerCell((ViewerRow) clone(), column, getElement()); 202 203 return null; 204 } 205 206 211 public abstract Control getControl(); 212 213 225 public abstract ViewerRow getNeighbor(int direction, boolean sameLevel); 226 227 232 public abstract TreePath getTreePath(); 233 234 public abstract Object clone(); 235 236 239 public abstract Object getElement(); 240 241 public int hashCode() { 242 final int prime = 31; 243 int result = 1; 244 result = prime * result 245 + ((getItem() == null) ? 0 : getItem().hashCode()); 246 return result; 247 } 248 249 public boolean equals(Object obj) { 250 if (this == obj) 251 return true; 252 if (obj == null) 253 return false; 254 if (getClass() != obj.getClass()) 255 return false; 256 final ViewerRow other = (ViewerRow) obj; 257 if (getItem() == null) { 258 if (other.getItem() != null) 259 return false; 260 } else if (!getItem().equals(other.getItem())) 261 return false; 262 return true; 263 } 264 265 } 266 | Popular Tags |