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

The following examples show how to use org.eclipse.ui.IWorkbenchPage#getInput() . 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: AbstractFindbugsView.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 *
 */
final void showPerspective() {
    IWorkbenchPage page = getSite().getPage();
    IWorkbenchWindow window = getSite().getWorkbenchWindow();
    IAdaptable input;
    if (page != null) {
        input = page.getInput();
    } else {
        input = ResourcesPlugin.getWorkspace().getRoot();
    }
    try {
        PlatformUI.getWorkbench().showPerspective(FindBugsPerspectiveFactory.ID, window, input);
    } catch (WorkbenchException e) {
        FindbugsPlugin.getDefault().logException(e, "Failed to open SpotBugs Perspective");
    }
}
 
Example 2
Source File: OpenJavaBrowsingPerspectiveAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	IWorkbench workbench= JavaPlugin.getDefault().getWorkbench();
	IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
	IWorkbenchPage page= window.getActivePage();
	IAdaptable input;
	if (page != null)
		input= page.getInput();
	else
		input= ResourcesPlugin.getWorkspace().getRoot();
	try {
		workbench.showPerspective(JavaUI.ID_BROWSING_PERSPECTIVE, window, input);
	} catch (WorkbenchException e) {
		ExceptionHandler.handle(e, window.getShell(),
			ActionMessages.OpenJavaBrowsingPerspectiveAction_dialog_title,
			ActionMessages.OpenJavaBrowsingPerspectiveAction_error_open_failed);
	}
}
 
Example 3
Source File: OpenJavaPerspectiveAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	IWorkbench workbench= JavaPlugin.getDefault().getWorkbench();
	IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
	IWorkbenchPage page= window.getActivePage();
	IAdaptable input;
	if (page != null)
		input= page.getInput();
	else
		input= ResourcesPlugin.getWorkspace().getRoot();
	try {
		workbench.showPerspective(JavaUI.ID_PERSPECTIVE, window, input);
	} catch (WorkbenchException e) {
		ExceptionHandler.handle(e, window.getShell(),
			ActionMessages.OpenJavaPerspectiveAction_dialog_title,
			ActionMessages.OpenJavaPerspectiveAction_error_open_failed);
	}
}
 
Example 4
Source File: FindBugsAction.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected static void switchPerspective(IWorkbenchPart part) {
    IWorkbenchWindow window = getWindow(part);
    IWorkbenchPage page = window.getActivePage();
    IAdaptable input;
    if (page != null) {
        input = page.getInput();
    } else {
        input = ResourcesPlugin.getWorkspace().getRoot();
    }
    try {
        PlatformUI.getWorkbench().showPerspective(FindBugsPerspectiveFactory.ID, window, input);
    } catch (WorkbenchException e) {
        FindbugsPlugin.getDefault().logException(e, "Failed to open SpotBugs Perspective");
    }
}