当前位置: 首页>>代码示例>>Java>>正文


Java IWorkbenchPartSite类代码示例

本文整理汇总了Java中org.eclipse.ui.IWorkbenchPartSite的典型用法代码示例。如果您正苦于以下问题:Java IWorkbenchPartSite类的具体用法?Java IWorkbenchPartSite怎么用?Java IWorkbenchPartSite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IWorkbenchPartSite类属于org.eclipse.ui包,在下文中一共展示了IWorkbenchPartSite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reorganizeImport

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
/**
 * @param project
 */
public static void reorganizeImport(final ICompilationUnit cu) {

	Display.getDefault().syncExec(() -> {
		try {
			IWorkbenchWindow iww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
			if (iww == null)
				return;
			IPartService partService = iww.getPartService();
			if (partService == null)
				return;
			IWorkbenchPart wp = partService.getActivePart();
			if (wp == null)
				return;
			IWorkbenchPartSite targetSite = wp.getSite();
			if (targetSite == null)
				return;
			organizeImports(cu, targetSite);
		} catch (Exception e) {
			ResourceManager.logException(e);
		}
	});
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:26,代码来源:JDTManager.java

示例2: getService

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
/**
 * Returns an OSGi service from {@link ExecutionEvent}. It looks up a service in the following
 * locations (if exist) in the given order:
 *
 * {@code HandlerUtil.getActiveSite(event)}
 * {@code HandlerUtil.getActiveEditor(event).getEditorSite()}
 * {@code HandlerUtil.getActiveEditor(event).getSite()}
 * {@code HandlerUtil.getActiveWorkbenchWindow(event)}
 * {@code PlatformUI.getWorkbench()}
 */
public static <T> T getService(ExecutionEvent event, Class<T> api) {
  IWorkbenchSite activeSite = HandlerUtil.getActiveSite(event);
  if (activeSite != null) {
    return activeSite.getService(api);
  }

  IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
  if (activeEditor != null) {
    IEditorSite editorSite = activeEditor.getEditorSite();
    if (editorSite != null) {
      return editorSite.getService(api);
    }
    IWorkbenchPartSite site = activeEditor.getSite();
    if (site != null) {
      return site.getService(api);
    }
  }

  IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
  if (workbenchWindow != null) {
    return workbenchWindow.getService(api);
  }

  return PlatformUI.getWorkbench().getService(api);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:36,代码来源:ServiceUtils.java

示例3: getDisplay

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
private Display getDisplay() {
  XtextEditor editor = this.editor;
  if (editor == null) {
    return null;
  }

  IWorkbenchPartSite site = editor.getSite();
  if (site == null) {
    return null;
  }

  Shell shell = site.getShell();
  if (shell == null || shell.isDisposed()) {
    return null;
  }

  Display display = shell.getDisplay();
  if (display == null || display.isDisposed()) {
    return null;
  }
  return display;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:23,代码来源:FixedHighlightingReconciler.java

示例4: AbstractPDFViewerRunnable

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
public AbstractPDFViewerRunnable(ProducePDFHandler handler, IWorkbenchPartSite site, IResource aSpecFile) {
	Assert.isNotNull(handler);
	Assert.isNotNull(site);
	Assert.isNotNull(aSpecFile);
	this.handler = handler;
	this.specFile = aSpecFile;
	
	final boolean autoRegenerate = TLA2TeXActivator.getDefault().getPreferenceStore()
			.getBoolean(ITLA2TeXPreferenceConstants.AUTO_REGENERATE);
	if (autoRegenerate) {
		// Subscribe to the event bus with which the TLA Editor save events are
		// distributed. In other words, every time the user saves a spec, we
		// receive an event and provided the spec corresponds to this PDF, we
		// regenerate it.
		// Don't subscribe in EmbeddedPDFViewerRunnable#though, because it is run
		// repeatedly and thus would cause us to subscribe multiple times.
		final IEventBroker eventService = site.getService(IEventBroker.class);
		Assert.isTrue(eventService.subscribe(TLAEditor.SAVE_EVENT, this));
		
		// Register for part close events to deregister the event handler
		// subscribed to the event bus. There is no point in regenerating
		// the PDF if no PDFEditor is open anymore.
		final IPartService partService = site.getService(IPartService.class);
		partService.addPartListener(this);
	}
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:27,代码来源:AbstractPDFViewerRunnable.java

示例5: getDisplay

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
private Display getDisplay() {
	XtextEditor editor = this.editor;
	if (editor == null){
		if(sourceViewer != null)
			return sourceViewer.getControl().getDisplay();
		return null;
	}
	IWorkbenchPartSite site = editor.getSite();
	if (site == null)
		return null;

	Shell shell = site.getShell();
	if (shell == null || shell.isDisposed())
		return null;

	Display display = shell.getDisplay();
	if (display == null || display.isDisposed())
		return null;
	return display;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:21,代码来源:HighlightingReconciler.java

示例6: isEnabled

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
@Override
public boolean isEnabled() {
	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (window == null) {
		return false;
	}
	IWorkbenchPartSite site = window.getActivePage().getActiveEditor().getSite();
	if (site == null) {
		return false;
	}
	ISelectionProvider selectionProvider = site.getSelectionProvider();
	if (selectionProvider == null) {
		return false;
	}
	ISelection currentSelection = selectionProvider.getSelection();
	setContext(refactoring, currentSelection);
	return refactoring.isExecutable();
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:19,代码来源:RenameElementHandler.java

示例7: getStatusLineManager

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
private IStatusLineManager getStatusLineManager() {
	IWorkbench wb = PlatformUI.getWorkbench();
	IWorkbenchWindow win = wb.getActiveWorkbenchWindow();

	IWorkbenchPage page = win.getActivePage();

	IWorkbenchPart part = page.getActivePart();
	if (part == null)
		return null;
	IWorkbenchPartSite site = part.getSite();
	IActionBars actionBars = null;
	if (site instanceof IEditorSite)
		actionBars = ((IEditorSite) site).getActionBars();
	else if (site instanceof IViewSite)
		actionBars = ((IViewSite) site).getActionBars();
	if (actionBars == null)
		return null;
	return actionBars.getStatusLineManager();
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:20,代码来源:ASPropertyWidget.java

示例8: disposePart

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
/**
 * Disposes the given part and its site.
 * 
 * @param part
 *          The part to dispose; must not be <code>null</code>.
 */
private void disposePart(final IWorkbenchPart part) {
	SafeRunner.run(new ISafeRunnable() {
		public void run() {
			IWorkbenchPartSite partSite = part.getSite();
			part.dispose();
			if (partSite instanceof MultiPageToolbarEditorSite) {
				((MultiPageToolbarEditorSite) partSite).dispose();
			}
		}

		public void handleException(Throwable e) {
			// Exception has already being logged by Core. Do nothing.
		}
	});
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:22,代码来源:MultiPageToolbarEditorPart.java

示例9: getStatusLineManager

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
private IStatusLineManager getStatusLineManager() {
	IWorkbench wb = PlatformUI.getWorkbench();
	IWorkbenchWindow win = wb.getActiveWorkbenchWindow();

	IWorkbenchPage page = win.getActivePage();
	if (page == null)
		return null;
	IWorkbenchPart part = page.getActivePart();
	if (part == null)
		return null;
	IWorkbenchPartSite site = part.getSite();
	IActionBars actionBars = null;
	if (site instanceof IEditorSite)
		actionBars = ((IEditorSite) site).getActionBars();
	else if (site instanceof IViewSite)
		actionBars = ((IViewSite) site).getActionBars();
	if (actionBars == null)
		return null;

	return actionBars.getStatusLineManager();
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:22,代码来源:ADataInput.java

示例10: initSelectionProvider

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
protected void initSelectionProvider() {
	// Overrides the editors selection provider to provide the text
	// selection if opened within an editor context
	try {
		IWorkbenchPartSite site = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
				.getActiveEditor().getSite();
		XtextStyledTextSelectionProvider xtextStyledTextSelectionProvider = new XtextStyledTextSelectionProvider();
		ChangeSelectionProviderOnFocusGain listener = new ChangeSelectionProviderOnFocusGain(site,
				xtextStyledTextSelectionProvider);
		styledText.addFocusListener(listener);
		styledText.addDisposeListener(listener);
	} catch (NullPointerException ex) {
		//Do nothing, not opened within editor context
	}

}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:17,代码来源:StyledTextXtextAdapter.java

示例11: search

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
public void search() {
	final IWorkbenchPart part = WorkbenchHelper.getActivePart();
	if (part instanceof IEditorPart) {
		final IEditorPart editor = (IEditorPart) part;
		final IWorkbenchPartSite site = editor.getSite();
		if (site != null) {
			final ISelectionProvider provider = site.getSelectionProvider();
			if (provider != null) {
				final ISelection viewSiteSelection = provider.getSelection();
				if (viewSiteSelection instanceof TextSelection) {
					final TextSelection textSelection = (TextSelection) viewSiteSelection;
					text.setText(textSelection.getText());
				}
			}
		}

	}
	activate(null);
	text.setFocus();

}
 
开发者ID:gama-platform,项目名称:gama,代码行数:22,代码来源:GamlSearchField.java

示例12: getStatusLineManager

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
static IStatusLineManager getStatusLineManager()
{
	try
	{
		IWorkbenchPartSite site = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
				.getActivePart().getSite();
		return ((IViewSite) site).getActionBars().getStatusLineManager();
	}
	catch (Exception e)
	{
		// try to get the IStatusLineManager through an active editor
		try
		{
			return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()
					.getEditorSite().getActionBars().getStatusLineManager();
		}
		catch (Exception e1)
		{
		}
	}
	return null;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:23,代码来源:StatusLineMessageTimerManager.java

示例13: clearSelection

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
/**
 * Clear all selection providers in all workench pages.
 */
public static void clearSelection() {

	final IWorkbenchWindow wbWin = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (wbWin != null) {

		final IWorkbenchPage[] wbPages = wbWin.getPages();
		for (final IWorkbenchPage wbPage : wbPages) {

			final IWorkbenchPart wbWinPagePart = wbPage.getActivePart();
			if (wbWinPagePart != null) {

				final IWorkbenchPartSite site = wbWinPagePart.getSite();
				if (site != null) {

					final ISelectionProvider selectionProvider = site.getSelectionProvider();

					if (selectionProvider instanceof PostSelectionProvider) {
						((PostSelectionProvider) selectionProvider).clearSelection();
					}
				}
			}
		}
	}
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:28,代码来源:Util.java

示例14: init

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
/**
 * Sets the site and input for this editor then creates and initializes the actions.
 * Subclasses may extend this method, but should always call <code>super.init(site, input)
 * </code>.
 * @see org.eclipse.ui.IEditorPart#init(IEditorSite, IEditorInput)
 */
public void init(IWorkbenchPartSite site, PlanEditorModel planEditorModel) {
	super.init(site, planEditorModel.getEPlan());
	this.planEditorModel = planEditorModel;
	EPlan ePlan = planEditorModel.getEPlan();
	this.domain = TransactionUtils.getDomain(ePlan);
	this.moveThread = new MoveThread(ePlan, this);
	IPreferenceStore store = TimelinePlugin.getDefault().getPreferenceStore();
	if (store.getBoolean(TimelinePreferencePage.P_SNAP_TO_ACTIVE)) {
		setSnapTolerance(SnapToTimelineHandler.DEFAULT_TOLERANCE);
	}
	//FIXME:  Make stores consistent.  See also SnapToAssessment.isEnabled().
	setSnapToOrbitEnabled(TimelineConstants.TIMELINE_PREFERENCES.getBoolean(TimelinePreferencePage.P_SNAP_TO_ORBIT_ACTIVE));
	timelineServices = ClassRegistry.createInstances(PlanTimelineService.class);
	for (PlanTimelineService s : timelineServices) {
		s.setTimeline(this);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:24,代码来源:PlanTimeline.java

示例15: init

import org.eclipse.ui.IWorkbenchPartSite; //导入依赖的package包/类
public void init(IWorkbenchPartSite site, T model) {
	this.site = site;
	this.model = model;
	this.timelineModel.eAdapters().add(timelineModelAdapter);
	if (site != null) {
		ISelectionProvider selectionProvider = site.getSelectionProvider();
		if (selectionProvider != null) {
			selectionProvider.addSelectionChangedListener(selectionListener);
		}
	}

	timelineServices = ClassRegistry.createInstances(TimelineService.class);
	for (TimelineService s : timelineServices) {
		s.setTimeline(this);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:Timeline.java


注:本文中的org.eclipse.ui.IWorkbenchPartSite类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。