本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
});
}
}
示例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());
}
});
}
}
示例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();
}
示例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);
}
}
示例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));
}
示例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);
}
}
示例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());
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
}
}