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

The following examples show how to use org.eclipse.ui.IWorkbenchPage#showView() . 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: BadSmellsMenu.java    From JDeodorant with MIT License 6 votes vote down vote up
/**
 * 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) {
	IWorkbenchPage page=window.getActivePage();
	try {
		if(action.getId().equals("gr.uom.java.jdeodorant.actions.FeatureEnvy")) {
			page.showView("gr.uom.java.jdeodorant.views.FeatureEnvy");
		}
		else if(action.getId().equals("gr.uom.java.jdeodorant.actions.TypeChecking")) {
			page.showView("gr.uom.java.jdeodorant.views.TypeChecking");
		}
		else if(action.getId().equals("gr.uom.java.jdeodorant.actions.LongMethod")) {
			page.showView("gr.uom.java.jdeodorant.views.LongMethod");
		}
		else if(action.getId().equals("gr.uom.java.jdeodorant.actions.GodClass")) {
			page.showView("gr.uom.java.jdeodorant.views.GodClass");
		}
		else if(action.getId().equals("gr.uom.java.jdeodorant.actions.DuplicatedCode")) {
			page.showView("gr.uom.java.jdeodorant.views.DuplicatedCode");
		}
	} catch (PartInitException e) {
		e.printStackTrace();
	}
	
}
 
Example 2
Source File: UIUtils.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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$
	}
}
 
Example 3
Source File: XdsConsoleLink.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
public void gotoLink(boolean activateEditor) {
    try {
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        if (marker != null) {
            if (marker.exists()) {
                IDE.openEditor(page, marker, activateEditor);
            }
        } else {
        	// LSA80 : ������ �������? ����� � ������ �� ��������� ������ �� core-��� ������� �������, 
        	// ����� � ������� ����� ����������, �� ����� ��� ����������.
            page.showView("org.eclipse.ui.views.ProblemView", null, IWorkbenchPage.VIEW_ACTIVATE); 
        }
    }
    catch (Exception e) { // hz (NPE, PartInitException...)
        e.printStackTrace();
    }
}
 
Example 4
Source File: ERDiagramMultiPageEditor.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Composite createPageContainer(Composite parent) {
	try {
		IWorkbenchPage page = this.getSite().getWorkbenchWindow()
				.getActivePage();

		if (page != null) {
			page.showView(IPageLayout.ID_OUTLINE);
		}

	} catch (PartInitException e) {
		Activator.showExceptionDialog(e);
	}

	return super.createPageContainer(parent);
}
 
Example 5
Source File: OpenViewHandler.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
	 * the command has been executed, so extract extract the needed information from the application context.
	 */
	public Object execute(ExecutionEvent event) throws ExecutionException {
		String viewId = event.getParameter("ViewId");
		if (viewId == null) {
			return null;
		}
		
		IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		IViewPart view = workbenchPage.findView(viewId);
		if (view == null) {
			try {
				workbenchPage.showView(viewId);
			} catch (PartInitException e) {
				e.printStackTrace();
			}
		} else {
			workbenchPage.hideView(view);
		}
//		ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
//		commandService.refreshElements(event.getCommand().getId(), null);
		return null;
	}
 
Example 6
Source File: CallHierarchyUI.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static CallHierarchyViewPart openView(IMember[] input, IWorkbenchWindow window) {
  	if (input.length == 0) {
	MessageDialog.openInformation(window.getShell(), CallHierarchyMessages.CallHierarchyUI_selectionDialog_title,
			CallHierarchyMessages.CallHierarchyUI_open_operation_unavialable);
	return null;
}
      IWorkbenchPage page= window.getActivePage();
try {
	CallHierarchyViewPart viewPart= getDefault().findLRUCallHierarchyViewPart(page); //find the first view which is not pinned
	String secondaryId= null;
	if (viewPart == null) {
		if (page.findViewReference(CallHierarchyViewPart.ID_CALL_HIERARCHY) != null) //all the current views are pinned, open a new instance
			secondaryId= String.valueOf(++getDefault().fViewCount);
	} else
		secondaryId= viewPart.getViewSite().getSecondaryId();
	viewPart= (CallHierarchyViewPart)page.showView(CallHierarchyViewPart.ID_CALL_HIERARCHY, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
	viewPart.setInputElements(input);
	return viewPart;
      } catch (CoreException e) {
          ExceptionHandler.handle(e, window.getShell(),
              CallHierarchyMessages.CallHierarchyUI_error_open_view, e.getMessage());
      }
      return null;
  }
 
Example 7
Source File: BrowserViewInstance.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void openURL(URL url) throws PartInitException {
	WebBrowserView view = (WebBrowserView) part;
	IWorkbenchWindow workbenchWindow = WebBrowserUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow();
	IWorkbenchPage workbenchPage = null;
	if (workbenchWindow != null) {
		workbenchPage = workbenchWindow.getActivePage();
	}
	if (workbenchPage == null) {
		throw new PartInitException("Cannot get Workbench page"); //$NON-NLS-1$
	}
	if (view == null) {
		view = (WebBrowserView) workbenchPage.showView(WebBrowserView.VIEW_ID, getId(), IWorkbenchPage.VIEW_CREATE);
		hookPart(workbenchPage, view);
	}
	if (view != null) {
		workbenchPage.bringToTop(view);
		view.setURL((url != null) ? url.toExternalForm() : null);
	}
}
 
Example 8
Source File: StartBillingProposalHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private BillingProposalView getOpenView(ExecutionEvent event){
	try {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
		IWorkbenchPage page = window.getActivePage();
		return (BillingProposalView) page.showView(BillingProposalView.ID);
	} catch (PartInitException e) {
		MessageDialog.openError(HandlerUtil.getActiveShell(event), "Fehler",
			"Konnte Rechnungs-Vorschlag View nicht öffnen");
	}
	return null;
}
 
Example 9
Source File: TmfAnalysisViewOutput.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Opens the view for this output. This method should always be called from
 * the main thread.
 *
 * @return The view that was just opened
 * @throws PartInitException
 *             Exception if the view did not open correctly
 * @since 2.1
 */
protected IViewPart openView() throws PartInitException {
    final IWorkbench wb = PlatformUI.getWorkbench();
    final IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();

    String viewId = fViewId;
    String secondaryId = fSecondaryId;
    if (secondaryId != null) {
        viewId += ':' + secondaryId;
    }

    return activePage.showView(viewId);
}
 
Example 10
Source File: CompareView.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * @param commitIsAhead
 *            true means that we are comparing with a commit that is not yet
 *            fetched (relevant in compare view ui), false means we are
 *            comparing with a commit that is already fetched
 */
public static void update(List<INavigationElement<?>> elements, Commit commit, boolean commitIsAhead) {
	try {
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		if (page == null)
			return;
		CompareView view = (CompareView) page.showView(ID);
		view.viewer.setLabelProvider(commitIsAhead ? ActionType.COMPARE_AHEAD : ActionType.COMPARE_BEHIND);
		view.update(elements, commit);
	} catch (PartInitException e) {
		log.error("Error compare view", e);
	}
}
 
Example 11
Source File: AddArticleToOrderHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	IWorkbenchPage activePage =
		HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
	// activate after BestellView usage, needed for selection provider
	IWorkbenchPart activePart = activePage.getActivePart();
	
	List<IArticle> articlesToOrder = getArticlesToOrder(
		HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection());
	if (articlesToOrder.isEmpty()) {
		log.debug("Skip handler execution as no articles are selected to add to an order!");
		return null;
	}
	
	// load BestellView and pass articles to order
	try {
		BestellView bestellView = (BestellView) activePage.showView(BestellView.ID);
		if (bestellView != null) {
			bestellView.addItemsToOrder(articlesToOrder);
		} else {
			log.error("Cant't load BestellView to add articles to order");
		}
		activePage.activate(activePart);
	} catch (PartInitException e) {
		log.error("Cant't load BestellView to add articles to order", e);
	}
	return null;
	
}
 
Example 12
Source File: BillingProposalRemoveHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private BillingProposalView getOpenView(ExecutionEvent event){
	try {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
		IWorkbenchPage page = window.getActivePage();
		return (BillingProposalView) page.showView(BillingProposalView.ID);
	} catch (PartInitException e) {
		MessageDialog.openError(HandlerUtil.getActiveShell(event), "Fehler",
			"Konnte Rechnungs-Vorschlag View nicht öffnen");
	}
	return null;
}
 
Example 13
Source File: ShowInNavigatorViewAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void run(IResource resource) {
	if (resource == null)
		return;
	try {
		IWorkbenchPage page= getSite().getWorkbenchWindow().getActivePage();
		IViewPart view= page.showView(JavaPlugin.ID_RES_NAV);
		if (view instanceof ISetSelectionTarget) {
			ISelection selection= new StructuredSelection(resource);
			((ISetSelectionTarget)view).selectReveal(selection);
		}
	} catch(PartInitException e) {
		ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.ShowInNavigatorView_error_activation_failed);
	}
}
 
Example 14
Source File: CallHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
static CallHierarchyViewPart findAndShowCallersView(IWorkbenchPartSite site) {
    IWorkbenchPage workbenchPage = site.getPage();
    CallHierarchyViewPart callersView = null;

    try {
        callersView = (CallHierarchyViewPart) workbenchPage.showView(CallHierarchyViewPart.ID_CALL_HIERARCHY);
    } catch (PartInitException e) {
        JavaPlugin.log(e);
    }

    return callersView;
}
 
Example 15
Source File: LoadTemplateCommand.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	// get the selection
	Brief template = null;
	ISelection selection =
		HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
	if (selection != null) {
		IStructuredSelection strucSelection = (IStructuredSelection) selection;
		Object firstElement = strucSelection.getFirstElement();
		if (firstElement != null && firstElement instanceof TextTemplate) {
			TextTemplate textTemplate = (TextTemplate) firstElement;
			template = textTemplate.getTemplate();
		}
	}
	
	// show template in textview
	try {
		if (template == null) {
			SWTHelper.alert(ch.elexis.core.ui.commands.Messages.LoadTemplateCommand_Error,
				ch.elexis.core.ui.commands.Messages.LoadTemplateCommand_NoTextTemplate);
			return null;
		}
		IWorkbenchPage activePage =
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		TextView textView = (TextView) activePage.showView(TextView.ID);
		if (!textView.openDocument(template)) {
			SWTHelper.alert(Messages.BriefAuswahlErrorHeading, //$NON-NLS-1$
				Messages.BriefAuswahlCouldNotLoadText); //$NON-NLS-1$
		}
	} catch (PartInitException e) {
		logger.error("Could not open TextView", e);
		ExHandler.handle(e);
	}
	return null;
}
 
Example 16
Source File: AbstractFindbugsView.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @return instance of annotations view or null if view couldn't be opened
 */
static IViewPart showBugTreeView() {
    IWorkbenchPage page = FindbugsPlugin.getActiveWorkbenchWindow().getActivePage();
    try {
        return page.showView(FindbugsPlugin.TREE_VIEW_ID);
    } catch (PartInitException e) {
        FindbugsPlugin.getDefault().logException(e, "Could not show bug tree view");
    }
    return null;
}
 
Example 17
Source File: CamelSpringUtil.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
public static IViewPart openSpringView(int mode) {
    // TESB-17301: 'Spring' View is not visible
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        IWorkbenchPage page = window.getActivePage();
        if (page != null) {
            try {
                return page.showView(SpringConfigurationView.ID, null, mode);
            } catch (PartInitException e) {
                ExceptionHandler.process(e);
            }
        }
    }
    return null;
}
 
Example 18
Source File: ToggleOutlineHandler.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	boolean toShow = !HandlerUtil.toggleCommandState(event.getCommand());
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	if (page != null)
	{
		if (toShow)
		{
			try
			{
				page.showView(OUTLINE_VIEW_ID);
			}
			catch (PartInitException e)
			{
				IdeLog.logError(CommonEditorPlugin.getDefault(), Messages.ToggleOutlineHandler_ERR_OpeningOutline,
						e);
			}
		}
		else
		{
			IViewPart viewPart = page.findView(OUTLINE_VIEW_ID);
			if (viewPart != null)
			{
				page.hideView(viewPart);
			}
		}
	}
	return null;
}
 
Example 19
Source File: ConsoleFactory.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 4 votes vote down vote up
public static void setActiveConsole() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    try {
        page.showView(console.getName());
    } catch (PartInitException e) {}
}
 
Example 20
Source File: CreateCiteHandler.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	// TODO: seems to be there is some refactoring needed in here
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	IViewPart part = null;
	try {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
		if (window != null) {
			IWorkbenchPage page = window.getActivePage();
			if (page != null) {
				part = page.showView(chartViewId);
			}
		}
	} catch (PartInitException e) {
		e.printStackTrace();
		return null;
	}
	if (part instanceof ICommunicationView) {
		view = (ICommunicationView) part;
	} else {
		return null;
	}

	view.getPreview().setTextToShow(noDataToDisplay);
	if (currentSelection.size() == 1) {
		view.getPreview().setDataPresent(true);
		ChartDataProvider provider = new ChartDataProvider();
		Term input = (Term) currentSelection.getFirstElement();
		Map<String, Integer> citeChartData = provider.calculateNumberOfPapersPerClass(input);
		BarChartConfiguration.get().getGeneralSettings().setChartTitle("Number of cites per subclass of " + input.getName());
		BarChartConfiguration.get().setTermSort(TermSort.SUBCLASS);
		Chart citeChart = ChartGenerator.createCiteBar(citeChartData);
		view.setAndRenderChart(citeChart);
	} else {
		view.setAndRenderChart(null);
	}
	return null;
}