KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > intro > universal > UniversalIntroPlugin


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.universal;
12
13 import org.eclipse.jface.resource.ImageRegistry;
14 import org.eclipse.ui.PlatformUI;
15 import org.eclipse.ui.internal.intro.universal.util.Log;
16 import org.eclipse.ui.intro.IIntroPart;
17 import org.eclipse.ui.plugin.AbstractUIPlugin;
18 import org.osgi.framework.BundleContext;
19
20 /**
21  * Intro main plugin.
22  */

23 public class UniversalIntroPlugin extends AbstractUIPlugin {
24     public static final String JavaDoc PLUGIN_ID = "org.eclipse.ui.intro.universal"; //$NON-NLS-1$
25

26     // The static shared instance.
27
private static UniversalIntroPlugin inst;
28
29     // used for performance logging. Time when the constructor of
30
// CustomizableIntroPart is called.
31
private long uiCreationStartTime;
32     
33     // image registry that can be disposed while the
34
// plug-in is still active. This is important for
35
// switching themes after the plug-in has been loaded.
36
private ImageRegistry volatileImageRegistry;
37     
38     /**
39      * The constructor.
40      */

41     public UniversalIntroPlugin() {
42         super();
43     }
44
45     /**
46      * Returns the shared plugin instance.
47      */

48     public static UniversalIntroPlugin getDefault() {
49         return inst;
50     }
51     
52     /**
53      * Returns the Intro Part.
54      */

55     public static IIntroPart getIntro() {
56         IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager()
57             .getIntro();
58         return introPart;
59     }
60
61     /**
62      * Returns the Intro Part after forcing an open on it.
63      */

64     public static IIntroPart showIntro(boolean standby) {
65         IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager()
66             .showIntro(PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
67                 standby);
68         return introPart;
69     }
70
71     /**
72      * Returns the standby state of the Intro Part. If the intro is closed,
73      * retruns false.
74      */

75     public static boolean isIntroStandby() {
76         return PlatformUI.getWorkbench().getIntroManager().isIntroStandby(
77             getIntro());
78     }
79
80     /**
81      * Sets the standby state of the Intro Part. If the intro is closed, retruns
82      * false.
83      */

84     public static void setIntroStandby(boolean standby) {
85         PlatformUI.getWorkbench().getIntroManager().setIntroStandby(getIntro(),
86             standby);
87     }
88
89
90     /**
91      * Returns the standby state of the Intro Part. If the intro is closed,
92      * retruns false.
93      */

94     public static boolean closeIntro() {
95         // Relies on Workbench.
96
return PlatformUI.getWorkbench().getIntroManager().closeIntro(
97             getIntro());
98     }
99     
100     public ImageRegistry getVolatileImageRegistry() {
101         if (volatileImageRegistry==null) {
102             volatileImageRegistry = createImageRegistry();
103             initializeImageRegistry(volatileImageRegistry);
104         }
105         return volatileImageRegistry;
106     }
107     
108     public void resetVolatileImageRegistry() {
109         if (volatileImageRegistry!=null) {
110             volatileImageRegistry.dispose();
111             volatileImageRegistry = null;
112         }
113     }
114
115
116     /*
117      * (non-Javadoc)
118      *
119      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
120      */

121     public void start(BundleContext context) throws Exception JavaDoc {
122         super.start(context);
123         inst = this;
124         if (Log.logInfo)
125             Log.info("IntroPlugin - calling start on Intro bundle"); //$NON-NLS-1$
126

127     }
128
129     /*
130      * (non-Javadoc)
131      *
132      * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
133      */

134     public void stop(BundleContext context) throws Exception JavaDoc {
135         resetVolatileImageRegistry();
136         super.stop(context);
137     }
138
139     public long gettUICreationStartTime() {
140         return uiCreationStartTime;
141     }
142
143     public void setUICreationStartTime(long uiCreationStartTime) {
144         this.uiCreationStartTime = uiCreationStartTime;
145     }
146
147
148 }
149
Popular Tags