Search in sources :

Example 51 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.

the class StopBrokerEnvAction method run.

/**
	 * Override the run method in order to complete stopping broker environment
	 */
public void run() {
    if (!CommonUITool.openConfirmBox(CONFIRM_CONTENT)) {
        return;
    }
    final Object[] obj = this.getSelectedObj();
    CubridBrokerFolder selection = (CubridBrokerFolder) obj[0];
    if (null == selection) {
        return;
    }
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    StopBrokerEnvTask task = new StopBrokerEnvTask(serverInfo);
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.stopBrokerEnvTaskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    selection.setRunning(false);
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    CommonUITool.refreshNavigatorTree(treeViewer, selection);
    ActionManager.getInstance().fireSelectionChanged(getSelection());
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) StopBrokerEnvTask(com.cubrid.cubridmanager.core.broker.task.StopBrokerEnvTask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridBrokerFolder(com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder)

Example 52 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.

the class MultiDatabaseLoginFailedDialog method editHost.

public void editHost(MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo) {
    if (multiDatabaseloginFailedInfo == null) {
        return;
    }
    CubridDatabase database = multiDatabaseloginFailedInfo.getCubridDatabase();
    //if login ,can't edit
    if (database.isLogined()) {
        return;
    }
    //		CubridDatabase oldDatabase = null;
    //		try {
    //			oldDatabase = database.clone();
    //		} catch (CloneNotSupportedException e) {
    //			//Ignore
    //		}
    LoginDatabaseDialog dialog = new LoginDatabaseDialog(getShell(), database);
    int returnVal = dialog.open();
    if (returnVal == IDialogConstants.OK_ID) {
        CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
        TreeViewer treeViewer = view.getViewer();
        database.removeAllChild();
        if (database.getLoader() != null) {
            database.getLoader().setLoaded(false);
        }
        treeViewer.refresh(database, true);
        treeViewer.expandToLevel(database, 1);
        /*Save the data*/
        DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
        if (editorConfig == null) {
            editorConfig = new DatabaseEditorConfig();
        }
        editorConfig.setBackGround(dialog.getSelectedColor());
        CMDBNodePersistManager.getInstance().addDatabase(database, editorConfig);
        ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
        LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
        multiDatabaseloginFailedInfo.setErrMsg("");
    }
    databaseTable.refresh();
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig)

Example 53 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer 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 54 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer 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 55 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer 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)

Aggregations

TreeViewer (org.eclipse.jface.viewers.TreeViewer)248 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 GridData (org.eclipse.swt.layout.GridData)50 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)45 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)43 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)42 Composite (org.eclipse.swt.widgets.Composite)42 Tree (org.eclipse.swt.widgets.Tree)42 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)40 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)39 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)38 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)36 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)36 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)36 GridLayout (org.eclipse.swt.layout.GridLayout)34 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)31 ArrayList (java.util.ArrayList)29 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)27 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)25