Search in sources :

Example 81 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent 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 82 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class CMHostNodePersistManager method addServer.

/**
	 *
	 * Add server
	 *
	 * @param server the CubridServer object
	 */
public void addServer(CubridServer server) {
    synchronized (this) {
        if (server != null) {
            serverList.add(server);
            ServerManager.getInstance().addServer(server.getServerInfo().getHostAddress(), server.getServerInfo().getHostMonPort(), server.getServerInfo().getUserName(), server.getServerInfo());
            saveServers();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.NODE_ADD));
        }
    }
}
Also used : CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 83 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent 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 84 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent 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)

Example 85 with CubridNodeChangedEvent

use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.

the class AddUserAction method doRun.

/**
	 * Perform do run
	 *
	 * @param node
	 */
public void doRun(ISchemaNode node) {
    // FIXME move this logic to core module
    CubridDatabase database = node.getDatabase();
    //		if (database.getDatabaseInfo().isHAMode()) {
    //			CommonUITool.openErrorBox(Messages.errNoSupportInHA);
    //			return;
    //		}
    String childId = database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridNodeLoader.USERS_FOLDER_ID;
    ICubridNode folderNode = database.getChild(childId);
    if (folderNode == null) {
        return;
    }
    EditUserDialog dlg = new EditUserDialog(getShell());
    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(true);
        GetUserAuthorizationsTask privilegeTask = new GetUserAuthorizationsTask(database.getDatabaseInfo(), con);
        try {
            for (DbUserInfo userInfo : userListInfo.getUserList()) {
                if (userInfo.getName().equals(node.getName())) {
                    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) {
        //Don't count the child
        if (!folderNode.getLoader().isLoaded()) {
            return;
        }
        CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
        if (navigatorView != null) {
            TreeViewer treeViewer = navigatorView.getViewer();
            if (treeViewer != null) {
                CubridNodeChangedEvent event = new CubridNodeChangedEvent(folderNode, CubridNodeChangedEventType.NODE_REFRESH);
                CubridNodeManager.getInstance().fireCubridNodeChanged(event);
                CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode);
            } else {
                CommonUITool.refreshNavigatorTree(treeViewer, node.getParent());
                setEnabled(false);
            }
        }
        ActionManager.getInstance().fireSelectionChanged(getSelection());
    }
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) Connection(java.sql.Connection) GetAllPartitionClassTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllPartitionClassTask) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) 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

CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)98 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)55 TreeViewer (org.eclipse.jface.viewers.TreeViewer)45 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)42 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)23 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)23 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)21 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)21 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)17 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)17 ArrayList (java.util.ArrayList)13 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)11 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)10 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)10 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)10 Display (org.eclipse.swt.widgets.Display)10 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)9 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)9 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)9 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)8