本文整理汇总了Java中org.eclipse.core.commands.State.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java State.getValue方法的具体用法?Java State.getValue怎么用?Java State.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.commands.State
的用法示例。
在下文中一共展示了State.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setEnabled
import org.eclipse.core.commands.State; //导入方法依赖的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: 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: getCommandState
import org.eclipse.core.commands.State; //导入方法依赖的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;
}
示例8: setCommandState
import org.eclipse.core.commands.State; //导入方法依赖的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);
}
}
示例9: handleStateChange
import org.eclipse.core.commands.State; //导入方法依赖的package包/类
public final void handleStateChange(final State state,
final Object oldValue) {
final Object newValue = state.getValue();
if (newValue instanceof Boolean) {
if (((Boolean) newValue).booleanValue()) {
activateMember((RadioState) state);
}
}
}
示例10: execute
import org.eclipse.core.commands.State; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Activator activator = Activator.getDefault();
IStructuredSelection sel = (IStructuredSelection) activator.getNavigatorViewer().getSelection();
ISpotterProjectElement projectElement = null;
if (!sel.isEmpty()) {
projectElement = (ISpotterProjectElement) sel.getFirstElement();
}
if (projectElement == null || activator.getSelectedProjects().size() != 1) {
return null;
}
Command command = event.getCommand();
State state = getCommandState(command);
boolean oldValue = (boolean) state.getValue();
String projectName = projectElement.getProject().getName();
// prompt confirmation only if trying to enable
boolean confirm = oldValue || DialogUtils.openConfirm(MSG_CONFIRM_ENABLE);
if (confirm && SpotterProjectSupport.setExpertModeEnabled(projectName, !oldValue)) {
HandlerUtil.toggleCommandState(command);
SpotterUtils.refreshProjectParent(projectElement);
}
return null;
}
示例11: getCurrentState
import org.eclipse.core.commands.State; //导入方法依赖的package包/类
private SelectInProgress getCurrentState() {
State state = getState(ID_SELECTS_IN_PROGRESS);
if (state == null) {
return null;
} else {
return (SelectInProgress) state.getValue();
}
}
示例12: getSelectedComparator
import org.eclipse.core.commands.State; //导入方法依赖的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);
}
}
示例13: SorterAdapter
import org.eclipse.core.commands.State; //导入方法依赖的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;
}
}
}
}
示例14: setEnabled
import org.eclipse.core.commands.State; //导入方法依赖的package包/类
@Override
public void setEnabled(final Object evaluationContext) {
super.setEnabled(evaluationContext);
if (_isInitializedState && _isInitializedView) {
return;
}
final IWorkbench wb = PlatformUI.getWorkbench();
if (_isInitializedState == false) {
/**
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* <p>
* getting the state works only the first time, otherwise it returns the OLD state
* <p>
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
final Command command = ((ICommandService) wb.getService(ICommandService.class)).getCommand(COMMAND_ID);
final State state = command.getState(RegistryToggleState.STATE_ID);
_isSyncPhotoWithTour = (Boolean) state.getValue();
_isInitializedState = true;
}
/*
* get PicDirView
*/
PicDirView picDirView = null;
for (final IWorkbenchWindow wbWindow : wb.getWorkbenchWindows()) {
final IWorkbenchPage wbPage = wbWindow.getActivePage();
if (wbPage != null) {
for (final IViewReference viewRef : wbPage.getViewReferences()) {
if (viewRef.getId().equals(PicDirView.ID)) {
final IViewPart viewPart = viewRef.getView(false);
if (viewPart instanceof PicDirView) {
picDirView = (PicDirView) viewPart;
break;
}
}
}
}
}
if (picDirView != null) {
_isInitializedView = true;
picDirView.setSelectionConverter(_isSyncPhotoWithTour ? _syncSelectionProvider : null);
}
// System.out.println(UI.timeStampNano() + " _isSyncPhotoWithTour " + _isSyncPhotoWithTour);
// // TODO remove SYSTEM.OUT.PRINTLN
}
示例15: onSelectionChanged
import org.eclipse.core.commands.State; //导入方法依赖的package包/类
private void onSelectionChanged(final ISelection selection, final IWorkbenchPart part) {
// System.out.println(UI.timeStampNano() + " onSelectionChanged\t" + selection);
// // TODO remove SYSTEM.OUT.PRINTLN
if (selection instanceof SyncSelection) {
final ISelection originalSelection = ((SyncSelection) selection).getSelection();
if (originalSelection instanceof PhotoSelection) {
showPhotosAndTours(((PhotoSelection) originalSelection).galleryPhotos);
}
} else if (selection instanceof PhotoSelection && part instanceof PicDirView) {
/**
* accept photo selection ONLY from the pic dir view, otherwise other photo selections
* will cause a view update
*/
final PhotoSelection photoSelection = (PhotoSelection) selection;
final Command command = _commandService.getCommand(ActionHandlerSyncPhotoWithTour.COMMAND_ID);
final State state = command.getState(RegistryToggleState.STATE_ID);
final boolean isSync = (Boolean) state.getValue();
if (isSync) {
showPhotosAndTours(photoSelection.galleryPhotos);
}
} else if (selection instanceof SelectionDeletedTours) {
clearView();
_photoMgr.resetTourStartEnd();
}
}