KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > splash > AbstractSplashHandler


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.splash;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.core.runtime.NullProgressMonitor;
15 import org.eclipse.swt.widgets.Shell;
16 import org.eclipse.ui.IWorkbench;
17 import org.eclipse.ui.IWorkbenchPreferenceConstants;
18 import org.eclipse.ui.PlatformUI;
19 import org.eclipse.ui.application.WorkbenchAdvisor;
20
21 /**
22  * Baseclass for splash implementations. Please note that methods on this class
23  * will be invoked while the Workbench is being instantiated. As such, any
24  * resource provided by the workbench plug-in cannot be guarenteed to be
25  * available to this class while executing. No attempt should be made to access
26  * {@link IWorkbench} or any subordinate interfaces or resources.
27  *
28  * @since 3.3
29  */

30 public abstract class AbstractSplashHandler {
31
32     private Shell shell;
33
34     /**
35      * Initialize this splash implementation. This is called very early in the
36      * workbench lifecycle before any window is created. The provided shell will
37      * already have a background image provided to it but subclasses are free to
38      * customize the shell in whatever way they see fit. Subclasses should
39      * ensure that they call the base implementation of this method at some
40      * point after their own method is invoked.
41      *
42      * <p>
43      * Calls to this method will be made from the UI thread.
44      * </p>
45      *
46      * @param splash
47      * the splash shell
48      */

49     public void init(Shell splash) {
50         this.shell = splash;
51     }
52
53     /**
54      * Signal the handler to end the splash and dispose of any resources.
55      * Subclasses should ensure that they call the base implementation of this
56      * method at some point after their own method is invoked.
57      *
58      * <p>
59      * Calls to this method will be made from the UI thread.
60      * </p>
61      */

62     public void dispose() {
63         shell.close();
64         shell = null;
65     }
66
67     /**
68      * Return the progress monitor responsible for showing bundle loading.
69      * Default implementation returns a null progress monitor.
70      *
71      * <p>
72      * Calls made to methods on this progress monitor may be made from non-UI
73      * threads so implementors must take care to ensure proper synchronization
74      * with the UI thread if necessary.
75      * </p>
76      *
77      * <p>
78      * Please note that progress will only be shown if the
79      * "org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP" property has been set to
80      * <code>true</code>. Because this property defaults to <code>false</code>
81      * RCP developers must set this property via a
82      * <code>plugin_customization.ini</code> file or by setting the preference
83      * on the Platform UI perference store in the
84      * {@link WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer)}
85      * method if they wish to have progress reported on startup.
86      * </p>
87      *
88      * @return the progress monitor
89      * @see NullProgressMonitor
90      * @see PlatformUI#getPreferenceStore()
91      * @see IWorkbenchPreferenceConstants#SHOW_PROGRESS_ON_STARTUP
92      * @see WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer)
93      */

94     public IProgressMonitor getBundleProgressMonitor() {
95         return new NullProgressMonitor();
96     }
97
98     /**
99      * Get the {@link Shell} associated with this splash screen. If this method
100      * returns a non-<code>null</code> value prior to the
101      * {@link #init(Shell)} being invoked then this shell will be used for the
102      * splash shell and it will subsequently be passed to the
103      * {@link #init(Shell)} method. In this way a splash handler may participate
104      * in splash processes prior to the workbench startup.
105      *
106      * <p>
107      * Calls to this method may be made from any thread. Implementors must take
108      * care to ensure proper synchronization with the UI thread if necessary.
109      * </p>
110      *
111      * @return the splash shell
112      */

113     public Shell getSplash() {
114         return shell;
115     }
116 }
117
Popular Tags