@Override public void stateChanged(final State newState) { if (!this.equals(fView.getCurrentPage()) || fTreeViewer == null || fTreeViewer.getTree().isDisposed()) // if this page is not active, then wait until we call refresh on next activation return; fTreeViewer.getTree().getDisplay().asyncExec(() -> fTreeViewer.setInput(newState)); }
@Override public ISelection getSelection() { // get the selection provider from the current page IPage currentPage = getCurrentPage(); // during workbench startup we may be in a state when // there is no current page if (currentPage == null) { return StructuredSelection.EMPTY; } IPageSite site = getPageSite(currentPage); if (site == null) { return StructuredSelection.EMPTY; } ISelectionProvider selProvider = site.getSelectionProvider(); if (selProvider != null) { return selProvider.getSelection(); } return StructuredSelection.EMPTY; }
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; }
@Override public void setSelection(ISelection selection) { // get the selection provider from the current page IPage currentPage = getCurrentPage(); // during workbench startup we may be in a state when // there is no current page if (currentPage == null) { return; } IPageSite site = getPageSite(currentPage); if (site == null) { return; } ISelectionProvider selProvider = site.getSelectionProvider(); // and set its selection if (selProvider != null) { selProvider.setSelection(selection); } }
@Override public void setWordWrap(boolean wordWrap) { fWordWrap = wordWrap; IWorkbenchPart part = getSite().getPart(); if (part instanceof PageBookView) { Control control = ((PageBookView) part).getCurrentPage().getControl(); if (control instanceof StyledText) { ((StyledText) control).setWordWrap(wordWrap); } } }
/** * The <code>PageBookView</code> implementation of this * <code>IAdaptable</code> method delegates to the current page, if it * implements <code>IAdaptable</code>. */ @Override public <T> T getAdapter(Class<T> key) { // delegate to the current page, if supported IPage page = getCurrentPage(); T adapter = Adapters.adapt(page, key); if (adapter != null) { return adapter; } // if the page did not find the adapter, look for one provided by // this view before delegating to super. adapter = getViewAdapter(key); if (adapter != null) { return adapter; } // delegate to super return super.getAdapter(key); }
if (part instanceof PageBookView) { PageBookView outline = (PageBookView) part; IPage currentPage = outline.getCurrentPage(); if (currentPage != null) { buffer.append(toolkit.createClassSection(text, PDERuntimeMessages.SpyDialog_activePageBook_title,
@Override public void stateResolved(final StateDelta delta) { if (!fView.getCurrentPage().equals(this) || fTreeViewer == null || fTreeViewer.getTree().isDisposed()) // if this page is not active, then wait until we call refresh on next activation return; fTreeViewer.getTree().getDisplay().asyncExec(() -> { if (delta == null) { fTreeViewer.refresh(); } else { BundleDelta[] deltas = delta.getChanges(); for (BundleDelta d : deltas) { int type = d.getType(); if (type == BundleDelta.REMOVED || type == BundleDelta.RESOLVED || type == BundleDelta.ADDED || type == BundleDelta.UNRESOLVED) { fTreeViewer.refresh(); break; } } } }); }
@Override public IStatus runInUIThread(IProgressMonitor monitor) { IConsoleView view = null; try { view = (IConsoleView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(IConsoleConstants.ID_CONSOLE_VIEW); } catch (PartInitException e) { e.printStackTrace(); } if (view != null) { // show it view.display(con); IViewPart vp =(IViewPart)view; if (vp instanceof PageBookView) { IPage page = ((PageBookView) vp).getCurrentPage(); viewer = ResourceUtils.getViewer(page); //if (viewer != null) // return viewer.getDocument(); } } return Status.OK_STATUS; } };
PageSite pageSite = getPageSite(getCurrentPage()); if (pageSite != null) { IEclipseContext pageContext = pageSite.getSiteContext();
IPage page = view.getCurrentPage(); if(page != null) { widget = page.getControl();