Java Code Examples for org.eclipse.ui.IWorkbenchPage#isPartVisible()

The following examples show how to use org.eclipse.ui.IWorkbenchPage#isPartVisible() . 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: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void showMarker(IMarker marker, String viewId, IWorkbenchPart source) {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IViewPart view = page.findView(viewId);
    if (!page.isPartVisible(view)) {
        try {
            view = page.showView(viewId);
        } catch (PartInitException e) {
            FindbugsPlugin.getDefault().logException(e, "Could not open view: " + viewId);
            return;
        }
    }
    if (view instanceof IMarkerSelectionHandler) {
        IMarkerSelectionHandler handler = (IMarkerSelectionHandler) view;
        handler.markerSelected(source, marker);
    } else if (DETAILS_VIEW_ID.equals(viewId) && view instanceof ISelectionListener) {
        ISelectionListener listener = (ISelectionListener) view;
        listener.selectionChanged(source, new StructuredSelection(marker));
    }
}
 
Example 2
Source File: JavaEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Makes sure that the editor's folding state is correct the next time
 * it becomes visible. If it already is visible, it toggles the folding
 * state. If not, it either registers a part listener to toggle folding
 * when the editor becomes visible, or cancels an already registered
 * runner.
 */
public void runWhenNextVisible() {
	// if there is one already: toggling twice is the identity
	if (fFoldingRunner != null) {
		fFoldingRunner.cancel();
		return;
	}
	IWorkbenchPartSite site= getSite();
	if (site != null) {
		IWorkbenchPage page= site.getPage();
		if (!page.isPartVisible(JavaEditor.this)) {
			// if we're not visible - defer until visible
			fPage= page;
			fFoldingRunner= this;
			page.addPartListener(this);
			return;
		}
	}
	// we're visible - run now
	toggleFolding();
}
 
Example 3
Source File: OccurrencesSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void install(IWorkbenchPage page) {
	page.addPartListener(this);
	fIsVisible= page.isPartVisible(getViewPart());
	if (fIsVisible) {
		installOnActiveEditor(page);
	}
}
 
Example 4
Source File: TabbedPropertySynchronizerListener.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private String activePropertyView(final IWorkbenchPage activePage) {
    for (final IViewReference ref : activePage.getViewReferences()) {
        final IWorkbenchPart part = ref.getPart(false);
        if (part != null && activePage.isPartVisible(part)) {
            final TabbedPropertySheetPage sheetPage = (TabbedPropertySheetPage) part.getAdapter(TabbedPropertySheetPage.class);
            if (sheetPage != null) {
                return ref.getId();
            }
        }
    }
    return null;
}