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

The following examples show how to use org.eclipse.nebula.widgets.grid.GridItem#setChecked() . 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: 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 2
Source File: CellRenderer.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value) {

	GridItem item = (GridItem) value;

	if (isCheck()) {
		if (event == IInternalWidget.MouseMove) {
			if (overCheck(item, point)) {
				setHoverDetail("check");
				return true;
			}
		}

		if (event == IInternalWidget.LeftMouseButtonDown) {
			if (overCheck(item, point)) {
				if (!item.getCheckable(getColumn())) {
					return false;
				}

				item.setChecked(getColumn(), !item.getChecked(getColumn()));
				item.getParent().redraw();

				item.fireCheckEvent(getColumn());

				return true;
			}
		}
	}

	if (isTree() && item.hasChildren()) {
		if (event == IInternalWidget.MouseMove) {
			if (overToggle(item, point)) {
				setHoverDetail("toggle");
				return true;
			}
		}

		if (event == IInternalWidget.LeftMouseButtonDown) {
			if (overToggle(item, point)) {
				item.setExpanded(!item.isExpanded());
				item.getParent().redraw();

				if (item.isExpanded()) {
					item.fireEvent(SWT.Expand);
				} else {
					item.fireEvent(SWT.Collapse);
				}

				return true;
			}
		}
	}

	return false;
}
 
Example 3
Source File: TBSearchCellRenderer.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value) {

	GridItem item = (GridItem) value;

	if (isCheck()) {
		if (event == IInternalWidget.MouseMove) {
			if (overCheck(item, point)) {
				setHoverDetail("check");
				return true;
			}
		}

		if (event == IInternalWidget.LeftMouseButtonDown) {
			if (overCheck(item, point)) {
				if (!item.getCheckable(getColumn())) {
					return false;
				}

				item.setChecked(getColumn(), !item.getChecked(getColumn()));
				item.getParent().redraw();

				item.fireCheckEvent(getColumn());

				return true;
			}
		}
	}

	if (isTree() && item.hasChildren()) {
		if (event == IInternalWidget.MouseMove) {
			if (overToggle(item, point)) {
				setHoverDetail("toggle");
				return true;
			}
		}

		if (event == IInternalWidget.LeftMouseButtonDown) {
			if (overToggle(item, point)) {
				item.setExpanded(!item.isExpanded());
				item.getParent().redraw();

				if (item.isExpanded()) {
					item.fireEvent(SWT.Expand);
				} else {
					item.fireEvent(SWT.Collapse);
				}

				return true;
			}
		}
	}

	return false;
}
 
Example 4
Source File: DefaultCellRenderer.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value)
{

    GridItem item = (GridItem)value;

    if (isCheck())
    {
        if (event == IInternalWidget.MouseMove)
        {
            if (overCheck(item, point))
            {
                setHoverDetail("check");
                return true;
            }
        }

        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (overCheck(item, point))
            {
                if (!item.getCheckable(getColumn()))
                {
                    return false;
                }

                item.setChecked(getColumn(), !item.getChecked(getColumn()));
                item.getParent().redraw();

                item.fireCheckEvent(getColumn());

                return true;
            }
        }
    }

    if (isTree() && item.hasChildren())
    {
        if (event == IInternalWidget.MouseMove)
        {
            if (overToggle(item, point))
            {
                setHoverDetail("toggle");
                return true;
            }
        }

        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (overToggle(item, point))
            {
                item.setExpanded(!item.isExpanded());
                item.getParent().redraw();

                if (item.isExpanded())
                {
                    item.fireEvent(SWT.Expand);
                }
                else
                {
                    item.fireEvent(SWT.Collapse);
                }

                return true;
            }
        }
    }

    return false;
}
 
Example 5
Source File: CellRenderer.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value) {

	GridItem item = (GridItem) value;

	if (isCheck()) {
		if (event == IInternalWidget.MouseMove) {
			if (overCheck(item, point)) {
				setHoverDetail("check");
				return true;
			}
		}

		if (event == IInternalWidget.LeftMouseButtonDown) {
			if (overCheck(item, point)) {
				if (!item.getCheckable(getColumn())) {
					return false;
				}

				item.setChecked(getColumn(), !item.getChecked(getColumn()));
				item.getParent().redraw();

				item.fireCheckEvent(getColumn());

				return true;
			}
		}
	}

	if (isTree() && item.hasChildren()) {
		if (event == IInternalWidget.MouseMove) {
			if (overToggle(item, point)) {
				setHoverDetail("toggle");
				return true;
			}
		}

		if (event == IInternalWidget.LeftMouseButtonDown) {
			if (overToggle(item, point)) {
				item.setExpanded(!item.isExpanded());
				item.getParent().redraw();

				if (item.isExpanded()) {
					item.fireEvent(SWT.Expand);
				} else {
					item.fireEvent(SWT.Collapse);
				}

				return true;
			}
		}
	}

	return false;
}
 
Example 6
Source File: TBSearchCellRenderer.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value) {

	GridItem item = (GridItem) value;

	if (isCheck()) {
		if (event == IInternalWidget.MouseMove) {
			if (overCheck(item, point)) {
				setHoverDetail("check");
				return true;
			}
		}

		if (event == IInternalWidget.LeftMouseButtonDown) {
			if (overCheck(item, point)) {
				if (!item.getCheckable(getColumn())) {
					return false;
				}

				item.setChecked(getColumn(), !item.getChecked(getColumn()));
				item.getParent().redraw();

				item.fireCheckEvent(getColumn());

				return true;
			}
		}
	}

	if (isTree() && item.hasChildren()) {
		if (event == IInternalWidget.MouseMove) {
			if (overToggle(item, point)) {
				setHoverDetail("toggle");
				return true;
			}
		}

		if (event == IInternalWidget.LeftMouseButtonDown) {
			if (overToggle(item, point)) {
				item.setExpanded(!item.isExpanded());
				item.getParent().redraw();

				if (item.isExpanded()) {
					item.fireEvent(SWT.Expand);
				} else {
					item.fireEvent(SWT.Collapse);
				}

				return true;
			}
		}
	}

	return false;
}
 
Example 7
Source File: DefaultCellRenderer.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value)
{

    GridItem item = (GridItem)value;

    if (isCheck())
    {
        if (event == IInternalWidget.MouseMove)
        {
            if (overCheck(item, point))
            {
                setHoverDetail("check");
                return true;
            }
        }

        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (overCheck(item, point))
            {
                if (!item.getCheckable(getColumn()))
                {
                    return false;
                }

                item.setChecked(getColumn(), !item.getChecked(getColumn()));
                item.getParent().redraw();

                item.fireCheckEvent(getColumn());

                return true;
            }
        }
    }

    if (isTree() && item.hasChildren())
    {
        if (event == IInternalWidget.MouseMove)
        {
            if (overToggle(item, point))
            {
                setHoverDetail("toggle");
                return true;
            }
        }

        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (overToggle(item, point))
            {
                item.setExpanded(!item.isExpanded());
                item.getParent().redraw();

                if (item.isExpanded())
                {
                    item.fireEvent(SWT.Expand);
                }
                else
                {
                    item.fireEvent(SWT.Collapse);
                }

                return true;
            }
        }
    }

    return false;
}