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

The following examples show how to use org.eclipse.nebula.widgets.grid.GridColumnGroup. 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: 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 #2
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 #3
Source File: DefaultColumnGroupHeaderRenderer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    if ((group.getStyle() & SWT.TOGGLE) != 0)
    {
        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (getToggleBounds().contains(point))
            {
                group.setExpanded(!group.getExpanded());

                if (group.getExpanded())
                {
                    group.notifyListeners(SWT.Expand,new Event());
                }
                else
                {
                    group.notifyListeners(SWT.Collapse,new Event());
                }
                return true;
            }
        }
        else
        {
            if (getToggleBounds().contains(point))
            {
                setHoverDetail("toggle");
                return true;
            }
        }
    }

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

    if ((group.getStyle() & SWT.TOGGLE) != 0)
    {
        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (getToggleBounds().contains(point))
            {
                group.setExpanded(!group.getExpanded());

                if (group.getExpanded())
                {
                    group.notifyListeners(SWT.Expand,new Event());
                }
                else
                {
                    group.notifyListeners(SWT.Collapse,new Event());
                }
                return true;
            }
        }
        else
        {
            if (getToggleBounds().contains(point))
            {
                setHoverDetail("toggle");
                return true;
            }
        }
    }

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

    if ((group.getStyle() & SWT.TOGGLE) != 0)
    {
        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (getToggleBounds().contains(point))
            {
                group.setExpanded(!group.getExpanded());

                if (group.getExpanded())
                {
                    group.notifyListeners(SWT.Expand,new Event());
                }
                else
                {
                    group.notifyListeners(SWT.Collapse,new Event());
                }
                return true;
            }
        }
        else
        {
            if (getToggleBounds().contains(point))
            {
                setHoverDetail("toggle");
                return true;
            }
        }
    }

    return false;
}
 
Example #6
Source File: GridSnippet6.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());

    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);
    column2.setSummary(false);
    GridColumn column3 = new GridColumn(columnGroup,SWT.NONE);
    column3.setText("Column 3");
    column3.setWidth(60);
    column3.setSummary(false);
    GridColumn summaryColumn = new GridColumn(columnGroup,SWT.NONE);
    summaryColumn.setText("Sum");
    summaryColumn.setWidth(93);
    summaryColumn.setDetail(false);
    summaryColumn.setSummary(true);
    GridItem item1 = new GridItem(grid,SWT.NONE);
    item1.setText("First Item");
    item1.setText(1,"100");
    item1.setText(2,"42");
    item1.setText(3,"142");
    GridItem item2 = new GridItem(grid,SWT.NONE);
    item2.setText("Second Item");
    item2.setText(1,"63");
    item2.setText(2,"92");
    item2.setText(3,"155");
    GridItem item3 = new GridItem(grid,SWT.NONE);
    item3.setText("Third Item");
    item3.setText(1,"7");
    item3.setText(2,"3");
    item3.setText(3,"10");
    
    shell.setSize(250,250);
    shell.open ();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose ();
}
 
Example #7
Source File: DefaultColumnGroupHeaderRenderer.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point computeSize(GC gc, int wHint, int hHint, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    gc.setFont(group.getHeaderFont());

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


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

        y = Math.max(y, topMargin + group.getImage().getBounds().height + bottomMargin);
    }

    if (!isWordWrap())
    {
      x += gc.stringExtent(group.getText()).x + rightMargin;
    }
    else
    {
      int toggleWidth = 0;
        if ((group.getStyle() & SWT.TOGGLE) != 0)
          toggleWidth = toggleRenderer.getSize().x;

      int plainTextWidth;
      if (wHint == SWT.DEFAULT)
        plainTextWidth = getBounds().width - x - rightMargin - toggleWidth;
      else
        plainTextWidth = wHint - x - rightMargin - toggleWidth;

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

        x += plainTextWidth + rightMargin;

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

        y = Math.max(y, textHeight);
    }
    return new Point(x, y);
}
 
Example #8
Source File: DefaultColumnGroupHeaderRenderer.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)
{
    GridColumnGroup group = (GridColumnGroup)value;

    gc.setFont(group.getHeaderFont());

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


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

        y = Math.max(y, topMargin + group.getImage().getBounds().height + bottomMargin);
    }

    if (!isWordWrap())
    {
      x += gc.stringExtent(group.getText()).x + rightMargin;
    }
    else
    {
      int toggleWidth = 0;
        if ((group.getStyle() & SWT.TOGGLE) != 0)
          toggleWidth = toggleRenderer.getSize().x;

      int plainTextWidth;
      if (wHint == SWT.DEFAULT)
        plainTextWidth = getBounds().width - x - rightMargin - toggleWidth;
      else
        plainTextWidth = wHint - x - rightMargin - toggleWidth;

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

        x += plainTextWidth + rightMargin;

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

        y = Math.max(y, textHeight);
    }
    return new Point(x, y);
}
 
Example #9
Source File: DefaultColumnGroupHeaderRenderer.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)
{
    GridColumnGroup group = (GridColumnGroup)value;

    gc.setFont(group.getHeaderFont());

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


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

        y = Math.max(y, topMargin + group.getImage().getBounds().height + bottomMargin);
    }

    if (!isWordWrap())
    {
      x += gc.stringExtent(group.getText()).x + rightMargin;
    }
    else
    {
      int toggleWidth = 0;
        if ((group.getStyle() & SWT.TOGGLE) != 0)
          toggleWidth = toggleRenderer.getSize().x;

      int plainTextWidth;
      if (wHint == SWT.DEFAULT)
        plainTextWidth = getBounds().width - x - rightMargin - toggleWidth;
      else
        plainTextWidth = wHint - x - rightMargin - toggleWidth;

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

        x += plainTextWidth + rightMargin;

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

        y = Math.max(y, textHeight);
    }
    return new Point(x, y);
}