Java 类org.eclipse.ui.IViewPart 实例源码

项目:OpenSPIFe    文件:EnsembleCommonNavigator.java   
/**
 * Utility method to get all open views that are instances of CommonNavigator
 * @param clazz the class type which extends EnsembleCommonNavigator
 * @return the list of viewers that are of type EnsembleCommonNavigator
 */
public static List<EnsembleCommonNavigator> getExistingInstances(Class<? extends EnsembleCommonNavigator> clazz) {
    List<EnsembleCommonNavigator> commonNavigators = new ArrayList<EnsembleCommonNavigator>();

    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow[] workbenchWindows = workbench.getWorkbenchWindows();
    for(IWorkbenchWindow workbenchWindow : workbenchWindows) {
        IWorkbenchPage[] pages = workbenchWindow.getPages();
        for(IWorkbenchPage page : pages) {
            IViewReference[] viewReferences = page.getViewReferences();                         
            for(IViewReference viewReference : viewReferences) {
                IViewPart view = viewReference.getView(false);
                    if(view != null) {
                        boolean assignableFrom = clazz.isAssignableFrom(view.getClass());
                        if(assignableFrom) {
                            commonNavigators.add((EnsembleCommonNavigator)view);
                        }
                }
            }
        }
    }

    return commonNavigators;
}
项目:OpenSPIFe    文件:NewResourceAction.java   
protected static IStructuredSelection getCurrentSelection() {
    IStructuredSelection structuredSeleciton = StructuredSelection.EMPTY;
    IWorkbench workbench = PlatformUI.getWorkbench();
    IViewReference[] viewReferences = workbench.getActiveWorkbenchWindow().getActivePage().getViewReferences();
    IViewPart viewPart = null;
    for(IViewReference viewReference : viewReferences) {
        IViewPart view = viewReference.getView(false);
        if(view instanceof CommonViewer) {
            viewPart = view;
        }
    }

    if(viewPart != null) {
        ISelectionProvider selectionProvider = viewPart.getSite().getSelectionProvider();
        ISelection selection = selectionProvider.getSelection();
        if(selection instanceof IStructuredSelection) {
            structuredSeleciton = (IStructuredSelection)selection;
        }
    }

    return structuredSeleciton;
}
项目:OpenSPIFe    文件:TestConstraintsView.java   
public void testCreateConstraintsView() throws Exception {
    if (PlatformUI.isWorkbenchRunning() == false) {
        return; // TODO: obtain a workbench
    }
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
    IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();

    IViewPart view = null;
    // Make the view
    view = workbenchPage.showView(
            "gov.nasa.arc.spife.core.constraints.view.ConstraintsView",
            null,
            IWorkbenchPage.VIEW_CREATE);
    assertNotNull(view);
}
项目:neoscada    文件:AbstractChartView.java   
@Override
public void run ()
{
    try
    {
        final IViewPart viewPart = getViewSite ().getWorkbenchWindow ().getActivePage ().showView ( ChartConfiguratorView.VIEW_ID );
        if ( viewPart instanceof ChartConfiguratorView )
        {
            ( (ChartConfiguratorView)viewPart ).setChartConfiguration ( getConfiguration () );
        }
    }
    catch ( final PartInitException e )
    {
        StatusManager.getManager ().handle ( e.getStatus (), StatusManager.BLOCK );
    }
}
项目:neoscada    文件:OpenExplorerHandler.java   
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    try
    {
        // the following cast might look a bit weird. But first an adapter is requested and it only adapts to "core" connection services.
        final ConnectionService connectionService = (ConnectionService)SelectionHelper.first ( getSelection (), org.eclipse.scada.core.connection.provider.ConnectionService.class );
        final IViewPart view = getActivePage ().showView ( SummaryExplorerViewPart.VIEW_ID, "" + this.counter++, IWorkbenchPage.VIEW_ACTIVATE );

        ( (SummaryExplorerViewPart)view ).setConnectionService ( connectionService );
    }
    catch ( final PartInitException e )
    {
        throw new ExecutionException ( "Failed to open view", e );
    }
    return null;
}
项目:convertigo-eclipse    文件:ProjectManager.java   
public ProjectExplorerView getProjectExplorerView() {
    if (projectExplorerView == null) {
        try {
            IViewPart viewPart =  PlatformUI
                                        .getWorkbench()
                                        .getActiveWorkbenchWindow()
                                        .getActivePage()
                                        .findView("com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView");
            if (viewPart != null)
                projectExplorerView = (ProjectExplorerView)viewPart;
        }
        catch (Exception e) {;}
    }

    return projectExplorerView;
}
项目:convertigo-eclipse    文件:ConvertigoPlugin.java   
/**
 * Gets the projects explorer view.
 * !!MUST BE CALLED IN A UI-THREAD!!
 * @return ProjectExplorerView : the explorer view of Convertigo Plugin
 */
public ProjectExplorerView getProjectExplorerView() {
    ProjectExplorerView projectExplorerView = null;
    IWorkbenchPage activePage = getActivePage();
    if (activePage != null) {
        IViewPart viewPart =  activePage.findView("com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView");
        if (viewPart != null)
            projectExplorerView = (ProjectExplorerView)viewPart;
        else {
            IWorkbench workbench = PlatformUI.getWorkbench();
            try {
                IWorkbenchPage page = workbench.showPerspective(ConvertigoPlugin.PLUGIN_PERSPECTIVE_ID, workbench.getActiveWorkbenchWindow());
                viewPart =  page.findView("com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView");
                if (viewPart != null) {
                    projectExplorerView = (ProjectExplorerView)viewPart;
                }
            } catch (WorkbenchException e) {}
        }
    }
    return projectExplorerView;
}
项目:convertigo-eclipse    文件:ConvertigoPlugin.java   
/**
 * Gets the source picker view.
 * !!MUST BE CALLED IN A UI-THREAD!!
 * @return SourcePickerView : the source picker view of Convertigo Plugin
 * @throws  
 */
public MobileDebugView getMobileDebugView() {
    MobileDebugView mobileDebugView = null;
    try {
        IWorkbenchPage activePage = getActivePage();
        if (activePage != null) {
            IViewPart viewPart =  activePage.findView("com.twinsoft.convertigo.eclipse.views.mobile.MobileDebugView");
            if (viewPart != null)
                mobileDebugView = (MobileDebugView) viewPart;
        }
        if (mobileDebugView == null) {
            mobileDebugView = (MobileDebugView) getActivePage().showView("com.twinsoft.convertigo.eclipse.views.mobile.MobileDebugView");
        }
    } catch (PartInitException e) {
        logException(e, "Failed to get the MobileDebugView");
    }
    return mobileDebugView;
}
项目:scanning    文件:XcenView.java   
private void showQueue() throws Exception {

        IViewReference[] refs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();

        boolean foundStatus = false;
        for (IViewReference vr : refs) {
            if (StatusQueueView.ID.equals(vr.getId())) foundStatus = true;
        }
        if (!foundStatus) {
            String secondId = XcenServices.getQueueViewSecondaryId();
            IViewPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(StatusQueueView.ID+":"+secondId, null, IWorkbenchPage.VIEW_VISIBLE);
            if (part !=null && part instanceof StatusQueueView) {
                StatusQueueView view = (StatusQueueView)part;
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(view);
                view.refresh();
            }
        }
    }
项目:scanning    文件:DetectorView.java   
private void showValidationResultsView(ValidateResults validateResults) {
    PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
        try {
            if (PageUtil.getPage().findView(ValidateResultsView.ID) == null) {
                IViewPart viewPart = PageUtil.getPage().showView(ValidateResultsView.ID);
                if (viewPart instanceof ValidateResultsView) {
                    ValidateResultsView validateResultsView = (ValidateResultsView)viewPart;
                    validateResultsView.update(validateResults);
                }
            } else {
                PageUtil.getPage().showView(ValidateResultsView.ID);
            }
        } catch (PartInitException e) {
            logger.warn("Unable to show validate results view " + e);
        }
    });
}
项目:scanning    文件:ExecuteView.java   
private Collection<DeviceInformation<?>> getDeviceInformation() throws ScanningException {

        IViewReference[] refs = PageUtil.getPage().getViewReferences();
        for (IViewReference iViewReference : refs) {
            IViewPart part = iViewReference.getView(false);
            if (part==null) continue;
            Object info = part.getAdapter(DeviceInformation.class);
            if (info!=null && info instanceof Collection) { // A collection of device information
                return (Collection<DeviceInformation<?>>)info;
            }
        }

        // We cannot find a part which has the temp information so
        // we use the server information.
        return dservice.getDeviceInformation();
    }
项目:xstreamer    文件:SquadSelectionChangeListener.java   
@Override
public void selectionChanged(SelectionChangedEvent event) {
    ISelection selection = event.getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structureSelection = (IStructuredSelection) selection;
        IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IViewPart view = activePage.findView(IMAGEVIEW_BUNDLE_ID);
        Bundle dataBundle = Platform.getBundle(XWING_DATA_BUNDLE_ID);

        if (structureSelection.getFirstElement() instanceof PilotTreeNode) {
            PilotTreeNode pilot = (PilotTreeNode) structureSelection.getFirstElement();
            Pilot p = (Pilot) pilot.getValue();

            if (view != null) {
                loadPilotImage(view, dataBundle, p);
            }               
        } else if (structureSelection instanceof TreeSelection) {
            try {
                UpgradeTypeTreeNode upgradeNode = (UpgradeTypeTreeNode) structureSelection.getFirstElement();
                loadUpgradeImage(view, dataBundle, (Upgrade)upgradeNode.getValue());
            } catch (ClassCastException ex) {
            }
        }
    }
}
项目:xstreamer    文件:LoadMapImageSelectionListener.java   
@Override
public void selectionChanged(SelectionChangedEvent event) {
    ISelection selection = event.getSelection();
    if (!(selection instanceof IStructuredSelection)) {
        return;
    }

    IStructuredSelection structuredSeleciton = (IStructuredSelection) selection;
    MapMetaData map = (MapMetaData) structuredSeleciton.getFirstElement();
    IViewPart view = findImageViewer();
    if (view == null) {
        return;
    }

    loadAndSaveImage(map, view);
}
项目:tlaplus    文件:UIHelper.java   
public static void showDynamicHelp() {
    // This may take a while, so use the busy indicator
    BusyIndicator.showWhile(null, new Runnable() {
        public void run() {
            getActiveWindow().getWorkbench().getHelpSystem().displayDynamicHelp();
            // the following ensure that the help view receives focus
            // prior to adding this, it would not receive focus if
            // it was opened into a folder or was already
            // open in a folder in which another part had focus
            IViewPart helpView = findView("org.eclipse.help.ui.HelpView");
            if (helpView != null && getActiveWindow() != null && getActiveWindow().getActivePage() != null) {
                getActiveWindow().getActivePage().activate(helpView);
            }
        }
    });
}
项目:tlaplus    文件:UIHelper.java   
/**
 * Tries to set the given message on the workbench's status line. This is a
 * best effort method which fails to set the status line if there is no
 * active editor present from where the statuslinemanager can be looked up.
 * 
 * @param msg
 *            The message to be shown on the status line
 */
public static void setStatusLineMessage(final String msg) {
    IStatusLineManager statusLineManager = null;
    ISelectionProvider selectionService = null;

    // First try to get the StatusLineManager from the IViewPart and only
    // resort back to the editor if a view isn't active right now.
    final IWorkbenchPart workbenchPart = getActiveWindow().getActivePage().getActivePart();
    if (workbenchPart instanceof IViewPart) {
        final IViewPart viewPart = (IViewPart) workbenchPart;
        statusLineManager = viewPart.getViewSite().getActionBars().getStatusLineManager();
        selectionService = viewPart.getViewSite().getSelectionProvider();
    } else if (getActiveEditor() != null) {
        final IEditorSite editorSite = getActiveEditor().getEditorSite();
        statusLineManager = editorSite.getActionBars().getStatusLineManager();
        selectionService = editorSite.getSelectionProvider();
    }

    if (statusLineManager != null && selectionService != null) {
        statusLineManager.setMessage(msg);
        selectionService.addSelectionChangedListener(new StatusLineMessageEraser(statusLineManager,
                selectionService));
    }
}
项目: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    文件:AbstractWorkbenchAction.java   
public void run(IAction action) {
    if(window == null) {
           logger.logError("the current window is null, we therefore don't apply any action"); //$NON-NLS-1$
        return;
    }
    Shell shell = window.getShell();
    String viewId = "de.anbos.eclipse.logviewer.plugin.LogViewer";
    IViewPart view = null;
    try {
        view = window.getActivePage().showView(viewId);
    } catch(PartInitException pie) {
           logger.logError(pie);
        return;
    }

    if(!(view instanceof LogViewer) | shell == null) {
        logger.logError("unable to get current shell or log file view for that matter"); //$NON-NLS-1$
        return;
    }
    // call abstract run
    actionDelegate.run((LogViewer)view,shell);
}
项目:testability-explorer    文件:TestabilityReportLaunchListener.java   
private void showHtmlReportView(final File reportDirectory) {
  Display.getDefault().asyncExec(new Runnable() {
    public void run() {
      IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      try {
        IViewPart viewPart = page.showView("com.google.test.metric.eclipse.ui.browserview");
        if (viewPart instanceof TestabilityReportView) {
          ((TestabilityReportView) viewPart).setUrl(reportDirectory.getAbsolutePath() 
              + "/" + TestabilityConstants.HTML_REPORT_FILENAME);
        }
      } catch (PartInitException e) {
        logger.logException("Error initializing Testability Report View", e);
      } 
    }
  });
}
项目:org.csstudio.display.builder    文件:RuntimeViewPart.java   
/** Open a runtime display
 *
 *  <p>Either opens a new display, or if there is already an existing view
 *  for that input, "activate" it, which pops a potentially hidden view to the top.
 *
 *  @param page Page to use. <code>null</code> for 'active' page
 *  @param close_handler Code to call when part is closed
 *  @param info DisplayInfo (to compare with currently open displays)
 *  @return {@link RuntimeViewPart}
 *  @throws Exception on error
 */
public static RuntimeViewPart open(IWorkbenchPage page, final Consumer<DisplayModel> close_handler, final DisplayInfo info)
        throws Exception
{
    if (page == null)
        page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (info != null)
        for (IViewReference view_ref : page.getViewReferences())
            if (view_ref.getId().startsWith(ID))
            {
                final IViewPart view = view_ref.getView(true);
                if (view instanceof RuntimeViewPart)
                {
                    final RuntimeViewPart runtime_view = (RuntimeViewPart) view;
                    if (info.equals(runtime_view.getDisplayInfo())) // Allow for runtime_view.getDisplayInfo() == null
                    {
                        page.showView(view_ref.getId(), view_ref.getSecondaryId(), IWorkbenchPage.VIEW_ACTIVATE);
                        return runtime_view;
                    }
                }
            }
    final RuntimeViewPart part = (RuntimeViewPart) page.showView(ID, UUID.randomUUID().toString(), IWorkbenchPage.VIEW_ACTIVATE);
    part.close_handler = close_handler;
    return part;
}
项目:PDFReporter-Studio    文件:TabbedPropertySheetPage.java   
/**
 * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars)
 */
public void setActionBars(IActionBars actionBars) {
    // Override the undo and redo global action handlers
    // to use the contributor action handlers
    IActionBars partActionBars = null;
    if (contributor instanceof IEditorPart) {
        IEditorPart editorPart = (IEditorPart) contributor;
        partActionBars = editorPart.getEditorSite().getActionBars();
    } else if (contributor instanceof IViewPart) {
        IViewPart viewPart = (IViewPart) contributor;
        partActionBars = viewPart.getViewSite().getActionBars();
    }

    if (partActionBars != null) {
        IAction action = partActionBars.getGlobalActionHandler(ActionFactory.UNDO.getId());
        if (action != null) {
            actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), action);
        }
        action = partActionBars.getGlobalActionHandler(ActionFactory.REDO.getId());
        if (action != null) {
            actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), action);
        }
    }
}
项目:gama    文件:WorkbenchHelper.java   
/**
 * @todo find a more robust way to find the view (maybe with the control ?)
 * @return
 */
public static IViewPart findFrontmostGamaViewUnderMouse() {
    final IWorkbenchPage page = getPage();
    if (page == null) { return null; }
    final Point p = getDisplay().getCursorLocation();
    for (final IViewPart part : page.getViews()) {
        if (part instanceof IGamaView.Display) {
            final IGamaView.Display display = (IGamaView.Display) part;
            if (display.isFullScreen())
                return part;
            if (page.isPartVisible(part) && display.containsPoint(p.x, p.y))
                return part;

        }
    }
    return null;
}
项目:gama    文件:SwtGui.java   
@Override
public void closeSimulationViews(final IScope scope, final boolean openModelingPerspective,
        final boolean immediately) {
    WorkbenchHelper.run(() -> {
        final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        final IViewReference[] views = page.getViewReferences();

        for (final IViewReference view : views) {
            final IViewPart part = view.getView(false);
            if (part instanceof IGamaView) {
                ((IGamaView) part).close(scope);

            }
        }
        if (openModelingPerspective) {
            PerspectiveHelper.openModelingPerspective(immediately);
        }
        getStatus(scope).neutralStatus("No simulation running");
    });

}
项目:HMM    文件:ConsolePageParticipant.java   
@Override
public void init(IPageBookViewPage page, IConsole console) {
    IPageSite pageSite = page.getSite();
    IWorkbenchPage workbenchPage = pageSite.getPage();
    IViewPart viewPart = workbenchPage.findView(IConsoleConstants.ID_CONSOLE_VIEW);
    IViewSite viewSite = viewPart.getViewSite();
    IActionBars actionBars = viewSite.getActionBars();
    IToolBarManager toolBarManager = actionBars.getToolBarManager();
    IContributionItem[] items = toolBarManager.getItems();
    for(int i = 0; i < items.length; ++i) {
        IContributionItem item = items[i];
        if(item instanceof ActionContributionItem) {
            IAction action = ((ActionContributionItem) item).getAction();
            String text = action.getText();
            if(text.equals("Pi&n Console") || text.equals("Open Console"))
                toolBarManager.remove(item);
        }
    }
}
项目:limpet    文件:StackedchartsEditControl.java   
public void init(IViewPart view)
{
  IActionBars actionBars = view.getViewSite().getActionBars();
  IToolBarManager toolBarManager = actionBars.getToolBarManager();

  final UndoAction undoAction = new UndoAction(view);
  toolBarManager.add(undoAction);
  undoAction.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/undo.png"));
  final RedoAction redoAction = new RedoAction(view);
  redoAction.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/redo.png"));
  toolBarManager.add(redoAction);

  viewer.getEditDomain().getCommandStack().addCommandStackListener(
      new CommandStackListener()
      {

        @Override
        public void commandStackChanged(EventObject event)
        {
          undoAction.setEnabled(undoAction.isEnabled());
          redoAction.setEnabled(redoAction.isEnabled());
        }
      });

}
项目:APICloud-Studio    文件:InvasiveThemeHijacker.java   
public void partActivated(IWorkbenchPartReference partRef)
{
    if (partRef instanceof IViewReference)
    {
        IViewReference viewRef = (IViewReference) partRef;
        String id = viewRef.getId();
        if ("org.eclipse.ui.console.ConsoleView".equals(id) || "org.eclipse.jdt.ui.TypeHierarchy".equals(id) //$NON-NLS-1$ //$NON-NLS-2$
                || "org.eclipse.jdt.callhierarchy.view".equals(id)) //$NON-NLS-1$
        {
            final IViewPart part = viewRef.getView(false);
            Display.getCurrent().asyncExec(new Runnable()
            {
                public void run()
                {
                    hijackView(part, false);
                }
            });
            return;
        }
    }
    if (partRef instanceof IEditorReference)
    {
        hijackOutline();
    }
}
项目:APICloud-Studio    文件:InvasiveThemeHijacker.java   
public void partClosed(IWorkbenchPartReference partRef)
{
    if (partRef instanceof IEditorReference)
    {
        IEditorPart part = (IEditorPart) partRef.getPart(false);
        if (part instanceof MultiPageEditorPart)
        {
            MultiPageEditorPart multi = (MultiPageEditorPart) part;
            if (pageListener != null)
            {
                multi.getSite().getSelectionProvider().removeSelectionChangedListener(pageListener);
            }
        }
    }
    // If it's a search view, remove any query listeners for it!
    else if (partRef instanceof IViewReference)
    {
        IViewPart view = (IViewPart) partRef.getPart(false);
        if (queryListeners.containsKey(view))
        {
            NewSearchUI.removeQueryListener(queryListeners.remove(view));
        }
    }
}
项目:APICloud-Studio    文件:UIUtils.java   
/**
 * Opens the internal HelpView and address it to the given doc url.
 * 
 * @param url
 */
public static void openHelp(String url)
{
    IWorkbenchPage page = getActivePage();
    if (page != null)
    {
        try
        {
            IViewPart part = page.showView(HELP_VIEW_ID);
            if (part != null)
            {
                HelpView view = (HelpView) part;
                view.showHelp(url);
            }
        }
        catch (PartInitException e)
        {
            IdeLog.logError(UIPlugin.getDefault(), e);
        }
    }
    else
    {
        IdeLog.logWarning(UIPlugin.getDefault(), "Could not open the help view. Active page was null."); //$NON-NLS-1$
    }
}
项目:slr-toolkit    文件:SaveAsPDFHandler.java   
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IViewPart part = null;
    part = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().findView(chartViewId);
    FileDialog dialog = new FileDialog(HandlerUtil.getActiveShell(event), SWT.SAVE);
    dialog.setFilterExtensions(new String[] { "*.pdf" });
    try {
        String result = dialog.open();
        if (result != null) {
            ICommunicationView view = (ICommunicationView) part;
            view.generatePDFForCurrentChart(result);
            view.redraw();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
项目:mytourbook    文件:TourPhotoLinkView.java   
private PicDirView getPicDirView(final IWorkbenchWindow wbWindow) {

        final IWorkbenchPage wbPage = wbWindow.getActivePage();
        if (wbPage != null) {

            for (final IViewReference viewRef : wbPage.getViewReferences()) {

                if (viewRef.getId().equals(PicDirView.ID)) {

                    final IViewPart viewPart = viewRef.getView(false);
                    if (viewPart instanceof PicDirView) {
                        return (PicDirView) viewPart;
                    }
                }
            }
        }

        return null;
    }
项目:mytourbook    文件:RawDataManager.java   
private RawDataView showRawDataView() {

        final IWorkbench workbench = PlatformUI.getWorkbench();
        final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();

        try {

            final IViewPart rawDataView = window.getActivePage().findView(RawDataView.ID);

            if (rawDataView == null) {

                // show raw data perspective when raw data view is not visible
                workbench.showPerspective(PerspectiveFactoryRawData.PERSPECTIVE_ID, window);
            }

            // show raw data view
            return (RawDataView) Util.showView(RawDataView.ID, true);

        } catch (final WorkbenchException e) {
            TourLogManager.logEx(e);
        }
        return null;
    }
项目:mytourbook    文件:TourCompareManager.java   
/**
 * @param isNextTour
 *            When <code>true</code> then navigate to the next tour, when <code>false</code>
 *            then navigate to the previous tour.
 * @return Returns the navigated tour or <code>null</code> when there is no next/previous tour.
 */
Object navigateTour(final boolean isNextTour) {

    Object navigatedTour = null;

    final IWorkbench workbench = PlatformUI.getWorkbench();
    final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    final IWorkbenchPage activePage = window.getActivePage();

    final IViewPart yearStatView = activePage.findView(YearStatisticView.ID);
    if (yearStatView instanceof YearStatisticView) {
        navigatedTour = ((YearStatisticView) yearStatView).navigateTour(isNextTour);
    }

    final IViewPart comparedTours = activePage.findView(TourCompareResultView.ID);
    if (comparedTours instanceof TourCompareResultView) {
        navigatedTour = ((TourCompareResultView) comparedTours).navigateTour(isNextTour);
    }

    return navigatedTour;
}
项目:mytourbook    文件:LocalizeAction.java   
/**
 * The action has been activated. The argument of the
 * method represents the 'real' action sitting
 * in the workbench UI.
 * @see IWorkbenchWindowActionDelegate#run
 */
public void run(IAction action) {
    IWorkbenchPart activePart = window.getActivePage().getActivePart();

    ITranslatableText tabTitle;
    if (activePart instanceof IEditorPart) {
        tabTitle = TranslatableNLS.bind(Messages.LocalizeDialog_TabTitle_EditorPart, activePart.getTitle()); //$NON-NLS-1$
    } else if (activePart instanceof IViewPart) {
        tabTitle = TranslatableNLS.bind(Messages.LocalizeDialog_TabTitle_ViewPart, activePart.getTitle()); //$NON-NLS-1$
    } else {
        tabTitle = TranslatableNLS.bind(Messages.LocalizeDialog_TabTitle_OtherPart, activePart.getTitle()); //$NON-NLS-1$
    }

    ITranslatableSet languageSet = (ITranslatableSet)activePart.getAdapter(ITranslatableSet.class);

    Dialog dialog = new LocalizeDialog(window.getShell(), tabTitle, languageSet, Activator.getDefault().getMenuTextSet()); 
    dialog.open();
}
项目:OpenSPIFe    文件:EditorPartUtils.java   
public static IStructuredSelection getCurrentSelection() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    if (workbench==null || workbench.getActiveWorkbenchWindow()==null) {
        return StructuredSelection.EMPTY;
    }
    IStructuredSelection structuredSelection = StructuredSelection.EMPTY;
    IViewReference[] viewReferences = workbench.getActiveWorkbenchWindow()
            .getActivePage().getViewReferences();
    IViewPart viewPart = null;
    for (IViewReference viewReference : viewReferences) {
        IViewPart view = viewReference.getView(false);
        if (view instanceof CommonViewer) {
            viewPart = view;
        }
    }

    if (viewPart != null) {
        ISelectionProvider selectionProvider = viewPart.getSite()
                .getSelectionProvider();
        ISelection selection = selectionProvider.getSelection();
        if (selection instanceof IStructuredSelection) {
            structuredSelection = (IStructuredSelection) selection;
        }
    }
    return structuredSelection;
}
项目: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();
}
项目:birt    文件:UIUtil.java   
/**
 * Gets the ViewPart with the specified id
 * 
 * @param id
 *            the id of view part
 * 
 * @return Returns the view part, or null if not found
 */

public static IViewPart getView( String id )
{
    IWorkbenchPage tPage = PlatformUI.getWorkbench( )
            .getActiveWorkbenchWindow( )
            .getActivePage( );
    IViewReference[] v = tPage.getViewReferences( );
    int i;
    for ( i = 0; i < v.length; i++ )
    {
        if ( v[i].getId( ).equals( id ) )
            return (IViewPart) v[i].getPart( true );
    }
    return null;
}
项目:birt    文件:AddElementtoReport.java   
public Object getTarget( )
{
    IViewPart viewPart = UIUtil.getView( IPageLayout.ID_OUTLINE );
    if ( !( viewPart instanceof ContentOutline ) )
    {
        return null;
    }
    ContentOutline outlineView = (ContentOutline) viewPart;

    ISelection selection = outlineView.getSelection( );
    if ( selection instanceof StructuredSelection )
    {
        StructuredSelection strSelection = (StructuredSelection) selection;
        if ( strSelection.size( ) == 1 )
        {
            return strSelection.getFirstElement( );
        }
    }
    return null;
}
项目:SPLevo    文件:VPMUIUtil.java   
private static void openViewPart(final VariationPointModel vpm, final SPLevoProject splevoProject) {
    Display.getDefault().asyncExec(new Runnable() {
        @Override
        public void run() {
            try {
                IWorkbenchWindow activeWorkbench = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                IViewPart viewPart = activeWorkbench.getActivePage().showView(VPExplorer.VIEW_ID);
                final VPExplorer explorer = (VPExplorer) viewPart;
                explorer.setVPM(vpm, splevoProject);
                if (splevoProject == null) {
                    logger.warn("The VPMExplorer is about to be loaded with an invalid (null) SPLevo project.");
                }
            } catch (PartInitException e) {
                logger.error("Could not create the VP explorer view", e);
            }
        }
    });
}
项目:translationstudio8    文件:ApplicationWorkbenchWindowAdvisor.java   
public void addWorkplaceListener(){
       IWorkspace workspace = ResourcesPlugin.getWorkspace(); 
       workspace.addResourceChangeListener(new IResourceChangeListener() {

        public void resourceChanged(IResourceChangeEvent event) {
            //刷新项目导航视图
            Display.getDefault().syncExec(new Runnable() {      
                public void run() {
                    IViewPart findView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                            .findView("net.heartsome.cat.common.ui.navigator.view");
                    if(null == findView){
                        return ;
                    }
                    IAction refreshActionHandler = findView.getViewSite().getActionBars()
                            .getGlobalActionHandler(ActionFactory.REFRESH.getId());
                    if(null == refreshActionHandler){
                        return;
                    }
                    refreshActionHandler.run();
                }
            });
        }
    });
}
项目:SPLevo    文件:ExplorerMediator.java   
private void openVPGroupingExplorer(final VariationPointModel vpm) {
    Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {
            try {
                IWorkbenchWindow activeWorkbench = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                IViewPart viewPart = activeWorkbench.getActivePage().showView(FeatureOutlineView.VIEW_ID);
                final FeatureOutlineView explorer = (FeatureOutlineView) viewPart;
                if (vpm != null) {
                    explorer.setVPM(vpm);
                }
            } catch (PartInitException e) {
                logger.error("Could not create the VP grouping explorer view", e);
            }
        }
    });
}
项目:n4js    文件:GHOLD_45_CheckIgnoreAnnotationAtClassLevel_PluginUITest.java   
private String getConsoleContent() {
    waitForIdleState();
    final IViewPart viewPart = showView(CONSOLE_VIEW_ID);
    final ConsoleView consoleView = assertInstanceOf(viewPart, ConsoleView.class);
    final IConsole console = consoleView.getConsole();
    // Can be null, if nothing was logged to the console yet. Such cases return with empty string instead.
    if (console == null) {
        return "";
    }
    final ProcessConsole processConsole = assertInstanceOf(console, ProcessConsole.class);
    return processConsole.getDocument().get();
}