use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class DatabaseDashboardEditor method createVolumnComposite.
/**
* create volumn information composite
*
* @param bar ExpandBar
* @param bar index
*
*/
public void createVolumnComposite(ExpandBar bar, int index) {
ExpandItem volumnItem = new ExpandItem(bar, SWT.NONE, index);
volumnItem.setText(Messages.exportDashboardVolumnTableTitle);
Composite volumnComposite = new Composite(bar, SWT.NONE);
volumnComposite.setLayout(new FillLayout());
volumnInfoTableViewer = new TableViewer(volumnComposite, SWT.BORDER | SWT.FULL_SELECTION);
volumnInfoTableViewer.getTable().setHeaderVisible(true);
volumnInfoTableViewer.getTable().setLinesVisible(true);
final TableViewerColumn columnVolumn = new TableViewerColumn(volumnInfoTableViewer, SWT.CENTER);
columnVolumn.getColumn().setWidth(140);
columnVolumn.getColumn().setText(Messages.volumnTableVolumnNameColumnLabel);
columnVolumn.getColumn().setToolTipText(Messages.volumnTableVolumnNameColumnLabel);
final TableViewerColumn columnType = new TableViewerColumn(volumnInfoTableViewer, SWT.CENTER);
columnType.getColumn().setWidth(90);
columnType.getColumn().setText(Messages.volumnTableVolumnTypeColumnLabel);
columnType.getColumn().setToolTipText(Messages.volumnTableVolumnTypeColumnLabel);
final TableViewerColumn columnFreeSize = new TableViewerColumn(volumnInfoTableViewer, SWT.RIGHT);
columnFreeSize.getColumn().setWidth(90);
columnFreeSize.getColumn().setText(Messages.volumnTableFreesizeColumnLabel);
columnFreeSize.getColumn().setToolTipText(Messages.volumnTableFreesizeColumnLabel);
final TableViewerColumn columnTotalSize = new TableViewerColumn(volumnInfoTableViewer, SWT.RIGHT);
columnTotalSize.getColumn().setWidth(90);
columnTotalSize.getColumn().setText(Messages.volumnTableTotalsizeColumnLabel);
columnTotalSize.getColumn().setToolTipText(Messages.volumnTableTotalsizeColumnLabel);
final TableViewerColumn lastModifyDate = new TableViewerColumn(volumnInfoTableViewer, SWT.CENTER);
lastModifyDate.getColumn().setWidth(90);
lastModifyDate.getColumn().setText(Messages.volumnTableLastModifyTimeColumnLabel);
lastModifyDate.getColumn().setToolTipText(Messages.volumnTableLastModifyTimeColumnLabel);
final TableViewerColumn columnLocation = new TableViewerColumn(volumnInfoTableViewer, SWT.LEFT);
columnLocation.getColumn().setWidth(300);
columnLocation.getColumn().setText(Messages.tblColumnVolPath);
columnLocation.getColumn().setToolTipText(Messages.tblColumnVolPath);
volumnInfoTableViewer.setContentProvider(new TableContentProvider());
volumnInfoTableViewer.setLabelProvider(new TableLabelProvider());
Table table = volumnInfoTableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
volumnInfoTableViewer.setInput(volumnInfoListData);
volumnItem.setControl(volumnComposite);
volumnItem.setHeight(130);
volumnItem.setExpanded(true);
Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
final MenuItem itemAddVolumn = new MenuItem(menu, SWT.PUSH);
itemAddVolumn.setText(com.cubrid.cubridmanager.ui.spi.Messages.setAddVolumeActionName);
itemAddVolumn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DefaultSchemaNode node = null;
for (ICubridNode cubridNode : database.getChildren()) {
if (cubridNode.getType().equals(CubridNodeType.DBSPACE_FOLDER)) {
node = (DefaultSchemaNode) cubridNode;
}
}
if (node == null) {
return;
}
// Gets the status of adding volume
GetAddVolumeStatusInfo getAddVolumeStatusInfo = new GetAddVolumeStatusInfo();
final CommonQueryTask<GetAddVolumeStatusInfo> statusTask = new CommonQueryTask<GetAddVolumeStatusInfo>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), getAddVolumeStatusInfo);
statusTask.setDbName(database.getLabel());
TaskExecutor taskExecutor = new CommonTaskExec(com.cubrid.cubridmanager.ui.cubrid.dbspace.Messages.getVolumeInfoTaskName);
taskExecutor.addTask(statusTask);
CommonQueryTask<DbSpaceInfoList> spaceInfoTask = null;
DatabaseInfo databaseInfo = database.getDatabaseInfo();
DbSpaceInfoList dbSpaceInfoList = databaseInfo.getDbSpaceInfoList();
int pageSize = 0;
if (null == dbSpaceInfoList) {
dbSpaceInfoList = new DbSpaceInfoList();
spaceInfoTask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfoList);
spaceInfoTask.setDbName(database.getLabel());
taskExecutor.addTask(spaceInfoTask);
}
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (spaceInfoTask == null) {
pageSize = dbSpaceInfoList.getPagesize();
} else {
final DbSpaceInfoList model = ((CommonQueryTask<DbSpaceInfoList>) spaceInfoTask).getResultModel();
pageSize = model.getPagesize();
}
getAddVolumeStatusInfo = statusTask.getResultModel();
//open add volumn dialog
AddVolumeDialog addVolumeDialog = new AddVolumeDialog(getSite().getShell());
addVolumeDialog.setGetAddVolumeStatusInfo(getAddVolumeStatusInfo);
addVolumeDialog.initPara(node);
addVolumeDialog.setTreeViewer(CubridNavigatorView.getNavigatorView("com.cubrid.cubridmanager.host.navigator").getViewer());
addVolumeDialog.setPageSize(pageSize);
int returnCode = addVolumeDialog.open();
//if add volumn refresh table
if (returnCode == IDialogConstants.OK_ID) {
volumnInfoListData.clear();
loadVolumnsInfo();
volumnInfoTableViewer.refresh();
}
}
});
volumnInfoTableViewer.getTable().setMenu(menu);
tableViewOnBarIndexMap.put(volumnInfoTableViewer, index);
}
use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class DatabaseDashboardEditor method createDatabaseComposite.
/**
* create database information composite
*
* @param bar ExpandBar
* @param bar index
*/
public void createDatabaseComposite(ExpandBar bar, int index) {
ExpandItem dbInfoItem = new ExpandItem(bar, SWT.NONE, index);
dbInfoItem.setText(Messages.exportDashboardDBTableTitle);
Composite dbComposite = new Composite(bar, SWT.None);
dbComposite.setLayout(new FillLayout());
dbInfoTableViewer = new TableViewer(dbComposite, SWT.BORDER | SWT.FULL_SELECTION);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.heightHint = 16;
dbInfoTableViewer.getTable().setLayoutData(gridData);
dbInfoTableViewer.getTable().setHeaderVisible(true);
dbInfoTableViewer.getTable().setLinesVisible(false);
final TableViewerColumn columnCPU = new TableViewerColumn(dbInfoTableViewer, SWT.CENTER);
columnCPU.getColumn().setWidth(60);
columnCPU.getColumn().setText("CPU");
columnCPU.getColumn().setToolTipText("CPU");
final TableViewerColumn columnMemory = new TableViewerColumn(dbInfoTableViewer, SWT.CENTER);
columnMemory.getColumn().setWidth(120);
columnMemory.getColumn().setText(com.cubrid.cubridmanager.ui.monitoring.Messages.dbSysMemInfoGroupName);
columnMemory.getColumn().setToolTipText(com.cubrid.cubridmanager.ui.monitoring.Messages.dbSysMemInfoGroupName);
final TableViewerColumn columnQPS = new TableViewerColumn(dbInfoTableViewer, SWT.CENTER);
columnQPS.getColumn().setWidth(80);
columnQPS.getColumn().setText("QPS");
columnQPS.getColumn().setToolTipText(com.cubrid.cubridmanager.ui.host.Messages.tipQps);
final TableViewerColumn columnHitRatio = new TableViewerColumn(dbInfoTableViewer, SWT.CENTER);
columnHitRatio.getColumn().setWidth(80);
columnHitRatio.getColumn().setText("Hit Ratio");
columnHitRatio.getColumn().setToolTipText(Messages.databaseTableHitRatioColumnLabel);
final TableViewerColumn columnIo1 = new TableViewerColumn(dbInfoTableViewer, SWT.CENTER);
columnIo1.getColumn().setWidth(100);
columnIo1.getColumn().setText("Fetch pages");
columnIo1.getColumn().setToolTipText("num_data_page_fetches");
final TableViewerColumn columnIo2 = new TableViewerColumn(dbInfoTableViewer, SWT.CENTER);
columnIo2.getColumn().setWidth(100);
columnIo2.getColumn().setText("Dirty pages");
columnIo2.getColumn().setToolTipText("num_data_page_dirties");
final TableViewerColumn columnIo3 = new TableViewerColumn(dbInfoTableViewer, SWT.CENTER);
columnIo3.getColumn().setWidth(100);
columnIo3.getColumn().setText("I/O Reads");
columnIo3.getColumn().setToolTipText("num_data_page_ioreads");
final TableViewerColumn columnIo4 = new TableViewerColumn(dbInfoTableViewer, SWT.CENTER);
columnIo4.getColumn().setWidth(100);
columnIo4.getColumn().setText("I/O Writes");
columnIo4.getColumn().setToolTipText("num_data_page_iowrites");
dbInfoTableViewer.setContentProvider(new TableContentProvider());
dbInfoTableViewer.setLabelProvider(new TableLabelProvider());
dbInfoTableViewer.setInput(dbInfoListData);
dbInfoItem.setControl(dbComposite);
dbInfoItem.setHeight(80);
dbInfoItem.setExpanded(true);
tableViewOnBarIndexMap.put(dbInfoTableViewer, index);
}
use of org.eclipse.jface.viewers.TableViewer 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;
}
use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method createBrokerConfTabItem.
/**
* create broker conf table
*/
public void createBrokerConfTabItem() {
Composite comp = new Composite(confTabFolder, SWT.NONE);
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
comp.setLayout(new GridLayout(1, false));
brokerConfTableCTabItem = new CTabItem(confTabFolder, SWT.NONE);
brokerConfTableCTabItem.setText(BROKERCONFCONFIGFILENAME);
brokerConfTabTableViewer = new TableViewer(comp, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
brokerConfTabTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
brokerConfTabTableViewer.getTable().setHeaderVisible(true);
brokerConfTabTableViewer.getTable().setLinesVisible(true);
brokerConfTabTableViewer.setUseHashlookup(true);
//create column
TableViewerColumn column = new TableViewerColumn(brokerConfTabTableViewer, SWT.LEFT);
column.getColumn().setWidth(0);
column.getColumn().setText("");
brokerConfTabTableViewer.setContentProvider(new UnifyHostCubridBrokerTableContentProvider());
brokerConfTabTableViewer.setLabelProvider(new UnifyHostCubridBrokerTableLabelProvider());
brokerConfTabTableViewer.setSorter(new BrokerConfTableViewerSorter());
//use to mark click point, the right click menu use this point
brokerConfTabTableViewer.getTable().addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event event) {
cubridBrokerTableClickPoint = new Point(event.x, event.y);
cubridBrokerTableClickPointTiming = System.currentTimeMillis();
}
});
registerCubridBrokerTableContextMenu();
brokerConfTableCTabItem.setControl(comp);
if (confTabFolder.getSelection() == null) {
confTabFolder.setSelection(brokerConfTableCTabItem);
}
}
use of org.eclipse.jface.viewers.TableViewer in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method createToolBar.
/**
*
* Create the tool bar
*
* @param parent the Composite
*
*/
private void createToolBar(Composite parent) {
final Composite toolBarComp = new Composite(parent, SWT.NONE);
{
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
toolBarComp.setLayoutData(gd);
GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 0;
gridLayout.horizontalSpacing = 0;
gridLayout.marginWidth = 0;
toolBarComp.setLayout(gridLayout);
}
ToolBar toolBar = new ToolBar(toolBarComp, SWT.FLAT);
ToolItem saveItem = new ToolItem(toolBar, SWT.PUSH);
saveItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_save.png"));
saveItem.setToolTipText(Messages.msgTipSaveAction);
saveItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (isDirty) {
String errMsg = validate();
if (errMsg != null) {
CommonUITool.openErrorBox(errMsg);
return;
}
doSave(new NullProgressMonitor());
setDirty(false);
}
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem addPropItem = new ToolItem(toolBar, SWT.PUSH);
addPropItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert.png"));
addPropItem.setToolTipText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorAddPropItemLabel);
addPropItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
HashMap<String, String> dataMap = new HashMap<String, String>();
dataMap.put("0", "new property");
TableViewer addDataTableViewer = null;
if (confTabFolder.getSelection() == brokerConfTableCTabItem) {
cubridBrokerConfListData.add(dataMap);
addDataTableViewer = brokerConfTabTableViewer;
} else if (confTabFolder.getSelection() == cubridConfTableCTabItem) {
cubridConfConfigListData.add(dataMap);
addDataTableViewer = cubridConfTabTableViewer;
} else if (confTabFolder.getSelection() == cubridCMConfTableCTabItem) {
cubridConfCMConfigListData.add(dataMap);
addDataTableViewer = cubridCMConfTabTableViewer;
}
for (int i = 1; i < addDataTableViewer.getTable().getColumnCount(); i++) {
dataMap.put(i + "", "");
}
addDataTableViewer.refresh();
setDirty(true);
addDataTableViewer.getTable().showItem(addDataTableViewer.getTable().getItem(addDataTableViewer.getTable().getItemCount() - 1));
}
});
ToolItem deletePropItem = new ToolItem(toolBar, SWT.PUSH);
deletePropItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete.png"));
deletePropItem.setToolTipText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeletePropItemLabel);
deletePropItem.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("all")
public void widgetSelected(SelectionEvent event) {
TableViewer delDataTableViewer = null;
List<Map<String, String>> delConfListData = null;
if (confTabFolder.getSelection() == brokerConfTableCTabItem) {
delDataTableViewer = brokerConfTabTableViewer;
delConfListData = cubridBrokerConfListData;
} else if (confTabFolder.getSelection() == cubridConfTableCTabItem) {
delDataTableViewer = cubridConfTabTableViewer;
delConfListData = cubridConfConfigListData;
} else if (confTabFolder.getSelection() == cubridCMConfTableCTabItem) {
delDataTableViewer = cubridCMConfTabTableViewer;
delConfListData = cubridConfCMConfigListData;
}
int selectionIndex = delDataTableViewer.getTable().getSelectionIndex();
if (selectionIndex < 0) {
CommonUITool.openErrorBox(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeletePropertyMsg);
return;
}
IStructuredSelection selection = (IStructuredSelection) delDataTableViewer.getSelection();
HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
if (!CommonUITool.openConfirmBox(Messages.bind(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeleteBrokerPropConfirm, valueMap.get("0")))) {
return;
}
delConfListData.remove(valueMap);
delDataTableViewer.refresh();
setDirty(true);
}
});
}
Aggregations