org.eclipse.ui.IWorkbenchPage#showView ( )源码实例Demo

下面列出了org.eclipse.ui.IWorkbenchPage#showView ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: 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$
	}
}
 
源代码2 项目: xds-ide   文件: XdsConsoleLink.java
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();
    }
}
 
源代码3 项目: ermaster-b   文件: ERDiagramMultiPageEditor.java
/**
 * {@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);
}
 
源代码4 项目: APICloud-Studio   文件: BrowserViewInstance.java
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);
	}
}
 
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;
  }
 
源代码6 项目: translationstudio8   文件: OpenViewHandler.java
/**
	 * 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;
	}
 
源代码7 项目: JDeodorant   文件: BadSmellsMenu.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) {
	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();
	}
	
}
 
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;
}
 
源代码9 项目: APICloud-Studio   文件: ToggleOutlineHandler.java
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;
}
 
源代码10 项目: tesb-studio-se   文件: CamelSpringUtil.java
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;
}
 
源代码11 项目: spotbugs   文件: AbstractFindbugsView.java
/**
 * @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;
}
 
源代码12 项目: elexis-3-core   文件: LoadTemplateCommand.java
@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;
}
 
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;
}
 
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);
	}
}
 
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;
}
 
源代码16 项目: elexis-3-core   文件: AddArticleToOrderHandler.java
@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;
	
}
 
源代码17 项目: olca-app   文件: CompareView.java
/**
 * @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);
	}
}
 
源代码18 项目: tracecompass   文件: TmfAnalysisViewOutput.java
/**
 * 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);
}
 
源代码19 项目: slr-toolkit   文件: CreateCiteHandler.java
@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;
}
 
源代码20 项目: CodeCheckerEclipsePlugin   文件: ConsoleFactory.java
public static void setActiveConsole() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    try {
        page.showView(console.getName());
    } catch (PartInitException e) {}
}