001: /*******************************************************************************
002: * Copyright (c) 2004, 2006 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.internal.intro.impl;
011:
012: import org.eclipse.core.runtime.Platform;
013: import org.eclipse.jface.resource.ImageRegistry;
014: import org.eclipse.ui.PlatformUI;
015: import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot;
016: import org.eclipse.ui.internal.intro.impl.model.loader.ExtensionPointManager;
017: import org.eclipse.ui.internal.intro.impl.presentations.IntroLaunchBar;
018: import org.eclipse.ui.internal.intro.impl.util.Log;
019: import org.eclipse.ui.intro.IIntroPart;
020: import org.eclipse.ui.plugin.AbstractUIPlugin;
021: import org.osgi.framework.BundleContext;
022:
023: /**
024: * Intro main plugin.
025: */
026: public class IntroPlugin extends AbstractUIPlugin {
027: public static final String PLUGIN_ID = "org.eclipse.ui.intro"; //$NON-NLS-1$
028:
029: // The static shared instance.
030: private static IntroPlugin inst;
031:
032: // We must keep track of the launch bar so that we can
033: // close it if intro is opened from the menu.
034: private IntroLaunchBar launchBar;
035:
036: // used for performance logging. Time when the constructor of
037: // CustomizableIntroPart is called.
038: private long uiCreationStartTime;
039:
040: // image registry that can be disposed while the
041: // plug-in is still active. This is important for
042: // switching themes after the plug-in has been loaded.
043: private ImageRegistry volatileImageRegistry;
044:
045: // debug options
046: public static boolean DEBUG = false;
047: public static boolean DEBUG_NO_BROWSER = false;
048:
049: /**
050: * The constructor.
051: */
052: public IntroPlugin() {
053: super ();
054: }
055:
056: /**
057: * Returns the shared plugin instance.
058: */
059: public static IntroPlugin getDefault() {
060: return inst;
061: }
062:
063: public ImageRegistry getVolatileImageRegistry() {
064: if (volatileImageRegistry == null) {
065: volatileImageRegistry = createImageRegistry();
066: initializeImageRegistry(volatileImageRegistry);
067: }
068: return volatileImageRegistry;
069: }
070:
071: public void resetVolatileImageRegistry() {
072: if (volatileImageRegistry != null) {
073: volatileImageRegistry.dispose();
074: volatileImageRegistry = null;
075: }
076: }
077:
078: public void closeLaunchBar() {
079: if (launchBar != null) {
080: launchBar.close();
081: launchBar = null;
082: }
083: }
084:
085: public void setLaunchBar(IntroLaunchBar launchBar) {
086: this .launchBar = launchBar;
087: }
088:
089: /**
090: * @return Returns the extensionPointManager.
091: */
092: public ExtensionPointManager getExtensionPointManager() {
093: return ExtensionPointManager.getInst();
094: }
095:
096: /**
097: * Returns the model root. Will always guarantee that model is loaded.
098: *
099: * @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()
110: .getIntroManager().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()
119: .getIntroManager().showIntro(
120: PlatformUI.getWorkbench()
121: .getActiveWorkbenchWindow(), standby);
122: return introPart;
123: }
124:
125: /**
126: * Returns the standby state of the Intro Part. If the intro is closed,
127: * retruns false.
128: */
129: public static boolean isIntroStandby() {
130: return PlatformUI.getWorkbench().getIntroManager()
131: .isIntroStandby(getIntro());
132: }
133:
134: /**
135: * Sets the standby state of the Intro Part. If the intro is closed, retruns
136: * false.
137: */
138: public static void setIntroStandby(boolean standby) {
139: PlatformUI.getWorkbench().getIntroManager().setIntroStandby(
140: getIntro(), standby);
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: * (non-Javadoc)
155: *
156: * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
157: */
158: public void start(BundleContext context) throws Exception {
159: super .start(context);
160: inst = this ;
161: if (Log.logInfo)
162: Log.info("IntroPlugin - calling start on Intro bundle"); //$NON-NLS-1$
163: // Setup debugging options
164: DEBUG = isDebugging();
165: if (DEBUG) {
166: DEBUG_NO_BROWSER = "true".equalsIgnoreCase(Platform.getDebugOption(PLUGIN_ID + "/flags/noBrowser")); //$NON-NLS-1$ //$NON-NLS-2$
167: }
168:
169: }
170:
171: /*
172: * (non-Javadoc)
173: *
174: * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
175: */
176: public void stop(BundleContext context) throws Exception {
177: resetVolatileImageRegistry();
178: super .stop(context);
179: }
180:
181: public long gettUICreationStartTime() {
182: return uiCreationStartTime;
183: }
184:
185: public void setUICreationStartTime(long uiCreationStartTime) {
186: this.uiCreationStartTime = uiCreationStartTime;
187: }
188:
189: }
|