Search in sources :

Example 66 with TreeItem

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);
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) TargetConfigMap(com.cubrid.cubridmanager.ui.monitoring.editor.TargetConfigMap) TreeItem(org.eclipse.swt.widgets.TreeItem) EnumTargetConfig(com.cubrid.cubridmanager.ui.monitoring.editor.EnumTargetConfig) TargetConfig(com.cubrid.cubridmanager.ui.monitoring.editor.TargetConfig) EnumTargetConfig(com.cubrid.cubridmanager.ui.monitoring.editor.EnumTargetConfig)

Example 67 with TreeItem

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 "";
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) TableItem(org.eclipse.swt.widgets.TableItem) TargetConfig(com.cubrid.cubridmanager.ui.monitoring.editor.TargetConfig) EnumTargetConfig(com.cubrid.cubridmanager.ui.monitoring.editor.EnumTargetConfig)

Example 68 with TreeItem

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]);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) TreeItem(org.eclipse.swt.widgets.TreeItem) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 69 with TreeItem

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));
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ISelection(org.eclipse.jface.viewers.ISelection) Tree(org.eclipse.swt.widgets.Tree) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) QueryConnDialog(com.cubrid.cubridquery.ui.connection.dialog.QueryConnDialog)

Example 70 with TreeItem

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;
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Tree(org.eclipse.swt.widgets.Tree) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

TreeItem (org.eclipse.swt.widgets.TreeItem)226 Tree (org.eclipse.swt.widgets.Tree)71 Point (org.eclipse.swt.graphics.Point)56 TreeColumn (org.eclipse.swt.widgets.TreeColumn)30 GridData (org.eclipse.swt.layout.GridData)29 Test (org.junit.Test)28 SelectionEvent (org.eclipse.swt.events.SelectionEvent)27 ArrayList (java.util.ArrayList)24 GridLayout (org.eclipse.swt.layout.GridLayout)23 Composite (org.eclipse.swt.widgets.Composite)22 TableItem (org.eclipse.swt.widgets.TableItem)21 Button (org.eclipse.swt.widgets.Button)20 Table (org.eclipse.swt.widgets.Table)20 TreeViewer (org.eclipse.jface.viewers.TreeViewer)19 FillLayout (org.eclipse.swt.layout.FillLayout)19 Label (org.eclipse.swt.widgets.Label)18 Group (org.eclipse.swt.widgets.Group)17 Text (org.eclipse.swt.widgets.Text)17 SelectionListener (org.eclipse.swt.events.SelectionListener)16 Rectangle (org.eclipse.swt.graphics.Rectangle)16