Java Code Examples for org.eclipse.ui.IViewReference#getView()
The following examples show how to use
org.eclipse.ui.IViewReference#getView() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TmfAlignmentSynchronizer.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Get the narrowest view that corresponds to the given alignment information. */ private static TmfView getNarrowestView(TmfTimeViewAlignmentInfo alignmentInfo) { IWorkbenchWindow workbenchWindow = getWorkbenchWindow(alignmentInfo.getShell()); if (workbenchWindow == null || workbenchWindow.getActivePage() == null) { // Only time aligned views that are part of a workbench window are supported return null; } IWorkbenchPage page = workbenchWindow.getActivePage(); int narrowestWidth = Integer.MAX_VALUE; TmfView narrowestView = null; for (IViewReference ref : page.getViewReferences()) { IViewPart view = ref.getView(false); if (isTimeAlignedView(view)) { TmfView tmfView = (TmfView) view; if (isCandidateForNarrowestView(tmfView, alignmentInfo, narrowestWidth)) { narrowestWidth = ((ITmfTimeAligned) tmfView).getAvailableWidth(getClampedTimeAxisOffset(alignmentInfo)); narrowestWidth = getClampedTimeAxisWidth(alignmentInfo, narrowestWidth); narrowestView = tmfView; } } } return narrowestView; }
Example 2
Source File: CompareView.java From olca-app with Mozilla Public License 2.0 | 6 votes |
public static void clear() { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (page == null) return; for (IViewReference viewRef : page.getViewReferences()) { if (!ID.equals(viewRef.getId())) continue; CompareView view = (CompareView) viewRef.getView(false); if (view == null) return; view.commit = null; view.currentSelection = null; view.input = null; view.viewer.setInput(new ArrayList<>()); } }
Example 3
Source File: OpenBrowserOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void openAsView(IWorkbenchPage page) throws PartInitException { WebBrowserView view = null; IViewReference findViewReference = page.findViewReference(WebBrowserView.WEB_BROWSER_VIEW_ID, WebBrowserUtil.encodeStyle(id, IWorkbenchBrowserSupport.AS_VIEW)); if (findViewReference == null) { view = (WebBrowserView) page.showView(WebBrowserView.WEB_BROWSER_VIEW_ID, WebBrowserUtil.encodeStyle(id, IWorkbenchBrowserSupport.AS_VIEW), IWorkbenchPage.VIEW_CREATE); } else { view = (WebBrowserView) findViewReference.getView(true); } if (name != null && name.length() > 0) { view.setBrowserViewName(name); } if (view != null) { view.setURL(url.toExternalForm()); if (bringPartToTop) { page.bringToTop(view); } } }
Example 4
Source File: PyCodeCoverageView.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Gets the py code coverage view. May only be called in the UI thread. If the view is not visible, if createIfNotThere * is true, it's made visible. * * Note that it may return null if createIfNotThere == false and the view is not currently shown or if not in the * UI thread. */ public static PyCodeCoverageView getView(boolean createIfNotThere) { IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); try { if (workbenchWindow == null) { return null; } IWorkbenchPage page = workbenchWindow.getActivePage(); if (createIfNotThere) { return (PyCodeCoverageView) page.showView(PY_COVERAGE_VIEW_ID, null, IWorkbenchPage.VIEW_ACTIVATE); } else { IViewReference viewReference = page.findViewReference(PY_COVERAGE_VIEW_ID); if (viewReference != null) { //if it's there, return it (but don't restore it if it's still not there). //when made visible, it'll handle things properly later on. return (PyCodeCoverageView) viewReference.getView(false); } } } catch (Exception e) { Log.log(e); } return null; }
Example 5
Source File: ScriptConsole.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * @param page the page where the console view is * @param restore whether we should try to restore it * @return a list with the parts containing the console */ private static List<IViewPart> getConsoleParts(IWorkbenchPage page, boolean restore) { List<IViewPart> consoleParts = new ArrayList<IViewPart>(); IViewReference[] viewReferences = page.getViewReferences(); for (IViewReference ref : viewReferences) { if (ref.getId().equals(IConsoleConstants.ID_CONSOLE_VIEW)) { IViewPart part = ref.getView(restore); if (part != null) { consoleParts.add(part); if (restore) { return consoleParts; } } } } return consoleParts; }
Example 6
Source File: UIUtils.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public static ViewPart getView(String viewId, boolean forceVisible) { IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); try { if (workbenchWindow == null) { return null; } IWorkbenchPage page = workbenchWindow.getActivePage(); if (forceVisible) { return (ViewPart) page.showView(viewId, null, IWorkbenchPage.VIEW_VISIBLE); } else { IViewReference viewReference = page.findViewReference(viewId); if (viewReference != null) { //if it's there, return it (but don't restore it if it's still not there). //when made visible, it'll handle things properly later on. return (ViewPart) viewReference.getView(false); } } } catch (Exception e) { Log.log(e); } return null; }
Example 7
Source File: InvasiveThemeHijacker.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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(); } }
Example 8
Source File: TmfAlignmentSynchronizer.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Get a view that corresponds to the alignment information. The view is * meant to be used as a "reference" for other views to align on. Heuristics * are applied to choose the best view. For example, the view has to be * visible. It also will prioritize the view with lowest time axis offset * because most of the interesting data should be in the time widget. * * @param alignmentInfo * alignment information * @param blackListedView * an optional black listed view that will not be used as * reference (useful for a view that just got created) * @return the reference view */ private static ITmfTimeAligned getReferenceView(TmfTimeViewAlignmentInfo alignmentInfo, TmfView blackListedView) { IWorkbenchWindow workbenchWindow = getWorkbenchWindow(alignmentInfo.getShell()); if (workbenchWindow == null || workbenchWindow.getActivePage() == null) { // Only time aligned views that are part of a workbench window are supported return null; } IWorkbenchPage page = workbenchWindow.getActivePage(); int lowestTimeAxisOffset = Integer.MAX_VALUE; ITmfTimeAligned referenceView = null; for (IViewReference ref : page.getViewReferences()) { IViewPart view = ref.getView(false); if (view != blackListedView && isTimeAlignedView(view)) { if (isCandidateForReferenceView((TmfView) view, alignmentInfo, lowestTimeAxisOffset)) { referenceView = (ITmfTimeAligned) view; lowestTimeAxisOffset = getClampedTimeAxisOffset(referenceView.getTimeViewAlignmentInfo()); } } } return referenceView; }
Example 9
Source File: CodeCheckerContext.java From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 | 6 votes |
/** * The refresher for Custom ReportList View. If secondary id is empty, * it checks if a refresh really needs to happen and if so updates every * custom view for the current project. If secondary-id is not empty, * it will search for the secondary-id custom view and * updates that particular one. * * @param pages the page list for the currently active workbench windows. * @param project the project, the user change his/her view to * @param secondaryId id of the {@link ReportListViewCustom} the refresh * @param considerProjectChange false if the refresh should always happen despite of no real need to force refresh */ private void refreshCustom(IWorkbenchPage[] pages, IProject project, String secondaryId, boolean considerProjectChange) { for(IWorkbenchPage page : pages) { for (IViewReference vp : page.getViewReferences()) { if (vp.getId().equals(ReportListViewCustom.ID)) { ReportListViewCustom rlvc = (ReportListViewCustom) vp.getView(true); if(secondaryId.isEmpty() && rlvc.getViewSite().getSecondaryId() != null) { if (!considerProjectChange || this.activeProject != project) { rlvc.onEditorChanged(project); } } else if(rlvc.getViewSite().getSecondaryId() != null && rlvc.getViewSite().getSecondaryId().equals(secondaryId)){ rlvc.onEditorChanged(project); return; } } } } }
Example 10
Source File: CodeCheckerContext.java From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 | 6 votes |
/** * The refresher for Current ReportList View. * * @param pages the page list for the currently active workbench windows * @param project the project, the user change his/her view to * @param filename the filename * @param considerViewerRefresh false if the refresh should always happen despite of no real need to force refresh */ private void refreshCurrent(IWorkbenchPage[] pages, IProject project, String filename, boolean considerViewerRefresh) { for(IWorkbenchPage page : pages) { for (IViewReference vp : page.getViewReferences()) { if (vp.getId().equals(ReportListView.ID)) { ReportListView rlv = (ReportListView) vp.getView(true); if (!considerViewerRefresh || rlv.getViewerRefresh()) { rlv.onEditorChanged(project, filename); } else { rlv.setViewerRefresh(true); } } } } }
Example 11
Source File: TmfAlignmentSynchronizer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static void restoreView(IViewReference ref) { IViewPart view = ref.getView(false); if (isTimeAlignedView(view)) { ITmfTimeAligned alignedView = (ITmfTimeAligned) view; alignedView.performAlign(getClampedTimeAxisOffset(alignedView.getTimeViewAlignmentInfo()), Integer.MAX_VALUE); } }
Example 12
Source File: TmfAlignmentSynchronizer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Realign views inside a given page * * @param page * the workbench page */ private void realignViews(IWorkbenchPage page) { IViewReference[] viewReferences = page.getViewReferences(); for (IViewReference ref : viewReferences) { IViewPart view = ref.getView(false); if (isTimeAlignedView(view)) { queueAlignment(((ITmfTimeAligned) view).getTimeViewAlignmentInfo(), false); } } }
Example 13
Source File: ViewHelper.java From codewind-eclipse with Eclipse Public License 2.0 | 5 votes |
public static IViewPart getViewPart(String viewId) { for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) { for (IWorkbenchPage page : window.getPages()) { for (IViewReference reference : page.getViewReferences()) { if (viewId.equals(reference.getId())) { return reference.getView(false); } } } } return null; }
Example 14
Source File: WorkbenchHelper.java From gama with GNU General Public License v3.0 | 5 votes |
public static IGamaView.Display findDisplay(final String id) { final IWorkbenchPage page = WorkbenchHelper.getPage(); if (page == null) { return null; } // Closing the workbench final IViewReference ref = page.findViewReference(id); if (ref == null) { return null; } final IViewPart view = ref.getView(false); if (view instanceof IGamaView.Display) { return (IGamaView.Display) view; } return null; }
Example 15
Source File: WorkbenchHelper.java From gama with GNU General Public License v3.0 | 5 votes |
public static IViewPart findView(final String id, final String second, final boolean restore) { final IWorkbenchPage page = WorkbenchHelper.getPage(); if (page == null) { return null; } // Closing the workbench final IViewReference ref = page.findViewReference(id, second); if (ref == null) { return null; } final IViewPart part = ref.getView(restore); return part; }
Example 16
Source File: TmfAlignmentSynchronizer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static void performAlignment(AlignmentOperation info) { TmfView referenceView = info.fView; if (isDisposedView(referenceView)) { return; } TmfTimeViewAlignmentInfo alignmentInfo = info.fAlignmentInfo; // The location of the view might have changed (resize, etc). Update the alignment info. alignmentInfo = new TmfTimeViewAlignmentInfo(alignmentInfo.getShell(), getViewLocation(referenceView), getClampedTimeAxisOffset(alignmentInfo)); TmfView narrowestView = getNarrowestView(alignmentInfo); if (narrowestView == null) { // No valid view found for this alignment. This could mean that the views for this alignment are now too narrow (width == 0) or that shell is not a workbench window. return; } int narrowestWidth = ((ITmfTimeAligned) narrowestView).getAvailableWidth(getClampedTimeAxisOffset(alignmentInfo)); narrowestWidth = getClampedTimeAxisWidth(alignmentInfo, narrowestWidth); IViewReference[] viewReferences = referenceView.getSite().getPage().getViewReferences(); for (IViewReference ref : viewReferences) { IViewPart view = ref.getView(false); if (isTimeAlignedView(view)) { TmfView tmfView = (TmfView) view; ITmfTimeAligned alignedView = (ITmfTimeAligned) view; if (!isDisposedView(tmfView) && isViewLocationNear(getViewLocation(tmfView), alignmentInfo.getViewLocation())) { alignedView.performAlign(getClampedTimeAxisOffset(alignmentInfo), narrowestWidth); } } } }
Example 17
Source File: AbstractDominoWizardPanel.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
private void refreshDataPalette(boolean dsRenamed) { IViewReference[] refs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences(); for(IViewReference ref : refs) { if(DesignerPartNames.DDE_VIEW_DATA_PALETTE.equals(ref.getId())){ IViewPart vp = ref.getView(false); if(vp instanceof IXPageUpdateListener) { ((IXPageUpdateListener)vp).xpageUpdated(dsRenamed ? IXPageUpdateListener.ADDED : IXPageUpdateListener.MODIFIED); break; } } } }
Example 18
Source File: CodeCheckerContext.java From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 | 5 votes |
/** * The refresher for Project ReportList View. * * @param pages the page list for the currently active workbench windows. * @param project the project, project the buglist to be refreshed * @param noFetch if true, the server will not be asked for new list */ private void refreshProject(IWorkbenchPage[] pages, IProject project, boolean noFetch) { Logger.log(IStatus.INFO, "Refreshing bug list for project:"+project.getName()); for(IWorkbenchPage page : pages) { for (IViewReference vp : page.getViewReferences()) { if (vp.getId().equals(ReportListViewProject.ID)) { ReportListViewProject rlvp = (ReportListViewProject) vp.getView(true); if (!noFetch || this.activeProject != project) { rlvp.onEditorChanged(project); } } } } }
Example 19
Source File: LoadersManager.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Changes the current unique loader to the given secondary viewId. * * @param loader The current loader * @param id the view secondary id or null */ private void setCurrentLoader(IUml2SDLoader loader, String id) { if (id == null) { return; } // Get the loader in use IUml2SDLoader currentLoader = fViewLoaderMap.get(id); if ((currentLoader != null) && (currentLoader != loader)) { if (loader != null) { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); // During Eclipse shutdown the active workbench window is null if (window == null) { return; } IWorkbenchPage persp = window.getActivePage(); try { // Search view corresponding to the viewId SDView sdview = null; IViewReference viewref = persp.findViewReference(id); if (viewref != null) { sdview = (SDView) viewref.getView(false); } // Make everything clean for the new loader if (sdview != null) { sdview.resetProviders(); } } catch (Exception e) { Activator.getDefault().logError("Error setting current loader class", e); //$NON-NLS-1$ } } // The old loader is going to be kicked currentLoader.dispose(); } // Replace the current loader by the new one in the map fViewLoaderMap.put(id, loader); // Store this loader in the preferences to be able to restore it when the workbench will be re-launched if (loader != null) { saveLastLoader(loader.getClass().getName(), id); } }
Example 20
Source File: LoadersManager.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Returns the loader in use in this Sequence Diagram View * * @param viewId The Sequence Diagram viewId * @param view The Sequence Diagram view (if known). Use null to reference the primary SD View. * @return the current loader if any - null otherwise */ public IUml2SDLoader getCurrentLoader(String viewId, SDView view) { if (viewId == null) { return null; } IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); // During Eclipse shutdown the active workbench window is null if (window == null) { return null; } IWorkbenchPage persp = window.getActivePage(); SDView sdView = view; try { // Search the view corresponding to the viewId if (sdView == null) { IViewReference viewref = persp.findViewReference(viewId); if (viewref != null) { sdView = (SDView) viewref.getView(false); } if (sdView == null) { // no corresponding view exists -> return null for the loader return null; } } // Return the loader corresponding to that view (if any) IUml2SDLoader loader = fViewLoaderMap.get(viewId); if (loader == null) { createLastLoaderIfAny(viewId); loader = fViewLoaderMap.get(viewId); } return loader; } catch (Exception e) { Activator.getDefault().logError("Error getting loader class", e); //$NON-NLS-1$ } return null; }