本文整理汇总了Java中org.eclipse.core.commands.State.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java State.setValue方法的具体用法?Java State.setValue怎么用?Java State.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.commands.State
的用法示例。
在下文中一共展示了State.setValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateElement
import org.eclipse.core.commands.State; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void updateElement(UIElement element, Map parameters) {
Activator activator = Activator.getDefault();
if (activator.getSelectedProjects().size() == 1) {
IProject project = activator.getSelectedProjects().iterator().next();
String projectName = project.getName();
boolean enabled = SpotterProjectSupport.isExpertViewEnabled(projectName);
State state = getCommandState(null);
state.setValue(Boolean.valueOf(enabled));
String label = (enabled ? "Disable" : "Enable") + " Expert View";
element.setText(label);
}
}
示例2: toggleButtonOff
import org.eclipse.core.commands.State; //导入方法依赖的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);
}
});
}
}
示例3: execute
import org.eclipse.core.commands.State; //导入方法依赖的package包/类
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);
// trigger element update
executeToggle(event, newState);
commandService.refreshElements(event.getCommand().getId(), null);
// return value is reserved for future apis
return null;
}
示例4: execute
import org.eclipse.core.commands.State; //导入方法依赖的package包/类
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);
// trigger element update
executeToggle(event, newState);
commandService.refreshElements(event.getCommand().getId(), null);
// return value is reserved for future apis
return null;
}
示例5: setToggleCommandState
import org.eclipse.core.commands.State; //导入方法依赖的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));
}
示例6: setCommandState
import org.eclipse.core.commands.State; //导入方法依赖的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);
}
}
示例7: setEnabled
import org.eclipse.core.commands.State; //导入方法依赖的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());
}
}
示例8: changeButtonState
import org.eclipse.core.commands.State; //导入方法依赖的package包/类
public void changeButtonState(Boolean value) {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = service.getCommand(ZoomSweepToolHandler.COMMAND_ID);
State state = command.getState(ZoomSweepToolHandler.ZOOM_SWEEP_TOOGLE_STATE);
state.setValue(value);
}
示例9: saveCurrentState
import org.eclipse.core.commands.State; //导入方法依赖的package包/类
private void saveCurrentState(SelectInProgress selectInProgress) {
State state = new State();
state.setValue(selectInProgress);
state.setId(ID_SELECTS_IN_PROGRESS);
addState(ID_SELECTS_IN_PROGRESS, state);
}