本文整理汇总了Java中org.eclipse.ui.handlers.HandlerUtil.getActiveWorkbenchWindow方法的典型用法代码示例。如果您正苦于以下问题:Java HandlerUtil.getActiveWorkbenchWindow方法的具体用法?Java HandlerUtil.getActiveWorkbenchWindow怎么用?Java HandlerUtil.getActiveWorkbenchWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.handlers.HandlerUtil
的用法示例。
在下文中一共展示了HandlerUtil.getActiveWorkbenchWindow方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
final ISourceProviderService service =
activeWorkbenchWindow.getService(ISourceProviderService.class);
final AnalysisSourceProvider sourceProvider =
(AnalysisSourceProvider) service.getSourceProvider(AnalysisSourceProvider.ANALYSIS_STATE);
sourceProvider.setPassive();
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
AlloyValidator.isCanceled = true;
AlloyOtherSolutionReasoning.getInstance().finish();
AlloyOtherSolutionDiscovering.getInstance().finish();
AlloyOtherSolutionReasoningForAtom.getInstance().finish();
Visualization.showViz();
}
});
thread.start();
return true;
}
示例2: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
final ISourceProviderService service =
activeWorkbenchWindow.getService(ISourceProviderService.class);
final AnalysisSourceProvider sourceProvider =
(AnalysisSourceProvider) service.getSourceProvider(AnalysisSourceProvider.ANALYSIS_STATE);
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if (sourceProvider.getEvaluationState() == EvaluationState.OPEN) {
Visualization.evaluatorOpen = false;
sourceProvider.setEvaluationState(EvaluationState.CLOSE);
} else if (sourceProvider.getEvaluationState() == EvaluationState.CLOSE) {
Visualization.evaluatorOpen = true;
sourceProvider.setEvaluationState(EvaluationState.OPEN);
}
Visualization.showViz();
}
});
thread.start();
return true;
}
示例3: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
final ISourceProviderService service =
activeWorkbenchWindow.getService(ISourceProviderService.class);
final AnalysisSourceProvider sourceProvider =
(AnalysisSourceProvider) service.getSourceProvider(AnalysisSourceProvider.ANALYSIS_STATE);
sourceProvider.setActive(ReasoningType.DISCOVER_RELATION);
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
final AlloyReasoning alloyReasoning = new AlloyReasoning();
final boolean reasoning = alloyReasoning.reasoning();
if (!reasoning) {
sourceProvider.setPassive();
}
Visualization.showViz();
}
});
thread.start();
return true;
}
示例4: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
final ISourceProviderService service =
activeWorkbenchWindow.getService(ISourceProviderService.class);
final AnalysisSourceProvider sourceProvider =
(AnalysisSourceProvider) service.getSourceProvider(AnalysisSourceProvider.ANALYSIS_STATE);
sourceProvider.setActive(ReasoningType.DISCOVER_ATOM);
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
final AlloyDiscovering alloyDiscovering = new AlloyDiscovering();
final boolean discovering =
alloyDiscovering.discovering();
if (!discovering) {
Visualization.sourceProvider.setPassive();
}
Visualization.showViz();
}
});
thread.start();
return true;
}
示例5: getService
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的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);
}
示例6: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection selection = HandlerUtil.getCurrentSelection(event);
POJO2DataTypeWizard wizard = new POJO2DataTypeWizard();
wizard.init(window.getWorkbench(),
selection instanceof IStructuredSelection
? (IStructuredSelection) selection : StructuredSelection.EMPTY);
WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
dialog.open();
return null;
}
示例7: showView
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
private static void showView(ExecutionEvent event) {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
try {
window.getActivePage().showView("pt.iscte.pandionj.view");
} catch (PartInitException e) {
}
}
示例8: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
final ICoverageSession session = sessionManager.getActiveSession();
final IEditorInput input = new CoverageSessionInput(session);
final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
try {
window.getActivePage().openEditor(input, ExecutionDataEditor.ID);
} catch (PartInitException e) {
throw new ExecutionException(
UIMessages.ExecutionDataEditorOpeningError_message, e);
}
return null;
}
示例9: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil
.getActiveWorkbenchWindow(event);
final Shell shell;
if (activeWorkbenchWindow == null) {
shell = null;
} else {
shell = activeWorkbenchWindow.getShell();
}
showPreferencePage(shell, Constants.PLACEHOLDERS_PREFERENCE_PAGE_ID);
return null;
}
示例10: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
boolean autoBuilding = ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
IWorkbenchWindow aww = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection sel = HandlerUtil.getCurrentSelection(event);
if (sel.isEmpty())
return null;
if (sel instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) sel;
if (selection != null) {
Object obj = selection.getFirstElement();
if (obj != null) {
try {
IResource selectedResource = null;
if (obj instanceof IJavaProject) {
IJavaProject jp = (IJavaProject) obj;
selectedResource = jp.getProject();
}
if (obj instanceof IPackageFragmentRoot) {
IPackageFragmentRoot pfr = (IPackageFragmentRoot) obj;
selectedResource = pfr.getCorrespondingResource();
}
if (obj instanceof IPackageFragment) {
IPackageFragment pf = (IPackageFragment) obj;
selectedResource = pf.getCorrespondingResource();
}
if (selectedResource != null && !selectedResource.exists())
return null;
// This is where the synchronization is done ...
ResourceManager.setAutoBuilding(false);
GraphWalkerContextManager.synchronizeBuildPolicies(selectedResource, aww);
} catch (Exception e) {
ResourceManager.logException(e);
} finally {
ResourceManager.setAutoBuilding(autoBuilding);
}
}
}
}
return null;
}
示例11: getModelEditor
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
private ModelEditor getModelEditor(final ExecutionEvent event) {
// is current editor a model editor?
final String activeEditorId = HandlerUtil.getActiveEditorId(event);
if (activeEditorId != null && activeEditorId.startsWith(ModelEditor.ID)) {
lastModelEditor = (ModelEditor) HandlerUtil.getActiveEditor(event);
}
// If lastModelEditor is still null, it means we haven't run the model
// checker yet AND the model editor view is *not* active. Lets search
// through all editors to find a model checker assuming only a single one
// is open right now. If more than one model editor is open, randomly
// select one. In case it's not the one intended to be run by the user,
// she has to activate the correct model editor manually.
//
// It is tempting to store the name of the lastModelEditor
// in e.g. an IDialogSetting to persistently store even across Toolbox
// restarts. However, the only way to identify a model editor here is by
// its name and almost all model editors carry the name "Model_1" (the
// default name). So we might end up using Model_1 which was the last
// model that ran for spec A, but right now spec B and two of its model
// editors are open ("Model_1" and "Model_2"). It would launch Model_1,
// even though Model_2 might be what the user wants.
if (lastModelEditor == null) {
final IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
final IWorkbenchPage[] pages = workbenchWindow.getPages();
for (final IWorkbenchPage page : pages) {
final IEditorReference[] editorReferences = page.getEditorReferences();
for (final IEditorReference editorRefs: editorReferences) {
if (editorRefs.getId().equals(ModelEditor.ID)) {
lastModelEditor = (ModelEditor) editorRefs.getEditor(true);
break;
}
}
}
}
// Validate that the lastModelEditor still belongs to the current
// open spec. E.g. lastModelEditor might still be around from when
// the user ran a it on spec X, but has switched to spec Y in the
// meantime. Closing the spec nulls the ModelEditor
if (lastModelEditor != null && lastModelEditor.isDisposed()) {
lastModelEditor = null;
}
// If the previous two attempts to find a model editor have failed, lets
// return whatever we have... which might be null.
return lastModelEditor;
}