Search in sources :

Example 11 with CubridNavigatorView

use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.

the class JobAutoDashboardEditorPart method expandBackOrQueryPlanChildNode.

public void expandBackOrQueryPlanChildNode() {
    Set<String> typeSet = new HashSet<String>();
    typeSet.add(CubridNodeType.JOB_FOLDER);
    ICubridNode jobFolderNode = CommonUITool.findNode(database, typeSet);
    if (jobFolderNode != null) {
        CubridNavigatorView view = CubridNavigatorView.getNavigatorView("com.cubrid.cubridmanager.host.navigator");
        if (view == null) {
            return;
        }
        TreeViewer treeViewer = view.getViewer();
        for (ICubridNode backOrQueryFolderNode : jobFolderNode.getChildren()) {
            //if not expand ,expand the node and wait until all children be added
            if (!treeViewer.getExpandedState(backOrQueryFolderNode)) {
                treeViewer.expandToLevel(backOrQueryFolderNode, 1);
            }
        }
    }
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) HashSet(java.util.HashSet)

Example 12 with CubridNavigatorView

use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.

the class JobAutoDashboardEditorPart method findAutoJobInfoNode.

/**
	 * find queryPlanoNode or backupPlanNode from treeView
	 *
	 * @param nodeType String
	 * @param nodeType id
	 * @return
	 */
public ICubridNode findAutoJobInfoNode(String nodeType, String id) {
    Set<String> typeSet = new HashSet<String>();
    typeSet.add(nodeType);
    ICubridNode node = CommonUITool.findNode(database, typeSet, id);
    //if backupPlanNode is null,expand the backupPlanNodeFolder then find again
    if (node == null) {
        CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
        TreeViewer treeViewer = view.getViewer();
        ICubridNode jobAutoFolderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridDatabaseLoader.JOB_AUTO_FOLDER_ID);
        String childNodeFolderID = nodeType.equals(CubridNodeType.BACKUP_PLAN) ? CubridJobAutoFolderLoader.BACKUP_PLAN_FOLDER_ID : CubridJobAutoFolderLoader.QUERY_PLAN_FOLDER_ID;
        DefaultSchemaNode folderNode = (DefaultSchemaNode) jobAutoFolderNode.getChild(jobAutoFolderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + childNodeFolderID);
        treeViewer.expandToLevel(folderNode, 1);
        //wait 5 times expand the folder node
        int time = 0;
        while (folderNode.getChildren().size() == 0 && time++ < 5) {
            try {
                Thread.sleep(500);
            } catch (Exception e) {
            }
        }
    }
    return CommonUITool.findNode(database, typeSet, id);
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) PartInitException(org.eclipse.ui.PartInitException) HashSet(java.util.HashSet)

Example 13 with CubridNavigatorView

use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.

the class RenameHostAction method doRun.

private void doRun(CubridServer server) {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    RenameHostDialog dlg = new RenameHostDialog(shell, server);
    int ret = dlg.open();
    if (ret == IDialogConstants.OK_ID) {
        server.setLabel(dlg.getNewName());
        server.getServerInfo().setServerName(dlg.getNewName());
        CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
        TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
        if (treeViewer == null) {
            LOGGER.error("Error: Can't find the navigator view:" + CubridHostNavigatorView.ID);
            return;
        }
        // Fire all the databases which are in the server logout
        List<ICubridNode> children = server.getChildren();
        if (children != null) {
            for (ICubridNode child : children) {
                if (!NodeType.DATABASE_FOLDER.equals(child.getType())) {
                    continue;
                }
                List<ICubridNode> childList = child.getChildren();
                if (childList == null) {
                    continue;
                }
                for (ICubridNode node : childList) {
                    if (!NodeType.DATABASE.equals(node.getType())) {
                        continue;
                    }
                    CubridDatabase database = (CubridDatabase) node;
                    database.setLogined(false);
                    CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
                }
            }
        }
        // Refresh the tree view
        server.removeAllChild();
        if (server.getLoader() != null) {
            server.getLoader().setLoaded(false);
        }
        treeViewer.refresh(server, true);
        treeViewer.expandToLevel(server, 1);
        treeViewer.setSelection(null, true);
        treeViewer.setSelection(new StructuredSelection(server), true);
        setEnabled(false);
        // Save the data
        CMHostNodePersistManager.getInstance().addServer(server.getServerInfo().getHostAddress(), server.getServerInfo().getHostMonPort(), server.getServerInfo().getUserName(), server.getServerInfo());
        QueryOptions.removePref(server.getServerInfo());
        BrokerIntervalSettingManager.getInstance().removeAllBrokerIntervalSettingInServer(server.getLabel());
        CMGroupNodePersistManager.getInstance().saveAllGroupNode();
        CMHostNodePersistManager.getInstance().saveServers();
        ActionManager.getInstance().fireSelectionChanged(getSelection());
        LayoutManager.getInstance().fireSelectionChanged(getSelection());
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_DISCONNECTED));
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) RenameHostDialog(com.cubrid.cubridmanager.ui.host.dialog.RenameHostDialog) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 14 with CubridNavigatorView

use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.

the class DeleteHostAction method doRun.

/**
	 * Perform do run
	 *
	 * @param objArr
	 */
public void doRun(Object[] objArr) {
    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
    if (navigatorView == null) {
        return;
    }
    StringBuilder hostNames = new StringBuilder();
    for (int i = 0; objArr != null && i < objArr.length; i++) {
        if (!isSupported(objArr[i])) {
            setEnabled(false);
            return;
        }
        ICubridNode node = (ICubridNode) objArr[i];
        hostNames.append(node.getLabel());
        if (i != objArr.length - 1) {
            hostNames.append(",");
        }
    }
    String msg = Messages.bind(Messages.msgConfirmDeleteHost, hostNames.toString());
    boolean isDelete = CommonUITool.openConfirmBox(getShell(), msg);
    if (!isDelete) {
        return;
    }
    TreeViewer viewer = navigatorView.getViewer();
    if (objArr == null) {
        LOGGER.error("objArr is null.");
        return;
    }
    for (int i = 0; i < objArr.length; i++) {
        CubridServer server = (CubridServer) objArr[i];
        boolean isContinue = HostUtils.processHostDeleted(server);
        List<CubridGroupNode> groups = CMGroupNodePersistManager.getInstance().getAllGroupNodes();
        for (CubridGroupNode grp : groups) {
            grp.removeChild(server);
        }
        if (isContinue) {
            viewer.remove(server);
        }
    }
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 15 with CubridNavigatorView

use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.

the class AddHostAction method run.

public void run() {
    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
    TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
    if (treeViewer == null) {
        return;
    }
    doRun(this.getSelectedObj());
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Aggregations

CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)50 TreeViewer (org.eclipse.jface.viewers.TreeViewer)36 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)25 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)22 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)21 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)15 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)13 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 TreeItem (org.eclipse.swt.widgets.TreeItem)7 ArrayList (java.util.ArrayList)6 Tree (org.eclipse.swt.widgets.Tree)6 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)6 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)5 ISelection (org.eclipse.jface.viewers.ISelection)5 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)4 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 WorkbenchWindow (org.eclipse.ui.internal.WorkbenchWindow)4 DatabaseMenuItem (com.cubrid.common.ui.query.control.DatabaseMenuItem)3