當前位置: 首頁>>代碼示例>>Java>>正文


Java HandlerUtil.getActiveWorkbenchWindow方法代碼示例

本文整理匯總了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;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:23,代碼來源:VizStopOtherSolutionHandler.java

示例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;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:25,代碼來源:OpenCloseEvaluatorHandler.java

示例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;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:25,代碼來源:VizDiscoverRelationsHandler.java

示例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;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:25,代碼來源:VizDiscoverAtomsHandler.java

示例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);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:36,代碼來源:ServiceUtils.java

示例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;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:13,代碼來源:POJO2DataTypeHandler.java

示例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) {

	}
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:9,代碼來源:Activator.java

示例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;
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:13,代碼來源:OpenSessionExecutionDataHandler.java

示例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;
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:15,代碼來源:ViewPlaceholdersHandler.java

示例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;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:42,代碼來源:SynchronizeBuildPoliciesHandler.java

示例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;
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:47,代碼來源:StartLaunchHandler.java


注:本文中的org.eclipse.ui.handlers.HandlerUtil.getActiveWorkbenchWindow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。