use of org.eclipse.ui.internal.commands.CommandImageService in project eclipse.platform.ui by eclipse-platform.
the class CommandLegacyActionWrapper method setHoverImageDescriptor.
@Override
public void setHoverImageDescriptor(final ImageDescriptor newImage) {
final String commandId = getActionDefinitionId();
final int type = CommandImageManager.TYPE_HOVER;
final ICommandImageService commandImageService = serviceLocator.getService(ICommandImageService.class);
if (commandImageService instanceof CommandImageService) {
((CommandImageService) commandImageService).bind(commandId, type, style, newImage);
}
}
use of org.eclipse.ui.internal.commands.CommandImageService in project dbeaver by serge-rider.
the class ApplicationActionBarAdvisor method patchImages.
private void patchImages() {
// We have to patch images manually because using commandImages extension point doesn't guarantee order
// WorkbenchImages.declareImage(IWorkbenchGraphicConstants.IMG_WIZBAN_IMPORT_WIZ, DBeaverIcons.getImageDescriptor(UIIcon.IMPORT), true);
// WorkbenchImages.declareImage(IWorkbenchGraphicConstants.IMG_WIZBAN_EXPORT_WIZ, DBeaverIcons.getImageDescriptor(UIIcon.EXPORT), true);
IWorkbenchWindow workbenchWindow = getActionBarConfigurer().getWindowConfigurer().getWindow();
if (workbenchWindow != null) {
ICommandImageService service = workbenchWindow.getService(ICommandImageService.class);
if (service instanceof CommandImageService) {
CommandImageService cis = (CommandImageService) service;
bindImage(cis, IWorkbenchCommandConstants.FILE_SAVE, UIIcon.SAVE);
bindImage(cis, IWorkbenchCommandConstants.FILE_SAVE_AS, UIIcon.SAVE_AS);
bindImage(cis, IWorkbenchCommandConstants.FILE_SAVE_ALL, UIIcon.SAVE_ALL);
/*
bindImage(cis, IWorkbenchCommandConstants.EDIT_COPY, UIIcon.EDIT_COPY);
bindImage(cis, IWorkbenchCommandConstants.EDIT_COPY, UIIcon.EDIT_COPY);
bindImage(cis, IWorkbenchCommandConstants.EDIT_COPY, UIIcon.EDIT_COPY);
bindImage(cis, IWorkbenchCommandConstants.EDIT_COPY, UIIcon.EDIT_COPY);
*/
bindImage(cis, IWorkbenchCommandConstants.FILE_IMPORT, UIIcon.IMPORT);
bindImage(cis, IWorkbenchCommandConstants.FILE_EXPORT, UIIcon.EXPORT);
bindImage(cis, IWorkbenchCommandConstants.FILE_REFRESH, UIIcon.REFRESH);
}
}
}
use of org.eclipse.ui.internal.commands.CommandImageService in project dbeaver by dbeaver.
the class ApplicationActionBarAdvisor method patchImages.
private void patchImages() {
// We have to patch images manually because using commandImages extension point doesn't guarantee order
// WorkbenchImages.declareImage(IWorkbenchGraphicConstants.IMG_WIZBAN_IMPORT_WIZ, DBeaverIcons.getImageDescriptor(UIIcon.IMPORT), true);
// WorkbenchImages.declareImage(IWorkbenchGraphicConstants.IMG_WIZBAN_EXPORT_WIZ, DBeaverIcons.getImageDescriptor(UIIcon.EXPORT), true);
IWorkbenchWindow workbenchWindow = getActionBarConfigurer().getWindowConfigurer().getWindow();
if (workbenchWindow != null) {
ICommandImageService service = workbenchWindow.getService(ICommandImageService.class);
if (service instanceof CommandImageService) {
CommandImageService cis = (CommandImageService) service;
bindImage(cis, IWorkbenchCommandConstants.FILE_SAVE, UIIcon.SAVE);
bindImage(cis, IWorkbenchCommandConstants.FILE_SAVE_AS, UIIcon.SAVE_AS);
bindImage(cis, IWorkbenchCommandConstants.FILE_SAVE_ALL, UIIcon.SAVE_ALL);
/*
bindImage(cis, IWorkbenchCommandConstants.EDIT_COPY, UIIcon.EDIT_COPY);
bindImage(cis, IWorkbenchCommandConstants.EDIT_COPY, UIIcon.EDIT_COPY);
bindImage(cis, IWorkbenchCommandConstants.EDIT_COPY, UIIcon.EDIT_COPY);
bindImage(cis, IWorkbenchCommandConstants.EDIT_COPY, UIIcon.EDIT_COPY);
*/
bindImage(cis, IWorkbenchCommandConstants.FILE_IMPORT, UIIcon.IMPORT);
bindImage(cis, IWorkbenchCommandConstants.FILE_EXPORT, UIIcon.EXPORT);
bindImage(cis, IWorkbenchCommandConstants.FILE_REFRESH, UIIcon.REFRESH);
}
}
}
use of org.eclipse.ui.internal.commands.CommandImageService in project eclipse.platform.ui by eclipse-platform.
the class Workbench method initializeDefaultServices.
/**
* Initializes all of the default services for the workbench. For initializing
* the command-based services, this also parses the registry and hooks up all
* the required listeners.
*/
private void initializeDefaultServices() {
final IContributionService contributionService = new ContributionService(getAdvisor());
serviceLocator.registerService(IContributionService.class, contributionService);
// TODO Correctly order service initialization
// there needs to be some serious consideration given to
// the services, and hooking them up in the correct order
final IEvaluationService evaluationService = serviceLocator.getService(IEvaluationService.class);
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
serviceLocator.registerService(ISaveablesLifecycleListener.class, new SaveablesList());
}
});
/*
* Phase 1 of the initialization of commands. When this phase completes, all the
* services and managers will exist, and be accessible via the
* getService(Object) method.
*/
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
Command.DEBUG_COMMAND_EXECUTION = Policy.DEBUG_COMMANDS;
commandManager = e4Context.get(CommandManager.class);
}
});
final CommandService[] commandService = new CommandService[1];
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
commandService[0] = initializeCommandService(e4Context);
}
});
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
ContextManager.DEBUG = Policy.DEBUG_CONTEXTS;
contextManager = e4Context.get(ContextManager.class);
}
});
IContextService cxs = ContextInjectionFactory.make(ContextService.class, e4Context);
final IContextService contextService = cxs;
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
contextManager.addContextManagerListener(contextManagerEvent -> {
if (contextManagerEvent.isContextChanged()) {
String id = contextManagerEvent.getContextId();
if (id != null) {
defineBindingTable(id);
}
}
});
EContextService ecs = e4Context.get(EContextService.class);
ecs.activateContext(IContextService.CONTEXT_ID_DIALOG_AND_WINDOW);
}
});
serviceLocator.registerService(IContextService.class, contextService);
final IBindingService[] bindingService = new BindingService[1];
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
BindingManager.DEBUG = Policy.DEBUG_KEY_BINDINGS;
bindingManager = e4Context.get(BindingManager.class);
bindingService[0] = ContextInjectionFactory.make(BindingService.class, e4Context);
}
});
// bindingService[0].readRegistryAndPreferences(commandService[0]);
serviceLocator.registerService(IBindingService.class, bindingService[0]);
final CommandImageManager commandImageManager = new CommandImageManager();
final CommandImageService commandImageService = new CommandImageService(commandImageManager, commandService[0]);
commandImageService.readRegistry();
serviceLocator.registerService(ICommandImageService.class, commandImageService);
final WorkbenchMenuService menuService = new WorkbenchMenuService(serviceLocator, e4Context);
serviceLocator.registerService(IMenuService.class, menuService);
// the service must be registered before it is initialized - its
// initialization uses the service locator to address a dependency on
// the menu service
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
menuService.readRegistry();
}
});
/*
* Phase 2 of the initialization of commands. The source providers that the
* workbench provides are creating and registered with the above services. These
* source providers notify the services when particular pieces of workbench
* state change.
*/
final SourceProviderService sourceProviderService = new SourceProviderService(serviceLocator);
serviceLocator.registerService(ISourceProviderService.class, sourceProviderService);
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
// this currently instantiates all players ... sigh
sourceProviderService.readRegistry();
ISourceProvider[] sourceproviders = sourceProviderService.getSourceProviders();
for (ISourceProvider sp : sourceproviders) {
evaluationService.addSourceProvider(sp);
if (!(sp instanceof ActiveContextSourceProvider)) {
contextService.addSourceProvider(sp);
}
}
}
});
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
// these guys are need to provide the variables they say
// they source
FocusControlSourceProvider focusControl = (FocusControlSourceProvider) sourceProviderService.getSourceProvider(ISources.ACTIVE_FOCUS_CONTROL_ID_NAME);
serviceLocator.registerService(IFocusService.class, focusControl);
menuSourceProvider = (MenuSourceProvider) sourceProviderService.getSourceProvider(ISources.ACTIVE_MENU_NAME);
}
});
/*
* Phase 3 of the initialization of commands. This handles the creation of
* wrappers for legacy APIs. By the time this phase completes, any code trying
* to access commands through legacy APIs should work.
*/
final IHandlerService[] handlerService = new IHandlerService[1];
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
handlerService[0] = new LegacyHandlerService(e4Context);
e4Context.set(IHandlerService.class, handlerService[0]);
handlerService[0].readRegistry();
}
});
workbenchContextSupport = new WorkbenchContextSupport(this, contextManager);
workbenchCommandSupport = new WorkbenchCommandSupport(bindingManager, commandManager, contextManager, handlerService[0]);
initializeCommandResolver();
bindingManager.addBindingManagerListener(bindingManagerListener);
serviceLocator.registerService(ISelectionConversionService.class, new SelectionConversionService());
backForwardListener = createBackForwardListener();
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
getDisplay().addFilter(SWT.MouseDown, backForwardListener);
}
});
}
use of org.eclipse.ui.internal.commands.CommandImageService in project eclipse.platform.ui by eclipse-platform.
the class CommandLegacyActionWrapper method setDisabledImageDescriptor.
@Override
public void setDisabledImageDescriptor(final ImageDescriptor newImage) {
final String commandId = getActionDefinitionId();
final int type = CommandImageManager.TYPE_DISABLED;
final ICommandImageService commandImageService = serviceLocator.getService(ICommandImageService.class);
if (commandImageService instanceof CommandImageService) {
((CommandImageService) commandImageService).bind(commandId, type, style, newImage);
}
}
Aggregations