protected Item newItem(Widget parent, int flags, int ix) { TableTreeItem item; if (ix >= 0) { if (parent instanceof TableTreeItem) { item = new TableTreeItem((TableTreeItem) parent, flags, ix); } else { item = new TableTreeItem((TableTree) parent, flags, ix); } } else { if (parent instanceof TableTreeItem) { item = new TableTreeItem((TableTreeItem) parent, flags); } else { item = new TableTreeItem((TableTree) parent, flags); } } return item; }
protected Item[] getChildren(Widget o) { if (o instanceof TableTreeItem) { return ((TableTreeItem) o).getItems(); } if (o instanceof TableTree) { return ((TableTree) o).getItems(); } return null; }
protected Item getChild(Widget widget, int index) { if (widget instanceof TableTreeItem) { return ((TableTreeItem) widget).getItem(index); } if (widget instanceof TableTree) { return ((TableTree) widget).getItem(index); } return null; }
protected void addTreeListener(Control c, TreeListener listener) { ((TableTree) c).addTreeListener(listener); }
protected int getItemCount(Control widget) { return ((TableTree) widget).getItemCount(); }
protected Item[] getSelection(Control widget) { return ((TableTree) widget).getSelection(); }
protected void removeAll(Control widget) { ((TableTree) widget).removeAll(); }
/** * Creates and returns the color image data for the given control * and RGB value. The image's size is either the control's item extent * or the cell editor's default extent, which is 16 pixels square. * * @param w the control * @param color the color */ private ImageData createColorImage(Control w, RGB color) { GC gc = new GC(w); FontMetrics fm = gc.getFontMetrics(); int size = fm.getAscent(); gc.dispose(); int indent = 6; int extent = DEFAULT_EXTENT; if (w instanceof Table) { extent = ((Table) w).getItemHeight() - 1; } else if (w instanceof Tree) { extent = ((Tree) w).getItemHeight() - 1; } else if (w instanceof TableTree) { extent = ((TableTree) w).getItemHeight() - 1; } if (size > extent) { size = extent; } int width = indent + size; int height = extent; int xoffset = indent; int yoffset = (height - size) / 2; RGB black = new RGB(0, 0, 0); PaletteData dataPalette = new PaletteData(new RGB[] { black, black, color }); ImageData data = new ImageData(width, height, 4, dataPalette); data.transparentPixel = 0; int end = size - 1; for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { if (x == 0 || y == 0 || x == end || y == end) { data.setPixel(x + xoffset, y + yoffset, 1); } else { data.setPixel(x + xoffset, y + yoffset, 2); } } } return data; }
/** * Creates a table tree viewer on the given table tree control. The viewer * has no input, no content provider, a default label provider, no sorter, * and no filters. * * @param tree * the table tree control */ public TableTreeViewer(TableTree tree) { super(); tableTree = tree; hookControl(tree); tableTreeEditor = new TableTreeEditor(tableTree); tableEditorImpl = new TableTreeEditorImpl(this); }
/** * Creates a table tree viewer on a newly-created table tree control under * the given parent. The table tree control is created using the given SWT * style bits. The viewer has no input, no content provider, a default label * provider, no sorter, and no filters. * * @param parent * the parent control * @param style * the SWT style bits */ public TableTreeViewer(Composite parent, int style) { this(new TableTree(parent, style)); }
/** * Returns this table tree viewer's table tree control. * * @return the table tree control */ public TableTree getTableTree() { return tableTree; }