Search in sources :

Example 1 with StartupRunnable

use of org.eclipse.ui.internal.StartupThreading.StartupRunnable in project eclipse.platform.ui by eclipse-platform.

the class WorkbenchAdvisor method openWindows.

/**
 * Opens the workbench windows on startup. The default implementation tries to
 * restore the previously saved workbench state using
 * <code>IWorkbenchConfigurer.restoreWorkbenchState()</code>. If there was no
 * previously saved state, or if the restore failed, then a first-time window is
 * opened using <code>IWorkbenchConfigurer.openFirstTimeWindow</code>.
 *
 * @return <code>true</code> to proceed with workbench startup, or
 *         <code>false</code> to exit
 */
public boolean openWindows() {
    final Display display = PlatformUI.getWorkbench().getDisplay();
    final boolean[] result = new boolean[1];
    // spawn another init thread. For API compatibility We guarantee this method is
    // called from
    // the UI thread but it could take enough time to disrupt progress reporting.
    // spawn a new thread to do the grunt work of this initialization and spin the
    // event loop
    // ourselves just like it's done in Workbench.
    final Throwable[] error = new Throwable[1];
    Thread initThread = new Thread() {

        @Override
        public void run() {
            try {
                // declare us to be a startup thread so that our syncs will be executed
                UISynchronizer.startupThread.set(Boolean.TRUE);
                final IWorkbenchConfigurer[] myConfigurer = new IWorkbenchConfigurer[1];
                StartupThreading.runWithoutExceptions(new StartupRunnable() {

                    @Override
                    public void runWithException() throws Throwable {
                        myConfigurer[0] = getWorkbenchConfigurer();
                    }
                });
                IStatus status = myConfigurer[0].restoreState();
                if (!status.isOK()) {
                    if (status.getCode() == IWorkbenchConfigurer.RESTORE_CODE_EXIT) {
                        result[0] = false;
                        return;
                    }
                    if (status.getCode() == IWorkbenchConfigurer.RESTORE_CODE_RESET) {
                        myConfigurer[0].openFirstTimeWindow();
                    }
                }
                result[0] = true;
            } catch (Throwable e) {
                error[0] = e;
            } finally {
                initDone = true;
                Thread.yield();
                try {
                    Thread.sleep(5);
                } catch (InterruptedException e) {
                // this is a no-op in this case.
                }
                display.wake();
            }
        }
    };
    initThread.start();
    while (true) {
        if (!display.readAndDispatch()) {
            if (initDone)
                break;
            display.sleep();
        }
    }
    // can only be a runtime or error
    if (error[0] instanceof Error)
        throw (Error) error[0];
    else if (error[0] instanceof RuntimeException)
        throw (RuntimeException) error[0];
    return result[0];
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) StartupRunnable(org.eclipse.ui.internal.StartupThreading.StartupRunnable) Display(org.eclipse.swt.widgets.Display)

Example 2 with StartupRunnable

use of org.eclipse.ui.internal.StartupThreading.StartupRunnable in project eclipse.platform.ui by eclipse-platform.

the class Workbench method doOpenFirstTimeWindow.

private void doOpenFirstTimeWindow() {
    try {
        final IAdaptable[] input = new IAdaptable[1];
        StartupThreading.runWithoutExceptions(new StartupRunnable() {

            @Override
            public void runWithException() throws Throwable {
                input[0] = getDefaultPageInput();
            }
        });
        openWorkbenchWindow(getDefaultPerspectiveId(), input[0]);
    } catch (final WorkbenchException e) {
        // Don't use the window's shell as the dialog parent,
        // as the window is not open yet (bug 76724).
        StartupThreading.runWithoutExceptions(new StartupRunnable() {

            @Override
            public void runWithException() throws Throwable {
                ErrorDialog.openError(null, WorkbenchMessages.Problems_Opening_Page, e.getMessage(), e.getStatus());
            }
        });
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) StartupRunnable(org.eclipse.ui.internal.StartupThreading.StartupRunnable) WorkbenchException(org.eclipse.ui.WorkbenchException)

Example 3 with StartupRunnable

use of org.eclipse.ui.internal.StartupThreading.StartupRunnable in project eclipse.platform.ui by eclipse-platform.

the class Workbench method initializeFonts.

/*
	 * Initializes the workbench fonts with the stored values.
	 */
private void initializeFonts() {
    StartupThreading.runWithoutExceptions(new StartupRunnable() {

        @Override
        public void runWithException() {
            FontDefinition[] fontDefinitions = WorkbenchPlugin.getDefault().getThemeRegistry().getFonts();
            ThemeElementHelper.populateRegistry(getThemeManager().getCurrentTheme(), fontDefinitions, PrefUtil.getInternalPreferenceStore());
            final IPropertyChangeListener themeToPreferencesFontSynchronizer = event -> {
                if (event.getNewValue() instanceof FontData[]) {
                    FontData[] fontData = (FontData[]) event.getNewValue();
                    PrefUtil.getInternalPreferenceStore().setValue(event.getProperty(), PreferenceConverter.getStoredRepresentation(fontData));
                }
            };
            getThemeManager().getCurrentTheme().getFontRegistry().addListener(themeToPreferencesFontSynchronizer);
            getThemeManager().addPropertyChangeListener(event -> {
                if (IThemeManager.CHANGE_CURRENT_THEME.equals(event.getProperty())) {
                    Object oldValue = event.getOldValue();
                    if (oldValue != null && oldValue instanceof ITheme) {
                        ((ITheme) oldValue).removePropertyChangeListener(themeToPreferencesFontSynchronizer);
                    }
                    Object newValue = event.getNewValue();
                    if (newValue != null && newValue instanceof ITheme) {
                        ((ITheme) newValue).addPropertyChangeListener(themeToPreferencesFontSynchronizer);
                    }
                }
            });
        }
    });
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) BufferedInputStream(java.io.BufferedInputStream) CommandService(org.eclipse.ui.internal.commands.CommandService) ISaveableFilter(org.eclipse.ui.ISaveableFilter) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewReference(org.eclipse.ui.IViewReference) Point(org.eclipse.swt.graphics.Point) IIntroManager(org.eclipse.ui.intro.IIntroManager) E4XMIResource(org.eclipse.e4.ui.internal.workbench.E4XMIResource) AbstractSplashHandler(org.eclipse.ui.splash.AbstractSplashHandler) ULocale(com.ibm.icu.util.ULocale) Map(java.util.Map) SWTException(org.eclipse.swt.SWTException) IServiceScopes(org.eclipse.ui.services.IServiceScopes) StatusManager(org.eclipse.ui.statushandlers.StatusManager) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) IEditorPart(org.eclipse.ui.IEditorPart) IEvaluationService(org.eclipse.ui.services.IEvaluationService) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) StatusUtil(org.eclipse.ui.internal.misc.StatusUtil) IThemeManager(org.eclipse.ui.themes.IThemeManager) IRunnableContext(org.eclipse.jface.operation.IRunnableContext) OpenStrategy(org.eclipse.jface.util.OpenStrategy) ActiveContextSourceProvider(org.eclipse.ui.internal.contexts.ActiveContextSourceProvider) Window(org.eclipse.jface.window.Window) WorkbenchMenuService(org.eclipse.ui.internal.menus.WorkbenchMenuService) BindingManager(org.eclipse.jface.bindings.BindingManager) IApplicationContext(org.eclipse.equinox.app.IApplicationContext) XMLMemento(org.eclipse.ui.XMLMemento) IShellProvider(org.eclipse.jface.window.IShellProvider) SafeRunner(org.eclipse.core.runtime.SafeRunner) MPartDescriptor(org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor) SubMonitor(org.eclipse.core.runtime.SubMonitor) CommandsFactoryImpl(org.eclipse.e4.ui.model.application.commands.impl.CommandsFactoryImpl) BusyIndicator(org.eclipse.swt.custom.BusyIndicator) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) ICommandService(org.eclipse.ui.commands.ICommandService) ListenerList(org.eclipse.core.runtime.ListenerList) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) WorkbenchContextSupport(org.eclipse.ui.internal.contexts.WorkbenchContextSupport) ColorDefinition(org.eclipse.ui.internal.themes.ColorDefinition) SplashHandlerFactory(org.eclipse.ui.internal.splash.SplashHandlerFactory) MWindow(org.eclipse.e4.ui.model.application.ui.basic.MWindow) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) ContributionService(org.eclipse.ui.internal.model.ContributionService) IMemento(org.eclipse.ui.IMemento) IWorkbenchContextSupport(org.eclipse.ui.contexts.IWorkbenchContextSupport) ProgressManager(org.eclipse.ui.internal.progress.ProgressManager) MCategory(org.eclipse.e4.ui.model.application.commands.MCategory) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) ISaveablesLifecycleListener(org.eclipse.ui.ISaveablesLifecycleListener) CompatibilityEditor(org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor) IOException(java.io.IOException) ServiceLocatorCreator(org.eclipse.ui.internal.services.ServiceLocatorCreator) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) WorkbenchCommandSupport(org.eclipse.ui.internal.commands.WorkbenchCommandSupport) EModelService(org.eclipse.e4.ui.workbench.modeling.EModelService) StringReader(java.io.StringReader) IContextService(org.eclipse.ui.contexts.IContextService) EvaluationService(org.eclipse.ui.internal.services.EvaluationService) ViewDescriptor(org.eclipse.ui.internal.registry.ViewDescriptor) ContextInjectionFactory(org.eclipse.e4.core.contexts.ContextInjectionFactory) UIEvents(org.eclipse.e4.ui.workbench.UIEvents) WorkbenchException(org.eclipse.ui.WorkbenchException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) WorkbenchAdvisor(org.eclipse.ui.application.WorkbenchAdvisor) URISyntaxException(java.net.URISyntaxException) IAction(org.eclipse.jface.action.IAction) IBindingManagerListener(org.eclipse.jface.bindings.IBindingManagerListener) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) Policy(org.eclipse.ui.internal.misc.Policy) IWorkbenchRegistryConstants(org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants) MCommandsFactory(org.eclipse.e4.ui.model.application.commands.MCommandsFactory) IStatus(org.eclipse.core.runtime.IStatus) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) FontDefinition(org.eclipse.ui.internal.themes.FontDefinition) IAdaptable(org.eclipse.core.runtime.IAdaptable) IWizardRegistry(org.eclipse.ui.wizards.IWizardRegistry) IBindingService(org.eclipse.ui.keys.IBindingService) Collection(java.util.Collection) UUID(java.util.UUID) ShowKeysListener(org.eclipse.ui.internal.keys.show.ShowKeysListener) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SourceProviderService(org.eclipse.ui.internal.services.SourceProviderService) Objects(java.util.Objects) ISourceProvider(org.eclipse.ui.ISourceProvider) WorkbenchThemeManager(org.eclipse.ui.internal.themes.WorkbenchThemeManager) ISourceProviderService(org.eclipse.ui.services.ISourceProviderService) ISelection(org.eclipse.jface.viewers.ISelection) IEditorRegistry(org.eclipse.ui.IEditorRegistry) CommandCallback(org.eclipse.jface.action.ExternalActionManager.CommandCallback) CompatibilityPart(org.eclipse.ui.internal.e4.compatibility.CompatibilityPart) SafeRunnable(org.eclipse.jface.util.SafeRunnable) WWinPartServiceSaveHandler(org.eclipse.ui.internal.WorkbenchWindow.WWinPartServiceSaveHandler) IExtensionDelta(org.eclipse.core.runtime.IExtensionDelta) IDecoratorManager(org.eclipse.ui.IDecoratorManager) IPerspectiveRegistry(org.eclipse.ui.IPerspectiveRegistry) Image(org.eclipse.swt.graphics.Image) IEventLoopAdvisor(org.eclipse.e4.ui.internal.workbench.swt.IEventLoopAdvisor) BundleEvent(org.osgi.framework.BundleEvent) HashSet(java.util.HashSet) E4Util(org.eclipse.ui.internal.e4.compatibility.E4Util) E4Application(org.eclipse.e4.ui.internal.workbench.swt.E4Application) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) DeviceData(org.eclipse.swt.graphics.DeviceData) IWorkbenchPreferenceConstants(org.eclipse.ui.IWorkbenchPreferenceConstants) WorkbenchLocationService(org.eclipse.ui.internal.services.WorkbenchLocationService) NotHandledException(org.eclipse.core.commands.NotHandledException) BindingService(org.eclipse.ui.internal.keys.BindingService) ServiceRegistration(org.osgi.framework.ServiceRegistration) IRegistryChangeListener(org.eclipse.core.runtime.IRegistryChangeListener) ISaveHandler(org.eclipse.e4.ui.workbench.modeling.ISaveHandler) FileInputStream(java.io.FileInputStream) EclipseSplashHandler(org.eclipse.ui.internal.splash.EclipseSplashHandler) UIStats(org.eclipse.ui.internal.misc.UIStats) ITheme(org.eclipse.ui.themes.ITheme) SynchronousBundleListener(org.osgi.framework.SynchronousBundleListener) FrameworkUtil(org.osgi.framework.FrameworkUtil) Arrays(java.util.Arrays) NotDefinedException(org.eclipse.core.commands.common.NotDefinedException) MultiStatus(org.eclipse.core.runtime.MultiStatus) MTrimContribution(org.eclipse.e4.ui.model.application.ui.menu.MTrimContribution) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) CoreException(org.eclipse.core.runtime.CoreException) PartRenderingEngine(org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine) IServiceLocatorCreator(org.eclipse.ui.internal.services.IServiceLocatorCreator) MenuSourceProvider(org.eclipse.ui.internal.services.MenuSourceProvider) IUpdateService(org.eclipse.e4.ui.internal.workbench.renderers.swt.IUpdateService) PartInitException(org.eclipse.ui.PartInitException) MBindingContext(org.eclipse.e4.ui.model.application.commands.MBindingContext) BidiUtils(org.eclipse.jface.util.BidiUtils) WorkbenchHelpSystem(org.eclipse.ui.internal.help.WorkbenchHelpSystem) MApplication(org.eclipse.e4.ui.model.application.MApplication) ServiceLocator(org.eclipse.ui.internal.services.ServiceLocator) Realm(org.eclipse.core.databinding.observable.Realm) EContextService(org.eclipse.e4.ui.services.EContextService) PreferenceConverter(org.eclipse.jface.preference.PreferenceConverter) MenuManager(org.eclipse.jface.action.MenuManager) Assert(org.eclipse.core.runtime.Assert) Set(java.util.Set) Status(org.eclipse.core.runtime.Status) IModelResourceHandler(org.eclipse.e4.ui.workbench.IModelResourceHandler) Saveable(org.eclipse.ui.Saveable) DisplayRealm(org.eclipse.jface.databinding.swt.DisplayRealm) IFocusService(org.eclipse.ui.swt.IFocusService) SWT(org.eclipse.swt.SWT) ICommandImageService(org.eclipse.ui.commands.ICommandImageService) IWorkbenchOperationSupport(org.eclipse.ui.operations.IWorkbenchOperationSupport) Dictionary(java.util.Dictionary) MCommand(org.eclipse.e4.ui.model.application.commands.MCommand) WorkbenchJob(org.eclipse.ui.progress.WorkbenchJob) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) ArrayList(java.util.ArrayList) Listener(org.eclipse.swt.widgets.Listener) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IApplication(org.eclipse.equinox.app.IApplication) IViewRegistry(org.eclipse.ui.views.IViewRegistry) NotEnabledException(org.eclipse.core.commands.NotEnabledException) FocusControlSourceProvider(org.eclipse.ui.internal.menus.FocusControlSourceProvider) LegacyHandlerService(org.eclipse.ui.internal.handlers.LegacyHandlerService) CommandManager(org.eclipse.core.commands.CommandManager) Shell(org.eclipse.swt.widgets.Shell) IWorkbenchHelpSystem(org.eclipse.ui.help.IWorkbenchHelpSystem) StringWriter(java.io.StringWriter) IElementFactory(org.eclipse.ui.IElementFactory) ExecutionException(org.eclipse.core.commands.ExecutionException) IPresentationEngine(org.eclipse.e4.ui.workbench.IPresentationEngine) PrefUtil(org.eclipse.ui.internal.util.PrefUtil) EventManager(org.eclipse.core.commands.common.EventManager) Command(org.eclipse.core.commands.Command) IWorkbenchListener(org.eclipse.ui.IWorkbenchListener) IIntroRegistry(org.eclipse.ui.internal.intro.IIntroRegistry) ServiceTracker(org.osgi.util.tracker.ServiceTracker) Platform(org.eclipse.core.runtime.Platform) ModalContext(org.eclipse.jface.operation.ModalContext) IEventBroker(org.eclipse.e4.core.services.events.IEventBroker) StartupRunnable(org.eclipse.ui.internal.StartupThreading.StartupRunnable) IExtensionTracker(org.eclipse.core.runtime.dynamichelpers.IExtensionTracker) Constants(org.osgi.framework.Constants) URL(java.net.URL) IWorkbenchCommandConstants(org.eclipse.ui.IWorkbenchCommandConstants) CommandImageManager(org.eclipse.ui.internal.commands.CommandImageManager) IMenuService(org.eclipse.ui.menus.IMenuService) UIExtensionTracker(org.eclipse.ui.internal.registry.UIExtensionTracker) ThemeElementHelper(org.eclipse.ui.internal.themes.ThemeElementHelper) IProgressService(org.eclipse.ui.progress.IProgressService) URI(java.net.URI) ProgressManagerUtil(org.eclipse.ui.internal.progress.ProgressManagerUtil) IExtension(org.eclipse.core.runtime.IExtension) MElementContainer(org.eclipse.e4.ui.model.application.ui.MElementContainer) NLS(org.eclipse.osgi.util.NLS) ExternalActionManager(org.eclipse.jface.action.ExternalActionManager) EObject(org.eclipse.emf.ecore.EObject) Display(org.eclipse.swt.widgets.Display) ContextService(org.eclipse.ui.internal.contexts.ContextService) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) BundleContext(org.osgi.framework.BundleContext) ISharedImages(org.eclipse.ui.ISharedImages) IHandlerService(org.eclipse.ui.handlers.IHandlerService) List(java.util.List) IDisposable(org.eclipse.ui.services.IDisposable) Category(com.ibm.icu.util.ULocale.Category) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) IViewDescriptor(org.eclipse.ui.views.IViewDescriptor) IProduct(org.eclipse.core.runtime.IProduct) Resource(org.eclipse.emf.ecore.resource.Resource) ContributionInfoMessages(org.eclipse.ui.internal.testing.ContributionInfoMessages) IWindowListener(org.eclipse.ui.IWindowListener) ILocalWorkingSetManager(org.eclipse.ui.ILocalWorkingSetManager) MBindingTable(org.eclipse.e4.ui.model.application.commands.MBindingTable) StartupMonitor(org.eclipse.osgi.service.runnable.StartupMonitor) PropertyPageContributorManager(org.eclipse.ui.internal.dialogs.PropertyPageContributorManager) HashMap(java.util.HashMap) IWorkbenchLocationService(org.eclipse.ui.internal.services.IWorkbenchLocationService) ContextManager(org.eclipse.core.commands.contexts.ContextManager) IntroDescriptor(org.eclipse.ui.internal.intro.IntroDescriptor) ContextFunction(org.eclipse.e4.core.contexts.ContextFunction) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) PreferenceManager(org.eclipse.jface.preference.PreferenceManager) IWorkbenchActivitySupport(org.eclipse.ui.activities.IWorkbenchActivitySupport) IWorkbenchCommandSupport(org.eclipse.ui.commands.IWorkbenchCommandSupport) ContributionInfo(org.eclipse.ui.testing.ContributionInfo) Hashtable(java.util.Hashtable) WorkbenchActivitySupport(org.eclipse.ui.internal.activities.ws.WorkbenchActivitySupport) Job(org.eclipse.core.runtime.jobs.Job) E4Workbench(org.eclipse.e4.ui.internal.workbench.E4Workbench) InjectionException(org.eclipse.e4.core.di.InjectionException) CommandAction(org.eclipse.ui.internal.actions.CommandAction) WorkbenchTestable(org.eclipse.ui.internal.testing.WorkbenchTestable) CommandImageService(org.eclipse.ui.internal.commands.CommandImageService) FontData(org.eclipse.swt.graphics.FontData) WorkbenchBrowserSupport(org.eclipse.ui.internal.browser.WorkbenchBrowserSupport) IWorkbench(org.eclipse.ui.IWorkbench) IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) Collections(java.util.Collections) InputStream(java.io.InputStream) BasicFactoryImpl(org.eclipse.e4.ui.model.application.ui.basic.impl.BasicFactoryImpl) ISources(org.eclipse.ui.ISources) IContributionService(org.eclipse.ui.model.IContributionService) ITheme(org.eclipse.ui.themes.ITheme) FontData(org.eclipse.swt.graphics.FontData) StartupRunnable(org.eclipse.ui.internal.StartupThreading.StartupRunnable) EObject(org.eclipse.emf.ecore.EObject)

Example 4 with StartupRunnable

use of org.eclipse.ui.internal.StartupThreading.StartupRunnable in project eclipse.platform.ui by eclipse-platform.

the class NavigationHistory method restoreState.

/**
 * Restore the state of this history from the memento.
 */
void restoreState(IMemento memento) {
    IMemento editorsMem = memento.getChild(IWorkbenchConstants.TAG_EDITORS);
    IMemento[] items = memento.getChildren(IWorkbenchConstants.TAG_ITEM);
    if (items.length == 0 || editorsMem == null) {
        if (page.getActiveEditor() != null) {
            markLocation(page.getActiveEditor());
        }
        return;
    }
    IMemento[] children = editorsMem.getChildren(IWorkbenchConstants.TAG_EDITOR);
    NavigationHistoryEditorInfo[] editorsInfo = new NavigationHistoryEditorInfo[children.length];
    for (int i = 0; i < editorsInfo.length; i++) {
        editorsInfo[i] = new NavigationHistoryEditorInfo(children[i]);
        editors.add(editorsInfo[i]);
    }
    for (int i = 0; i < items.length; i++) {
        IMemento item = items[i];
        int index = item.getInteger(IWorkbenchConstants.TAG_INDEX).intValue();
        NavigationHistoryEditorInfo info = editorsInfo[index];
        info.refCount++;
        NavigationHistoryEntry entry = new NavigationHistoryEntry(info, page, null, null);
        history.add(entry);
        entry.restoreState(item);
        if (item.getString(IWorkbenchConstants.TAG_ACTIVE) != null) {
            activeEntry = i;
        }
    }
    final NavigationHistoryEntry entry = getEntry(activeEntry);
    if (entry != null && entry.editorInfo.editorInput != null) {
        if (page.getActiveEditor() == page.findEditor(entry.editorInfo.editorInput)) {
            StartupThreading.runWithoutExceptions(new StartupRunnable() {

                @Override
                public void runWithException() throws Throwable {
                    gotoEntry(entry);
                }
            });
        }
    }
}
Also used : StartupRunnable(org.eclipse.ui.internal.StartupThreading.StartupRunnable) IMemento(org.eclipse.ui.IMemento)

Example 5 with StartupRunnable

use of org.eclipse.ui.internal.StartupThreading.StartupRunnable 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;
}
Also used : ShowKeysListener(org.eclipse.ui.internal.keys.show.ShowKeysListener) IIntroRegistry(org.eclipse.ui.internal.intro.IIntroRegistry) StartupRunnable(org.eclipse.ui.internal.StartupThreading.StartupRunnable) IProduct(org.eclipse.core.runtime.IProduct) IEvaluationService(org.eclipse.ui.services.IEvaluationService) EvaluationService(org.eclipse.ui.internal.services.EvaluationService) IEvaluationService(org.eclipse.ui.services.IEvaluationService)

Aggregations

StartupRunnable (org.eclipse.ui.internal.StartupThreading.StartupRunnable)7 Display (org.eclipse.swt.widgets.Display)4 ULocale (com.ibm.icu.util.ULocale)2 Category (com.ibm.icu.util.ULocale.Category)2 BufferedInputStream (java.io.BufferedInputStream)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Dictionary (java.util.Dictionary)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2