Search in sources :

Example 46 with ICubridNode

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

the class OpenJobAutomationInfoAction method run.

public void run() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    final Object[] obj = this.getSelectedObj();
    if (!isSupported(obj) || obj.length == 0) {
        setEnabled(false);
        return;
    }
    ICubridNode node = (ICubridNode) obj[0];
    if (node.getType().equals(CubridNodeType.JOB_FOLDER)) {
        CubridNavigatorView view = CubridNavigatorView.getNavigatorView("com.cubrid.cubridmanager.host.navigator");
        if (view == null) {
            return;
        }
        //if not expand ,expand the node and wait until all children be added
        TreeViewer treeViewer = view.getViewer();
        if (!treeViewer.getExpandedState(node)) {
            treeViewer.expandToLevel(node, 1);
            while (node.getChildren().size() == 0) {
                ThreadUtil.sleep(500);
            }
        }
        openJobsDetailInfoEditor(NodeUtil.getCubridDatabase(node));
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 47 with ICubridNode

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

the class AddBackupPlanAction method run.

/**
	 * Creates a Dialog which is the instance of EditBackupPlanDialog to add a backup plan
	 *
	 * @param database
	 */
public void run(CubridDatabase database) {
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    ICubridNode jobAutoFolderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridDatabaseLoader.JOB_AUTO_FOLDER_ID);
    DefaultSchemaNode buckupPlanFolderNode = (DefaultSchemaNode) jobAutoFolderNode.getChild(jobAutoFolderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridJobAutoFolderLoader.BACKUP_PLAN_FOLDER_ID);
    EditBackupPlanDialog editBackupPlanDlg = new EditBackupPlanDialog(getShell(), true);
    editBackupPlanDlg.setOperation(AddEditType.ADD);
    editBackupPlanDlg.initPara(buckupPlanFolderNode);
    if (editBackupPlanDlg.open() == Dialog.OK) {
        BackupPlanInfo backupPlanInfo = editBackupPlanDlg.getBackupPlanInfo();
        String newBackupId = backupPlanInfo.getBackupid();
        DefaultSchemaNode newNode = new DefaultSchemaNode(newBackupId, newBackupId, ICON_PATH);
        newNode.setContainer(false);
        newNode.setType(CubridNodeType.BACKUP_PLAN);
        newNode.setModelObj(backupPlanInfo);
        buckupPlanFolderNode.addChild(newNode);
        treeViewer.add(buckupPlanFolderNode, newNode);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
    } else {
        canceledTask = true;
    }
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) EditBackupPlanDialog(com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditBackupPlanDialog) BackupPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo)

Example 48 with ICubridNode

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

the class DeleteBackupPlanAction method run.

/**
	 * Deletes the selected backup plan
	 * 
	 */
public void run(ISchemaNode[] nodeArray) {
    List<String> nodeNames = new ArrayList<String>();
    for (Object obj : nodeArray) {
        ICubridNode selection = (ICubridNode) obj;
        nodeNames.add(selection.getLabel());
    }
    if (!CommonUITool.openConfirmBox(Messages.bind(Messages.delBackupPlanConfirmContent, nodeNames))) {
        return;
    }
    String taskName = Messages.bind(Messages.delBackupPlanTaskName, nodeNames);
    CommonTaskExec taskExecutor = new CommonTaskExec(taskName);
    for (Object obj : nodeArray) {
        CubridDatabase database = null;
        if (obj instanceof DefaultSchemaNode) {
            database = ((DefaultSchemaNode) obj).getDatabase();
        }
        if (database == null) {
            CommonUITool.openErrorBox(Messages.msgSelectDB);
            return;
        }
        ServerInfo serverInfo = database.getServer().getServerInfo();
        DelBackupPlanTask delBackupPlanTask = new DelBackupPlanTask(serverInfo);
        delBackupPlanTask.setDbname(database.getName());
        String backupid = ((DefaultSchemaNode) obj).getLabel();
        delBackupPlanTask.setBackupid(backupid);
        taskExecutor.addTask(delBackupPlanTask);
    }
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    for (Object obj : nodeArray) {
        TreeViewer treeViewer = (TreeViewer) this.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) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) DelBackupPlanTask(com.cubrid.cubridmanager.core.cubrid.jobauto.task.DelBackupPlanTask)

Example 49 with ICubridNode

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

the class VolumeFolderInfoEditor method nodeChanged.

/**
	 *
	 * @see com.cubrid.common.ui.spi.event.ICubridNodeChangedListener#nodeChanged(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)
	 * @param event the CubridNodeChangedEvent object
	 */
public void nodeChanged(CubridNodeChangedEvent event) {
    ICubridNode eventNode = event.getCubridNode();
    if (!(eventNode instanceof ISchemaNode) || event.getType() != CubridNodeChangedEventType.CONTAINER_NODE_REFRESH || cubridNode == null) {
        return;
    }
    if (!CubridNodeType.DBSPACE_FOLDER.equals(eventNode.getType())) {
        return;
    }
    ISchemaNode eventSchemaNode = (ISchemaNode) eventNode;
    ISchemaNode schemaNode = (ISchemaNode) cubridNode;
    if (!eventSchemaNode.getDatabase().getId().equals(schemaNode.getDatabase().getId())) {
        return;
    }
    synchronized (this) {
        if (database.getDatabaseInfo().getDbSpaceInfoList() == null) {
            loadData();
        }
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 50 with ICubridNode

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

the class DBSpaceLabelProvider method nodeChanged.

/**
	 * Perform node change event
	 */
public void nodeChanged(CubridNodeChangedEvent event) {
    ICubridNode cubridNode = event.getCubridNode();
    CubridNodeChangedEventType eventType = event.getType();
    if (cubridNode == null || eventType == null) {
        return;
    }
    if (NodeType.SERVER.equals(cubridNode.getType())) {
        if (CubridNodeChangedEventType.SERVER_DISCONNECTED.equals(eventType) || CubridNodeChangedEventType.NODE_REMOVE.equals(eventType)) {
            if (serverInfo != null && StringUtil.isEqualNotIgnoreNull(cubridNode.getName(), serverInfo.getServerName())) {
                IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                if (window == null) {
                    return;
                }
                window.getActivePage().closeEditor(this, true);
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CubridNodeChangedEventType(com.cubrid.common.ui.spi.event.CubridNodeChangedEventType) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Aggregations

ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)362 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)67 ArrayList (java.util.ArrayList)67 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)62 TreeViewer (org.eclipse.jface.viewers.TreeViewer)62 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)55 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)55 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)41 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)40 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)33 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)32 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)31 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)27 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)26 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)25 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)25 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)25 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)25 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)23 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)22