Java Code Examples for org.eclipse.nebula.widgets.grid.GridItem#setColumnSpan()

The following examples show how to use org.eclipse.nebula.widgets.grid.GridItem#setColumnSpan() . 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: 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 2
Source File: GridColumnLabelProvider.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void update(ViewerCell cell) {
	super.update(cell);

	Object element = cell.getElement();

	String rowText = getRowHeaderText(element);
	int colSpan = getColumnSpan(element);
	int rowSpan = getRowSpan(element);

	GridItem gridItem = (GridItem)cell.getViewerRow().getItem();
	if (rowText != null) {
		gridItem.setHeaderText(rowText);
	}

	gridItem.setColumnSpan(cell.getColumnIndex(), colSpan);
	gridItem.setRowSpan(cell.getColumnIndex(), rowSpan);
}
 
Example 3
Source File: GridColumnLabelProvider.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void update(ViewerCell cell) {
	super.update(cell);

	Object element = cell.getElement();

	String rowText = getRowHeaderText(element);
	int colSpan = getColumnSpan(element);
	int rowSpan = getRowSpan(element);

	GridItem gridItem = (GridItem)cell.getViewerRow().getItem();
	if (rowText != null) {
		gridItem.setHeaderText(rowText);
	}

	gridItem.setColumnSpan(cell.getColumnIndex(), colSpan);
	gridItem.setRowSpan(cell.getColumnIndex(), rowSpan);
}
 
Example 4
Source File: GridColumnLabelProvider.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void update(ViewerCell cell) {
	super.update(cell);

	Object element = cell.getElement();

	String rowText = getRowHeaderText(element);
	int colSpan = getColumnSpan(element);
	int rowSpan = getRowSpan(element);

	GridItem gridItem = (GridItem)cell.getViewerRow().getItem();
	if (rowText != null) {
		gridItem.setHeaderText(rowText);
	}

	gridItem.setColumnSpan(cell.getColumnIndex(), colSpan);
	gridItem.setRowSpan(cell.getColumnIndex(), rowSpan);
}
 
Example 5
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 6
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 7
Source File: TestBug246608.java    From nebula with Eclipse Public License 2.0 4 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.setAutoWidth(true);

	GridColumn column1 = new GridColumn(grid, SWT.NONE);
	column1.setText("Column 1");
	column1.setWidth(150);
	column1.setWordWrap(true);
	column1.setVerticalAlignment(SWT.TOP);

	GridColumn column2 = new GridColumn(grid, SWT.NONE);
	column2.setText("Column 2");
	column2.setWidth(200);
	column2.setWordWrap(true);
	column2.setVerticalAlignment(SWT.CENTER);

	GridColumn column3 = new GridColumn(grid, SWT.NONE);
	column3.setText("Column 3");
	column3.setWidth(200);
	column3.setVerticalAlignment(SWT.BOTTOM);

	GridItem item1 = new GridItem(grid, SWT.NONE);
	item1.setText(0, "Item 1, Column 0: " + MEDIUM_TEXT);
	item1.setText(1, "Item 1, Column 1: " + MEDIUM_TEXT);
	item1.setText(2, "Item 1, Column 2: " + MEDIUM_TEXT);
	item1.setHeight(150);

	GridItem item2 = new GridItem(grid, SWT.NONE);
	item2.setText("Item 2, Columns 0-1: " + MEDIUM_TEXT);
	item2.setColumnSpan(0, 1);
	item2.setText(2, "Item 2, Column 2: Dummy");
	item2.setHeight(100);

	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);
	item3.setText(2, "Item 3, Column 2: Column");
	item3.setHeight(120);

	shell.setSize(600, 500);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example 8
Source File: GridSnippet7.java    From nebula with Eclipse Public License 2.0 4 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.setFooterVisible(true);

	GridColumn column = new GridColumn(grid, SWT.NONE);
	column.setText("Column 1");
	column.setWidth(100);
	column.setHeaderControl(new CCombo(grid, SWT.READ_ONLY | SWT.BORDER));
	column.setMoveable(true);

	GridColumn column2 = new GridColumn(grid, SWT.NONE);
	column2.setText("Column 2");
	column2.setWidth(100);
	column2.setMoveable(true);
	column2.setHeaderControl(new Text(grid, SWT.BORDER));

	for (int i = 0; i < 100; i++) {
		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");
	}

	grid.addMouseListener(new MouseAdapter() {

		public void mouseDown(MouseEvent e) {
			if (e.y < grid.getHeaderHeight()) {
				System.out.println("header click");
			}
		}

	});

	shell.setSize(200, 200);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example 9
Source File: GridRowSpanSnippet.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 *
 * @param args
 */
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 two rows");
    item2.setText(1, "xxxxxxx");
    item2.setRowSpan(0, 1);
    item2.setColumnSpan(0, 1);


    GridItem item3 = new GridItem(grid, SWT.NONE);
    item3.setText("Third Item");
    item3.setText(1, "xxxxxxx");

    shell.setSize(200,200);
    shell.open ();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch ()) display.sleep ();
    }

    display.dispose ();
}