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


Java HandlerUtil.getCurrentSelectionChecked方法代码示例

本文整理汇总了Java中org.eclipse.ui.handlers.HandlerUtil.getCurrentSelectionChecked方法的典型用法代码示例。如果您正苦于以下问题:Java HandlerUtil.getCurrentSelectionChecked方法的具体用法?Java HandlerUtil.getCurrentSelectionChecked怎么用?Java HandlerUtil.getCurrentSelectionChecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.ui.handlers.HandlerUtil的用法示例。


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

示例1: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);

	IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
	try {
		view = (N4IDEXpectView) windows[0].getActivePage().showView(
				N4IDEXpectView.ID);
	} catch (PartInitException e) {
		N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
	}

	Description desc = (Description) selection.getFirstElement();
	if (desc.isTest() && view.testsExecutionStatus.hasFailed(desc)) {
		Throwable failureException = view.testsExecutionStatus.getFailure(desc).getException();

		if (failureException instanceof ComparisonFailure) {
			ComparisonFailure cf = (ComparisonFailure) failureException;
			// display comparison view
			displayComparisonView(cf, desc);
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:XpectCompareCommandHandler.java

示例2: getProjects

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
public static List<IProject> getProjects(ExecutionEvent event) throws ExecutionException {
  List<IProject> projects = new ArrayList<>();

  ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
  if (selection instanceof IStructuredSelection) {
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    for (Object selected : structuredSelection.toList()) {
      IProject project = AdapterUtil.adapt(selected, IProject.class);
      if (project != null) {
        projects.add(project);
      }
    }
  }

  return projects;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:17,代码来源:ProjectFromSelectionHelper.java

示例3: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException
{
    /*
     * Try to get the spec from active navigator if any
     */
    ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
    if (selection != null && selection instanceof IStructuredSelection
            && ((IStructuredSelection) selection).size() == 1)
    {
        Object selected = ((IStructuredSelection) selection).getFirstElement();
        if (selected instanceof Model)
        {
            Map<String, String> parameters = new HashMap<String, String>();

            // fill the model name for the handler
            parameters.put(OpenModelHandler.PARAM_MODEL_NAME, ((Model) selected).getName());
            // delegate the call to the open model handler
            UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters);
        }
    }
    return null;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:23,代码来源:OpenModelHandlerDelegate.java

示例4: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
	/*
	 * Try to get the spec from active navigator if any
	 */
	final ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection != null && selection instanceof IStructuredSelection
			&& ((IStructuredSelection) selection).size() == 1) {
		Object selected = ((IStructuredSelection) selection).getFirstElement();
		if (selected instanceof ModelContentProvider.Group) {
			// Convert the group to its corresponding spec
			selected = ((Group) selected).getSpec();
		}

		if (selected instanceof Spec) {
			final Map<String, String> parameters = new HashMap<String, String>();
			// fill the spec name for the handler
			parameters.put(NewModelHandler.PARAM_SPEC_NAME, ((Spec) selected).getName());
			// delegate the call to the new model handler
			UIHelper.runCommand(NewModelHandler.COMMAND_ID, parameters);
		}
	}
	return null;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:24,代码来源:NewModelHandlerSelectedDelegate.java

示例5: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	final ISelection selection = HandlerUtil
			.getCurrentSelectionChecked(event);
	try {
		breakpointUtils.toggleBreakpoints(selection);
	} catch (CoreException e) {
		throw new ExecutionException("Error while toggling breakpoint.", e);
	}

	return null;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:17,代码来源:GemocToggleBreakpointHandler.java

示例6: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	final ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	try {
		breakpointUtils.toggleBreakpoints(selection);
	} catch (CoreException e) {
		throw new ExecutionException("Error while toggling breakpoint.", e);
	}

	return null;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:16,代码来源:AbstractToggleBreakpointHandler.java

示例7: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
/**
 * When called will check if provided data contains {@link Description test description} with failed status stored
 * in {@link N4IDEXpectView test view}. If that holds, will generate data for bug report in a console view,
 * otherwise will show message to reconfigure and rerun Xpect tests.
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);

	IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
	try {
		view = (N4IDEXpectView) windows[0].getActivePage().showView(
				N4IDEXpectView.ID);
	} catch (PartInitException e) {
		N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
	}

	Description desc = (Description) selection.getFirstElement();

	// handle failed suite
	if (desc.isSuite()) {
		final N4IDEXpectView finalview = view;

		boolean suitePassed = desc.getChildren().stream()
				.noneMatch(childDescription -> finalview.testsExecutionStatus.hasFailed(childDescription));

		if (suitePassed) {
			XpectFileContentsUtil.getXpectFileContentAccess(desc).ifPresent(
					xpectFielContentAccess -> {
						if (xpectFielContentAccess.containsFixme()) {
							generateAndDisplayReport(
									N4IDEXpectFileNameUtil.getSuiteName(desc),
									xpectFielContentAccess.getContetns());
						}
					});

		} else {
			XpectConsole console = ConsoleDisplayMgr.getOrCreate("generated bug for "
					+ N4IDEXpectFileNameUtil.getSuiteName(desc));
			console.clear();
			String ls = System.lineSeparator();
			console.log("Suite must be passing and contain XPECT FIXME marker to be submited bug report. Please :"
					+ ls + " - fix failing tests" + ls + " - mark test in question with XPECT FIXME");
		}
	}

	return null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:50,代码来源:GenerateXpectReportCommandHandler.java

示例8: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException
 {
     final ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
     if (selection != null && selection instanceof IStructuredSelection)
     {
         // model file
         final Model model = (Model) ((IStructuredSelection) selection).getFirstElement();

         // a) fail if model is in use
if (model.isRunning()) {
	MessageDialog.openError(UIHelper.getShellProvider().getShell(), "Could not rename models",
			"Could not rename the model " + model.getName()
					+ ", because it is being model checked.");
	return null;
}
if (model.isSnapshot()) {
	MessageDialog.openError(UIHelper.getShellProvider().getShell(), "Could not rename model",
			"Could not rename the model " + model.getName()
					+ ", because it is a snapshot.");
	return null;
}

         // b) open dialog prompting for new model name
         final IInputValidator modelNameInputValidator = new ModelNameValidator(model.getSpec());
         final InputDialog dialog = new InputDialog(UIHelper.getShell(), "Rename model...",
                 "Please input the new name of the model", model.getName(), modelNameInputValidator);
         dialog.setBlockOnOpen(true);
         if(dialog.open() == Window.OK) {
         	// c) close model editor if open
             final IEditorPart editor = model.getAdapter(ModelEditor.class);
             if(editor != null) {
             	reopenModelEditorAfterRename = true;
             	UIHelper.getActivePage().closeEditor(editor, true);
             }
             
             final Job j = new ToolboxJob("Renaming model...") {
		/* (non-Javadoc)
		 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
		 */
		protected IStatus run(IProgressMonitor monitor) {
			// d) rename
			final String newModelName = dialog.getValue();
			model.rename(newModelName);

			// e) reopen (in UI thread)
            if (reopenModelEditorAfterRename) {
	            UIHelper.runUIAsync(new Runnable(){
					/* (non-Javadoc)
					 * @see java.lang.Runnable#run()
					 */
					public void run() {
						Map<String, String> parameters = new HashMap<String, String>();
						parameters.put(OpenModelHandler.PARAM_MODEL_NAME, newModelName);
						UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters);
					}
	            });
            }
			return Status.OK_STATUS;
		}
	};
	j.schedule();
         }
     }
     return null;
 }
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:66,代码来源:RenameModelHandlerDelegate.java

示例9: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
/**
 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	final TLCSpec spec = ToolboxHandle.getCurrentSpec().getAdapter(TLCSpec.class);
	
	Model model = null;
	/*
	 * First try to get the model from the parameters. It is an optional
	 * parameter, so it may not have been set.
	 */
	final String paramModelName = (String) event.getParameter(PARAM_MODEL_NAME);
	if (paramModelName != null) {
		// The name is given which means the user clicked the main menu
		// instead of the spec explorer. Under the constraint that only ever
		// a single spec can be open, lookup the current spec to eventually
		// get the corresponding model.
		model = spec.getModel(paramModelName);
	} else {
		/*
		 * No parameter try to get it from active navigator if any
		 */
		final ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
		if (selection != null && selection instanceof IStructuredSelection) {
			// model
			model = (Model) ((IStructuredSelection) selection).getFirstElement();
		}
	}

	if (model != null) {
		final InputDialog dialog = new InputDialog(UIHelper.getShellProvider().getShell(), "Clone model...",
				"Please input the new name of the model", spec.getModelNameSuggestion(model), new ModelNameValidator(spec));
		dialog.setBlockOnOpen(true);
		if (dialog.open() == Window.OK) {
			final String usersChosenName = dialog.getValue();
			if (model.copy(usersChosenName) == null) {
				throw new ExecutionException(
						"Failed to copy with name " + usersChosenName + " from model " + model.getName());
			}

			// Open the previously created model
			final Map<String, String> parameters = new HashMap<String, String>();
			parameters.put(OpenModelHandler.PARAM_MODEL_NAME, usersChosenName);
			UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters);
		}
	}
	return null;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:49,代码来源:CloneModelHandlerDelegate.java


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