public static IConsole getConsole(IWorkbenchPart part) { if(!(part instanceof IViewPart)){ return null; } IViewPart vp =(IViewPart) part; if (vp instanceof PageBookView) { IPage page = ((PageBookView) vp).getCurrentPage(); ITextViewer viewer = getViewer(page); if (viewer == null || viewer.getDocument() == null) return null; } IConsole con = null; try { con = ((IConsoleView)part).getConsole(); } catch (Exception e) { } return con; }
private ISelection getSelection(IWorkbenchPart part, ISelection selection) { // for some reason, selection is empty when we select a revision from the P4 history view if (!(part instanceof PageBookView)) { return selection; } IPage page = ((PageBookView)part).getCurrentPage(); if (!(page instanceof P4HistoryPage)) { return selection; } return getSelection((P4HistoryPage)page); }
private void refreshPaletteView(final IWorkbenchPart part) { final PageBookView paletteView = findPaletteView(part); if (paletteView == null) { return; } part.getSite().getWorkbenchWindow().getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { paletteView.partClosed(part); paletteView.partActivated(part); } }); }
private PageBookView findPaletteView(final IWorkbenchPart part) { final IViewReference[] views = part.getSite().getPage().getViewReferences(); for (final IViewReference view : views) { if (PaletteView.ID.equals(view.getId())) { return (PageBookView) view.getPart(true); } } return null; }
public static void log(Class<? extends PageBookView> class1, String string, PartInitException e) { // TODO Auto-generated method stub }
/** * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ @SuppressWarnings("unchecked") public Object execute(ExecutionEvent event) throws ExecutionException { ITextEditor editor = getTextEditor(event); if (editor == null) { if (isWindowCommand()) { Object result = checkExecute(event); if (result == Check.Fail) { beep(); result = null; } return result; } else if (isConsoleCommand()) { // intercept and dispatch execution if console supported and used in a console view IWorkbenchPart activePart = HandlerUtil.getActivePart(event); if (activePart != null && (activePart instanceof IConsoleView) && (activePart instanceof PageBookView)) { IPage textPage = ((PageBookView)activePart).getCurrentPage(); if (textPage instanceof TextConsolePage) { return ((IConsoleDispatch)this).consoleDispatch(((TextConsolePage)textPage).getViewer(),(IConsoleView)activePart,event); } } } } try { setThisEditor(editor); isEditable = getEditable(); if (editor == null || isBlocked()) { beep(); asyncShowMessage(editor, INEDITABLE_BUFFER, true); return null; } // Retrieve the universal-argument parameter value if passed if (extractUniversalCount(event) != 1) { // check if we should dispatch a related command based on the universal argument String dispatchId = checkDispatchId(event.getCommand().getId()); if (dispatchId != null) { // recurse on new id (inverse or arg value driven) return dispatchId(editor, dispatchId, getParams(event.getCommand(), event.getParameters())); } } setThisDocument(editor.getDocumentProvider().getDocument(editor.getEditorInput())); // Get the current selection ISelectionProvider selectionProvider = editor.getSelectionProvider(); ITextSelection selection = (ITextSelection) selectionProvider.getSelection(); preTransform(editor, selection); return transformWithCount(editor, getThisDocument(), selection, event); } finally { // normal commands clean up here if (isTransform()) { postExecute(); } } }