Moving GridColumnGroup in Grid [message #1485780] |
Mon, 24 November 2014 14:40 |
Kris Slowinski Messages: 18 Registered: August 2011 |
Junior Member |
|
|
Is it possible to move the entire GridColumnGroup? I can move GridColumn if they are marked as movable ( GridColumn#setMovable(true) ), but I cannot find a corresponding method of doing that for the column group. I have a working example:
import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.GridColumnGroup;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/*
* Simple column grouping example
*/
public class ColumnGrouping {
private final static int ROWS = 1000;
private final Grid grid;
private ColumnGrouping(Shell shell) {
grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
grid.setHeaderVisible(true);
createColumn("Column 1");
GridColumnGroup columnGroup = createColumnGroup("Column 2");
createColumn(columnGroup, "Column 2.1");
createColumn(columnGroup, "Column 2.2");
createColumn("Column 3");
createCoordinateItems();
}
private void createColumn(String title) {
GridColumn column = new GridColumn(grid,SWT.NONE);
column.setText(title);
column.setWidth(100);
column.setMoveable(true);
}
private void createColumn(GridColumnGroup columnGroup, String title) {
GridColumn column = new GridColumn(columnGroup,SWT.NONE);
column.setText(title);
column.setWidth(100);
column.setMoveable(true);
}
private GridColumnGroup createColumnGroup(String title) {
GridColumnGroup columnGroup = new GridColumnGroup(grid,SWT.NONE);
columnGroup.setText(title);
return columnGroup;
}
private void createCoordinateItems() {
for (int i = 0; i < ROWS; i++) {
GridItem item = new GridItem(grid,SWT.NONE);
for (int j = 0; j < grid.getColumnCount(); j++) {
item.setText(j,(i+1) + "," + (j+1));
}
}
}
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
new ColumnGrouping(shell);
shell.setSize(500,500);
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
[Updated on: Mon, 24 November 2014 14:46] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03618 seconds