use of com.cubrid.common.ui.spi.TableViewerSorter 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 com.cubrid.common.ui.spi.TableViewerSorter in project cubrid-manager by CUBRID.
the class CQBUserEditor method createPartControl.
/**
* Create the page content
*
* @param parent the parent composite
*/
public void createPartControl(Composite parent) {
GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 5;
gridLayout.marginWidth = 5;
GridData gridData = new GridData();
gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
topComp = new Composite(parent, SWT.NONE);
topComp.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
topComp.setLayout(gridLayout);
CLabel lblUser = new CLabel(topComp, SWT.NONE);
lblUser.setFont(new Font(topComp.getDisplay(), lblUser.getFont().toString(), 14, SWT.BOLD));
lblUser.setBackground(topComp.getBackground());
lblUser.setLayoutData(gridData);
lblUser.setText(userName);
lblUserGroup = new Label(topComp, SWT.NONE);
lblUserGroup.setBackground(topComp.getBackground());
lblUserGroup.setText("");
lblUserGroup.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
lblUserMember = new Label(topComp, SWT.NONE);
lblUserMember.setBackground(topComp.getBackground());
lblUserMember.setText("");
lblUserMember.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
GridData gridData1 = new GridData(GridData.FILL_HORIZONTAL);
gridData1.heightHint = 4;
CLabel lbl = new CLabel(topComp, SWT.SHADOW_IN);
lbl.setLayoutData(gridData1);
lbl = new CLabel(topComp, SWT.NONE);
lbl.setBackground(topComp.getBackground());
lbl.setText(Messages.lblOwnerClassList);
Composite ownerComp = new Composite(topComp, SWT.NONE);
ownerComp.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.marginWidth = 1;
layout.marginHeight = 1;
ownerComp.setLayout(layout);
final String[] columnNameArr = new String[] { Messages.tblColOwnerClassName, Messages.tblColOwnerClassSchema, Messages.tblColOwnerClassType };
ownerClassTableViewer = CommonUITool.createCommonTableViewer(ownerComp, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
ownerClassTableViewer.setInput(ownerClassListData);
lbl = new CLabel(topComp, SWT.SHADOW_IN);
lbl.setLayoutData(gridData1);
lbl = new CLabel(topComp, SWT.NONE);
lbl.setBackground(topComp.getBackground());
lbl.setText(Messages.lblAuthorizationList);
authComp = new Composite(topComp, SWT.NONE);
authComp.setLayoutData(new GridData(GridData.FILL_BOTH));
layout = new GridLayout();
layout.marginWidth = 1;
layout.marginHeight = 1;
authComp.setLayout(layout);
authComp.setBackground(topComp.getBackground());
if (DB_DBA_USERNAME.equalsIgnoreCase(userName)) {
CLabel clbl = new CLabel(authComp, SWT.NONE);
clbl.setBackground(topComp.getBackground());
clbl.setText(Messages.lblDbaAllAuth);
} else {
final String[] authColumnNameArr = new String[] { Messages.tblColAuthTable, Messages.tblColAuthSelect, Messages.tblColAuthInsert, Messages.tblColAuthUpdate, Messages.tblColAuthDelete, Messages.tblColAuthAlter, Messages.tblColAuthIndex, Messages.tblColAuthExecute, Messages.tblColAuthGrantselect, Messages.tblColAuthGrantinsert, Messages.tblColAuthGrantupdate, Messages.tblColAuthGrantdelete, Messages.tblColAuthGrantalter, Messages.tblColAuthGrantindex, Messages.tblColAuthGrantexecute };
authTableViewer = createCommonTableViewer(authComp, authColumnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
authTableViewer.setLabelProvider(new ExTableLabelProvider());
authTableViewer.setInput(authListData);
}
loadData();
}
use of com.cubrid.common.ui.spi.TableViewerSorter 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;
}
use of com.cubrid.common.ui.spi.TableViewerSorter in project cubrid-manager by CUBRID.
the class CommonUITool method createCommonTableViewer.
/**
*
* Create the common table viewer that can be sorted by TableViewerSorter
* object,this viewer's input object must be List<Map<String,Object>> and
* Map's key must be column index,Map's value of the column must be String.
*
* @param parent the parent composite
* @param sorter the table sorter
* @param columnNameArr the column name array
* @param columnwidthArr the column width array
* @param gridData the gridData layout object
* @return the TableViewer object
*/
public static TableViewer createCommonTableViewer(Composite parent, ViewerSorter sorter, final String[] columnNameArr, int[] columnwidthArr, 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);
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();
packTable(tableViewer);
}
});
}
if (columnwidthArr != null) {
tblColumn.setWidth(columnwidthArr[i]);
} else {
tblColumn.pack();
}
}
return tableViewer;
}
use of com.cubrid.common.ui.spi.TableViewerSorter in project cubrid-manager by CUBRID.
the class DatabaseStatusEditor method createCommonTableViewer.
/**
*
* Create the common table viewer that can be sorted by TableViewerSorter
* object,this viewer's input object must be List<Map<String,Object>> and
* Map's key must be column index,Map's value of the column must be String.
*
* @param parent the parent composite
* @param sorter the sorter
* @param columnNameArr the column name array
* @param gridData the griddata
* @return the table viewer
*/
public static TableViewer createCommonTableViewer(Composite parent, ViewerSorter sorter, final String[] columnNameArr, GridData gridData) {
final TableViewer tableViewer = new TableViewer(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.NO_SCROLL);
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);
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