Search in sources :

Example 76 with IWorkbenchWindow

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

the class JdbcManageComposite method isJdbcDriverUsing.

/**
	 * 
	 * Return whether the JDBC driver is using
	 * 
	 * @param jdbcVersion String
	 * @return boolean
	 */
private boolean isJdbcDriverUsing(String jdbcVersion) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return false;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return false;
    }
    IViewReference[] viewReference = page.getViewReferences();
    for (int i = 0; viewReference != null && i < viewReference.length; i++) {
        IViewPart viewPart = viewReference[i].getView(false);
        if (!(viewPart instanceof CubridNavigatorView)) {
            continue;
        }
        CubridNavigatorView navigatorView = (CubridNavigatorView) viewPart;
        List<ICubridNode> list = getUsingJdbcNodeList(navigatorView);
        if (list == null) {
            continue;
        }
        for (ICubridNode node : list) {
            if (NodeType.SERVER.equals(node.getType())) {
                CubridServer server = (CubridServer) node;
                ServerInfo serverInfo = server.getServerInfo();
                if (serverInfo == null) {
                    continue;
                }
                if (serverInfo.isConnected() && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
                    CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcServer, new Object[] { serverInfo.getServerName(), jdbcVersion }));
                    return true;
                }
            } else if (NodeType.DATABASE.equals(node.getType())) {
                CubridDatabase database = (CubridDatabase) node;
                if (database == null || database.getServer() == null || database.getServer().getServerInfo() == null) {
                    continue;
                }
                ServerInfo serverInfo = database.getServer().getServerInfo();
                if (serverInfo == null) {
                    LOGGER.error("The serverInfo is a null.");
                    return false;
                }
                boolean isSameVersion = StringUtil.isEqual(serverInfo.getJdbcDriverVersion(), jdbcVersion);
                if (isSameVersion && database.isLogined()) {
                    CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcConn, new Object[] { database.getName(), jdbcVersion }));
                    return true;
                }
            }
        }
    }
    IEditorReference[] editorReference = page.getEditorReferences();
    for (int i = 0; editorReference != null && i < editorReference.length; i++) {
        IEditorPart editorPart = editorReference[i].getEditor(false);
        if (!(editorPart instanceof QueryEditorPart)) {
            continue;
        }
        QueryEditorPart queryEditorPart = (QueryEditorPart) editorPart;
        CubridServer server = queryEditorPart.getSelectedServer();
        ServerInfo serverInfo = server == null ? null : server.getServerInfo();
        String partName = queryEditorPart.getPartName();
        if (serverInfo != null && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
            CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcQuery, new Object[] { partName, jdbcVersion }));
            return true;
        }
    }
    return false;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) IEditorReference(org.eclipse.ui.IEditorReference) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 77 with IWorkbenchWindow

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

the class RunSQLFileDialog method buttonPressed.

/**
	 * When press button,call it
	 * 
	 * @param buttonId the button id
	 */
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        if (!validate()) {
            return;
        }
        for (CubridDatabase database : cubridDatabases) {
            RunSQLFileEditorInput input = new RunSQLFileEditorInput(database, filesList, fileCharsetCombo.getText(), threadCountSpinner.getSelection(), commitCountSpinner.getSelection(), saveErrExcelPath.getText());
            try {
                IWorkbench workbench = PlatformUI.getWorkbench();
                IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
                workbenchWindow.getActivePage().openEditor(input, RunSQLFileViewPart.ID);
            } catch (Exception e) {
                LOGGER.error("", e);
            }
        }
    }
    setReturnCode(buttonId);
    close();
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) RunSQLFileEditorInput(com.cubrid.common.ui.common.sqlrunner.part.RunSQLFileEditorInput) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 78 with IWorkbenchWindow

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

the class FavoriteQueryNavigatorView method getInstance.

public static FavoriteQueryNavigatorView getInstance() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return null;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return null;
    }
    IViewReference viewReference = page.findViewReference(ID);
    if (viewReference != null) {
        IViewPart viewPart = viewReference.getView(false);
        return viewPart instanceof FavoriteQueryNavigatorView ? (FavoriteQueryNavigatorView) viewPart : null;
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 79 with IWorkbenchWindow

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

the class FavoriteQueryNavigatorView method setFocus.

public void setFocus() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return;
    }
    IViewReference viewReference = page.findViewReference(ID);
    if (viewReference != null) {
        IViewPart viewPart = viewReference.getView(false);
        getSite().getPage().activate(viewPart);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 80 with IWorkbenchWindow

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

the class CubridDdlNavigatorView method getInstance.

public static CubridDdlNavigatorView getInstance() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return null;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return null;
    }
    IViewReference viewReference = page.findViewReference(ID);
    if (viewReference != null) {
        IViewPart viewPart = viewReference.getView(false);
        return viewPart instanceof CubridDdlNavigatorView ? (CubridDdlNavigatorView) viewPart : null;
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

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