org.eclipse.nebula.widgets.grid.GridColumn Java Examples

The following examples show how to use org.eclipse.nebula.widgets.grid.GridColumn. 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 vote down vote up
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: GridSnippet2.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
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 #3
Source File: GridPropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void applyFont(final GridColumn column, final FontData fd, String target) {
	if (target.equals(HEADER)) {
		if (column.getHeaderFont() != null && !column.getHeaderFont().equals(column.getDisplay().getSystemFont())) {
			column.getHeaderFont().dispose();
		}
	} else {
		if (column.getFooterFont() != null && !column.getFooterFont().equals(column.getDisplay().getSystemFont())) {
			column.getFooterFont().dispose();
		}
	}
	final Font newFont = new Font(column.getDisplay(), fd);
	if (target.equals(HEADER)) {
		column.setHeaderFont(newFont);
	} else {
		column.setFooterFont(newFont);
	}

	column.getParent().addListener(SWT.Dispose, e -> {
		if (newFont != null && !newFont.isDisposed()) {
			newFont.dispose();
		}
	});
}
 
Example #4
Source File: GridSnippet1.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
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 #5
Source File: FirstPart.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@PostConstruct
public void createComposite(final Composite parent) {
	parent.setLayout(new FillLayout());

	grid = new Grid(parent,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");

	grid.setData(CSS_ID, "one");

}
 
Example #6
Source File: GridCopyEnable.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
void clearSelection() {
	int start = selection.x;
	int end = selection.y;
	selection.x = selection.y = caretOffset;
	selectionAnchor = -1;
	// redraw old selection, if any
	if (end - start > 0 && gridTable.getItems().length != 0) {
		if (layout == null && focusItemIndex != -1 && focusItemIndex != -1) {
			GridItem item = gridTable.getItem(focusItemIndex);
			GridColumn col = gridTable.getColumn(focusColIndex);
			GridCellRenderer gcr = col.getCellRenderer();
			if (gcr != null && gcr instanceof XGridCellRenderer) {
				GC gc = new GC(gcr.getDisplay());
				layout = ((XGridCellRenderer) gcr).getTextLayout(gc, item, focusColIndex, true, false);
				gc.dispose();
			}
			if (layout == null) {
				return;
			}
		}
		Rectangle rect = layout.getBounds(start, end);
		gridTable.redraw(rect.x + coordinateOffsetX, rect.y + coordinateOffsetY, rect.width, rect.height, false);
	}
}
 
Example #7
Source File: GridCopyEnable.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
void clearSelection() {
	int start = selection.x;
	int end = selection.y;
	selection.x = selection.y = caretOffset;
	selectionAnchor = -1;
	// redraw old selection, if any
	if (end - start > 0 && gridTable.getItems().length != 0) {
		if (layout == null && focusItemIndex != -1 && focusItemIndex != -1) {
			GridItem item = gridTable.getItem(focusItemIndex);
			GridColumn col = gridTable.getColumn(focusColIndex);
			GridCellRenderer gcr = col.getCellRenderer();
			if (gcr != null && gcr instanceof XGridCellRenderer) {
				GC gc = new GC(gcr.getDisplay());
				layout = ((XGridCellRenderer) gcr).getTextLayout(gc, item, focusColIndex, true, false);
				gc.dispose();
			}
			if (layout == null) {
				return;
			}
		}
		Rectangle rect = layout.getBounds(start, end);
		gridTable.redraw(rect.x + coordinateOffsetX, rect.y + coordinateOffsetY, rect.width, rect.height, false);
	}
}
 
Example #8
Source File: GridViewerColumn.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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 #9
Source File: GridViewerColumn.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
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 #10
Source File: GridSnippet5.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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.TOGGLE);
    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);
    column3.setSummary(false);
    column3.setDetail(true);
    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 #11
Source File: GridSnippet4.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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 #12
Source File: GridWithTextWrapping.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
protected static void calculateHeight() {
	for (GridItem item : fGrid.getItems()) {
		GC gc = new GC(item.getDisplay());
		GridColumn gridColumn = fGrid.getColumn(0);
		Point textBounds = gridColumn.getCellRenderer().computeSize(gc, gridColumn.getWidth(), SWT.DEFAULT, item);
		gc.dispose();
		item.setHeight(textBounds.y);
	}
}
 
Example #13
Source File: GridSnippet8.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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: DefaultColumnHeaderRenderer.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the bounds reserved for the control
 */
protected Rectangle getControlBounds(Object value, boolean preferred) {
	Rectangle bounds = getBounds();
	GridColumn column = (GridColumn) value;
	Point controlSize = computeControlSize(column);

	int y = getBounds().y + getBounds().height - bottomMargin - controlSize.y;

	return new Rectangle(bounds.x+3,y,bounds.width-6,controlSize.y);
}
 
Example #15
Source File: GridSnippetBug472289.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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 #16
Source File: GridSnippet12.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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 #17
Source File: DefaultColumnHeaderRenderer.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the bounds reserved for the control
 */
protected Rectangle getControlBounds(Object value, boolean preferred) {
	Rectangle bounds = getBounds();
	GridColumn column = (GridColumn) value;
	Point controlSize = computeControlSize(column);

	int y = getBounds().y + getBounds().height - bottomMargin - controlSize.y;

	return new Rectangle(bounds.x+3,y,bounds.width-6,controlSize.y);
}
 
Example #18
Source File: GridViewerColumn.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
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 #19
Source File: GridColumnLayout.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@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 #20
Source File: GridColumnLayout.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@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 #21
Source File: GridViewerColumn.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
GridViewerColumn(ColumnViewer viewer, GridColumn column) {
	super(viewer, column);
	this.viewer = viewer;
    this.column = column;
    hookColumnResizeListener();
    hookVisibilityListener();
}
 
Example #22
Source File: GridViewerColumn.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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 #23
Source File: DefaultColumnHeaderRenderer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @see org.eclipse.nebula.widgets.grid.GridHeaderRenderer#getControlBounds(java.lang.Object, boolean)
 */
protected Rectangle getControlBounds(Object value, boolean preferred) {
	Rectangle bounds = getBounds();
	GridColumn column = (GridColumn) value;
	Point controlSize = computeControlSize(column);

	int y = getBounds().y + getBounds().height - bottomMargin - controlSize.y;

	return new Rectangle(bounds.x+3,y,bounds.width-6,controlSize.y);
}
 
Example #24
Source File: GridSnippet3.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
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 #25
Source File: GridCopyEnable.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
void doMouseLocationChange(int x, int y, boolean select) {
	if (gridTable.getItems().length == 0) {
		defaultCaret.setVisible(false);
		return;
	}
	Point eventP = new Point(x, y);
	GridItem _focusItem = gridTable.getItem(eventP);
	GridColumn col = gridTable.getColumn(eventP);
	if (_focusItem == null) {
		return;
	}
	GridCellRenderer gcr = col.getCellRenderer();
	int colIndex = gcr.getColumn();
	if (gcr == null || !(gcr instanceof XGridCellRenderer) || !copyAbleColumnIndexs.contains(colIndex)) {
		return;
	}
	XGridCellRenderer cellRender = (XGridCellRenderer) gcr;

	Rectangle cellBounds = _focusItem.getBounds(colIndex);
	GC gc = new GC(Display.getDefault());
	layout = cellRender.getTextLayout(gc, _focusItem, colIndex, true, false);
	if (layout == null) {
		gc.dispose();
		return;
	}
	focusContent = layout.getText();
	coordinateOffsetX = cellBounds.x + cellRender.leftMargin;
	coordinateOffsetY = cellBounds.y + cellRender.topMargin + cellRender.textTopMargin;
	if (!select) {
		focusCellRect.x = cellBounds.x;
		focusCellRect.y = cellBounds.y;
		focusCellRect.height = cellBounds.height;
		focusCellRect.width = cellBounds.width;
		focusColIndex = colIndex;
		focusItemIndex = gridTable.getIndexOfItem(_focusItem);
	}

	int[] trailing = new int[1];
	int newCaretOffset = layout.getOffset(x - coordinateOffsetX, y - coordinateOffsetY, trailing);

	int newCaretLine = layout.getLineIndex(newCaretOffset + trailing[0]);
	int lineStart = layout.getLineOffsets()[newCaretLine];
	Point point = null;
	if (newCaretOffset + trailing[0] == lineStart && trailing[0] != 0) {
		newCaretOffset += trailing[0];
		newCaretOffset = layout.getPreviousOffset(newCaretOffset, SWT.MOVEMENT_CLUSTER);
		point = layout.getLocation(newCaretOffset, true);
	} else {
		newCaretOffset += trailing[0];
		point = layout.getLocation(newCaretOffset, false);
	}

	// check area, only in cell area effective
	boolean vchange = focusCellRect.y <= y && y < focusCellRect.y + focusCellRect.height;
	boolean hchange = focusCellRect.x <= x && x < focusCellRect.x + focusCellRect.width;

	if (vchange && hchange && newCaretOffset != caretOffset) {
		focusItem = _focusItem;
		caretOffset = newCaretOffset;
		if (select) {
			doMouseSelection();
		}
		defaultCaret.setVisible(true);
		Rectangle rc = layout.getLineBounds(newCaretLine);
		defaultCaret.setBounds(point.x + coordinateOffsetX, point.y + coordinateOffsetY, 0, rc.height);
	}
	if (!select) {
		caretOffset = newCaretOffset;
		clearSelection();
	}
	layout.dispose();
	layout = null;
	gc.dispose();
}
 
Example #26
Source File: GridViewerColumn.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
GridViewerColumn(ColumnViewer viewer, GridColumn column) {
	super(viewer, column);
	this.viewer = viewer;
    this.column = column;
    hookColumnResizeListener();
}
 
Example #27
Source File: DefaultColumnHeaderRenderer.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
private Point computeControlSize(GridColumn column) {
	if( column.getHeaderControl() != null ) {
		return column.getHeaderControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
	}
	return new Point(0,0);
}
 
Example #28
Source File: GridPropertyHandler.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private void applyFont(final Grid grid, final FontData fd, String target) {
	for (GridColumn column : grid.getColumns()) {
		applyFont(column, fd, target);
	}
}
 
Example #29
Source File: DefaultColumnHeaderRenderer.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
    * {@inheritDoc}
    */
   public Point computeSize(GC gc, int wHint, int hHint, Object value)
   {
       GridColumn column = (GridColumn)value;

       gc.setFont(column.getHeaderFont());

       int x = leftMargin;
       int y = topMargin + gc.getFontMetrics().getHeight() + bottomMargin;


       if (column.getImage() != null)
       {
           x += column.getImage().getBounds().width + imageSpacing;

           y = Math.max(y, topMargin + column.getImage().getBounds().height + bottomMargin);
       }
       if (!isWordWrap())
       {
         x += gc.stringExtent(column.getText()).x + rightMargin;
       }
       else
       {
         int plainTextWidth;
         if (wHint == SWT.DEFAULT)
           plainTextWidth = getBounds().width - x - rightMargin;
         else
           plainTextWidth = wHint - x - rightMargin;

         getTextLayout(gc, column);
           textLayout.setText(column.getText());
           textLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);

           x += plainTextWidth + rightMargin;

           int textHeight = topMargin;
           textHeight += textLayout.getBounds().height;
           textHeight += bottomMargin;

           y = Math.max(y, textHeight);
       }


	y += computeControlSize(column).y;

	return new Point(x, y);
}
 
Example #30
Source File: DefaultColumnHeaderRenderer.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
    * {@inheritDoc}
    */
   public Point computeSize(GC gc, int wHint, int hHint, Object value)
   {
       GridColumn column = (GridColumn)value;

       gc.setFont(column.getHeaderFont());

       int x = leftMargin;
       int y = topMargin + gc.getFontMetrics().getHeight() + bottomMargin;


       if (column.getImage() != null)
       {
           x += column.getImage().getBounds().width + imageSpacing;

           y = Math.max(y, topMargin + column.getImage().getBounds().height + bottomMargin);
       }
       if (!isWordWrap())
       {
         x += gc.stringExtent(column.getText()).x + rightMargin;
       }
       else
       {
         int plainTextWidth;
         if (wHint == SWT.DEFAULT)
           plainTextWidth = getBounds().width - x - rightMargin;
         else
           plainTextWidth = wHint - x - rightMargin;

         getTextLayout(gc, column);
           textLayout.setText(column.getText());
           textLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);

           x += plainTextWidth + rightMargin;

           int textHeight = topMargin;
           textHeight += textLayout.getBounds().height;
           textHeight += bottomMargin;

           y = Math.max(y, textHeight);
       }


	y += computeControlSize(column).y;

	return new Point(x, y);
}