org.eclipse.nebula.widgets.grid.Grid Java Examples
The following examples show how to use
org.eclipse.nebula.widgets.grid.Grid.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GridSnippet1.java From nebula with Eclipse Public License 2.0 | 7 votes |
public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); shell.setLayout(new FillLayout()); Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); grid.setHeaderVisible(true); GridColumn column = new GridColumn(grid,SWT.NONE); column.setTree(true); column.setText("Column 1"); column.setWidth(100); GridItem item1 = new GridItem(grid,SWT.NONE); item1.setText("Root Item"); GridItem item2 = new GridItem(item1,SWT.NONE); item2.setText("Second item"); GridItem item3 = new GridItem(item2,SWT.NONE); item3.setText("Third Item"); shell.setSize(200,200); shell.open (); while (!shell.isDisposed()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }
Example #2
Source File: GridViewerEditor.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * FIXME * {@inheritDoc} */ public ViewerCell getFocusCell() { Grid grid = (Grid)getViewer().getControl(); if( grid.getCellSelectionEnabled() ) { Point p = grid.getFocusCell(); if( p.x >= 0 && p.y >= 0 ) { GridItem item = grid.getItem(p.y); if( item != null ) { ViewerRow row = getViewerRowFromItem(item); return row.getCell(p.x); } } } return null; }
Example #3
Source File: GridViewerEditor.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * FIXME * {@inheritDoc} */ @Override public ViewerCell getFocusCell() { Grid grid = (Grid)getViewer().getControl(); if( grid.getCellSelectionEnabled() ) { Point p = grid.getFocusCell(); if( p.x >= 0 && p.y >= 0 ) { GridItem item = grid.getItem(p.y); if( item != null ) { ViewerRow row = getViewerRowFromItem(item); return row.getCell(p.x); } } } return null; }
Example #4
Source File: GridSnippet2.java From nebula with Eclipse Public License 2.0 | 6 votes |
public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); shell.setLayout(new FillLayout()); Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); grid.setHeaderVisible(true); GridColumn column = new GridColumn(grid,SWT.NONE); column.setText("Column 1"); column.setWidth(100); GridColumn column2 = new GridColumn(grid,SWT.NONE); column2.setText("Column 2"); column2.setWidth(100); GridItem item1 = new GridItem(grid,SWT.NONE); item1.setText("First Item"); item1.setText(1,"xxxxxxx"); GridItem item2 = new GridItem(grid,SWT.NONE); item2.setText("This cell spans both columns"); item1.setText(1,"xxxxxxx"); item2.setColumnSpan(0,1); GridItem item3 = new GridItem(grid,SWT.NONE); item3.setText("Third Item"); item1.setText(1,"xxxxxxx"); shell.setSize(200,200); shell.open (); while (!shell.isDisposed()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }
Example #5
Source File: GridViewerEditor.java From nebula with Eclipse Public License 2.0 | 6 votes |
public ViewerCell getFocusCell() { Grid grid = (Grid)getViewer().getControl(); if( grid.getCellSelectionEnabled() ) { Point p = grid.getFocusCell(); if( p.x >= 0 && p.y >= 0 ) { GridItem item = grid.getItem(p.y); if( item != null ) { ViewerRow row = getViewerRowFromItem(item); return row.getCell(p.x); } } } return null; }
Example #6
Source File: GridPropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void applyCSSPropertyFont(final Object element, final Grid grid, final CSSValue value, String target) throws Exception { if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) { final CSSValueList valueList = (CSSValueList) value; final int length = valueList.getLength(); for (int i = 0; i < length; i++) { final CSSValue value2 = valueList.item(i); if (value2.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final String cssProp = CSS2FontHelper.getCSSFontPropertyName((CSSPrimitiveValue) value2); if (cssProp.equals("font-family")) { applyCSSPropertyFamily(element, grid, value2, target); } else if (cssProp.equals("font-size")) { applyCSSPropertySize(element, grid, value2, target); } else if (cssProp.equals("font-weight") && ("bold".equals(value2.getCssText()) || "bolder".equals(value2.getCssText()))) { applyCSSPropertyWeight(element, grid, value2, target); } else if (cssProp.equals("font-style") && ("italic".equals(value2.getCssText()) || "oblique".equals(value2.getCssText()))) { applyCSSPropertyStyle(element, grid, value2, target); } } } } }
Example #7
Source File: GridPropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private boolean applyCSSPropertyStyle(final Object element, final Grid grid, final CSSValue value, String target) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(grid); boolean modified = false; if ("italic".equals(value.getCssText()) || "oblique".equals(value.getCssText())) { modified = (fd.getStyle() & SWT.ITALIC) != SWT.ITALIC; if (modified) { fd.setStyle(fd.getStyle() | SWT.ITALIC); } } else { modified = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC; if (modified) { fd.setStyle(fd.getStyle() | ~SWT.ITALIC); } } if (modified) { applyFont(grid, fd, target); } } return true; }
Example #8
Source File: GridPropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private boolean applyCSSPropertyWeight(final Object element, final Grid grid, final CSSValue value, String target) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(grid); boolean modified = false; if ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) { modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | SWT.BOLD); } } else { modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | ~SWT.BOLD); } } if (modified) { applyFont(grid, fd, target); } } return true; }
Example #9
Source File: GridSnippet1.java From nebula with Eclipse Public License 2.0 | 6 votes |
public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); shell.setLayout(new FillLayout()); Grid grid = new Grid(shell,/*SWT.BORDER |*/ SWT.V_SCROLL | SWT.H_SCROLL); // grid.setHeaderVisible(true); GridColumn column = new GridColumn(grid,SWT.NONE); // column.setTree(true); // column.setText("Column 1"); // column.setWidth(100); GridItem item1 = new GridItem(grid,SWT.NONE); item1.setText("Root Item"); GridItem item2 = new GridItem(grid,SWT.NONE); item2.setText("Second item"); GridItem item3 = new GridItem(grid,SWT.NONE); item3.setText("Third Item"); shell.setSize(200,200); shell.open (); while (!shell.isDisposed()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }
Example #10
Source File: GridViewerEditor.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ protected void updateFocusCell(ViewerCell focusCell, ColumnViewerEditorActivationEvent event) { Grid grid = ((Grid)getViewer().getControl()); if (event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC || event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL) { grid.setFocusColumn(grid.getColumn(focusCell.getColumnIndex())); grid.setFocusItem((GridItem) focusCell.getItem()); if( selectionFollowsEditor ) { grid.setCellSelection(new Point(focusCell.getColumnIndex(),grid.indexOf((GridItem)focusCell.getItem()))); } } grid.showColumn(grid.getColumn(focusCell.getColumnIndex())); grid.showItem((GridItem) focusCell.getItem()); }
Example #11
Source File: GridSnippet12.java From nebula with Eclipse Public License 2.0 | 5 votes |
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); grid.setHeaderVisible(true); GridColumn firstColumn = new GridColumn(grid, SWT.NONE); firstColumn.setText("Column 1 (START Truncation)"); firstColumn.setWidth(150); firstColumn.getCellRenderer().setTruncationStyle(SWT.LEFT); GridColumn secondColumn = new GridColumn(grid, SWT.NONE); secondColumn.setText("Column 1 (MIDDLE Truncation)"); secondColumn.setWidth(150); secondColumn.getCellRenderer().setTruncationStyle(SWT.CENTER); GridColumn thirdColumn = new GridColumn(grid, SWT.NONE); thirdColumn.setText("Column 1 (END Truncation)"); thirdColumn.setWidth(150); thirdColumn.getCellRenderer().setTruncationStyle(SWT.RIGHT); for (int i = 0; i < 50; i++) { GridItem item = new GridItem(grid, SWT.NONE); item.setText(0, "Start truncation for this text (line #" + i + ")"); item.setText(1, "Middle truncation for this text (line #" + i + ")"); item.setText(2, "End truncation for this text (line #" + i + ")"); } shell.setSize(500,400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Example #12
Source File: GridSnippetBug472289.java From nebula with Eclipse Public License 2.0 | 5 votes |
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); grid.setHeaderVisible(true); grid.setMoveOnTab(true); GridColumn column = new GridColumn(grid, SWT.NONE); column.setText("Column 1"); column.setWidth(100); GridColumn column2 = new GridColumn(grid, SWT.NONE); column2.setText("Column 2"); column2.setWidth(100); GridItem item1 = new GridItem(grid, SWT.NONE); item1.setText("First Item"); item1.setText(1, "xxxxxxx"); GridItem item2 = new GridItem(grid, SWT.NONE); item2.setText("This cell spans both columns"); item1.setText(1, "xxxxxxx"); item2.setColumnSpan(0, 1); GridItem item3 = new GridItem(grid, SWT.NONE); item3.setText("Third Item"); item1.setText(1, "xxxxxxx"); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Example #13
Source File: GridSnippet8.java From nebula with Eclipse Public License 2.0 | 5 votes |
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); grid.setHeaderVisible(true); grid.setAutoHeight(true); grid.setAutoWidth(true); GridColumn column1 = new GridColumn(grid, SWT.NONE); column1.setText("Column 1"); column1.setWidth(150); column1.setWordWrap(true); GridColumn column2 = new GridColumn(grid, SWT.NONE); column2.setText("Column 2"); column2.setWidth(200); column2.setWordWrap(true); GridItem item1 = new GridItem(grid, SWT.NONE); item1.setText(0, "Item 1, Column 0: " + LONG_TEXT); item1.setText(1, "Item 1, Column 1: " + LONG_TEXT); GridItem item2 = new GridItem(grid, SWT.NONE); item2.setText("Item 2, Columns 0-1: " + LONG_TEXT); item2.setColumnSpan(0, 1); GridItem item3 = new GridItem(grid, SWT.NONE); item3.setText(0, "Item 3, Column 0: " + MEDIUM_TEXT); item3.setText(1, "Item 3, Column 1: " + MEDIUM_TEXT); shell.setSize(400, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Example #14
Source File: GridColumnLayout.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * {@inheritDoc} */ protected void setColumnWidths(Scrollable tableTree, int[] widths) { GridColumn[] columns = ((Grid) tableTree).getColumns(); for (int i = 0; i < widths.length; i++) { columns[i].setWidth(widths[i]); } }
Example #15
Source File: GridTreeViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** {@inheritDoc} */ protected Item[] getChildren(Widget o) { if (o instanceof GridItem) { return ((GridItem) o).getItems(); } if (o instanceof Grid) { return ((Grid) o).getRootItems(); } return null; }
Example #16
Source File: GridViewerEditor.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
GridViewerEditor(ColumnViewer viewer, ColumnViewerEditorActivationStrategy editorActivationStrategy, int feature) { super(viewer, editorActivationStrategy, feature); this.selectionFollowsEditor = (feature & SELECTION_FOLLOWS_EDITOR) == SELECTION_FOLLOWS_EDITOR; this.gridEditor = new GridEditor((Grid) viewer.getControl()); }
Example #17
Source File: GridSnippet4.java From nebula with Eclipse Public License 2.0 | 5 votes |
public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); shell.setLayout(new FillLayout()); Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); grid.setHeaderVisible(true); GridColumn column = new GridColumn(grid,SWT.NONE); column.setText("Column 1"); column.setWidth(100); GridColumnGroup columnGroup = new GridColumnGroup(grid,SWT.NONE); columnGroup.setText("Column Group"); GridColumn column2 = new GridColumn(columnGroup,SWT.NONE); column2.setText("Column 2"); column2.setWidth(60); GridColumn column3 = new GridColumn(columnGroup,SWT.NONE); column3.setText("Column 3"); column3.setWidth(60); GridItem item1 = new GridItem(grid,SWT.NONE); item1.setText("First Item"); item1.setText(1,"abc"); GridItem item2 = new GridItem(grid,SWT.NONE); item2.setText("Second Item"); item2.setText(2,"def"); GridItem item3 = new GridItem(grid,SWT.NONE); item3.setText("Third Item"); item3.setText(1,"xyz"); shell.setSize(250,250); shell.open (); while (!shell.isDisposed()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }
Example #18
Source File: GridSnippet3.java From nebula with Eclipse Public License 2.0 | 5 votes |
public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); shell.setLayout(new FillLayout()); Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); grid.setHeaderVisible(true); GridColumn column = new GridColumn(grid,SWT.NONE); column.setText("Column 1"); column.setWidth(100); GridColumn column2 = new GridColumn(grid,SWT.CHECK | SWT.CENTER); column2.setText("Column 2"); column2.setWidth(100); GridItem item1 = new GridItem(grid,SWT.NONE); item1.setText("First Item"); item1.setChecked(1,true); GridItem item2 = new GridItem(grid,SWT.NONE); item2.setText("Second Item"); GridItem item3 = new GridItem(grid,SWT.NONE); item3.setText("Third Item"); shell.setSize(250,250); shell.open (); while (!shell.isDisposed()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }
Example #19
Source File: GridColumnLayout.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * {@inheritDoc} */ protected void updateColumnData(Widget column) { GridColumn gColumn = (GridColumn) column; Grid g = gColumn.getParent(); if (!IS_GTK || g.getColumn(g.getColumnCount() - 1) != gColumn) { gColumn.setData(LAYOUT_DATA, new ColumnPixelData(gColumn.getWidth())); layout(g.getParent(), true); } }
Example #20
Source File: GridViewerColumn.java From nebula with Eclipse Public License 2.0 | 5 votes |
private static GridColumn createColumn(Grid table, int style, int index) { if (index >= 0) { return new GridColumn(table, style, index); } return new GridColumn(table, style); }
Example #21
Source File: GridViewerColumn.java From nebula with Eclipse Public License 2.0 | 5 votes |
private static GridColumn createColumn(Grid table, int style, int index) { if (index >= 0) { return new GridColumn(table, style, index); } return new GridColumn(table, style); }
Example #22
Source File: GridTreeViewer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected Item[] getChildren(Widget o) { if (o instanceof GridItem) { return ((GridItem) o).getItems(); } if (o instanceof Grid) { return ((Grid) o).getRootItems(); } return null; }
Example #23
Source File: GridTreeViewer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** {@inheritDoc} */ protected Item[] getChildren(Widget o) { if (o instanceof GridItem) { return ((GridItem) o).getItems(); } if (o instanceof Grid) { return ((Grid) o).getRootItems(); } return null; }
Example #24
Source File: GridPropertyHandler.java From nebula with Eclipse Public License 2.0 | 5 votes |
private boolean applyCSSPropertyFamily(final Object element, final Grid grid, final CSSValue value, String target) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(grid); final boolean modified = !fd.getName().equals(value.getCssText()); if (modified) { fd.setName(value.getCssText()); applyFont(grid, fd, target); } } return true; }
Example #25
Source File: GridCopyEnable.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * @param gridTable */ public GridCopyEnable(Grid gridTable) { Assert.isNotNull(gridTable); this.gridTable = gridTable; defaultCaret = new Caret(gridTable, SWT.NONE); clipboard = new Clipboard(gridTable.getDisplay()); this.gridTable.setCaret(defaultCaret); this.gridTable.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_IBEAM)); initListener(); }
Example #26
Source File: GridTreeViewer.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ protected int getItemCount(Control control) { return ((Grid) control).getItemCount(); }
Example #27
Source File: GridTreeViewer.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** {@inheritDoc} */ protected int getItemCount(Control control) { return ((Grid) control).getItemCount(); }
Example #28
Source File: GridTreeViewer.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** {@inheritDoc} */ protected void addTreeListener(Control control, TreeListener listener) { ((Grid) control).addTreeListener(listener); }
Example #29
Source File: CellRenderer.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * Calculates the sequence of branch lines which should be rendered for the provided item * @param item * @return an array of integers composed using the constants in {@link BranchRenderer} */ private int[] getBranches(GridItem item) { int[] branches = new int[item.getLevel() + 1]; GridItem[] roots = item.getParent().getRootItems(); // Is this a node or a leaf? if (item.getParentItem() == null) { // Add descender if not last item if (!item.isExpanded() && roots[roots.length - 1].equals(item)) { if (item.hasChildren()) branches[item.getLevel()] = BranchRenderer.LAST_ROOT; else branches[item.getLevel()] = BranchRenderer.SMALL_L; } else { if (item.hasChildren()) branches[item.getLevel()] = BranchRenderer.ROOT; else branches[item.getLevel()] = BranchRenderer.SMALL_T; } } else if (item.hasChildren()) if (item.isExpanded()) branches[item.getLevel()] = BranchRenderer.NODE; else branches[item.getLevel()] = BranchRenderer.NONE; else branches[item.getLevel()] = BranchRenderer.LEAF; // Branch for current item GridItem parent = item.getParentItem(); if (parent == null) return branches; // Are there siblings below this item? if (parent.indexOf(item) < parent.getItemCount() - 1) branches[item.getLevel() - 1] = BranchRenderer.T; // Is the next node a root? else if (parent.getParentItem() == null && !parent.equals(roots[roots.length - 1])) branches[item.getLevel() - 1] = BranchRenderer.T; // This must be the last element at this level else branches[item.getLevel() - 1] = BranchRenderer.L; Grid grid = item.getParent(); item = parent; parent = item.getParentItem(); // Branches for parent items while (item.getLevel() > 0) { if (parent.indexOf(item) == parent.getItemCount() - 1) { if (parent.getParentItem() == null && !grid.getRootItem(grid.getRootItemCount() - 1).equals(parent)) branches[item.getLevel() - 1] = BranchRenderer.I; else branches[item.getLevel() - 1] = BranchRenderer.NONE; } else branches[item.getLevel() - 1] = BranchRenderer.I; item = parent; parent = item.getParentItem(); } // item should be null at this point return branches; }
Example #30
Source File: DefaultCellRenderer.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * Calculates the sequence of branch lines which should be rendered for the provided item * @param item * @return an array of integers composed using the constants in {@link BranchRenderer} */ private int[] getBranches(GridItem item) { int[] branches = new int[item.getLevel() + 1]; GridItem[] roots = item.getParent().getRootItems(); // Is this a node or a leaf? if (item.getParentItem() == null) { // Add descender if not last item if (!item.isExpanded() && roots[roots.length-1].equals(item)) { if (item.hasChildren()) branches[item.getLevel()] = BranchRenderer.LAST_ROOT; else branches[item.getLevel()] = BranchRenderer.SMALL_L; } else { if (item.hasChildren()) branches[item.getLevel()] = BranchRenderer.ROOT; else branches[item.getLevel()] = BranchRenderer.SMALL_T; } } else if (item.hasChildren()) if (item.isExpanded()) branches[item.getLevel()] = BranchRenderer.NODE; else branches[item.getLevel()] = BranchRenderer.NONE; else branches[item.getLevel()] = BranchRenderer.LEAF; // Branch for current item GridItem parent = item.getParentItem(); if (parent == null) return branches; // Are there siblings below this item? if (parent.indexOf(item) < parent.getItemCount() - 1) branches[item.getLevel() - 1] = BranchRenderer.T; // Is the next node a root? else if (parent.getParentItem() == null && !parent.equals(roots[roots.length - 1])) branches[item.getLevel() - 1] = BranchRenderer.T; // This must be the last element at this level else branches[item.getLevel() - 1] = BranchRenderer.L; Grid grid = item.getParent(); item = parent; parent = item.getParentItem(); // Branches for parent items while(item.getLevel() > 0) { if (parent.indexOf(item) == parent.getItemCount() - 1) { if (parent.getParentItem() == null && !grid.getRootItem(grid.getRootItemCount() - 1).equals(parent)) branches[item.getLevel() - 1] = BranchRenderer.I; else branches[item.getLevel() - 1] = BranchRenderer.NONE; } else branches[item.getLevel() - 1] = BranchRenderer.I; item = parent; parent = item.getParentItem(); } // item should be null at this point return branches; }