Search in sources :

Example 71 with IViewPart

use of org.eclipse.ui.IViewPart in project translationstudio8 by heartsome.

the class ExecuteGoogleTransHandler method execute.

/**
	 * (non-Javadoc)
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
	 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (!(editor instanceof IXliffEditor)) {
        return null;
    }
    PrefrenceParameters ps = PrefrenceParameters.getInstance();
    if (!ps.isGoogleState()) {
        MessageDialog.openError(window.getShell(), Messages.getString("handler.ExecuteGoogleTransHandler.msgTitle"), Messages.getString("handler.ExecuteGoogleTransHandler.msg"));
        return null;
    }
    final IXliffEditor xliffEditor = (IXliffEditor) editor;
    final int[] selectedRowIndexs = xliffEditor.getSelectedRows();
    if (selectedRowIndexs.length == 0) {
        return null;
    }
    ISimpleMatcher matcher = new SimpleMatcherGoogleImpl();
    IViewPart viewPart = window.getActivePage().findView(MatchViewPart.ID);
    if (viewPart != null && viewPart instanceof MatchViewPart) {
        MatchViewPart matchView = (MatchViewPart) viewPart;
        matchView.manualExecSimpleTranslation(selectedRowIndexs[0], xliffEditor, matcher);
    }
    return null;
}
Also used : MatchViewPart(net.heartsome.cat.ts.ui.translation.view.MatchViewPart) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) ISimpleMatcher(net.heartsome.cat.ts.tm.simpleMatch.ISimpleMatcher) PrefrenceParameters(net.heartsome.cat.ts.machinetranslation.bean.PrefrenceParameters) SimpleMatcherGoogleImpl(net.heartsome.cat.ts.machinetranslation.SimpleMatcherGoogleImpl) IEditorPart(org.eclipse.ui.IEditorPart) IXliffEditor(net.heartsome.cat.ts.ui.editors.IXliffEditor)

Example 72 with IViewPart

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

the class StatusLineContrItem method changeStuatusLineForViewOrEditPart.

/**
	 *
	 * When selection changed,change status line message for view part or editor
	 * part
	 *
	 * @param node the ICubridNode object
	 * @param workbenchPart the IWorkbenchPart object
	 */
public void changeStuatusLineForViewOrEditPart(ICubridNode node, IWorkbenchPart workbenchPart) {
    WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    String nodePath = "";
    if (workbenchPart == null) {
        if (null != node.getViewId()) {
            IViewPart viewPart = LayoutUtil.getViewPart(node, node.getViewId());
            if (viewPart != null) {
                nodePath = viewPart.getTitle();
            }
        }
        if (null != node.getEditorId()) {
            IEditorPart editorPart = LayoutUtil.getEditorPart(node, node.getEditorId());
            if (editorPart != null) {
                nodePath = editorPart.getTitle();
            }
        }
    } else {
        nodePath = workbenchPart.getTitle();
    }
//window.setStatus(nodePath == null ? "" : nodePath);
}
Also used : WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) IEditorPart(org.eclipse.ui.IEditorPart)

Example 73 with IViewPart

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

the class WorkbenchContrItem method processNodeRemoveWhenRefreshContainer.

/**
	 * When refresh the container node and if this child node is deleted, then
	 * close it's editor or view part
	 *
	 * @param eventNode ICubridNode
	 * @param page IWorkbenchPage
	 */
protected void processNodeRemoveWhenRefreshContainer(ICubridNode eventNode, IWorkbenchPage page) {
    synchronized (this) {
        IEditorReference[] editorRefArr = page.getEditorReferences();
        if (editorRefArr != null && editorRefArr.length > 0) {
            for (IEditorReference editorRef : editorRefArr) {
                try {
                    IEditorInput editorInput = editorRef.getEditorInput();
                    if (editorInput instanceof ICubridNode) {
                        ICubridNode editorNode = (ICubridNode) editorInput;
                        ICubridNode parentNode = editorNode.getParent();
                        if (editorNode != null && parentNode != null && parentNode.getId().equals(eventNode.getId()) && eventNode.getChild(editorNode.getId()) == null) {
                            processNodeRemove(editorNode, page);
                        }
                    }
                } catch (PartInitException e1) {
                    LOGGER.error(e1.getMessage());
                }
            }
        }
        IViewReference[] viewRefArr = page.getViewReferences();
        if (viewRefArr != null && viewRefArr.length > 0) {
            for (IViewReference viewRef : viewRefArr) {
                IViewPart viewPart = viewRef.getView(false);
                if (viewPart instanceof CubridViewPart) {
                    ICubridNode viewPartNode = ((CubridViewPart) viewPart).getCubridNode();
                    if (viewPartNode == null) {
                        continue;
                    }
                    ICubridNode parentNode = viewPartNode.getParent();
                    if (viewPartNode != null && parentNode != null && parentNode.getId().equals(eventNode.getId()) && eventNode.getChild(viewPartNode.getId()) == null) {
                        processNodeRemove(viewPartNode, page);
                    }
                }
            }
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IEditorReference(org.eclipse.ui.IEditorReference) CubridViewPart(com.cubrid.common.ui.spi.part.CubridViewPart) IViewReference(org.eclipse.ui.IViewReference) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 74 with IViewPart

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

the class WorkbenchContrItem 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 75 with IViewPart

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

the class CubridIndexNavigatorView method getInstance.

public static CubridIndexNavigatorView 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 CubridIndexNavigatorView ? (CubridIndexNavigatorView) 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

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