Search in sources :

Example 36 with IViewPart

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

Example 37 with IViewPart

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

the class CubridColumnNavigatorView method getInstance.

public static CubridColumnNavigatorView 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 CubridColumnNavigatorView ? (CubridColumnNavigatorView) 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 38 with IViewPart

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

the class DbDashboardHistoryAction method run.

/**
	 * Open monitor host detail windows.
	 */
public void run() {
    if (getSelectedObj() == null || getSelectedObj().length == 0) {
        return;
    }
    Object obj = getSelectedObj()[0];
    if (!(obj instanceof DatabaseMonitorPart)) {
        return;
    }
    DatabaseMonitorPart part = (DatabaseMonitorPart) obj;
    DatabaseNode dn = (DatabaseNode) part.getModel();
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return;
    }
    HostNode hn = dn.getParent();
    String secondaryId = new StringBuffer(dn.getDbName()).append("&").append(hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
    IViewReference viewReference = page.findViewReference(DbDashboardHistoryViewPart.ID, secondaryId);
    if (viewReference == null) {
        try {
            IViewPart viewPart = page.showView(DbDashboardHistoryViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
            ((DbDashboardHistoryViewPart) viewPart).init((DatabaseNode) part.getModel());
        } catch (PartInitException ex) {
            viewReference = null;
        }
    } else {
        IViewPart viewPart = viewReference.getView(false);
        window.getActivePage().bringToTop(viewPart);
        ((DbDashboardHistoryViewPart) viewPart).init((DatabaseNode) part.getModel());
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DbDashboardHistoryViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.DbDashboardHistoryViewPart) PartInitException(org.eclipse.ui.PartInitException) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)

Example 39 with IViewPart

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

the class WorkbenchContrItem method closeAllEditorAndViewInDatabase.

/**
	 * Close all editor and view part related with this CUBRID Manager database
	 * node,not include query editor
	 *
	 * @param databaseNode the CubridDatabase object
	 * @param eventType CubridNodeChangedEventType
	 */
public void closeAllEditorAndViewInDatabase(CubridDatabase databaseNode, CubridNodeChangedEventType eventType) {
    IWorkbenchPage page = LayoutUtil.getActivePage();
    if (page == null) {
        return;
    }
    IEditorReference[] editorRefArr = page.getEditorReferences();
    for (int i = 0; editorRefArr != null && i < editorRefArr.length; i++) {
        IEditorReference editorRef = editorRefArr[i];
        try {
            IEditorInput editorInput = editorRef.getEditorInput();
            if (!(editorInput instanceof ISchemaNode)) {
                continue;
            }
            ISchemaNode schemaNode = ((ISchemaNode) editorInput);
            ISchemaNode dbNode = schemaNode.getDatabase();
            if (dbNode.getId().equals(databaseNode.getId())) {
                page.closeEditor(editorRef.getEditor(false), true);
            }
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage());
        }
    }
    IViewReference[] viewRefArr = page.getViewReferences();
    if (viewRefArr == null || viewRefArr.length == 0) {
        return;
    }
    for (IViewReference viewRef : viewRefArr) {
        IViewPart viewPart = viewRef.getView(false);
        if (!(viewPart instanceof CubridViewPart)) {
            continue;
        }
        CubridViewPart cubridViewPart = (CubridViewPart) viewPart;
        ICubridNode cubridNode = cubridViewPart.getCubridNode();
        if (!(cubridNode instanceof ISchemaNode)) {
            continue;
        }
        ICubridNode cubridDatabaseNode = ((ISchemaNode) cubridNode).getDatabase();
        if (cubridDatabaseNode.getId().equals(databaseNode.getId())) {
            page.hideView(viewPart);
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IEditorReference(org.eclipse.ui.IEditorReference) CubridViewPart(com.cubrid.common.ui.spi.part.CubridViewPart) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorInput(org.eclipse.ui.IEditorInput)

Example 40 with IViewPart

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

the class WorkbenchContrItem method processNodeRemove.

/**
	 * When node remove, close this node's editor or view part
	 *
	 * @param eventNode ICubridNode
	 * @param page IWorkbenchPage
	 */
protected void processNodeRemove(ICubridNode eventNode, IWorkbenchPage page) {
    List<IEditorPart> editorParts = LayoutUtil.getEditorParts(eventNode);
    for (IEditorPart part : editorParts) {
        if (part != null) {
            page.closeEditor(part, false);
        }
    }
    List<IViewPart> viewParts = LayoutUtil.getViewParts(eventNode);
    for (IViewPart part : viewParts) {
        if (part != null) {
            page.hideView(part);
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IEditorPart(org.eclipse.ui.IEditorPart)

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