Search in sources :

Example 91 with CubridNodeChangedEvent

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

the class EditQueryPlanAction method run.

/**
	 * 
	 * Creates a Dialog which is the instance of EditBackupPlanDialog to edit a
	 * query plan
	 * 
	 */
public int run(CubridDatabase database, DefaultSchemaNode schemaNode) {
    if (database == null) {
        CommonUITool.openErrorBox(Messages.msgSelectDB);
        return IDialogConstants.CANCEL_ID;
    }
    boolean withUser = CompatibleUtil.isSupportQueryPlanWithUser(database.getDatabaseInfo());
    boolean isEditAble = false;
    if (CubridNodeType.QUERY_PLAN.equals(schemaNode.getType()) && database != null && database.isLogined()) {
        DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
            isEditAble = true;
        }
    }
    EditQueryPlanDialog editQueryPlanDlg = new EditQueryPlanDialog(getShell(), isEditAble);
    editQueryPlanDlg.setOperation(AddEditType.EDIT);
    editQueryPlanDlg.initPara(schemaNode);
    if (editQueryPlanDlg.open() == Dialog.OK) {
        // Sets the data of task
        List<ICubridNode> list = schemaNode.getParent().getChildren();
        List<String> msgList = new ArrayList<String>();
        QueryPlanInfo queryPlan = null;
        QueryPlanInfoHelp qHelp = new QueryPlanInfoHelp();
        for (ICubridNode icn : list) {
            if (!icn.isContainer()) {
                queryPlan = (QueryPlanInfo) icn.getAdapter(QueryPlanInfo.class);
                qHelp.setQueryPlanInfo(queryPlan);
                msgList.add(qHelp.buildMsg(withUser));
            }
        }
        ServerInfo serverInfo = database.getServer().getServerInfo();
        SetQueryPlanListTask task = new SetQueryPlanListTask(serverInfo);
        task.setDbname(database.getName());
        task.buildMsg(msgList);
        String taskName = Messages.bind(com.cubrid.cubridmanager.ui.cubrid.jobauto.Messages.editQueryPlanTaskName, schemaNode.getName());
        TaskExecutor taskExecutor = new CommonTaskExec(taskName);
        taskExecutor.addTask(task);
        new ExecTaskWithProgress(taskExecutor).exec();
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(schemaNode, CubridNodeChangedEventType.NODE_REFRESH));
        ActionManager.getInstance().fireSelectionChanged(getSelection());
        return IDialogConstants.OK_ID;
    }
    return IDialogConstants.CANCEL_ID;
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) EditQueryPlanDialog(com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditQueryPlanDialog) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) SetQueryPlanListTask(com.cubrid.cubridmanager.core.cubrid.jobauto.task.SetQueryPlanListTask) QueryPlanInfoHelp(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) QueryPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo)

Example 92 with CubridNodeChangedEvent

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

the class AddQueryPlanAction method run.

public void run(CubridDatabase database) {
    ICubridNode jobAutoFolderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridDatabaseLoader.JOB_AUTO_FOLDER_ID);
    DefaultSchemaNode queryPlanFolderNode = (DefaultSchemaNode) jobAutoFolderNode.getChild(jobAutoFolderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridJobAutoFolderLoader.QUERY_PLAN_FOLDER_ID);
    boolean withUser = false;
    if (CompatibleUtil.isSupportQueryPlanWithUser(database.getDatabaseInfo())) {
        withUser = true;
    }
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    EditQueryPlanDialog editQueryPlanDlg = new EditQueryPlanDialog(getShell(), true);
    editQueryPlanDlg.setDatabase(database);
    editQueryPlanDlg.setOperation(AddEditType.ADD);
    editQueryPlanDlg.initPara(queryPlanFolderNode);
    DefaultSchemaNode newNode = null;
    if (editQueryPlanDlg.open() == Dialog.OK) {
        // Sets the data of task
        QueryPlanInfoHelp queryPlanInfoHelp = editQueryPlanDlg.getQueryPlanInfo();
        QueryPlanInfo queryPlanInfo = queryPlanInfoHelp.getQueryPlanInfo();
        String newQueryId = queryPlanInfoHelp.getQuery_id();
        newNode = new DefaultSchemaNode(newQueryId, newQueryId, ICON_PATH);
        newNode.setContainer(false);
        newNode.setType(CubridNodeType.QUERY_PLAN);
        newNode.setModelObj(queryPlanInfo);
        List<ICubridNode> list = queryPlanFolderNode.getChildren();
        List<String> msgList = new ArrayList<String>();
        QueryPlanInfo queryPlan = null;
        QueryPlanInfoHelp qHelp = new QueryPlanInfoHelp();
        for (ICubridNode icn : list) {
            if (!icn.isContainer()) {
                queryPlan = (QueryPlanInfo) icn.getAdapter(QueryPlanInfo.class);
                qHelp.setQueryPlanInfo(queryPlan);
                msgList.add(qHelp.buildMsg(withUser));
            }
        }
        qHelp.setQueryPlanInfo(queryPlanInfo);
        msgList.add(qHelp.buildMsg(withUser));
        ServerInfo serverInfo = database.getServer().getServerInfo();
        SetQueryPlanListTask task = new SetQueryPlanListTask(serverInfo);
        task.setDbname(database.getName());
        task.buildMsg(msgList);
        String taskName = Messages.bind(com.cubrid.cubridmanager.ui.cubrid.jobauto.Messages.addQueryPlanTaskName, newQueryId);
        TaskExecutor taskExecutor = new CommonTaskExec(taskName);
        taskExecutor.addTask(task);
        new ExecTaskWithProgress(taskExecutor).exec();
        if (!taskExecutor.isSuccess()) {
            return;
        }
    } else {
        canceledTask = true;
    }
    if (null != newNode) {
        queryPlanFolderNode.addChild(newNode);
        treeViewer.add(queryPlanFolderNode, newNode);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) EditQueryPlanDialog(com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditQueryPlanDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) SetQueryPlanListTask(com.cubrid.cubridmanager.core.cubrid.jobauto.task.SetQueryPlanListTask) QueryPlanInfoHelp(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) QueryPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo)

Example 93 with CubridNodeChangedEvent

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

the class AddMonitorDashboardAction method run.

/**
	 * Open the dialog
	 */
public void run() {
    AddDashboardDialog dialog = new AddDashboardDialog(getShell());
    int returnCode = dialog.open();
    if (returnCode == IDialogConstants.OK_ID) {
        Dashboard dashboard = dialog.getDashboard();
        DefaultCubridNode dashboardNode = new DefaultCubridNode(dashboard.getName(), dashboard.getName(), "icons/navigator/status_item.png");
        dashboardNode.setType(CubridNodeType.MONITOR_DASHBOARD);
        dashboardNode.setEditorId(MonitorDashboardEditor.ID);
        dashboardNode.setModelObj(dashboard);
        MonitorDashboardPersistManager.getInstance().addMonitorDashboard(dashboardNode);
        ISelectionProvider provider = getSelectionProvider();
        if (provider instanceof TreeViewer) {
            TreeViewer treeViewer = (TreeViewer) provider;
            /*TOOLS-3665 Refresh the input of TreeViewer*/
            treeViewer.setInput(CubridMonitorNavigatorView.getTreeViewerInput());
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(dashboardNode, CubridNodeChangedEventType.NODE_ADD));
            LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(dashboardNode);
        }
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) AddDashboardDialog(com.cubrid.cubridmanager.ui.mondashboard.dialog.AddDashboardDialog) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 94 with CubridNodeChangedEvent

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

the class MonitorDashboardPersistManager method addMonitorDashboard.

/**
	 * 
	 * Add monitoring dash board
	 * 
	 * @param node The ICubridNode
	 */
public void addMonitorDashboard(ICubridNode node) {
    synchronized (this) {
        if (node != null) {
            monitorDashboardList.add(node);
            saveDashboard();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_ADD));
        }
    }
}
Also used : CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 95 with CubridNodeChangedEvent

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

the class MonitorDashboardPersistManager method removeMonitorDashboard.

/**
	 * 
	 * Remove monitor dash board
	 * 
	 * @param node The ICubridNode
	 */
public void removeMonitorDashboard(ICubridNode node) {
    synchronized (this) {
        if (node != null) {
            monitorDashboardList.remove(node);
            saveDashboard();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REMOVE));
        }
    }
}
Also used : CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

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