Search in sources :

Example 81 with IViewPart

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

the class CubridWorkbenchContrItem method reopenEditorOrView.

/**
	 * ReOpen the editor or view part of this CUBRID node
	 *
	 * @param cubridNode the ICubridNode object
	 */
public void reopenEditorOrView(ICubridNode cubridNode) {
    if (cubridNode == null) {
        return;
    }
    String editorId = cubridNode.getEditorId();
    String viewId = cubridNode.getViewId();
    if (editorId != null && editorId.trim().length() > 0) {
        IEditorPart editorPart = LayoutUtil.getEditorPart(cubridNode, editorId);
        if (editorPart != null) {
            openEditorOrView(cubridNode);
        }
    } else if (viewId != null && viewId.trim().length() > 0) {
        IViewPart viewPart = LayoutUtil.getViewPart(cubridNode, viewId);
        if (viewPart != null) {
            openEditorOrView(cubridNode);
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IEditorPart(org.eclipse.ui.IEditorPart)

Example 82 with IViewPart

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

the class LayoutUtil method getViewPart.

/**
	 * 
	 * Get the view part of this cubrid node and viewId
	 * 
	 * @param cubridNode the ICubridNode object
	 * @param viewId the view id
	 * @return the IViewPart object
	 */
public static IViewPart getViewPart(ICubridNode cubridNode, String viewId) {
    IWorkbenchPage page = getActivePage();
    if (page == null) {
        return null;
    }
    IViewReference[] viewRefArr = page.getViewReferences();
    if (viewRefArr == null || viewRefArr.length == 0) {
        return null;
    }
    for (IViewReference viewRef : viewRefArr) {
        IViewPart viewPart = viewRef.getView(false);
        String id = viewRef.getId();
        if (viewPart instanceof CubridViewPart) {
            CubridViewPart cubridViewPart = (CubridViewPart) viewPart;
            ICubridNode node = cubridViewPart.getCubridNode();
            if (node != null && node.getId().equals(cubridNode.getId()) && viewId.equals(id)) {
                return viewPart;
            }
        }
    }
    return null;
}
Also used : IViewPart(org.eclipse.ui.IViewPart) CubridViewPart(com.cubrid.common.ui.spi.part.CubridViewPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 83 with IViewPart

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

the class LayoutUtil method getViewParts.

/**
	 * 
	 * Get the view parts of this CUBRID node
	 * 
	 * @param cubridNode the ICubridNode object
	 * @return List<IViewPart>
	 */
public static List<IViewPart> getViewParts(ICubridNode cubridNode) {
    List<IViewPart> viewPartList = new ArrayList<IViewPart>();
    IWorkbenchPage page = getActivePage();
    if (page == null) {
        return viewPartList;
    }
    IViewReference[] viewRefArr = page.getViewReferences();
    if (viewRefArr == null || viewRefArr.length == 0) {
        return viewPartList;
    }
    for (IViewReference viewRef : viewRefArr) {
        IViewPart viewPart = viewRef.getView(false);
        if (viewPart instanceof CubridViewPart) {
            CubridViewPart cubridViewPart = (CubridViewPart) viewPart;
            ICubridNode node = cubridViewPart.getCubridNode();
            if (node != null && node.getId().equals(cubridNode.getId())) {
                viewPartList.add(viewPart);
            }
        }
    }
    return viewPartList;
}
Also used : IViewPart(org.eclipse.ui.IViewPart) CubridViewPart(com.cubrid.common.ui.spi.part.CubridViewPart) IViewReference(org.eclipse.ui.IViewReference) ArrayList(java.util.ArrayList) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 84 with IViewPart

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

the class LayoutUtil method closeEditorAndView.

/**
	 * 
	 * Close the editor or view part relating to this given CUBIRD node, but the
	 * query editor is not included.
	 * 
	 * @param cubridNode the ICubridNode object
	 */
public static void closeEditorAndView(ICubridNode cubridNode) {
    IWorkbenchPage page = getActivePage();
    if (page == null) {
        return;
    }
    String editorId = cubridNode.getEditorId();
    if (editorId != null) {
        IEditorPart editorPart = getEditorPart(cubridNode, editorId);
        if (editorPart != null) {
            page.closeEditor(editorPart, false);
        }
    }
    String viewId = cubridNode.getViewId();
    if (viewId != null) {
        IViewPart viewPart = getViewPart(cubridNode, viewId);
        if (null != viewPart) {
            page.hideView(viewPart);
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

Example 85 with IViewPart

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

the class BrokerMonitorPart method performRequest.

/**
	 * @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
	 * @param req Request
	 */
public void performRequest(Request req) {
    if (req.getType() == RequestConstants.REQ_OPEN) {
        BrokerNode bn = (BrokerNode) getModel();
        String brokerName = bn.getBrokerName();
        HostNode hn = bn.getParent();
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
            return;
        }
        IWorkbenchPage page = window.getActivePage();
        if (page == null) {
            return;
        }
        String secondaryId = new StringBuffer(brokerName + "@" + hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
        IViewReference viewReference = page.findViewReference(BrokerDashboardViewPart.ID, secondaryId);
        if (viewReference == null) {
            try {
                IViewPart viewPart = page.showView(BrokerDashboardViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
                ((BrokerDashboardViewPart) viewPart).init((BrokerNode) getModel());
            } catch (PartInitException ex) {
                viewReference = null;
            }
        } else {
            IViewPart viewPart = viewReference.getView(false);
            window.getActivePage().bringToTop(viewPart);
            ((BrokerDashboardViewPart) viewPart).init((BrokerNode) getModel());
        }
    }
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) BrokerDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.BrokerDashboardViewPart) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

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