本文整理汇总了Java中org.eclipse.ui.handlers.RegistryToggleState类的典型用法代码示例。如果您正苦于以下问题:Java RegistryToggleState类的具体用法?Java RegistryToggleState怎么用?Java RegistryToggleState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegistryToggleState类属于org.eclipse.ui.handlers包,在下文中一共展示了RegistryToggleState类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setEnabled
import org.eclipse.ui.handlers.RegistryToggleState; //导入依赖的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.ui.handlers.RegistryToggleState; //导入依赖的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: setEnabled
import org.eclipse.ui.handlers.RegistryToggleState; //导入依赖的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());
}
}
示例4: selectionChanged
import org.eclipse.ui.handlers.RegistryToggleState; //导入依赖的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);
}
}
}
示例5: getCommandState
import org.eclipse.ui.handlers.RegistryToggleState; //导入依赖的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;
}
示例6: setCommandState
import org.eclipse.ui.handlers.RegistryToggleState; //导入依赖的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);
}
}
示例7: createPartControl
import org.eclipse.ui.handlers.RegistryToggleState; //导入依赖的package包/类
@Override
public void createPartControl(final Composite parent) {
view.createView(parent);
final ICommandService commandService = (ICommandService)getSite().getService(ICommandService.class);
final Command command = commandService.getCommand(UIConstants.TOGGLE_SHOW_ONLY_ERRORS_AND_WARNINGS_COMMAND_ID);
setShowOnlyErrorsAndWarnings((Boolean)command.getState(RegistryToggleState.STATE_ID).getValue());
}
示例8: setEnabled
import org.eclipse.ui.handlers.RegistryToggleState; //导入依赖的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
}
示例9: onSelectionChanged
import org.eclipse.ui.handlers.RegistryToggleState; //导入依赖的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();
}
}