use of org.eclipse.swt.widgets.TreeItem in project cubrid-manager by CUBRID.
the class DiagStatusMonitorTemplateDialog method insertTreeObject.
/**
* Inserts terms to tree
*
*/
private void insertTreeObject() {
TargetConfigMap targetConfigMap = TargetConfigMap.getInstance();
EnumMap<EnumTargetConfig, TargetConfig> group = targetConfigMap.getMap();
TreeItem root = new TreeItem(targetTree, SWT.NONE);
root.setText(STATUS_MONITOR_LST);
serverInfo = selection.getServer().getServerInfo();
ServerType serverType = serverInfo.getServerType();
TargetConfig tc = null;
if (serverType == ServerType.BOTH || serverType == ServerType.DATABASE) {
TreeItem db = new TreeItem(root, SWT.NONE);
db.setText(STATUS_MONITOR_LST_DB);
TreeItem serverQuery = new TreeItem(db, SWT.NONE);
serverQuery.setText(targetConfigMap.getQueryCategory());
TreeItem serverConn = new TreeItem(db, SWT.NONE);
serverConn.setText(targetConfigMap.getConnCategory());
TreeItem serverBuffer = new TreeItem(db, SWT.NONE);
serverBuffer.setText(targetConfigMap.getBufferCategory());
TreeItem serverLock = new TreeItem(db, SWT.NONE);
serverLock.setText(targetConfigMap.getLockCategory());
TreeItem queryOpenedPage = new TreeItem(serverQuery, SWT.NONE);
TreeItem querySlowQuery = new TreeItem(serverQuery, SWT.NONE);
TreeItem queryFullScan = new TreeItem(serverQuery, SWT.NONE);
TreeItem connCliRequest = new TreeItem(serverConn, SWT.NONE);
TreeItem connAbortedClients = new TreeItem(serverConn, SWT.NONE);
TreeItem connConnReq = new TreeItem(serverConn, SWT.NONE);
TreeItem connConnReject = new TreeItem(serverConn, SWT.NONE);
TreeItem bufferPageWrite = new TreeItem(serverBuffer, SWT.NONE);
TreeItem bufferPageRead = new TreeItem(serverBuffer, SWT.NONE);
TreeItem lockDeadlock = new TreeItem(serverLock, SWT.NONE);
TreeItem lockRequest = new TreeItem(serverLock, SWT.NONE);
tc = group.get(EnumTargetConfig.SERVER_QUERY_OPENED_PAGE);
queryOpenedPage.setData(tc);
queryOpenedPage.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.SERVER_QUERY_SLOW_QUERY);
querySlowQuery.setData(tc);
querySlowQuery.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.SERVER_QUERY_FULL_SCAN);
queryFullScan.setData(tc);
queryFullScan.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.SERVER_CONN_CLI_REQUEST);
connCliRequest.setData(tc);
connCliRequest.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.SERVER_CONN_ABORTED_CLIENTS);
connAbortedClients.setData(tc);
connAbortedClients.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.SERVER_CONN_CONN_REQ);
connConnReq.setData(tc);
connConnReq.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.SERVER_CONN_CONN_REJ);
connConnReject.setData(tc);
connConnReject.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.SERVER_BUFFER_PAGE_WRITE);
bufferPageWrite.setData(tc);
bufferPageWrite.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.SERVER_BUFFER_PAGE_READ);
bufferPageRead.setData(tc);
bufferPageRead.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.SERVER_LOCK_DEADLOCK);
lockDeadlock.setData(tc);
lockDeadlock.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.SERVER_LOCK_REQUEST);
lockRequest.setData(tc);
lockRequest.setText(tc.getDisplayName());
db.setExpanded(true);
}
if (serverType == ServerType.BOTH || serverType == ServerType.BROKER) {
TreeItem broker = new TreeItem(root, SWT.NONE);
broker.setText(STATUS_MONITOR_LST_BROKER);
TreeItem activeSession = new TreeItem(broker, SWT.NONE);
TreeItem requestSec = new TreeItem(broker, SWT.NONE);
TreeItem querySec = new TreeItem(broker, SWT.NONE);
TreeItem transactionSec = new TreeItem(broker, SWT.NONE);
TreeItem longQuery = new TreeItem(broker, SWT.NONE);
TreeItem longTran = new TreeItem(broker, SWT.NONE);
TreeItem errQuery = new TreeItem(broker, SWT.NONE);
tc = group.get(EnumTargetConfig.CAS_ST_ACTIVE_SESSION);
activeSession.setData(tc);
activeSession.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.CAS_ST_REQUEST);
requestSec.setData(tc);
requestSec.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.CAS_ST_QUERY);
querySec.setData(tc);
querySec.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.CAS_ST_TRANSACTION);
transactionSec.setData(tc);
transactionSec.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.CAS_ST_LONG_QUERY);
longQuery.setData(tc);
longQuery.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.CAS_ST_LONG_TRAN);
longTran.setData(tc);
longTran.setText(tc.getDisplayName());
tc = group.get(EnumTargetConfig.CAS_ST_ERROR_QUERY);
errQuery.setData(tc);
errQuery.setText(tc.getDisplayName());
broker.setExpanded(true);
}
root.setExpanded(true);
}
use of org.eclipse.swt.widgets.TreeItem in project cubrid-manager by CUBRID.
the class DiagStatusMonitorTemplateDialog method insertItemToTargetList.
/**
* Inserts the items of target list
*
* @param item TreeItem
* @return String
*/
private String insertItemToTargetList(TreeItem item) {
TreeItem parent = item.getParentItem();
if (null == parent) {
// root node clicked
return "";
}
if (item.getItems().length == 0) {
boolean hasSame = false;
for (TableItem tableItem : tagetTbl.getItems()) {
if (tableItem.getData() == item.getData()) {
hasSame = true;
break;
}
}
if (!hasSame) {
TargetConfig tc = (TargetConfig) item.getData();
TableItem newItem = new TableItem(tagetTbl, SWT.NONE);
newItem.setText(0, tc.getCategory());
newItem.setText(1, tc.getDisplayName());
newItem.setData(tc);
}
} else {
for (TreeItem treeItem : item.getItems()) {
insertItemToTargetList(treeItem);
}
}
return "";
}
use of org.eclipse.swt.widgets.TreeItem in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method getSelectedServer.
private CubridServer[] getSelectedServer() {
Set<CubridServer> list = new LinkedHashSet<CubridServer>();
TreeItem[] items = serviceTreeViewer.getTree().getSelection();
for (TreeItem item : items) {
Object obj = item.getData();
if (obj != null) {
if (obj instanceof ServiceDashboardInfo) {
obj = ((ServiceDashboardInfo) obj).getServer();
}
if (obj instanceof CubridServer && !list.contains(obj)) {
list.add((CubridServer) obj);
} else if (obj instanceof CubridGroupNode) {
CubridGroupNode node = (CubridGroupNode) obj;
for (ICubridNode childNode : node.getChildren()) {
if (childNode != null && childNode instanceof CubridServer & !list.contains(childNode)) {
list.add((CubridServer) childNode);
}
}
}
}
}
return list.toArray(new CubridServer[0]);
}
use of org.eclipse.swt.widgets.TreeItem in project cubrid-manager by CUBRID.
the class PasteQueryConnAction method run.
/**
* Paste the query connection
*/
public void run() {
Object[] objs = this.getSelectedObj();
if (!isSupported(objs[0])) {
setEnabled(false);
return;
}
objs = null;
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection strSelection = (IStructuredSelection) selection;
objs = strSelection.toArray();
}
if (objs == null || objs.length == 0) {
return;
}
if (!(objs[0] instanceof CubridDatabase)) {
return;
}
CubridDatabase pastedDb = (CubridDatabase) objs[0];
QueryConnDialog dialog = new QueryConnDialog(getShell(), pastedDb, true);
int returnCode = dialog.open();
if (returnCode == QueryConnDialog.CONNECT_ID || returnCode == QueryConnDialog.SAVE_ID) {
CubridDatabase database = dialog.getDatabase();
CQBDBNodePersistManager.getInstance().addDatabase(database, false);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
return;
}
Tree tree = treeViewer.getTree();
TreeItem item;
CubridGroupNode parent = getParentGroupNode();
if (navigatorView.isShowGroup()) {
item = new TreeItem(navigatorView.getTreeItemByData(parent), SWT.NONE);
} else {
item = new TreeItem(tree, SWT.NONE);
}
parent.addChild(database);
CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
item.setText(database.getLabel());
item.setData(database);
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
treeViewer.setSelection(new StructuredSelection(database), true);
if (returnCode == QueryConnDialog.CONNECT_ID) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
}
}
}
use of org.eclipse.swt.widgets.TreeItem in project cubrid-manager by CUBRID.
the class CreateConnectionByUrlWizard method performFinish.
/**
* Perform finish
*/
public boolean performFinish() {
List<CubridDatabase> parsedDatabaseList = connectionPriviewPage.getParsedConnection();
/*Add the database list to the tree*/
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
return false;
}
for (CubridDatabase database : parsedDatabaseList) {
CQBDBNodePersistManager.getInstance().addDatabase(database, false);
Tree tree = treeViewer.getTree();
TreeItem item;
CubridGroupNode parent = CQBGroupNodePersistManager.getInstance().getDefaultGroup();
if (navigatorView.isShowGroup()) {
item = new TreeItem(navigatorView.getTreeItemByData(parent), SWT.NONE);
} else {
item = new TreeItem(tree, SWT.NONE);
}
parent.addChild(database);
item.setText(database.getLabel());
item.setData(database);
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
treeViewer.setSelection(new StructuredSelection(database), true);
}
CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
return true;
}
Aggregations