Search in sources :

Example 31 with IViewPart

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

the class SqlmapNavigatorView method getInstance.

/**
	 * Return current SqlmapNavigatorView instance.
	 *
	 * @return
	 */
public static SqlmapNavigatorView 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 SqlmapNavigatorView ? (SqlmapNavigatorView) 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 32 with IViewPart

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

the class BrokerEnvStatusView method createTable.

/**
	 * This method initializes table
	 *
	 */
private void createTable() {
    tableViewer = new TableViewer(composite, SWT.FULL_SELECTION);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLinesVisible(true);
    BrokerTblColumnSetHelp bcsh = BrokerTblColumnSetHelp.getInstance();
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerEnvStatusColumn, BrokerEnvStatusColumn.values());
    TableLayout tlayout = new TableLayout();
    for (BrokerEnvStatusColumn column : BrokerEnvStatusColumn.values()) {
        if (column.getValue() == -1) {
            tlayout.addColumnData(new ColumnWeightData(0, 0, false));
        } else {
            tlayout.addColumnData(new ColumnWeightData(10, 40, true));
        }
    }
    tableViewer.getTable().setLayout(tlayout);
    tableViewer.getTable().addMouseListener(new MouseAdapter() {

        public void mouseDoubleClick(MouseEvent event) {
            int index = -1;
            if ((index = tableViewer.getTable().getSelectionIndex()) >= 0) {
                TableItem tableItem = tableViewer.getTable().getItem(index);
                String brokename = tableItem.getText(0).trim();
                ICubridNode input = null;
                for (ICubridNode node : cubridNode.getChildren()) {
                    if (node.getLabel().equalsIgnoreCase(brokename)) {
                        input = node;
                        break;
                    }
                }
                LayoutManager.getInstance().setCurrentSelectedNode(input);
                IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                if (null == window) {
                    return;
                }
                IWorkbenchPage activePage = window.getActivePage();
                IViewPart viewPart = window.getActivePage().findView(BrokerStatusView.ID);
                if (null != viewPart) {
                    activePage.hideView(viewPart);
                }
                try {
                    activePage.showView(BrokerStatusView.ID);
                } catch (PartInitException e1) {
                    LOGGER.error(e1.getMessage(), e1);
                }
            }
        }
    });
    makeTableColumn();
    tableViewer.setContentProvider(new BrokersStatusContentProvider());
    ServerInfo serverInfo = cubridNode.getServer().getServerInfo();
    BrokersStatusLabelProvider brokersStatusLabelProvider = new BrokersStatusLabelProvider();
    brokersStatusLabelProvider.setServerInfo(serverInfo);
    tableViewer.setLabelProvider(brokersStatusLabelProvider);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) MouseEvent(org.eclipse.swt.events.MouseEvent) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TableItem(org.eclipse.swt.widgets.TableItem) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) BrokerEnvStatusColumn(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerEnvStatusColumn) BrokerTblColumnSetHelp(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerTblColumnSetHelp) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 33 with IViewPart

use of org.eclipse.ui.IViewPart 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 34 with IViewPart

use of org.eclipse.ui.IViewPart 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 35 with IViewPart

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

Aggregations

IViewPart (org.eclipse.ui.IViewPart)104 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)58 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)39 IEditorPart (org.eclipse.ui.IEditorPart)34 PartInitException (org.eclipse.ui.PartInitException)28 IViewReference (org.eclipse.ui.IViewReference)26 ArrayList (java.util.ArrayList)16 IFile (org.eclipse.core.resources.IFile)15 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)15 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)15 IEditorInput (org.eclipse.ui.IEditorInput)13 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)13 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)10 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)10 ITermViewPart (net.heartsome.cat.ts.ui.view.ITermViewPart)10 Shell (org.eclipse.swt.widgets.Shell)9 IEditorReference (org.eclipse.ui.IEditorReference)9 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)8 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)8 IProject (org.eclipse.core.resources.IProject)8