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


Java Command.getState方法代码示例

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


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

示例1: 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

示例2: test

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
public boolean test(final Object receiver, final String property,
		final Object[] args, final Object expectedValue) {
	if (receiver instanceof IServiceLocator && args.length == 1
			&& args[0] instanceof String) {
		final IServiceLocator locator = (IServiceLocator) receiver;
		if (TOGGLE_PROPERTY_NAME.equals(property)) {
			final String commandId = args[0].toString();
			final ICommandService commandService = (ICommandService) locator
					.getService(ICommandService.class);
			final Command command = commandService.getCommand(commandId);
			final State state = command
					.getState(RegistryToggleState.STATE_ID);
			if (state != null) {
				return state.getValue().equals(expectedValue);
			}
		}
	}
	return false;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:20,代码来源:CommandsPropertyTester.java

示例3: getCommandState

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
/**
 * Retrieves the toggle state of the command.
 * 
 * @param expertViewCommand
 *            the command or <code>null</code> to manually try to lookup the
 *            command
 * 
 * @return the toggle state of the command
 */
private State getCommandState(Command expertViewCommand) {
	Command command = expertViewCommand;

	if (command == null && commandService != null) {
		command = commandService.getCommand(EXPERT_VIEW_COMMAND_ID);
	}

	if (command == null) {
		throw new RuntimeException("Unable to retrieve command " + EXPERT_VIEW_COMMAND_ID);
	}

	State state = command.getState(TOGGLE_STATE_ID);

	if (state == null) {
		throw new RuntimeException("Unable to retrieve state " + TOGGLE_STATE_ID + " from command "
				+ EXPERT_VIEW_COMMAND_ID);
	}

	return state;
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:30,代码来源:ExpertViewHandler.java

示例4: toggleButtonOff

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
private void toggleButtonOff(){
	ICommandService commandService =
		(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
	Command toggleCommand = commandService.getCommand(COMMAND_ID);
	
	State state = toggleCommand.getState("STYLE");
	boolean currentState = (Boolean) state.getValue();
	if (currentState) {
		// turn it off
		state.setValue(!currentState);
		UiDesk.getDisplay().syncExec(new Runnable() {
			
			public void run(){
				commandService.refreshElements(toggleCommand.getId(), null);
			}
		});
	}
}
 
开发者ID:elexis,项目名称:elexis-3-base,代码行数:19,代码来源:InputHandler.java

示例5: updateElement

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
@Override
public void updateElement(final UIElement element, Map parameters){
	ICommandService commandService =
		(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
	Command command = commandService.getCommand(ID);
	final State state = command.getState(IMenuStateIds.STYLE);
	if (state != null) {
		PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
			@Override
			public void run(){
				element.setChecked((Boolean) state.getValue());
			}
		});
		
	}
	
}
 
开发者ID:elexis,项目名称:elexis-3-base,代码行数:18,代码来源:ServerControl.java

示例6: createGraphLayout

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected DirectedGraphLayout createGraphLayout() {

    // gets target command menu.
    ICommandService commandService =
            (ICommandService) PlatformUI.getWorkbench()
                .getService(ICommandService.class);
    Command radioCommand = commandService.getCommand(CONST_ARRANGE_ANGLE_COMMAND);

    // gets current arrange direction state.
    State state = radioCommand.getState(CONST_RADIO_COMMAND_STATE);
    String currentState = state.getValue().toString();

    // sets command state to angle instance.
    if (currentState.equals(CONST_HORIZONTAL_VALUE)) {
        ArrangeAngle.createInstance().setAngle(ArrangeAngle.Direction.Horizontal);
    } else {
        ArrangeAngle.createInstance().setAngle(ArrangeAngle.Direction.Vertical);
    }

    return new DcaseDirectedGraphLayout();
}
 
开发者ID:d-case,项目名称:d-case_editor,代码行数:26,代码来源:DcaseLayoutProvider.java

示例7: updateElement

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
@Override
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
    ICommandService service = (ICommandService) element.getServiceLocator().getService(ICommandService.class);
    String state = (String) parameters.get(RadioState.PARAMETER_ID);
    Command command = service.getCommand(SwitchProcessorCompoundContributionItem.SWITCH_PROCESSOR_COMMAND);
    State commandState = command.getState(RadioState.STATE_ID);
    if (commandState.getValue().equals(state)) {
        element.setChecked(true);
    }
}
 
开发者ID:yamcs,项目名称:yamcs-studio,代码行数:11,代码来源:SwitchProcessorHandler.java

示例8: setToggleCommandState

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
public static void setToggleCommandState(String commandId, String stateId, boolean stateValue) throws ExecutionException
{
	ICommandService svc = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
	Command command = svc.getCommand(commandId);
	State state = command.getState("org.eclipse.ui.commands.toggleState");
	if (state == null)
		throw new ExecutionException("The command does not have a toggle state"); //$NON-NLS-1$
	if (!(state.getValue() instanceof Boolean))
		throw new ExecutionException("The command's toggle state doesn't contain a boolean value"); //$NON-NLS-1$
	state.setValue(new Boolean(stateValue));
}
 
开发者ID:Spacecraft-Code,项目名称:SPELL,代码行数:12,代码来源:CommandHelper.java

示例9: setCommandState

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
private void setCommandState(boolean state)
{
	ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
	Command command = service.getCommand(COMMAND_ID);
	State commandState = command.getState(COMMAND_STATE);
	if (((Boolean) commandState.getValue()) != state)
	{
		commandState.setValue(state);
		service.refreshElements(COMMAND_ID, null);
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:12,代码来源:CommonEditorPlugin.java

示例10: setEnabled

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
@Override
public void setEnabled(Object evaluationContext)
{
	Object activeSite = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_SITE_NAME);
	Object activeEditor = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_EDITOR_NAME);
	if (activeSite instanceof IWorkbenchSite && activeEditor instanceof AbstractThemeableEditor)
	{
		ICommandService commandService = (ICommandService) ((IWorkbenchSite) activeSite)
				.getService(ICommandService.class);
		Command command = commandService.getCommand(COMMAND_ID);
		State state = command.getState(RegistryToggleState.STATE_ID);
		state.setValue(((AbstractThemeableEditor) activeEditor).getWordWrapEnabled());
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:15,代码来源:ToggleWordWrapHandler.java

示例11: selectionChanged

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
protected void selectionChanged(ISelection selection) {
	boolean enabled = isEnabledForSelection(selection);
	setBaseEnabled(enabled);
	Command command = getCommand();
	State state = command.getState(RegistryToggleState.STATE_ID);
	if (state != null) {
		boolean checked = isCheckedForSelection(selection);
		try {
			setCommandState(command, checked);
		} catch (ExecutionException e) {
			LogUtil.error(e);
		}
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:15,代码来源:AbstractPlanEditorHandler.java

示例12: getCommandState

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
protected static boolean getCommandState(Command command) {
	State toggleState = command.getState(RegistryToggleState.STATE_ID);
	if (toggleState != null) {
		Object value = toggleState.getValue();
		if (CommonUtils.equals(Boolean.TRUE, value)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:11,代码来源:AbstractPlanEditorHandler.java

示例13: setCommandState

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
protected static void setCommandState(Command command, boolean newValue) throws ExecutionException {
	State state = command.getState(RegistryToggleState.STATE_ID);
	if(state == null)
		throw new ExecutionException("The command does not have a toggle state"); //$NON-NLS-1$
	 if(!(state.getValue() instanceof Boolean))
		throw new ExecutionException("The command's toggle state doesn't contain a boolean value"); //$NON-NLS-1$
	boolean oldValue = ((Boolean) state.getValue()).booleanValue();
	if (oldValue != newValue) {
		HandlerUtil.toggleCommandState(command);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:12,代码来源:AbstractPlanEditorHandler.java

示例14: getSelectedComparator

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
public static ViewerSortOrder getSelectedComparator(){
	ICommandService service =
		(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
	Command command = service.getCommand(ApplyCustomSortingHandler.CMD_ID);
	State state = command.getState(ApplyCustomSortingHandler.STATE_ID);
	
	if ((Boolean) state.getValue()) {
		return ViewerSortOrder.getSortOrderPerValue(ViewerSortOrder.MANUAL.val);
	} else {
		return ViewerSortOrder.getSortOrderPerValue(ViewerSortOrder.DEFAULT.val);
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:13,代码来源:MedicationViewHelper.java

示例15: SorterAdapter

import org.eclipse.core.commands.Command; //导入方法依赖的package包/类
public SorterAdapter(ExecutionEvent event){
	ICommandService commandService = (ICommandService) HandlerUtil.getActiveSite(event)
		.getService(ICommandService.class);
	if (commandService != null) {
		Command command = commandService.getCommand(ApplyCustomSortingHandler.CMD_ID);
		State state = command.getState(ApplyCustomSortingHandler.STATE_ID);
		if (state.getValue() instanceof Boolean) {
			if ((Boolean) state.getValue()) {
				mode = SorterAdapter.CompareMode.MANUAL;
			}
		}
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:14,代码来源:PrintTakingsListHandler.java


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