use of com.centurylink.mdw.plugin.designer.model.ProcessInstanceSort in project mdw-designer by CenturyLinkCloud.
the class ProcessInstanceListView method createTable.
private void createTable(Composite parent) {
int style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;
processInstanceTable = new Table(parent, style);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 10;
processInstanceTable.setLayoutData(gridData);
processInstanceTable.setLinesVisible(true);
processInstanceTable.setHeaderVisible(true);
for (int i = 0; i < columnSpecs.size(); i++) {
ColumnSpec colSpec = columnSpecs.get(i);
int styles = SWT.LEFT;
if (colSpec.readOnly)
style = style | SWT.READ_ONLY;
TableColumn column = new TableColumn(processInstanceTable, styles, i);
column.setText(colSpec.label);
column.setWidth(colSpec.width);
column.setResizable(colSpec.resizable);
column.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableColumn sortColumn = tableViewer.getTable().getSortColumn();
TableColumn currentColumn = (TableColumn) e.widget;
int direction = tableViewer.getTable().getSortDirection();
if (sortColumn == currentColumn) {
direction = direction == SWT.UP ? SWT.DOWN : SWT.UP;
} else {
tableViewer.getTable().setSortColumn(currentColumn);
direction = SWT.DOWN;
}
tableViewer.getTable().setSortDirection(direction);
ProcessInstanceSort sort = contentProvider.getSort();
sort.setSort(currentColumn.getText());
sort.setAscending(direction == SWT.UP);
refreshTable();
}
});
}
// double-click
processInstanceTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
ProcessInstanceVO processInstanceInfo = (ProcessInstanceVO) e.item.getData();
handleOpen(processInstanceInfo);
}
});
// right-click menu
processInstanceTable.addListener(SWT.MenuDetect, new Listener() {
public void handleEvent(Event event) {
processInstanceTable.setMenu(createContextMenu(processInstanceTable.getShell()));
}
});
// auto-adjust column width
processInstanceTable.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
int tableWidth = processInstanceTable.getBounds().width;
int cumulative = 0;
TableColumn[] tableColumns = processInstanceTable.getColumns();
for (int i = 0; i < tableColumns.length; i++) {
if (i == tableColumns.length - 1)
tableColumns[i].setWidth(tableWidth - cumulative - 25);
cumulative += tableColumns[i].getWidth();
}
}
});
}
Aggregations