Java 类org.eclipse.ui.part.IPage 实例源码

项目:LogViewer    文件:ResourceUtils.java   
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;
  }
项目:LogViewer    文件:ResourceUtils.java   
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;
}
项目:APICloud-Studio    文件:ExpandLevelHandler.java   
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;
}
项目:OpenSPIFe    文件:PlanAdvisorView.java   
@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);
}
项目:OpenSPIFe    文件:ConstraintsView.java   
@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("");
    }
   }
项目:OpenSPIFe    文件:MultiPagePlanEditor.java   
/**
 * {@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();
}
项目:mesfavoris    文件:P4RevisionBookmarkPropertiesProvider.java   
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);
}
项目:SPELL    文件:ProcedurePageView.java   
@Override
protected IPage createDefaultPage(PageBook book)
{
    MessagePage defaultPage = new MessagePage();
    initPage(defaultPage);
    defaultPage.setMessage(m_defaultMsg);
    defaultPage.createControl(book);
    setPartName(m_defaultTitle);
    return defaultPage;
}
项目:PDFReporter-Studio    文件:ReportStateView.java   
@Override
protected IPage createDefaultPage(PageBook book) {
    ReportStatePage page = new ReportStatePage(null);
    initPage(page);
    page.createControl(book);
    return page;
}
项目:APICloud-Studio    文件:InvasiveThemeHijacker.java   
protected void hijackConsole(IViewPart view)
{
    if (view instanceof ConsoleView)
    {
        IPage currentPage = ((ConsoleView) view).getCurrentPage();
        if (currentPage != null)
        {
            hookTheme(currentPage.getControl(), false);
        }
    }
}
项目:APICloud-Studio    文件:CollapseAllHandler.java   
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;
}
项目:APICloud-Studio    文件:ExpandAllHandler.java   
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;
}
项目:OpenSPIFe    文件:PlanAdvisorView.java   
@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);
    }
}
项目:OpenSPIFe    文件:DefaultPageBookView.java   
/**
 * {@inheritDoc}
 */
@Override
protected IPage createDefaultPage(PageBook book) {
    MessagePage page = new MessagePage();
    initPage(page);
    page.createControl(book);
    page.setMessage("default page");
    return page;
}
项目:OpenSPIFe    文件:DetailPage.java   
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;
}
项目:OpenSPIFe    文件:DetailView.java   
@Override
protected IPage createDefaultPage(PageBook book) {
       IPage page = super.createDefaultPage(book);
       if (page instanceof MessagePage) {
           ((MessagePage)page).setMessage("Nothing currently selected.");
       }
       return page;
   }
项目:OpenSPIFe    文件:SPIFeTemplatePlanViewAddNewItemAction.java   
private SPIFeTemplatePlanPage getCurrentPage() {
    IPage currentPage = templatePlanView.getCurrentPage();
    if (currentPage instanceof SPIFeTemplatePlanPage) {
        return (SPIFeTemplatePlanPage)currentPage;
    }
    return null;
}
项目:OpenSPIFe    文件:PlanPageBookView.java   
/**
 * 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;
}
项目:OpenSPIFe    文件:PlanPageBookView.java   
/**
 * 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);
}
项目:OpenSPIFe    文件:TemplatePlanView.java   
/**
 * 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;
}
项目:OpenSPIFe    文件:TemplatePlanView.java   
/**
 * 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();
    }
}
项目:OpenSPIFe    文件:TemplatePlanView.java   
/**
 * 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();
        }
    }
}
项目:OpenSPIFe    文件:PlanRulesView.java   
@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("");
}
  }
项目:tesb-studio-se    文件:SpringConfigurationView.java   
@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;
}
项目:gef-gwt    文件:PaletteView.java   
/**
 * 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;
}
项目:gef-gwt    文件:PaletteView.java   
/**
 * @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;
}
项目:gef-gwt    文件:CommandStackInspector.java   
/**
 * @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;
}
项目:birt    文件:LibraryExplorerView.java   
/**
 * 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;
}
项目:birt    文件:LibraryExplorerView.java   
/**
 * 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( );
}
项目:birt    文件:DataView.java   
/**
 * 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;
}
项目:birt    文件:AttributeView.java   
protected IPage createDefaultPage( PageBook book )
{
    MessagePage page = new MessagePage( );
    initPage( page );
    page.createControl( book );
    page.setMessage( defaultText );
    if ( defaultPartName == null )
    {
        defaultPartName = getPartName( );
    }
    return page;
}
项目:e4macs    文件:EmacsPlusCmdHandler.java   
/**
 * @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();
        }
    }
}
项目:emf.utils    文件:DummyActionBarContributor.java   
@Override
public void shareGlobalActions(IPage page, IActionBars actionBars) {
}
项目:birt    文件:DataView.java   
/**
 * 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( );
}
项目:birt    文件:AttributeView.java   
/**
 * 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( );
}
项目:SPELL    文件:WatchVariablesView.java   
/**************************************************************************
 * 
 *************************************************************************/
@Override
public void notifyActive(IPage page, boolean active) {}
项目:SPELL    文件:WatchVariablesPage.java   
/***********************************************************************
 * Notify that this page becomes active/inactive
 * 
 * @param active
 **********************************************************************/
public void notifyActive(IPage page, boolean active);
项目:OpenSPIFe    文件:PlanPageBookView.java   
/**
 * Override in your subclass to handle page activation, if necessary
 * @param page the page being activated
 */
protected void pageActivated(IPage page) {
    // no default behavior
}