Search in sources :

Example 86 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode 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 87 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class AddQueryPlanAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    CubridDatabase database = null;
    DefaultSchemaNode selection = null;
    if (obj.length > 0 && obj[0] instanceof DefaultSchemaNode) {
        selection = (DefaultSchemaNode) obj[0];
        database = selection.getDatabase();
    }
    assert (null != selection);
    if (database == null) {
        CommonUITool.openErrorBox(Messages.msgSelectDB);
        return;
    }
    run(database);
}
Also used : CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 88 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class BackupErrLogAction method run.

/**
	 *
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Shell shell = getShell();
    Object[] obj = this.getSelectedObj();
    DefaultSchemaNode node = null;
    if (obj.length > 0 && obj[0] instanceof DefaultSchemaNode) {
        node = (DefaultSchemaNode) obj[0];
    }
    if (node == null) {
        return;
    }
    BackupErrLogDialog dlg = new BackupErrLogDialog(shell);
    dlg.setDatabase(node.getDatabase());
    try {
        if (dlg.loadData(shell)) {
            dlg.open();
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}
Also used : BackupErrLogDialog(com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.BackupErrLogDialog) Shell(org.eclipse.swt.widgets.Shell) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Aggregations

DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)88 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)33 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)22 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)21 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)18 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)17 ArrayList (java.util.ArrayList)15 TreeViewer (org.eclipse.jface.viewers.TreeViewer)10 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)9 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)9 Display (org.eclipse.swt.widgets.Display)9 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)8 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)7 File (java.io.File)5 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)4 GetAllClassListTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask)4 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)4