Search in sources :

Example 91 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.

the class DeleteDatabaseConfirmDialog method buttonPressed.

/**
	 * When button pressed,handle with the event
	 * 
	 * @param buttonId the button id
	 */
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        String pass = text.getText();
        if (pass == null) {
            pass = "";
        }
        /*TOOLS-3633*/
        ServerInfo serverInfo = database.getServer().getServerInfo();
        LoginDatabaseTask loginDatabaseTask = new LoginDatabaseTask(serverInfo);
        loginDatabaseTask.setCMUser(serverInfo.getUserName());
        loginDatabaseTask.setDbName(database.getDatabaseInfo().getDbName());
        loginDatabaseTask.setDbUser(USERNAME_DBA);
        loginDatabaseTask.setDbPassword(pass);
        TaskExecutor taskExcutor = new CommonTaskExec(Messages.msgCheckPassword);
        taskExcutor.addTask(loginDatabaseTask);
        new ExecTaskWithProgress(taskExcutor).exec();
        if (!taskExcutor.isSuccess()) {
            return;
        }
    }
    super.buttonPressed(buttonId);
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) LoginDatabaseTask(com.cubrid.cubridmanager.core.cubrid.database.task.LoginDatabaseTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Example 92 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.

the class BrokersParameterPropertyPage method performOk.

/**
	 * Save the page content
	 * 
	 * @return <code>true</code> if it saved successfully;<code>false</code>
	 *         otherwise
	 */
public boolean performOk() {
    if (adminlogTxt == null || adminlogTxt.isDisposed()) {
        return true;
    }
    // execute delete broker task
    if (isTableChange()) {
        CommonTaskExec taskExec = new CommonTaskExec(Messages.setBrokerConfParametersTaskName);
        for (String bname : deletedBrokerLst) {
            DeleteBrokerTask task = new DeleteBrokerTask(serverInfo);
            task.setBrokerName(bname);
            taskExec.addTask(task);
        }
        //remove the default value
        String[][] brokerParameters = ConfConstants.getBrokerParameters(serverInfo);
        for (Map.Entry<String, Map<String, String>> entry : newConfParaMap.entrySet()) {
            Map<String, String> paraMap = entry.getValue();
            for (String[] brokerPara : brokerParameters) {
                if (brokerPara[0].equals(ConfConstants.APPL_SERVER_PORT)) {
                    String port = paraMap.get(ConfConstants.BROKER_PORT);
                    if (null != port) {
                        int serverPortValue = Integer.parseInt(paraMap.get(ConfConstants.BROKER_PORT)) + 1;
                        String serverPort = paraMap.get(ConfConstants.APPL_SERVER_PORT);
                        if (serverPort.equalsIgnoreCase(Integer.toString(serverPortValue))) {
                            paraMap.remove(ConfConstants.APPL_SERVER_PORT);
                        }
                    }
                } else if (ConfConstants.isDefaultBrokerParameter(brokerPara[0]) && brokerPara[2].equals(paraMap.get(brokerPara[0]))) {
                    paraMap.remove(brokerPara[0]);
                }
            }
        }
        // execute set parameter task
        SetBrokerConfParameterTask setBrokerConfParameterTask = new SetBrokerConfParameterTask(serverInfo);
        setBrokerConfParameterTask.setConfParameters(newConfParaMap);
        taskExec.addTask(setBrokerConfParameterTask);
        new ExecTaskWithProgress(taskExec).exec();
        if (taskExec.isSuccess()) {
            CommonUITool.openInformationBox(Messages.titleSuccess, RESTART_BROKER_MSG);
        }
    }
    // refresh tap
    if (isSettingChange()) {
        boolean isOn = refreshBtn.getSelection();
        String interval = intervalTxt.getText().trim();
        String serverName = node.getServer().getLabel();
        String nodeName = node.getLabel();
        BrokerIntervalSetting setting = new BrokerIntervalSetting(serverName, nodeName, interval, isOn);
        newIntervalSettingMap.put(serverName + "_" + brokerEnvName, setting);
        BrokerIntervalSettingManager manager = BrokerIntervalSettingManager.getInstance();
        for (Map.Entry<String, BrokerIntervalSetting> entry : oldIntervalSettingMap.entrySet()) {
            String brokerName = entry.getValue().getBrokerName();
            manager.removeBrokerIntervalSetting(serverName, brokerName);
        }
        for (Map.Entry<String, BrokerIntervalSetting> entry : newIntervalSettingMap.entrySet()) {
            BrokerIntervalSetting newSetting = entry.getValue();
            manager.setBrokerInterval(newSetting);
        }
    }
    return true;
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) BrokerIntervalSettingManager(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSettingManager) Point(org.eclipse.swt.graphics.Point) BrokerIntervalSetting(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting) DeleteBrokerTask(com.cubrid.cubridmanager.core.broker.task.DeleteBrokerTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) Map(java.util.Map) HashMap(java.util.HashMap) SetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.SetBrokerConfParameterTask)

Example 93 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.

the class DeleteQueryPlanAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run(ISchemaNode[] nodeArray) {
    List<String> nodeNames = new ArrayList<String>();
    CubridDatabase database = null;
    for (Object obj : nodeArray) {
        if (obj instanceof DefaultSchemaNode) {
            database = ((DefaultSchemaNode) obj).getDatabase();
        }
        ICubridNode selection = (ICubridNode) obj;
        nodeNames.add(selection.getLabel());
    }
    if (!CommonUITool.openConfirmBox(Messages.bind(Messages.delQueryPlanConfirmContent, nodeNames))) {
        return;
    }
    if (database == null) {
        CommonUITool.openErrorBox(Messages.msgSelectDB);
        return;
    }
    ICubridNode parentSelection = ((DefaultSchemaNode) nodeArray[0]).getParent();
    boolean withUser = CompatibleUtil.isSupportQueryPlanWithUser(database.getDatabaseInfo());
    List<ICubridNode> list = parentSelection.getChildren();
    List<String> msgList = new ArrayList<String>();
    QueryPlanInfo queryPlan = null;
    QueryPlanInfoHelp qHelp = new QueryPlanInfoHelp();
    for (ICubridNode icn : list) {
        if (!icn.isContainer()) {
            boolean isRemove = false;
            for (String nodeName : nodeNames) {
                if (icn.getLabel().equals(nodeName)) {
                    isRemove = true;
                    break;
                }
            }
            if (isRemove) {
                continue;
            }
            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(Messages.delQueryPlanTaskName, nodeNames);
    TaskExecutor taskExecutor = new CommonTaskExec(taskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    for (Object obj : nodeArray) {
        TreeViewer treeViewer = (TreeViewer) getSelectionProvider();
        DefaultSchemaNode delNode = ((DefaultSchemaNode) obj);
        ICubridNode parentNode = delNode.getParent();
        parentNode.removeChild(delNode);
        treeViewer.remove(delNode);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) 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) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) QueryPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo)

Example 94 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec 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 95 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.

the class AutoAddVolumeLogDialog method loadData.

/**
	 * load the data
	 * 
	 * @return boolean
	 */
public boolean loadData() {
    CommonQueryTask<AutoAddVolumeLogList> task = new CommonQueryTask<AutoAddVolumeLogList>(server.getServerInfo(), CommonSendMsg.getCommonSimpleSendMsg(), new AutoAddVolumeLogList());
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.getAuotAddedVolLogTaskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (!taskExecutor.isSuccess()) {
        return false;
    }
    volumeLogList = task.getResultModel();
    return true;
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) AutoAddVolumeLogList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.AutoAddVolumeLogList)

Aggregations

CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)106 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)106 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)81 TreeViewer (org.eclipse.jface.viewers.TreeViewer)31 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)24 ArrayList (java.util.ArrayList)24 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)23 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)18 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)14 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)13 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)13 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)12 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)11 IEditorPart (org.eclipse.ui.IEditorPart)11 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)9 HashMap (java.util.HashMap)9 AbstractUITask (com.cubrid.common.core.task.AbstractUITask)8 Map (java.util.Map)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)8