use of org.eclipse.ui.internal.services.EvaluationService in project eclipse.platform.ui by eclipse-platform.
the class Workbench method init.
/**
* Initializes the workbench now that the display is created.
*
* @return true if init succeeded.
*/
private boolean init() {
// setup debug mode if required.
if (WorkbenchPlugin.getDefault().isDebugging()) {
WorkbenchPlugin.DEBUG = true;
ModalContext.setDebugMode(true);
}
// Set up the JFace preference store
JFaceUtil.initializeJFacePreferences();
// TODO Correctly order service initialization
// there needs to be some serious consideration given to
// the services, and hooking them up in the correct order
// $NON-NLS-1$
e4Context.set("org.eclipse.core.runtime.Platform", Platform.class);
final EvaluationService evaluationService = new EvaluationService(e4Context);
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
serviceLocator.registerService(IEvaluationService.class, evaluationService);
}
});
initializeLazyServices();
// Initialize the activity support.
activityHelper = ActivityPersistanceHelper.getInstance();
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
WorkbenchImages.getImageRegistry();
}
});
initializeE4Services();
IIntroRegistry introRegistry = WorkbenchPlugin.getDefault().getIntroRegistry();
if (introRegistry.getIntroCount() > 0) {
IProduct product = Platform.getProduct();
if (product != null) {
introDescriptor = (IntroDescriptor) introRegistry.getIntroForProduct(product.getId());
}
}
initializeDefaultServices();
initializeFonts();
initializeApplicationColors();
// now that the workbench is sufficiently initialized, let the advisor
// have a turn.
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
advisor.internalBasicInitialize(getWorkbenchConfigurer());
}
});
// configure use of color icons in toolbars
boolean useColorIcons = PrefUtil.getInternalPreferenceStore().getBoolean(IPreferenceConstants.COLOR_ICONS);
ActionContributionItem.setUseColorIconsInToolbars(useColorIcons);
// initialize workbench single-click vs double-click behavior
initializeSingleClickOption();
initializeGlobalization();
initializeNLExtensions();
initializeWorkbenchImages();
// hook shortcut visualizer
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() {
new ShowKeysListener(Workbench.this, PrefUtil.getInternalPreferenceStore());
}
});
// attempt to restore a previous workbench state
try {
// $NON-NLS-1$
UIStats.start(UIStats.RESTORE_WORKBENCH, "Workbench");
final boolean[] bail = new boolean[1];
StartupThreading.runWithoutExceptions(new StartupRunnable() {
@Override
public void runWithException() throws Throwable {
advisor.preStartup();
// TODO compat: open the windows here/instantiate the model
// TODO compat: instantiate the WW around the model
initializationDone = true;
if (isClosing() || !advisor.openWindows()) {
// if (isClosing()) {
bail[0] = true;
}
restoreWorkbenchState();
}
});
if (bail[0])
return false;
} finally {
// $NON-NLS-1$
UIStats.end(UIStats.RESTORE_WORKBENCH, this, "Workbench");
}
return true;
}
use of org.eclipse.ui.internal.services.EvaluationService 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);
}
});
}
Aggregations