Search in sources :

Example 1 with HostDashboardEditor

use of com.cubrid.cubridmanager.ui.host.editor.HostDashboardEditor 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 2 with HostDashboardEditor

use of com.cubrid.cubridmanager.ui.host.editor.HostDashboardEditor 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 3 with HostDashboardEditor

use of com.cubrid.cubridmanager.ui.host.editor.HostDashboardEditor in project cubrid-manager by CUBRID.

the class HostDashboardAction method closeEditor.

public void closeEditor(ServerInfo serverInfo) {
    HostDashboardEditor editor = getOpenedEditorPart(serverInfo.getServerName());
    if (editor != null) {
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
            return;
        }
        window.getActivePage().closeEditor(editor, true);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) HostDashboardEditor(com.cubrid.cubridmanager.ui.host.editor.HostDashboardEditor)

Aggregations

HostDashboardEditor (com.cubrid.cubridmanager.ui.host.editor.HostDashboardEditor)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 IEditorReference (org.eclipse.ui.IEditorReference)1 PartInitException (org.eclipse.ui.PartInitException)1