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