001: /*******************************************************************************
002: * Copyright (c) 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.splash;
011:
012: import org.eclipse.core.runtime.IProgressMonitor;
013: import org.eclipse.core.runtime.NullProgressMonitor;
014: import org.eclipse.swt.widgets.Shell;
015: import org.eclipse.ui.IWorkbench;
016: import org.eclipse.ui.IWorkbenchPreferenceConstants;
017: import org.eclipse.ui.PlatformUI;
018: import org.eclipse.ui.application.WorkbenchAdvisor;
019:
020: /**
021: * Baseclass for splash implementations. Please note that methods on this class
022: * will be invoked while the Workbench is being instantiated. As such, any
023: * resource provided by the workbench plug-in cannot be guarenteed to be
024: * available to this class while executing. No attempt should be made to access
025: * {@link IWorkbench} or any subordinate interfaces or resources.
026: *
027: * @since 3.3
028: */
029: public abstract class AbstractSplashHandler {
030:
031: private Shell shell;
032:
033: /**
034: * Initialize this splash implementation. This is called very early in the
035: * workbench lifecycle before any window is created. The provided shell will
036: * already have a background image provided to it but subclasses are free to
037: * customize the shell in whatever way they see fit. Subclasses should
038: * ensure that they call the base implementation of this method at some
039: * point after their own method is invoked.
040: *
041: * <p>
042: * Calls to this method will be made from the UI thread.
043: * </p>
044: *
045: * @param splash
046: * the splash shell
047: */
048: public void init(Shell splash) {
049: this .shell = splash;
050: }
051:
052: /**
053: * Signal the handler to end the splash and dispose of any resources.
054: * Subclasses should ensure that they call the base implementation of this
055: * method at some point after their own method is invoked.
056: *
057: * <p>
058: * Calls to this method will be made from the UI thread.
059: * </p>
060: */
061: public void dispose() {
062: shell.close();
063: shell = null;
064: }
065:
066: /**
067: * Return the progress monitor responsible for showing bundle loading.
068: * Default implementation returns a null progress monitor.
069: *
070: * <p>
071: * Calls made to methods on this progress monitor may be made from non-UI
072: * threads so implementors must take care to ensure proper synchronization
073: * with the UI thread if necessary.
074: * </p>
075: *
076: * <p>
077: * Please note that progress will only be shown if the
078: * "org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP" property has been set to
079: * <code>true</code>. Because this property defaults to <code>false</code>
080: * RCP developers must set this property via a
081: * <code>plugin_customization.ini</code> file or by setting the preference
082: * on the Platform UI perference store in the
083: * {@link WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer)}
084: * method if they wish to have progress reported on startup.
085: * </p>
086: *
087: * @return the progress monitor
088: * @see NullProgressMonitor
089: * @see PlatformUI#getPreferenceStore()
090: * @see IWorkbenchPreferenceConstants#SHOW_PROGRESS_ON_STARTUP
091: * @see WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer)
092: */
093: public IProgressMonitor getBundleProgressMonitor() {
094: return new NullProgressMonitor();
095: }
096:
097: /**
098: * Get the {@link Shell} associated with this splash screen. If this method
099: * returns a non-<code>null</code> value prior to the
100: * {@link #init(Shell)} being invoked then this shell will be used for the
101: * splash shell and it will subsequently be passed to the
102: * {@link #init(Shell)} method. In this way a splash handler may participate
103: * in splash processes prior to the workbench startup.
104: *
105: * <p>
106: * Calls to this method may be made from any thread. Implementors must take
107: * care to ensure proper synchronization with the UI thread if necessary.
108: * </p>
109: *
110: * @return the splash shell
111: */
112: public Shell getSplash() {
113: return shell;
114: }
115: }
|