Search in sources :

Example 1 with DelStatusTemplateTask

use of com.cubrid.cubridmanager.core.monitoring.task.DelStatusTemplateTask in project cubrid-manager by CUBRID.

the class DeleteStatusMonitorTemplateAction method delStatusTemp.

/**
	 * delete status template task.
	 * 
	 * @param activePage IWorkbenchPage
	 * @param selection ICubridNode
	 * @return DelStatusTemplateTask
	 */
private DelStatusTemplateTask delStatusTemp(IWorkbenchPage activePage, ICubridNode selection) {
    DelStatusTemplateTask delTsk = new DelStatusTemplateTask(selection.getServer().getServerInfo());
    IViewReference viewRef = activePage.findViewReference(StatusMonitorViewPart.ID, selection.getLabel());
    if (viewRef != null) {
        IViewPart viewPart = viewRef.getView(false);
        //closes the view part
        if (null != viewPart && viewPart.getTitle().endsWith(selection.getLabel())) {
            activePage.hideView(viewPart);
        }
    }
    delTsk.setTemplateName(selection.getName());
    return delTsk;
}
Also used : IViewPart(org.eclipse.ui.IViewPart) DelStatusTemplateTask(com.cubrid.cubridmanager.core.monitoring.task.DelStatusTemplateTask) IViewReference(org.eclipse.ui.IViewReference)

Example 2 with DelStatusTemplateTask

use of com.cubrid.cubridmanager.core.monitoring.task.DelStatusTemplateTask in project cubrid-manager by CUBRID.

the class DeleteStatusMonitorTemplateAction method run.

/**
	 * Deletes the selected status template
	 * 
	 */
public void run() {
    Object[] objs = this.getSelectedObj();
    assert (objs != null);
    List<String> nodeNames = new ArrayList<String>();
    for (Object obj : objs) {
        ICubridNode selection = (ICubridNode) obj;
        nodeNames.add(selection.getLabel());
    }
    if (!CommonUITool.openConfirmBox(Messages.bind(Messages.delStatusMonitorConfirmContent, nodeNames))) {
        return;
    }
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IWorkbenchPage activePage = window.getActivePage();
    String taskName = Messages.bind(Messages.delTemplateTaskName, nodeNames);
    TaskExecutor taskExecutor = new CommonTaskExec(taskName);
    for (Object obj : objs) {
        ICubridNode selection = (ICubridNode) obj;
        if (CubridNodeType.STATUS_MONITOR_TEMPLATE.equals(selection.getType())) {
            DelStatusTemplateTask delTsk = delStatusTemp(activePage, selection);
            taskExecutor.addTask(delTsk);
        }
    }
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    CommonUITool.refreshNavigatorTree(treeViewer, ((ICubridNode) objs[0]).getParent());
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) DelStatusTemplateTask(com.cubrid.cubridmanager.core.monitoring.task.DelStatusTemplateTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Aggregations

DelStatusTemplateTask (com.cubrid.cubridmanager.core.monitoring.task.DelStatusTemplateTask)2 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 ArrayList (java.util.ArrayList)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 IViewPart (org.eclipse.ui.IViewPart)1 IViewReference (org.eclipse.ui.IViewReference)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1