KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > intro > impl > IntroPlugin


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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.internal.intro.impl;
12
13 import org.eclipse.jface.resource.ImageRegistry;
14 import org.eclipse.ui.PlatformUI;
15 import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot;
16 import org.eclipse.ui.internal.intro.impl.model.loader.ExtensionPointManager;
17 import org.eclipse.ui.internal.intro.impl.presentations.IntroLaunchBar;
18 import org.eclipse.ui.internal.intro.impl.util.Log;
19 import org.eclipse.ui.intro.IIntroPart;
20 import org.eclipse.ui.plugin.AbstractUIPlugin;
21 import org.osgi.framework.BundleContext;
22
23 /**
24  * Intro main plugin.
25  */

26 public class IntroPlugin extends AbstractUIPlugin {
27     public static final String JavaDoc PLUGIN_ID = "org.eclipse.ui.intro"; //$NON-NLS-1$
28

29     // The static shared instance.
30
private static IntroPlugin inst;
31
32     // We must keep track of the launch bar so that we can
33
// close it if intro is opened from the menu.
34
private IntroLaunchBar launchBar;
35
36     // used for performance logging. Time when the constructor of
37
// CustomizableIntroPart is called.
38
private long uiCreationStartTime;
39     
40     // image registry that can be disposed while the
41
// plug-in is still active. This is important for
42
// switching themes after the plug-in has been loaded.
43
private ImageRegistry volatileImageRegistry;
44
45
46
47     /**
48      * The constructor.
49      */

50     public IntroPlugin() {
51         super();
52     }
53
54     /**
55      * Returns the shared plugin instance.
56      */

57     public static IntroPlugin getDefault() {
58         return inst;
59     }
60     
61     public ImageRegistry getVolatileImageRegistry() {
62         if (volatileImageRegistry==null) {
63             volatileImageRegistry = createImageRegistry();
64             initializeImageRegistry(volatileImageRegistry);
65         }
66         return volatileImageRegistry;
67     }
68     
69     public void resetVolatileImageRegistry() {
70         if (volatileImageRegistry!=null) {
71             volatileImageRegistry.dispose();
72             volatileImageRegistry = null;
73         }
74     }
75
76
77     public void closeLaunchBar() {
78         if (launchBar != null) {
79             launchBar.close();
80             launchBar = null;
81         }
82     }
83
84     public void setLaunchBar(IntroLaunchBar launchBar) {
85         this.launchBar = launchBar;
86     }
87
88
89     /**
90      * @return Returns the extensionPointManager.
91      */

92     public ExtensionPointManager getExtensionPointManager() {
93         return ExtensionPointManager.getInst();
94     }
95
96     /**
97      * Returns the model root. Will always guarantee that model is loaded.
98      *
99      * @return Returns the introModelRoot.
100      */

101     public IntroModelRoot getIntroModelRoot() {
102         return getExtensionPointManager().getCurrentModel();
103     }
104
105     /**
106      * Returns the Intro Part.
107      */

108     public static IIntroPart getIntro() {
109         IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager()
110             .getIntro();
111         return introPart;
112     }
113
114     /**
115      * Returns the Intro Part after forcing an open on it.
116      */

117     public static IIntroPart showIntro(boolean standby) {
118         IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager()
119             .showIntro(PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
120                 standby);
121         return introPart;
122     }
123
124     /**
125      * Returns the standby state of the Intro Part. If the intro is closed,
126      * retruns false.
127      */

128     public static boolean isIntroStandby() {
129         return PlatformUI.getWorkbench().getIntroManager().isIntroStandby(
130             getIntro());
131     }
132
133     /**
134      * Sets the standby state of the Intro Part. If the intro is closed, retruns
135      * false.
136      */

137     public static void setIntroStandby(boolean standby) {
138         PlatformUI.getWorkbench().getIntroManager().setIntroStandby(getIntro(),
139             standby);
140     }
141
142
143     /**
144      * Returns the standby state of the Intro Part. If the intro is closed,
145      * retruns false.
146      */

147     public static boolean closeIntro() {
148         // Relies on Workbench.
149
return PlatformUI.getWorkbench().getIntroManager().closeIntro(
150             getIntro());
151     }
152
153
154     /*
155      * (non-Javadoc)
156      *
157      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
158      */

159     public void start(BundleContext context) throws Exception JavaDoc {
160         super.start(context);
161         inst = this;
162         if (Log.logInfo)
163             Log.info("IntroPlugin - calling start on Intro bundle"); //$NON-NLS-1$
164

165     }
166
167     /*
168      * (non-Javadoc)
169      *
170      * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
171      */

172     public void stop(BundleContext context) throws Exception JavaDoc {
173         resetVolatileImageRegistry();
174         super.stop(context);
175     }
176
177     public long gettUICreationStartTime() {
178         return uiCreationStartTime;
179     }
180
181     public void setUICreationStartTime(long uiCreationStartTime) {
182         this.uiCreationStartTime = uiCreationStartTime;
183     }
184
185
186 }
187
Popular Tags