Search in sources :

Example 41 with CubridNavigatorView

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

the class CubridDatabaseLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(final ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = (CubridDatabase) parent;
        database.getDatabaseInfo().clear();
        if (!database.isLogined()) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        //when refresh,firstly check whether this database exist
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
        ParamDumpTask paramDumpTask = null;
        if (CompatibleUtil.isSupportGetParamDump(serverInfo)) {
            paramDumpTask = new ParamDumpTask(serverInfo);
            paramDumpTask.setDbName(database.getLabel());
            paramDumpTask.setBoth(YesNoType.N);
        }
        monitorCancel(monitor, new ITask[] { getDatabaseListTask, paramDumpTask });
        getDatabaseListTask.execute();
        if (!checkResult(getDatabaseListTask, monitor)) {
            parent.removeAllChild();
            return;
        }
        List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
        ParamDumpInfo paraDumpInfo = null;
        if (paramDumpTask != null) {
            paramDumpTask.execute();
            if (!checkResult(paramDumpTask, monitor)) {
                parent.removeAllChild();
                return;
            }
            paraDumpInfo = paramDumpTask.getContent();
        }
        String databaseName = database.getLabel();
        boolean isExist = false;
        for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
            DatabaseInfo dbInfo = databaseInfoList.get(i);
            if (dbInfo.getDbName().equalsIgnoreCase(databaseName)) {
                database.setRunningType(dbInfo.getRunningType());
                isExist = true;
            }
        }
        if (!isExist) {
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    CommonUITool.openErrorBox(Messages.errDatabaseNoExist);
                    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
                    TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
                    if (treeViewer != null) {
                        CommonUITool.refreshNavigatorTree(treeViewer, parent.getParent());
                    }
                }
            });
            setLoaded(true);
            return;
        }
        if (!loadReplication(parent, monitor)) {
            setLoaded(true);
            return;
        }
        // add tables folder
        addTableFolder(monitor, database);
        // add views folder
        addViewFolder(monitor, database);
        // add serials folder
        addSerialFolder(monitor, database);
        // add user folder
        addUserFolder(monitor, database);
        // add triggers folder
        addTriggerFolder(monitor, database);
        // add stored procedure folder
        addProcedureFolder(monitor, database);
        // add job automation folder
        addJobAutoFolder(monitor, database);
        // add database space folder
        addSpaceFolder(monitor, database);
        // set parameter dump information
        database.getDatabaseInfo().setParaDumpInfo(paraDumpInfo);
        // set charset info
        setDbCollation(database);
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ParamDumpInfo(com.cubrid.cubridmanager.core.cubrid.database.model.ParamDumpInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) ParamDumpTask(com.cubrid.cubridmanager.core.cubrid.database.task.ParamDumpTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) Display(org.eclipse.swt.widgets.Display)

Example 42 with CubridNavigatorView

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

the class CubridWorkbenchContrItem method refreshAfterConnected.

private void refreshAfterConnected(CubridServer cubridServer) {
    cubridServer.getLoader().setLoaded(false);
    CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
    TreeViewer treeViewer = view.getViewer();
    treeViewer.refresh(cubridServer, true);
    treeViewer.expandToLevel(cubridServer, 1);
    ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
    LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
    CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(cubridServer, CubridNodeChangedEventType.SERVER_CONNECTED));
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 43 with CubridNavigatorView

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

the class CubridWorkbenchContrItem method processDoubleClickNavigatorEvent.

public void processDoubleClickNavigatorEvent(DoubleClickEvent event) {
    ISelection selection = event.getSelection();
    if (selection == null || selection.isEmpty()) {
        return;
    }
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    if (!(obj instanceof ICubridNode)) {
        return;
    }
    // open the monitor dashboard view
    ICubridNode cubridNode = (ICubridNode) obj;
    if (CubridNodeType.MONITOR_DASHBOARD.equals(cubridNode.getType())) {
        ISelectionAction action = (ISelectionAction) ActionManager.getInstance().getAction(OpenMonitorDashboardAction.ID);
        if (action != null && action.isSupported(cubridNode)) {
            action.run();
            return;
        }
    }
    /*[TOOLS-3668] - MonitorStatistic node*/
    if (CubridNodeType.MONITOR_STATISTIC_PAGE.equals(cubridNode.getType())) {
        ISelectionAction action = (ISelectionAction) ActionManager.getInstance().getAction(OpenMonitorStatisticPageAction.ID);
        if (action != null && action.isSupported(cubridNode)) {
            action.run();
            return;
        }
    }
    /*CubridServer node*/
    if (cubridNode instanceof CubridServer) {
        CubridServer cubridServer = (CubridServer) cubridNode;
        if (cubridServer.isConnected()) {
            ServerInfo serverInfo = cubridServer.getServerInfo();
            //open host dashboard
            if (serverInfo != null && serverInfo.isConnected()) {
                openHostDashboard(serverInfo);
            }
        } else if (connectHost(cubridServer.getServerInfo(), true)) {
            refreshAfterConnected(cubridServer);
        } else {
            EditHostAction action = (EditHostAction) ActionManager.getInstance().getAction(EditHostAction.ID);
            if (action == null) {
                LOGGER.error("The EditHostAction is a null.");
            } else {
                action.run();
            }
        }
        return;
    }
    CubridServer server = cubridNode.getServer();
    if (server == null || !server.isConnected()) {
        return;
    }
    /*CubridDatabase node*/
    if (cubridNode instanceof CubridDatabase) {
        CubridDatabase database = (CubridDatabase) cubridNode;
        if (database.isLogined()) {
            openEditorOrView(database);
            return;
        }
        LoginDatabaseAction loginDatabaseAction = (LoginDatabaseAction) ActionManager.getInstance().getAction(LoginDatabaseAction.ID);
        loginDatabaseAction.doRun(new CubridDatabase[] { database });
        return;
    }
    /*Other node*/
    if (!LayoutManager.getInstance().isUseClickOnce()) {
        boolean useSelectQuery = ActionSupportUtil.isSupportMultiSelection(obj, new String[] { NodeType.USER_TABLE, NodeType.USER_VIEW, NodeType.SYSTEM_TABLE, NodeType.SYSTEM_VIEW, NodeType.USER_PARTITIONED_TABLE_FOLDER }, false);
        if (useSelectQuery) {
            openSelectQuery(selection);
        } else {
            openEditorOrView(cubridNode);
        }
    }
    boolean useExpandFolder = NodeType.contains(cubridNode.getType(), new String[] { NodeType.TABLE_FOLDER, NodeType.VIEW_FOLDER, NodeType.TRIGGER_FOLDER, NodeType.SERIAL_FOLDER, NodeType.USER_FOLDER, CubridNodeType.JOB_FOLDER });
    if (useExpandFolder) {
        CubridDatabase database = (CubridDatabase) cubridNode.getParent();
        CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
        TreeViewer treeViewer = view.getViewer();
        if (cubridNode.getType() == NodeType.TABLE_FOLDER) {
            // if not expand, expand the node and wait until all children be added
            int sleepCount = 0;
            if (!treeViewer.getExpandedState(cubridNode)) {
                treeViewer.expandToLevel(cubridNode, 1);
                while (cubridNode.getChildren().size() == 0) {
                    try {
                        Thread.sleep(500);
                        sleepCount++;
                        if (sleepCount > 5) {
                            break;
                        }
                    } catch (Exception e) {
                        LOGGER.debug("", e);
                    }
                }
            }
            openTablesDetailInfoPart(database);
            return;
        }
        //if not open child node ,edit serial from dashboard can not open edit dialog
        if (!treeViewer.getExpandedState(cubridNode)) {
            treeViewer.expandToLevel(cubridNode, 1);
        }
        if (StringUtil.isEqual(cubridNode.getType(), NodeType.VIEW_FOLDER)) {
            openViewsDetailInfoPart(database);
        } else if (StringUtil.isEqual(cubridNode.getType(), NodeType.TRIGGER_FOLDER)) {
            openTriggersDetailInfoPart(database);
        } else if (StringUtil.isEqual(cubridNode.getType(), NodeType.SERIAL_FOLDER)) {
            openSerialsDetailInfoPart(database);
        } else if (StringUtil.isEqual(cubridNode.getType(), CubridNodeType.JOB_FOLDER)) {
            openJobsDetailInfoPart(database);
        } else if (StringUtil.isEqual(cubridNode.getType(), NodeType.USER_FOLDER)) {
            openUsersDetailInfoPart(database);
        }
    }
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) LoginDatabaseAction(com.cubrid.cubridmanager.ui.cubrid.database.action.LoginDatabaseAction) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) PartInitException(org.eclipse.ui.PartInitException) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) ISelection(org.eclipse.jface.viewers.ISelection) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) ISelectionAction(com.cubrid.common.ui.spi.action.ISelectionAction) EditHostAction(com.cubrid.cubridmanager.ui.host.action.EditHostAction)

Example 44 with CubridNavigatorView

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

the class DeleteUserAction method doRun.

public void doRun(ISchemaNode node) {
    // FIXME move this logic to core module
    CubridDatabase database = node.getDatabase();
    if (database == null || node == null) {
        CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
        return;
    }
    String childId = database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridNodeLoader.USERS_FOLDER_ID;
    ICubridNode folderNode = database.getChild(childId);
    if (folderNode == null || !folderNode.getLoader().isLoaded()) {
        return;
    }
    //		if (database.getDatabaseInfo().isHAMode()) {
    //			CommonUITool.openErrorBox(com.cubrid.cubridmanager.ui.common.Messages.errNoSupportInHA);
    //			return;
    //		}
    TaskExecutor taskExecutor = new CommonTaskExec(CommonTaskName.DELETE_USER_TASK_NAME);
    DropUserTask task = new DropUserTask(database.getDatabaseInfo(), node.getName());
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (taskExecutor.isSuccess()) {
        CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
        if (navigatorView != null) {
            TreeViewer treeViewer = navigatorView.getViewer();
            if (treeViewer != null) {
                //refresh user folder count label
                CubridNodeChangedEvent event = new CubridNodeChangedEvent(folderNode, CubridNodeChangedEventType.NODE_REFRESH);
                CubridNodeManager.getInstance().fireCubridNodeChanged(event);
                CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, node.getParent());
                CommonUITool.openInformationBox(com.cubrid.common.ui.common.Messages.titleSuccess, Messages.msgDeleteUserSuccess);
            }
        }
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DropUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.DropUserTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) 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 45 with CubridNavigatorView

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

the class EditUserAction method doRun.

/**
	 * Perform do run
	 *
	 * @param node
	 */
public void doRun(ISchemaNode node) {
    // FIXME move this logic to core module
    CubridDatabase database = node.getDatabase();
    EditUserDialog dlg = new EditUserDialog(shell);
    Connection con = null;
    try {
        con = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), false);
        final GetAllClassListTask classInfoTask = new GetAllClassListTask(database.getDatabaseInfo(), con);
        final GetAllPartitionClassTask partitionTask = new GetAllPartitionClassTask(database.getDatabaseInfo(), con);
        GetUserListTask task = new GetUserListTask(database.getDatabaseInfo(), con);
        DbUserInfoList userListInfo = null;
        try {
            userListInfo = task.getResultModel();
        } catch (Exception e) {
            LOGGER.error("load user failed", e);
            return;
        }
        boolean isSuccess = dlg.execTask(-1, new ITask[] { classInfoTask, partitionTask }, getShell());
        if (!isSuccess) {
            return;
        }
        dlg.setUserListInfo(userListInfo);
        dlg.setDatabase(database);
        dlg.setUserName(node.getName());
        dlg.setPartitionClassMap(partitionTask.getPartitionClassMap());
        dlg.setNewFlag(false);
        GetUserAuthorizationsTask privilegeTask = new GetUserAuthorizationsTask(database.getDatabaseInfo(), con);
        try {
            for (DbUserInfo userInfo : userListInfo.getUserList()) {
                userInfo.setUserAuthorizations(privilegeTask.getUserAuthorizations(userInfo.getName()));
            }
        } catch (Exception e) {
            LOGGER.error("get user failed", e);
            return;
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage());
    } finally {
        QueryUtil.freeQuery(con);
    }
    if (dlg.open() == IDialogConstants.OK_ID) {
        if (database.getServer() != null) {
            persisteManager.updateDBPassword(database.getServer().getServerName(), database.getServer().getHostAddress(), database.getServer().getMonPort(), database.getDatabaseInfo().getDbName(), database.getDatabaseInfo().getAuthLoginedDbUserInfo().getName(), dlg.getInputtedPassword(), database.isAutoSavePassword());
        }
        CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
        if (navigationView != null) {
            TreeViewer treeViewer = navigationView.getViewer();
            if (treeViewer != null) {
                DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
                if (userInfo != null && userInfo.getName().equalsIgnoreCase(node.getName())) {
                    CommonUITool.openInformationBox(Messages.titleLogout, Messages.msgLogoutInfomation);
                    database.setLogined(false);
                    database.setAutoSavePassword(false);
                    CubridNodeChangedEvent event = new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT);
                    CubridNodeManager.getInstance().fireCubridNodeChanged(event);
                    database.removeAllChild();
                    treeViewer.refresh(database, true);
                } else {
                    CommonUITool.refreshNavigatorTree(treeViewer, node.getParent());
                    setEnabled(false);
                }
            }
        }
        ActionManager.getInstance().fireSelectionChanged(getSelection());
        persisteManager.savaAllServers();
        persisteManager.saveAllGroupNodes();
    }
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) Connection(java.sql.Connection) GetAllPartitionClassTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllPartitionClassTask) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) EditUserDialog(com.cubrid.common.ui.cubrid.user.dialog.EditUserDialog) GetUserAuthorizationsTask(com.cubrid.cubridmanager.core.cubrid.user.task.GetUserAuthorizationsTask) GetUserListTask(com.cubrid.cubridmanager.core.cubrid.user.task.GetUserListTask) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) GetAllClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

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