當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。