Search in sources :

Example 91 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow 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)

Example 92 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.

the class EditBrokerConfigAction method run.

public void run() {
    final Object[] obj = this.getSelectedObj();
    if (obj == null || obj.length <= 0) {
        setEnabled(false);
        return;
    }
    CubridServer server = null;
    if (obj[0] instanceof CubridServer) {
        server = (CubridServer) obj[0];
    } else if (obj[0] instanceof CubridBrokerFolder) {
        server = ((CubridBrokerFolder) obj[0]).getServer();
    }
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null || server == null) {
        return;
    }
    ConfEditInput editorInput = new ConfEditInput();
    String id = ConfigType.CUBRID_BROKER.getValue() + "&" + server.getId();
    editorInput.setId(id);
    editorInput.setServerInfo(server.getServerInfo());
    editorInput.setName(server.getName());
    editorInput.setServerName(server.getServerName());
    editorInput.setServerPort(server.getMonPort());
    String[] tipMsg = new String[] { ConfigType.CUBRID_BROKER.getValue(), server.getName(), server.getServerName(), server.getMonPort() };
    String toolTipText = Messages.bind(Messages.msgEditorTooltip, tipMsg);
    editorInput.setToolTipText(toolTipText);
    try {
        window.getActivePage().openEditor(editorInput, EditCMCubridBrokerConfPart.ID);
    } catch (Exception ex) {
        LOGGER.error("", ex);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridBrokerFolder(com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder)

Example 93 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.

the class HostDashboardAction method getOpenedEditorPart.

/**
	 * Get all opened query editor
	 * 
	 * @return
	 */
private HostDashboardEditor getOpenedEditorPart(String serverName) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return null;
    }
    IEditorReference[] editorReferences = window.getActivePage().getEditorReferences();
    for (IEditorReference reference : editorReferences) {
        if (reference.getId().equals(HostDashboardEditor.ID)) {
            HostDashboardEditor editor = (HostDashboardEditor) reference.getEditor(false);
            if (editor != null && editor.getServerInfo() != null && editor.getServerInfo().getServerName().equals(serverName)) {
                return editor;
            }
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) HostDashboardEditor(com.cubrid.cubridmanager.ui.host.editor.HostDashboardEditor)

Example 94 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.

the class HostDashboardAction method doRun.

public void doRun(ServerInfo serverInfo) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (null == window) {
        return;
    }
    // Check it open same editor
    HostDashboardEditor editorPart = getOpenedEditorPart(serverInfo.getServerName());
    if (editorPart == null) {
        HostDashboardEditorInput editorInput = new HostDashboardEditorInput(serverInfo);
        editorInput.setName(serverInfo.getServerName());
        editorInput.setToolTipText(serverInfo.getServerName());
        try {
            editorPart = (HostDashboardEditor) window.getActivePage().openEditor(editorInput, HostDashboardEditor.ID);
        } catch (PartInitException ex) {
            LOGGER.error(ex.getMessage());
        }
    } else {
        window.getActivePage().activate(editorPart);
        editorPart.loadAllData();
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) PartInitException(org.eclipse.ui.PartInitException) HostDashboardEditor(com.cubrid.cubridmanager.ui.host.editor.HostDashboardEditor)

Example 95 with IWorkbenchWindow

use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.

the class LogViewAction method run.

/**
	 * Open the log editor and show log content
	 */
public void run() {
    final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    if (cubridNode == null) {
        Object[] obj = this.getSelectedObj();
        if (!isSupported(obj[0])) {
            setEnabled(false);
            return;
        }
        cubridNode = (ICubridNode) obj[0];
    }
    LogInfo logInfo = (LogInfo) cubridNode.getAdapter(LogInfo.class);
    final String filePath = logInfo.getPath();
    TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {

        public IStatus exec(IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                cubridNode = null;
                return Status.CANCEL_STATUS;
            }
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (monitor.isCanceled()) {
                    cubridNode = null;
                    return Status.CANCEL_STATUS;
                }
                if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
                    cubridNode = null;
                    return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
                }
                if (task instanceof CheckFileTask) {
                    CheckFileTask checkFileTask = (CheckFileTask) task;
                    final String[] files = checkFileTask.getExistFiles();
                    if (files == null || files.length == 0) {
                        return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, Messages.bind(Messages.errLogFileNoExist, filePath));
                    }
                } else if (task instanceof GetLogListTask) {
                    GetLogListTask getLogListTask = (GetLogListTask) task;
                    final LogContentInfo logContentInfo = (LogContentInfo) getLogListTask.getLogContent();
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            IEditorPart editorPart = LayoutUtil.getEditorPart(cubridNode, LogEditorPart.ID);
                            if (editorPart != null) {
                                window.getActivePage().closeEditor(editorPart, false);
                            }
                            try {
                                IEditorPart editor = window.getActivePage().openEditor(cubridNode, LogEditorPart.ID);
                                ((LogEditorPart) editor).setTableInfo(logContentInfo, true);
                            } catch (PartInitException e) {
                                LOGGER.error(e.getMessage(), e);
                            }
                        }
                    });
                }
                if (monitor.isCanceled()) {
                    cubridNode = null;
                    return Status.CANCEL_STATUS;
                }
            }
            cubridNode = null;
            return Status.OK_STATUS;
        }
    };
    CheckFileTask checkFileTask = new CheckFileTask(cubridNode.getServer().getServerInfo());
    checkFileTask.setFile(new String[] { filePath });
    taskJobExecutor.addTask(checkFileTask);
    GetLogListTask task = new GetLogListTask(cubridNode.getServer().getServerInfo());
    task.setPath(filePath);
    task.setStart("1");
    task.setEnd("100");
    taskJobExecutor.addTask(task);
    String jobName = Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
    taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITask(com.cubrid.common.core.task.ITask) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) IEditorPart(org.eclipse.ui.IEditorPart) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask) PartInitException(org.eclipse.ui.PartInitException) CheckFileTask(com.cubrid.cubridmanager.core.cubrid.database.task.CheckFileTask) LogEditorPart(com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)

Aggregations

IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)363 IEditorPart (org.eclipse.ui.IEditorPart)136 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)102 PartInitException (org.eclipse.ui.PartInitException)81 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)41 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)39 IViewPart (org.eclipse.ui.IViewPart)39 ArrayList (java.util.ArrayList)37 IEditorReference (org.eclipse.ui.IEditorReference)35 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)32 IWorkbench (org.eclipse.ui.IWorkbench)32 IFile (org.eclipse.core.resources.IFile)30 ISelection (org.eclipse.jface.viewers.ISelection)29 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)27 Shell (org.eclipse.swt.widgets.Shell)26 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)24 CoreException (org.eclipse.core.runtime.CoreException)23 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)21 IProject (org.eclipse.core.resources.IProject)20 QueryUnit (com.cubrid.common.ui.query.editor.QueryUnit)19