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; }
public static ITextViewer getViewer(IPage page) { if(page == null){ return null; } if(page instanceof TextConsolePage) { return ((TextConsolePage)page).getViewer(); } if(page.getClass().equals(MessagePage.class)){ // empty page placeholder return null; } try { /* * org.eclipse.cdt.internal.ui.buildconsole.BuildConsolePage does not * extend TextConsolePage, so we get access to the viewer with dirty tricks */ Method method = page.getClass().getDeclaredMethod("getViewer", (Class<?>[])null); method.setAccessible(true); return (ITextViewer) method.invoke(page, (Object[])null); } catch (Exception e) { // AnyEditToolsPlugin.logError("Can't get page viewer from the console page", e); } return null; }
public Object execute(ExecutionEvent event) throws ExecutionException { // assumes to expand to level 1 if not specified int level = 1; String levelStr = event.getParameter(LEVEL); if (levelStr != null) { level = Integer.parseInt(levelStr); } IWorkbenchPart part = HandlerUtil.getActivePart(event); if (part instanceof ContentOutline) { IPage page = ((ContentOutline) part).getCurrentPage(); if (page instanceof CommonOutlinePage) { CommonOutlinePage outlinePage = (CommonOutlinePage) page; // we want to expand to the specified level and collapse everything below outlinePage.collapseAll(); outlinePage.expandToLevel(level); } } return null; }
@Override public Object getAdapter(Class key) { if (key.equals(IContextProvider.class)) { return new ContextProvider(ID); } if (key.equals(TreeViewer.class)) { IPage page = this.getCurrentPage(); if (page instanceof PlanAdvisorPage) { PlanAdvisorPage planAdvisorPage = (PlanAdvisorPage) page; return planAdvisorPage.getPlanAdvisorTreeViewer(); } else { return null; } } return super.getAdapter(key); }
@Override protected void pageActivated(IPage page) { if (page instanceof ConstraintsPage) { ConstraintsPage constraintsPage = (ConstraintsPage)page; final EPlan plan = constraintsPage.getPlan(); WidgetUtils.runInDisplayThread(page.getControl(), new Runnable() { @Override public void run() { String planName = plan.getName(); if(planName == null) { planName = ""; } setContentDescription(planName); } }); } else { setContentDescription(""); } }
/** * {@inheritDoc} */ @Override public boolean isSaveOnCloseNeeded() { // workaround for SPF-6678 "Dirty bit is only set when focus is removed from field in Template View, Details View " IWorkbenchPartSite site = getSite(); if (site != null) { IWorkbenchPage page = site.getPage(); IViewReference[] viewReferences = page.getViewReferences(); for (IViewReference iViewReference : viewReferences) { IViewPart viewPart = iViewReference.getView(false); if(viewPart != null) { Object adapter = viewPart.getAdapter(IPage.class); if(adapter instanceof DetailPage) { DetailPage detailPage = (DetailPage) adapter; if(detailPage.hasSheet()) { this.setFocus(); break; } } } } } // end workaround return super.isSaveOnCloseNeeded(); }
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); }
@Override protected IPage createDefaultPage(PageBook book) { MessagePage defaultPage = new MessagePage(); initPage(defaultPage); defaultPage.setMessage(m_defaultMsg); defaultPage.createControl(book); setPartName(m_defaultTitle); return defaultPage; }
@Override protected IPage createDefaultPage(PageBook book) { ReportStatePage page = new ReportStatePage(null); initPage(page); page.createControl(book); return page; }
protected void hijackConsole(IViewPart view) { if (view instanceof ConsoleView) { IPage currentPage = ((ConsoleView) view).getCurrentPage(); if (currentPage != null) { hookTheme(currentPage.getControl(), false); } } }
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchPart part = HandlerUtil.getActivePart(event); if (part instanceof ContentOutline) { IPage page = ((ContentOutline) part).getCurrentPage(); if (page instanceof CommonOutlinePage) { ((CommonOutlinePage) page).collapseAll(); } } return null; }
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchPart part = HandlerUtil.getActivePart(event); if (part instanceof ContentOutline) { IPage page = ((ContentOutline) part).getCurrentPage(); if (page instanceof CommonOutlinePage) { ((CommonOutlinePage) page).expandAll(); } } return null; }
@Override protected void pageActivated(IPage page) { if (page instanceof PlanAdvisorPage) { PlanAdvisorPage planAdvisorPage = (PlanAdvisorPage) page; EPlan plan = planAdvisorPage.getPlan(); PlanAdvisorMember planAdvisorMember = PlanAdvisorMember.get(plan); viewIconListener.setPlanAdvisorMember(planAdvisorMember); } else { viewIconListener.setPlanAdvisorMember(null); } }
/** * {@inheritDoc} */ @Override protected IPage createDefaultPage(PageBook book) { MessagePage page = new MessagePage(); initPage(page); page.createControl(book); page.setMessage("default page"); return page; }
private DetailPage getCurrentDetailPage(IWorkbenchPage page) { DetailView detailView = DetailView.getDetailView(page); if (detailView != null) { IPage currentPage = detailView.getCurrentPage(); if (currentPage instanceof DetailPage) return (DetailPage)currentPage; } return null; }
@Override protected IPage createDefaultPage(PageBook book) { IPage page = super.createDefaultPage(book); if (page instanceof MessagePage) { ((MessagePage)page).setMessage("Nothing currently selected."); } return page; }
private SPIFeTemplatePlanPage getCurrentPage() { IPage currentPage = templatePlanView.getCurrentPage(); if (currentPage instanceof SPIFeTemplatePlanPage) { return (SPIFeTemplatePlanPage)currentPage; } return null; }
/** * Creates, initializes and returns the default page for this view, giving it the default * message. Implements the abstract method from Eclipse class PageBookView. * @param book the PageBook control that will become the parent of the new page * @return the newly-created page */ @Override protected IPage createDefaultPage(PageBook book) { MessagePage page = new MessagePage(); initPage(page); page.createControl(book); page.setMessage(defaultMessage); return page; }
/** * If the argument is not null, prefix the call to the superclass by performing the * pre-open operation. This operation can be supplied by the concrete subclass. * @param pageRec the page being opened */ @Override protected void showPageRec(PageRec pageRec) { if (pageRec != null) { IPage page = pageRec.page; pageActivated(page); } super.showPageRec(pageRec); }
/** * Return the current page's plan. * @return the page's plan; may be null if the current page is not a TemplatePlanPage or * if the page has no plan */ public EPlan getCurrentTemplatePlan() { IPage currentPage = getCurrentPage(); EPlan plan = null; if(currentPage instanceof TemplatePlanPage) { TemplatePlanPage templatePlanPage = (TemplatePlanPage)currentPage; plan = templatePlanPage.getTemplatePlan(); } return plan; }
/** * Override the default pageActivated behavior to update the enablement of the addAction * * @param page an IPage that has been activated, becoming the current page of the view */ @Override protected void pageActivated(IPage page) { super.pageActivated(page); if(addAction != null) { addAction.updateEnablement(); } }
/** * Auxiliary factoring out a repeated operation in method partVisible(IWorkbenchPart). * If the current page is a TemplatePlanPage and it has no template plan, load it into the * TreeViewer. */ private void loadTemplatePlans() { IPage currentPage = getCurrentPage(); if (currentPage instanceof TemplatePlanPage) { TemplatePlanPage templatePlanPage = (TemplatePlanPage) currentPage; if (templatePlanPage.getTemplatePlans().isEmpty()) { templatePlanPage.loadTemplatePlans(); } } }
@Override protected void pageActivated(IPage page) { if (page instanceof PlanRulesPage) { PlanRulesPage planRulesPage = (PlanRulesPage)page; final EPlan plan = planRulesPage.getPlan(); WidgetUtils.runInDisplayThread(page.getControl(), new Runnable() { @Override public void run() { setContentDescription(plan.getName()); } }); } else { setContentDescription(""); } }
@Override protected IPage createDefaultPage(PageBook book) { MessagePage page = new MessagePage(); initPage(page); page.createControl(book); page.setMessage(CamelDesignerMessages.getString("SpringConfigurationView_defaultMessage")); //$NON-NLS-1$ return page; }
/** * Creates a default page saying that a palette is not available. * * @see org.eclipse.ui.part.PageBookView#createDefaultPage(org.eclipse.ui.part.PageBook) */ protected IPage createDefaultPage(PageBook book) { MessagePage page = new MessagePage(); initPage(page); page.createControl(book); page.setMessage(GEFMessages.Palette_Not_Available); return page; }
/** * @see org.eclipse.ui.part.PageBookView#doCreatePage(org.eclipse.ui.IWorkbenchPart) */ protected PageRec doCreatePage(IWorkbenchPart part) { // Try to get a custom palette page Object obj = part.getAdapter(PalettePage.class); if (obj != null && obj instanceof IPage) { IPage page = (IPage) obj; page.createControl(getPageBook()); initPage((IPageBookViewPage) page); return new PageRec(part, page); } // Use the default page by returning null return null; }
/** * @see PageBookView#doCreatePage(org.eclipse.ui.IWorkbenchPart) */ protected PageRec doCreatePage(IWorkbenchPart part) { // Try to get a custom command stack page. Object obj = part.getAdapter(CommandStackInspectorPage.class); if (obj instanceof IPage) { IPage page = (IPage) obj; page.createControl(getPageBook()); return new PageRec(part, page); } // Use the default page return null; }
/** * Creates and returns the default page for this view. * * @param book * the pagebook control * @return the default page */ protected IPage createDefaultPage( PageBook book ) { MessagePage page = new MessagePage( ); initPage( page ); page.createControl( book ); page.setMessage( defaultText ); return page; }
/** * Destroys a page in the pagebook for a particular part. This page was * returned as a result from <code>doCreatePage</code>. * * @param part * the input part * @param pageRecord * a page record for the part * @see #doCreatePage */ protected void doDestroyPage( IWorkbenchPart part, PageRec pageRecord ) { if ( treeViewPage != null && prefs != null ) { prefs.removePreferenceChangeListener( treeViewPage ); } this.resourceFolder = null; IPage page = pageRecord.page; page.dispose( ); pageRecord.dispose( ); }
protected IPage createDefaultPage( PageBook book ) { MessagePage page = new MessagePage( ); initPage( page ); page.createControl( book ); page.setMessage( defaultText ); if ( defaultPartName == null ) { defaultPartName = getPartName( ); } return page; }
/** * @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(); } } }
@Override public void shareGlobalActions(IPage page, IActionBars actionBars) { }
/** * Destroys a page in the pagebook for a particular part. This page was * returned as a result from <code>doCreatePage</code>. * * @param part * the input part * @param pageRecord * a page record for the part * @see #doCreatePage */ protected void doDestroyPage( IWorkbenchPart part, PageRec pageRecord ) { IPage page = pageRecord.page; page.dispose( ); pageRecord.dispose( ); }
/************************************************************************** * *************************************************************************/ @Override public void notifyActive(IPage page, boolean active) {}
/*********************************************************************** * Notify that this page becomes active/inactive * * @param active **********************************************************************/ public void notifyActive(IPage page, boolean active);
/** * Override in your subclass to handle page activation, if necessary * @param page the page being activated */ protected void pageActivated(IPage page) { // no default behavior }