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


Java Command类代码示例

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


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

示例1: hookToCommands

import org.eclipse.core.commands.Command; //导入依赖的package包/类
private void hookToCommands(final ToolItem lastEdit, final ToolItem nextEdit) {
	final UIJob job = new UIJob("Hooking to commands") {

		@Override
		public IStatus runInUIThread(final IProgressMonitor monitor) {
			final ICommandService service = WorkbenchHelper.getService(ICommandService.class);
			final Command nextCommand = service.getCommand(IWorkbenchCommandConstants.NAVIGATE_FORWARD_HISTORY);
			nextEdit.setEnabled(nextCommand.isEnabled());
			final ICommandListener nextListener = e -> nextEdit.setEnabled(nextCommand.isEnabled());

			nextCommand.addCommandListener(nextListener);
			final Command lastCommand = service.getCommand(IWorkbenchCommandConstants.NAVIGATE_BACKWARD_HISTORY);
			final ICommandListener lastListener = e -> lastEdit.setEnabled(lastCommand.isEnabled());
			lastEdit.setEnabled(lastCommand.isEnabled());
			lastCommand.addCommandListener(lastListener);
			// Attaching dispose listeners to the toolItems so that they remove the
			// command listeners properly
			lastEdit.addDisposeListener(e -> lastCommand.removeCommandListener(lastListener));
			nextEdit.addDisposeListener(e -> nextCommand.removeCommandListener(nextListener));
			return Status.OK_STATUS;
		}
	};
	job.schedule();

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

示例2: getLabel

import org.eclipse.core.commands.Command; //导入依赖的package包/类
@Override
public String getLabel() {
	final StringBuilder label = new StringBuilder();

	try {
		Command command = parameterizedCommand.getCommand();
		label.append(parameterizedCommand.getName());
		if (command.getDescription() != null && command.getDescription().length() != 0) {
			label.append(separator).append(command.getDescription());
		}
	} catch (NotDefinedException e) {
		label.append(parameterizedCommand.getId());
	}

	return label.toString();
}
 
开发者ID:dakaraphi,项目名称:eclipse-plugin-commander,代码行数:17,代码来源:CommandElement.java

示例3: createContents

import org.eclipse.core.commands.Command; //导入依赖的package包/类
@PostConstruct
public Control createContents(Composite parent, NLPService nlpService, ECommandService commandService, EHandlerService handlerService) {
	l = new Label(parent, SWT.None);
	int size = 0;
	updateSize(nlpService);
	Button b = new Button(parent, SWT.PUSH);
	b.setImage(TermSuiteUI.getImg(TermSuiteUI.IMG_CLEAR_CO).createImage());
	b.setSize(50, -1);
	b.setToolTipText("Clear all preprocessed corpus save in cache");
	b.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			Command command = commandService.getCommand(TermSuiteUI.COMMAND_CLEAR_CACHE_ID);
		    ParameterizedCommand pCmd = new ParameterizedCommand(command, null);
		    if (handlerService.canExecute(pCmd)) 
		    	handlerService.executeHandler(pCmd);
		}
	});
	return parent;
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:21,代码来源:WorskpaceSizeControl.java

示例4: execute

import org.eclipse.core.commands.Command; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {

    final IWorkbenchSite site = HandlerUtil.getActiveSite(event);
    final ICommandService cs = (ICommandService) site
        .getService(ICommandService.class);
    final IHandlerService hs = (IHandlerService) site
        .getService(IHandlerService.class);
    final Command command = cs
        .getCommand(IWorkbenchCommandConstants.FILE_IMPORT);

    try {
      hs.executeCommand(ParameterizedCommand.generateCommand(command,
          Collections.singletonMap(
              IWorkbenchCommandConstants.FILE_IMPORT_PARM_WIZARDID,
              SessionImportWizard.ID)),
          null);
    } catch (CommandException e) {
      EclEmmaUIPlugin.log(e);
    }

    return null;
  }
 
开发者ID:eclipse,项目名称:eclemma,代码行数:23,代码来源:ImportSessionHandler.java

示例5: execute

import org.eclipse.core.commands.Command; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {

    final IWorkbenchSite site = HandlerUtil.getActiveSite(event);
    final ICommandService cs = (ICommandService) site
        .getService(ICommandService.class);
    final IHandlerService hs = (IHandlerService) site
        .getService(IHandlerService.class);
    final Command command = cs
        .getCommand(IWorkbenchCommandConstants.FILE_EXPORT);

    try {
      hs.executeCommand(ParameterizedCommand.generateCommand(command,
          Collections.singletonMap(
              IWorkbenchCommandConstants.FILE_EXPORT_PARM_WIZARDID,
              SessionExportWizard.ID)),
          null);
    } catch (CommandException e) {
      EclEmmaUIPlugin.log(e);
    }

    return null;
  }
 
开发者ID:eclipse,项目名称:eclemma,代码行数:23,代码来源:ExportSessionHandler.java

示例6: performDrop

import org.eclipse.core.commands.Command; //导入依赖的package包/类
@Override
public boolean performDrop(Object data) {
    IServiceLocator locator = Helper.getWB();
    ICommandService svc = (ICommandService)locator.getService(
            ICommandService.class);
    Command cmd = svc.getCommand(CMD_ID_MOVE_ENTRY);

    Map<String, String> params = new HashMap<>();

    params.put("source", data.toString());

    TreeNode en = (TreeNode)getCurrentTarget();
    EntryData ed = EntryData.of(en);
    params.put("target", String.valueOf(ed.entryID()));

    try {
        cmd.executeWithChecks(
        		new ExecutionEvent(cmd, params, getCurrentEvent(), null));
    } catch (ExecutionException | NotDefinedException | NotEnabledException
            | NotHandledException e) {
        throw new RuntimeException(e);
    }
    return true;
}
 
开发者ID:insweat,项目名称:hssd,代码行数:25,代码来源:DropEntryHandler.java

示例7: execute

import org.eclipse.core.commands.Command; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ViewEditor viewer = getViewEditor(event);

  Command command = event.getCommand();
  String optionId = command.getId();

  // For now, simply flip this one state.
  String value = viewer.getOption(optionId);
  if (Strings.isNullOrEmpty(value)) {
    value = StatsViewExtension.SHAPE_DEGREE_MODE_ID.getLabel();
  } else {
    value = null;
  }

  viewer.setOption(optionId, value);
  return null;
}
 
开发者ID:google,项目名称:depan,代码行数:19,代码来源:StatsShapeOptionHandler.java

示例8: execute

import org.eclipse.core.commands.Command; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ViewEditor viewer = getViewEditor(event);

  Command command = event.getCommand();
  String optionId = command.getId();

  // For now, simply flip this one state.
  String value = viewer.getOption(optionId);
  if (Strings.isNullOrEmpty(value)) {
    value = StatsViewExtension.COLOR_ROOT_MODE_ID.getLabel();
  } else {
    value = null;
  }

  viewer.setOption(optionId, value);
  return null;
}
 
开发者ID:google,项目名称:depan,代码行数:19,代码来源:StatsRootOptionHandler.java

示例9: execute

import org.eclipse.core.commands.Command; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ViewEditor viewer = getViewEditor(event);

  Command command = event.getCommand();
  String optionId = command.getId();

  // For now, simply flip this one state.
  String value = viewer.getOption(optionId);
  if (Strings.isNullOrEmpty(value)) {
    value = StatsViewExtension.RATIO_DEGREE_MODE_ID.getLabel();
  } else {
    value = null;
  }

  viewer.setOption(optionId, value);
  return null;
}
 
开发者ID:google,项目名称:depan,代码行数:19,代码来源:StatsRatioOptionHandler.java

示例10: execute

import org.eclipse.core.commands.Command; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ViewEditor viewer = getViewEditor(event);

  Command command = event.getCommand();
  String optionId = command.getId();

  // For now, simply flip this one state.
  String value = viewer.getOption(optionId);
  if (Strings.isNullOrEmpty(value)) {
    value = StatsViewExtension.SIZE_DEGREE_MODE_ID.getLabel();
  } else {
    value = null;
  }

  viewer.setOption(optionId, value);
  return null;
}
 
开发者ID:google,项目名称:depan,代码行数:19,代码来源:StatsSizeOptionHandler.java

示例11: isElogAvailable

import org.eclipse.core.commands.Command; //导入依赖的package包/类
public static boolean isElogAvailable() {
    try {
        if (LogbookClientManager.getLogbookClientFactory() == null)
            return false;

        // Check if logbook dialog is available
        ICommandService commandService = PlatformUI
                .getWorkbench().getActiveWorkbenchWindow()
                .getService(ICommandService.class);
        Command command = commandService
                .getCommand(OPEN_LOGENTRY_BUILDER_DIALOG_ID);
        if (command == null) {
            return false;
        }

        return true;
    } catch (Exception e) {
        return false;
    }
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:21,代码来源:SendToElogAction.java

示例12: executeCommand

import org.eclipse.core.commands.Command; //导入依赖的package包/类
private static void executeCommand(IWorkbench workbench, String commandName, Map<String, Object> params) {
    if (workbench == null) {
        workbench = PlatformUI.getWorkbench();
    }
    // get command
    ICommandService commandService = (ICommandService)workbench.getService(ICommandService.class);
    Command command = commandService != null ? commandService.getCommand(commandName) : null;
    // get handler service
    //IBindingService bindingService = (IBindingService)workbench.getService(IBindingService.class);
    //TriggerSequence[] triggerSequenceArray = bindingService.getActiveBindingsFor("de.anbos.eclipse.easyshell.plugin.commands.open");
    IHandlerService handlerService = (IHandlerService)workbench.getService(IHandlerService.class);
    if (command != null && handlerService != null) {
        ParameterizedCommand paramCommand = ParameterizedCommand.generateCommand(command, params);
        try {
            handlerService.executeCommand(paramCommand, null);
        } catch (Exception e) {
            Activator.logError(Activator.getResourceString("easyshell.message.error.handlerservice.execution"), paramCommand.toString(), e, true);
        }
    }
}
 
开发者ID:anb0s,项目名称:EasyShell,代码行数:21,代码来源:Utils.java

示例13: setEnabled

import org.eclipse.core.commands.Command; //导入依赖的package包/类
@Override
public void setEnabled(final Object evaluationContext) {

	super.setEnabled(evaluationContext);

	if (_isAppPhotoFilterInitialized == false) {

		_isAppPhotoFilterInitialized = true;

		/*
		 * initialize app photo filter, this is a hack because the whole app startup should be
		 * sometimes be streamlined, it's more and more confusing
		 */
		final Command command = ((ICommandService) PlatformUI//
				.getWorkbench()
				.getService(ICommandService.class))//
				.getCommand(ActionHandlerPhotoFilter.COMMAND_ID);

		final State state = command.getState(RegistryToggleState.STATE_ID);
		final Boolean isPhotoFilterActive = (Boolean) state.getValue();

		TourbookPlugin.setActivePhotoFilter(isPhotoFilterActive);
	}
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:25,代码来源:ActionHandlerPhotoFilter.java

示例14: execute

import org.eclipse.core.commands.Command; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Command command = event.getCommand();
	ISelection selection = HandlerUtil.getCurrentSelection(event);
	Set<? extends EPlanElement> elements = PlanEditorUtil.emfFromSelection(selection);
	final IUndoableOperation op;
	boolean state = getCommandState(command);
	if (state) {
		op = new UnpinOperation(elements);
	} else {
		op = new PinOperation(elements);
	}
	CommonUtils.execute(op, getUndoContext());
	setCommandState(command, !state);
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:PinHandler.java

示例15: execute

import org.eclipse.core.commands.Command; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Command command = event.getCommand();
	ISelection selection = HandlerUtil.getCurrentSelection(event);
	Set<EPlanElement> allElements = PlanEditorUtil.emfFromSelection(selection);
	List<EPlanElement> elements = EPlanUtils.getConsolidatedPlanElements(allElements);
	boolean state = getCommandState(command);
	IEditorPart editor = getActiveEditor();
	final IUndoableOperation op;
	if (state) {
		op = new UnchainOperation(elements);
	} else {
		PlanStructureModifier modifier = PlanStructureModifier.INSTANCE;
		List<EPlanChild> children = CommonUtils.castList(EPlanChild.class, elements);
		op = new ChainOperation(modifier, children, true);
	}
	WidgetUtils.execute(op, getUndoContext(), null, editor.getSite());
	setCommandState(command, !state);
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:21,代码来源:ChainHandler.java


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