use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class SettingCubridConfPage method createControl.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
setControl(container);
setDescription(Messages.descSettingCubridPage);
Composite leftComposite = new Composite(container, SWT.NONE);
leftComposite.setLayout(new GridLayout(3, false));
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 5);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 5);
leftData.right = new FormAttachment(50, -5);
leftComposite.setLayoutData(leftData);
Label separator = new Label(container, SWT.SEPARATOR);
FormData separatorData = new FormData();
separatorData.top = new FormAttachment(0, 5);
separatorData.bottom = new FormAttachment(100, -5);
separatorData.left = new FormAttachment(50, -5);
separatorData.right = new FormAttachment(50, 5);
separator.setLayoutData(separatorData);
Composite rightComposite = new Composite(container, SWT.NONE);
rightComposite.setLayout(new GridLayout(3, false));
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(50, 5);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
/*Create left widget*/
Label hostALabel = new Label(leftComposite, SWT.None);
hostALabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostALabel.setText(Messages.lblMaster);
masterHostLabel = new Label(leftComposite, SWT.None);
masterHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
masterViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION);
masterViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
masterViewer.getTable().setLinesVisible(true);
masterViewer.getTable().setHeaderVisible(true);
masterViewer.setContentProvider(new TableContentProvider());
masterViewer.setLabelProvider(new CubridConfTableProvider());
masterViewer.setColumnProperties(PROPS);
CellEditor[] editorsA = new CellEditor[2];
editorsA[0] = null;
editorsA[1] = new TextCellEditor(masterViewer.getTable());
masterViewer.setCellEditors(editorsA);
masterViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(PROPS[1])) {
return true;
}
return false;
}
public Object getValue(Object element, String property) {
DataModel model = (DataModel) element;
if (property.equals(PROPS[0])) {
return model.getKey() == null ? "" : model.getKey();
} else if (property.equals(PROPS[1])) {
return model.getValue() == null ? "" : model.getValue();
}
return "";
}
public void modify(Object element, String property, Object value) {
TableItem item = (TableItem) element;
DataModel model = (DataModel) item.getData();
model.setValue(value.toString());
masterViewer.refresh(model);
updateHAModel(masterViewer, model, false);
}
});
TableColumn keyAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
keyAColumn.setText(Messages.lblKey);
keyAColumn.setWidth(160);
TableColumn valueAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
valueAColumn.setText(Messages.lblValue);
valueAColumn.setWidth(200);
Label masterDBLabel = new Label(leftComposite, SWT.None);
masterDBLabel.setText(Messages.lblDatabase);
masterDBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
masterDBCombo = new Combo(leftComposite, SWT.BORDER | SWT.READ_ONLY);
masterDBCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
masterDBCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
HAModel haModel = getConfigHAWizard().getHaModel();
/*Init table data*/
initTableData(haModel.getMasterServer(), true);
HAServer haServer = haModel.getSlaveServer();
initTableData(haServer, false);
}
});
ToolBar toolBarA = new ToolBar(leftComposite, SWT.None);
toolBarA.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
ToolItem addItemA = new ToolItem(toolBarA, SWT.None);
addItemA.setToolTipText(Messages.itemAddParameter);
addItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
addItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addParameter(masterViewer);
}
});
ToolItem editItemA = new ToolItem(toolBarA, SWT.None);
editItemA.setToolTipText(Messages.itemEditParameter);
editItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
editItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editParameter(masterViewer);
}
});
ToolItem dropItemA = new ToolItem(toolBarA, SWT.None);
dropItemA.setToolTipText(Messages.itemDeleteParameter);
dropItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
dropItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
dropParameter(masterViewer);
}
});
/*Create right widget*/
Label hostBLabel = new Label(rightComposite, SWT.None);
hostBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostBLabel.setText(Messages.lblSlave);
slaveHostLabel = new Label(rightComposite, SWT.None);
slaveHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
slaveViewer = new TableViewer(rightComposite, SWT.BORDER | SWT.FULL_SELECTION);
slaveViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
slaveViewer.getTable().setLinesVisible(true);
slaveViewer.getTable().setHeaderVisible(true);
slaveViewer.setContentProvider(new TableContentProvider());
slaveViewer.setLabelProvider(new CubridConfTableProvider());
slaveViewer.setColumnProperties(PROPS);
CellEditor[] editorsB = new CellEditor[2];
editorsB[0] = null;
editorsB[1] = new TextCellEditor(slaveViewer.getTable());
slaveViewer.setCellEditors(editorsB);
slaveViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(PROPS[1])) {
return true;
}
return false;
}
public Object getValue(Object element, String property) {
DataModel model = (DataModel) element;
if (property.equals(PROPS[0])) {
return model.getKey() == null ? "" : model.getKey();
} else if (property.equals(PROPS[1])) {
return model.getValue() == null ? "" : model.getValue();
}
return "";
}
public void modify(Object element, String property, Object value) {
TableItem item = (TableItem) element;
DataModel model = (DataModel) item.getData();
model.setValue(value.toString());
slaveViewer.refresh(model);
updateHAModel(slaveViewer, model, false);
}
});
TableColumn keyBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
keyBColumn.setText(Messages.lblKey);
keyBColumn.setWidth(160);
TableColumn valueBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
valueBColumn.setText(Messages.lblValue);
valueBColumn.setWidth(200);
ToolBar toolBarB = new ToolBar(rightComposite, SWT.None);
toolBarB.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 3, 1, -1, -1));
ToolItem addItemB = new ToolItem(toolBarB, SWT.None);
addItemB.setToolTipText(Messages.itemAddParameter);
addItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
addItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addParameter(slaveViewer);
}
});
ToolItem editItemB = new ToolItem(toolBarB, SWT.None);
editItemB.setToolTipText(Messages.itemEditParameter);
editItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
editItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editParameter(slaveViewer);
}
});
ToolItem dropItemB = new ToolItem(toolBarB, SWT.None);
dropItemB.setToolTipText(Messages.itemDeleteParameter);
dropItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
dropItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
dropParameter(slaveViewer);
}
});
}
use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class CQBUserEditor method createCommonTableViewer.
/**
* Create common tableViewer
*
* @param parent the parent composite
* @param columnNameArr the column name array
* @param gridData the grid data
* @return the table viewer
*/
public TableViewer createCommonTableViewer(Composite parent, final String[] columnNameArr, GridData gridData) {
final TableViewer tableViewer = new TableViewer(parent, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
tableViewer.setContentProvider(new TableContentProvider());
tableViewer.setLabelProvider(new ExTableLabelProvider());
tableViewer.setSorter(new TableViewerSorter());
tableViewer.getTable().setLinesVisible(true);
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLayoutData(gridData);
for (int i = 0; i < columnNameArr.length; i++) {
final TableColumn tblColumn = new TableColumn(tableViewer.getTable(), SWT.CHECK);
tblColumn.setData(false);
tblColumn.setText(columnNameArr[i]);
tblColumn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
TableColumn column = (TableColumn) event.widget;
int j = 0;
for (j = 0; j < columnNameArr.length; j++) {
if (column.getText().equals(columnNameArr[j])) {
break;
}
}
TableViewerSorter sorter = ((TableViewerSorter) tableViewer.getSorter());
if (sorter == null) {
return;
}
sorter.doSort(j);
tableViewer.getTable().setSortColumn(column);
tableViewer.getTable().setSortDirection(sorter.isAsc() ? SWT.UP : SWT.DOWN);
tableViewer.refresh();
for (int k = 0; k < tableViewer.getTable().getColumnCount(); k++) {
tableViewer.getTable().getColumn(k).pack();
}
return;
}
});
tblColumn.pack();
}
return tableViewer;
}
use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class ColumnViewerSorter method createTablesDetailInfoTable.
/**
* createTablesDetailInfoTable
*
* @param parent
*/
public void createTablesDetailInfoTable(Composite parent) {
final Composite tableComposite = new Composite(parent, SWT.NONE);
tableComposite.setLayout(new FillLayout());
tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
tableListView = new TableViewer(tableComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
tableListView.getTable().setHeaderVisible(true);
tableListView.getTable().setLinesVisible(true);
final TableViewerColumn columnTableName = new TableViewerColumn(tableListView, SWT.LEFT);
columnTableName.getColumn().setWidth(150);
columnTableName.getColumn().setText(Messages.tablesDetailInfoPartColTableName);
columnTableName.getColumn().addSelectionListener(new SelectionAdapter() {
boolean isAsc = false;
public void widgetSelected(SelectionEvent e) {
tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_NAME));
tableListView.getTable().setSortColumn(columnTableName.getColumn());
tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
isAsc = !isAsc;
}
});
final TableViewerColumn columnTableDesc = new TableViewerColumn(tableListView, SWT.LEFT);
columnTableDesc.getColumn().setWidth(200);
columnTableDesc.getColumn().setText(Messages.tablesDetailInfoPartColTableMemo);
columnTableDesc.getColumn().addSelectionListener(new SelectionAdapter() {
boolean isAsc = false;
public void widgetSelected(SelectionEvent e) {
tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_MEMO));
tableListView.getTable().setSortColumn(columnTableDesc.getColumn());
tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
isAsc = !isAsc;
}
});
final TableViewerColumn columnRecordsCount = new TableViewerColumn(tableListView, SWT.LEFT);
columnRecordsCount.getColumn().setWidth(60);
columnRecordsCount.getColumn().setText(Messages.tablesDetailInfoPartColRecordsCount);
columnRecordsCount.getColumn().addSelectionListener(new SelectionAdapter() {
boolean isAsc = false;
public void widgetSelected(SelectionEvent e) {
tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_RECORD));
tableListView.getTable().setSortColumn(columnRecordsCount.getColumn());
tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
isAsc = !isAsc;
}
});
final TableViewerColumn columnColumnsCount = new TableViewerColumn(tableListView, SWT.LEFT);
columnColumnsCount.getColumn().setWidth(80);
columnColumnsCount.getColumn().setText(Messages.tablesDetailInfoPartColColumnsCount);
columnColumnsCount.getColumn().addSelectionListener(new SelectionAdapter() {
boolean isAsc = false;
public void widgetSelected(SelectionEvent e) {
tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_COLUMN));
tableListView.getTable().setSortColumn(columnColumnsCount.getColumn());
tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
isAsc = !isAsc;
}
});
final TableViewerColumn columnPK = new TableViewerColumn(tableListView, SWT.LEFT);
columnPK.getColumn().setWidth(50);
columnPK.getColumn().setText(Messages.tablesDetailInfoPartColPK);
columnPK.getColumn().addSelectionListener(new SelectionAdapter() {
boolean isAsc = false;
public void widgetSelected(SelectionEvent e) {
tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_PK));
tableListView.getTable().setSortColumn(columnPK.getColumn());
tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
isAsc = !isAsc;
}
});
final TableViewerColumn columnTableUK = new TableViewerColumn(tableListView, SWT.LEFT);
columnTableUK.getColumn().setWidth(50);
columnTableUK.getColumn().setText(Messages.tablesDetailInfoPartColUK);
columnTableUK.getColumn().addSelectionListener(new SelectionAdapter() {
boolean isAsc = false;
public void widgetSelected(SelectionEvent e) {
tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_UK));
tableListView.getTable().setSortColumn(columnTableUK.getColumn());
tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
isAsc = !isAsc;
}
});
final TableViewerColumn columnFK = new TableViewerColumn(tableListView, SWT.LEFT);
columnFK.getColumn().setWidth(50);
columnFK.getColumn().setText(Messages.tablesDetailInfoPartColFK);
columnFK.getColumn().addSelectionListener(new SelectionAdapter() {
boolean isAsc = false;
public void widgetSelected(SelectionEvent e) {
tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_FK));
tableListView.getTable().setSortColumn(columnFK.getColumn());
tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
isAsc = !isAsc;
}
});
final TableViewerColumn columnIndex = new TableViewerColumn(tableListView, SWT.LEFT);
columnIndex.getColumn().setWidth(50);
columnIndex.getColumn().setText(Messages.tablesDetailInfoPartColIndex);
columnIndex.getColumn().addSelectionListener(new SelectionAdapter() {
boolean isAsc = false;
public void widgetSelected(SelectionEvent e) {
tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_INDEX));
tableListView.getTable().setSortColumn(columnIndex.getColumn());
tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
isAsc = !isAsc;
}
});
final TableViewerColumn columnRecordsSize = new TableViewerColumn(tableListView, SWT.LEFT);
columnRecordsSize.getColumn().setWidth(100);
columnRecordsSize.getColumn().setText(Messages.tablesDetailInfoPartColTableRecordsSize);
columnRecordsSize.getColumn().addSelectionListener(new SelectionAdapter() {
boolean isAsc = false;
public void widgetSelected(SelectionEvent e) {
tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_SIZE));
tableListView.getTable().setSortColumn(columnRecordsSize.getColumn());
tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
isAsc = !isAsc;
}
});
tableListView.setContentProvider(new TableDashboardContentProvider());
tableListView.setLabelProvider(new TableDashboardLabelProvider());
tableListView.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
TableDetailInfo oneTableDetail = (TableDetailInfo) selection.getFirstElement();
openTableDetail(oneTableDetail);
}
});
tableListView.getTable().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
copySelectedTableNamesToClipboard();
} else if (event.keyCode == SWT.CR) {
showEditDialog(tableListView.getTable(), tableListView.getTable().getSelectionIndex());
}
}
});
registerContextMenu();
}
use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class TableDashboardComposite method createColumnsTable.
/**
* Create the column information table
*
*/
private void createColumnsTable(Composite topComposite) {
columnTableView = new TableViewer(topComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
Table columnsTable = columnTableView.getTable();
columnsTable.setLinesVisible(true);
columnsTable.setHeaderVisible(true);
final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
gdColumnsTable.heightHint = 189;
columnsTable.setLayoutData(gdColumnsTable);
// 0 PK
TableColumn tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setAlignment(SWT.CENTER);
tblCol.setWidth(WIDTH_PKCOLUMN);
tblCol.setText(Messages.tblColumnPK);
// 1 NAME
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_NAMECOLUMN);
tblCol.setText(Messages.tblColumnName);
// 2 MEMO
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_NAMECOLUMN);
tblCol.setText(Messages.tblColumnMemo);
// 3 DATATYPE
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_DATATYPECOLUMN);
tblCol.setText(Messages.tblColumnDataType);
// 4 DEFAULT
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(98);
tblCol.setText(Messages.tblColumnDefault);
// 5 AUTO INCREMENT
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setAlignment(SWT.CENTER);
tblCol.setWidth(100);
tblCol.setText(Messages.tblColumnAutoIncr);
// 6 NOT NULL
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_NOTNULLCOLUMN);
tblCol.setText(Messages.tblColumnNotNull);
tblCol.setAlignment(SWT.CENTER);
// 7 UK
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_UNIQUECOLUMN);
tblCol.setText(Messages.tblColumnUnique);
tblCol.setAlignment(SWT.CENTER);
// 8 SHARED
tblCol = new TableColumn(columnsTable, SWT.NONE);
tblCol.setWidth(WIDTH_SHAREDCOLUMN);
tblCol.setResizable(true);
tblCol.setText(Messages.tblColumnShared);
tblCol.setAlignment(SWT.CENTER);
labelProvider = new TableDashboardDetailLabelProvider(null, null);
columnTableView.setContentProvider(new TableDashboardDetailContentProvider());
columnTableView.setLabelProvider(labelProvider);
columnTableView.getTable().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
copyTablesDetailToClipboard();
} else if (event.keyCode == SWT.CR) {
showEditDialog(columnTableView.getTable(), columnTableView.getTable().getSelectionIndex());
}
}
});
registerContextMenu();
}
use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class CreateViewDialog method createCommonTableViewer.
/**
* create Common Table Viewer
*
* @param parent Composite
* @param sorter ViewerSorter
* @param columnNameArr String[]
* @param gridData GridData
* @return TableViewer
*/
public TableViewer createCommonTableViewer(Composite parent, ViewerSorter sorter, final String[] columnNameArr, GridData gridData) {
final TableViewer tableViewer = new TableViewer(parent, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
tableViewer.setContentProvider(new TableContentProvider());
tableViewer.setLabelProvider(new TableLabelProvider());
if (sorter != null) {
tableViewer.setSorter(sorter);
}
tableViewer.getTable().setLinesVisible(true);
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLayoutData(gridData);
for (int i = 0; i < columnNameArr.length; i++) {
final TableColumn tblColumn = new TableColumn(tableViewer.getTable(), SWT.LEFT | (isPropertyQuery ? SWT.NULL : SWT.READ_ONLY));
tblColumn.setText(columnNameArr[i]);
if (sorter != null) {
tblColumn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
TableColumn column = (TableColumn) event.widget;
int j = 0;
for (j = 0; j < columnNameArr.length; j++) {
if (column.getText().equals(columnNameArr[j])) {
break;
}
}
TableViewerSorter sorter = ((TableViewerSorter) tableViewer.getSorter());
if (sorter == null) {
return;
}
sorter.doSort(j);
tableViewer.getTable().setSortColumn(column);
tableViewer.getTable().setSortDirection(sorter.isAsc() ? SWT.UP : SWT.DOWN);
tableViewer.refresh();
for (int k = 0; k < tableViewer.getTable().getColumnCount(); k++) {
tableViewer.getTable().getColumn(k).pack();
}
}
});
}
tblColumn.pack();
}
return tableViewer;
}
Aggregations