Search in sources :

Example 41 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer 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 42 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer 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 43 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer 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 44 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.

the class HostDialog method closeTestServerConnection.

/**
	 *
	 * Close the test server connection
	 *
	 */
public void closeTestServerConnection() {
    if (testConnServerInfo != null) {
        ServerManager.getInstance().setConnected(testConnServerInfo.getHostAddress(), testConnServerInfo.getHostMonPort(), testConnServerInfo.getUserName(), false);
    }
    //clear and reset the tree view items of the server to avoid troublesome error prompt, for UX improvement.
    if (server != null) {
        CubridWorkbenchContrItem.closeAllEditorAndViewInServer(server, false);
        server.removeAllChild();
        TreeViewer viewer = (TreeViewer) LayoutManager.getInstance().getSelectionProvider();
        viewer.refresh(server);
        viewer.setSelection(null, true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_DISCONNECTED));
    }
    testConnServerInfo = null;
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 45 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.

the class NewMultiHostConnectionDialog method editHost.

public void editHost(FailedHostServerInfo multiHostConnectionFailedServerInfo) {
    // get selected dbdata
    if (multiHostConnectionFailedServerInfo == null || multiHostConnectionFailedServerInfo.getCubridServer().isConnected()) {
        return;
    }
    HostDialog dialog = new HostDialog(getShell(), false, false);
    ServerInfo oldServerInfo = multiHostConnectionFailedServerInfo.getCubridServer().getServerInfo();
    dialog.setServer(multiHostConnectionFailedServerInfo.getCubridServer());
    if (dialog.open() != HostDialog.CONNECT_ID) {
        return;
    }
    ServerInfo serverInfo = dialog.getServerInfo();
    if (!serverInfo.getServerName().equals(multiHostConnectionFailedServerInfo.getCubridServer().getLabel())) {
        QueryOptions.removePref(multiHostConnectionFailedServerInfo.getCubridServer().getServerInfo());
        BrokerIntervalSettingManager.getInstance().removeAllBrokerIntervalSettingInServer(multiHostConnectionFailedServerInfo.getCubridServer().getLabel());
    }
    if (oldServerInfo.isConnected() && !oldServerInfo.equals(serverInfo)) {
        HostUtils.processHostDisconnected(multiHostConnectionFailedServerInfo.getCubridServer());
    }
    multiHostConnectionFailedServerInfo.getCubridServer().setId(serverInfo.getServerName());
    multiHostConnectionFailedServerInfo.getCubridServer().setLabel(serverInfo.getServerName());
    multiHostConnectionFailedServerInfo.getCubridServer().setServerInfo(serverInfo);
    multiHostConnectionFailedServerInfo.getCubridServer().setAutoSavePassword(dialog.isSavePassword());
    CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
    CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(multiHostConnectionFailedServerInfo.getCubridServer(), CubridNodeChangedEventType.SERVER_CONNECTED));
    multiHostConnectionFailedServerInfo.getCubridServer().getLoader().setLoaded(false);
    CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
    TreeViewer treeViewer = view.getViewer();
    treeViewer.refresh(multiHostConnectionFailedServerInfo.getCubridServer(), true);
    treeViewer.expandToLevel(multiHostConnectionFailedServerInfo.getCubridServer(), 1);
    ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
    LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
    multiHostConnectionFailedServerInfo.setErrConnectionMsg("");
    serverTable.refresh();
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Aggregations

TreeViewer (org.eclipse.jface.viewers.TreeViewer)248 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 GridData (org.eclipse.swt.layout.GridData)50 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)45 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)43 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)42 Composite (org.eclipse.swt.widgets.Composite)42 Tree (org.eclipse.swt.widgets.Tree)42 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)40 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)39 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)38 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)36 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)36 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)36 GridLayout (org.eclipse.swt.layout.GridLayout)34 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)31 ArrayList (java.util.ArrayList)29 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)27 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)25