List of usage examples for org.eclipse.jface.menus IMenuStateIds STYLE
String STYLE
To view the source code for org.eclipse.jface.menus IMenuStateIds STYLE.
Click Source Link
From source file:ch.elexis.barcode.scanner.internal.ToggleHandler.java
License:Open Source License
public final Object execute(ExecutionEvent event) throws ExecutionException { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); // update toggled state State state = event.getCommand().getState(IMenuStateIds.STYLE); if (state == null) throw new ExecutionException( "You need to declare a ToggleState with id=STYLE for your command to use ToggleHandler!"); boolean currentState = (Boolean) state.getValue(); boolean newState = !currentState; state.setValue(newState);// www . j a v a 2 s . c o m // trigger element update executeToggle(event, newState); commandService.refreshElements(event.getCommand().getId(), null); // return value is reserved for future apis return null; }
From source file:ch.elexis.barcode.scanner.internal.ToggleHandler.java
License:Open Source License
/** * Update command element with toggle state *//*w w w . j av a2s. c om*/ public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); Command command = commandService.getCommand(COMMAND_ID); State state = command.getState(IMenuStateIds.STYLE); if (state != null) element.setChecked((Boolean) state.getValue()); }
From source file:com.google.dart.tools.debug.ui.launch.ToggleBreakOnExceptionsHandler.java
License:Open Source License
@Override public final Object execute(ExecutionEvent event) throws ExecutionException { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); State state = event.getCommand().getState(IMenuStateIds.STYLE); if (state == null) { throw new ExecutionException("declare a ToggleState with id=STYLE"); }/*from w ww . ja v a 2 s . c om*/ boolean value = !DartDebugCorePlugin.getPlugin().getBreakOnExceptions(); state.setValue(value); executeToggle(event, value); commandService.refreshElements(event.getCommand().getId(), null); return null; }
From source file:de.ralfebert.rcputils.handler.ToggleHandler.java
License:Open Source License
public final Object execute(ExecutionEvent event) throws ExecutionException { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); this.commandId = event.getCommand().getId(); // update toggled state State state = event.getCommand().getState(IMenuStateIds.STYLE); if (state == null) throw new ExecutionException( "You need to declare a ToggleState with id=STYLE for your command to use ToggleHandler!"); boolean currentState = (Boolean) state.getValue(); boolean newState = !currentState; state.setValue(newState);/*from w ww . j av a 2 s .c om*/ // trigger element update executeToggle(event, newState); commandService.refreshElements(event.getCommand().getId(), null); // return value is reserved for future apis return null; }
From source file:de.ralfebert.rcputils.handler.ToggleHandler.java
License:Open Source License
/** * Update command element with toggle state *//*from ww w . ja v a2s .c om*/ public void updateElement(UIElement element, Map parameters) { if (this.commandId != null) { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); Command command = commandService.getCommand(commandId); State state = command.getState(IMenuStateIds.STYLE); if (state != null) element.setChecked((Boolean) state.getValue()); } }
From source file:net.yatomiya.e4.ui.workbench.renderers.swt.HandledContributionItem.java
License:Open Source License
/** * *///from ww w.j a va 2s . c om private void generateCommand() { if (getModel().getCommand() != null && getModel().getWbCommand() == null) { String cmdId = getModel().getCommand().getElementId(); if (cmdId == null) { Activator.log(IStatus.ERROR, "Unable to generate parameterized command for " + getModel() //$NON-NLS-1$ + ". ElementId is not allowed to be null."); //$NON-NLS-1$ return; } List<MParameter> modelParms = getModel().getParameters(); Map<String, Object> parameters = new HashMap<>(4); for (MParameter mParm : modelParms) { parameters.put(mParm.getName(), mParm.getValue()); } ParameterizedCommand parmCmd = commandService.createCommand(cmdId, parameters); Activator.trace(Policy.DEBUG_MENUS, "command: " + parmCmd, null); //$NON-NLS-1$ if (parmCmd == null) { Activator.log(IStatus.ERROR, "Unable to generate parameterized command for " + getModel() //$NON-NLS-1$ + " with " + parameters); //$NON-NLS-1$ return; } getModel().setWbCommand(parmCmd); styleState = parmCmd.getCommand().getState(IMenuStateIds.STYLE); toggleState = parmCmd.getCommand().getState(ORG_ECLIPSE_UI_COMMANDS_TOGGLE_STATE); radioState = parmCmd.getCommand().getState(ORG_ECLIPSE_UI_COMMANDS_RADIO_STATE); updateState(); if (styleState != null) { styleState.addListener(stateListener); } else if (toggleState != null) { toggleState.addListener(stateListener); } else if (radioState != null) { radioState.addListener(stateListener); } } }
From source file:org.dafoe.terminologiclevel.saillance.commands.FilterRegularExpression.java
License:Open Source License
@Override // checked => new state protected void executeToggle(ExecutionEvent event, boolean checked) { SaillanceViewPart viewPart;// w w w . j a va 2 s .c om viewPart = (SaillanceViewPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .findView(SaillanceViewPart.ID); if (checked) { FilterRegularExpressionDialog dial = new FilterRegularExpressionDialog( HandlerUtil.getActivePart(event).getSite().getShell(), viewPart); int res = dial.open(); if (res == Dialog.CANCEL) { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); State state = event.getCommand().getState(IMenuStateIds.STYLE); state.setValue(false); executeToggle(event, false); commandService.refreshElements(event.getCommand().getId(), null); } } else { viewPart.removeRegularExpressionFilter(); } }
From source file:org.dafoe.terminologiclevel.saillance.commands.ToggleHandler.java
License:Open Source License
public final Object execute(ExecutionEvent event) throws ExecutionException { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); this.commandId = event.getCommand().getId(); // update toggled state State state = event.getCommand().getState(IMenuStateIds.STYLE); if (state == null) throw new ExecutionException( "You need to declare a ToggleState with id=STYLE for your command to use ToggleHandler!"); //$NON-NLS-1$ boolean currentState = (Boolean) state.getValue(); boolean newState = !currentState; state.setValue(newState);/*from w w w . java2s . co m*/ // trigger element update executeToggle(event, newState); commandService.refreshElements(event.getCommand().getId(), null); // return value is reserved for future apis return null; }
From source file:org.dafoe.terminologiclevel.saillance.commands.ToggleHandler.java
License:Open Source License
/** * Update command element with toggle state *//*w w w.jav a 2s . co m*/ @SuppressWarnings("unchecked") public void updateElement(UIElement element, Map parameters) { if (this.commandId != null) { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench() .getService(ICommandService.class); Command command = commandService.getCommand(commandId); State state = command.getState(IMenuStateIds.STYLE); if (state != null) element.setChecked((Boolean) state.getValue()); } }
From source file:org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.java
License:Open Source License
/** * /* w w w. j a va 2 s .c om*/ */ private void generateCommand() { if (model.getCommand() != null && model.getWbCommand() == null) { String cmdId = model.getCommand().getElementId(); List<MParameter> modelParms = model.getParameters(); Map<String, String> parameters = new HashMap<String, String>(4); for (MParameter mParm : modelParms) { parameters.put(mParm.getName(), mParm.getValue()); } ParameterizedCommand parmCmd = commandService.createCommand(cmdId, parameters); Activator.trace(Policy.DEBUG_MENUS, "command: " + parmCmd, null); //$NON-NLS-1$ model.setWbCommand(parmCmd); styleState = parmCmd.getCommand().getState(IMenuStateIds.STYLE); toggleState = parmCmd.getCommand().getState(ORG_ECLIPSE_UI_COMMANDS_TOGGLE_STATE); radioState = parmCmd.getCommand().getState(ORG_ECLIPSE_UI_COMMANDS_RADIO_STATE); updateState(); if (styleState != null) { styleState.addListener(stateListener); } else if (toggleState != null) { toggleState.addListener(stateListener); } else if (radioState != null) { radioState.addListener(stateListener); } } }