KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > UIPlugin


1 /*******************************************************************************
2  * Copyright (c) 2000, 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;
12
13 import org.eclipse.core.runtime.Assert;
14 import org.eclipse.jface.preference.IPreferenceStore;
15 import org.eclipse.jface.resource.ImageRegistry;
16 import org.eclipse.ui.internal.util.PrefUtil;
17 import org.eclipse.ui.plugin.AbstractUIPlugin;
18 import org.osgi.framework.BundleContext;
19
20 /**
21  * The plug-in class for the org.eclipse.ui plug-in.
22  * This class is internal to the workbench and should not be
23  * referenced by clients.
24  */

25 public final class UIPlugin extends AbstractUIPlugin {
26
27     private static UIPlugin inst;
28
29     /**
30      * Creates an instance of the UIPlugin.
31      *
32      * @since 3.0
33      */

34     public UIPlugin() {
35         super();
36         inst = this;
37     }
38
39     /**
40      * Returns the image registry for this plugin.
41      *
42      * Where are the images? The images (typically gifs) are found in the
43      * same plugins directory.
44      *
45      * @see ImageRegistry
46      *
47      * Note: The workbench uses the standard JFace ImageRegistry to track its images. In addition
48      * the class WorkbenchGraphicResources provides convenience access to the graphics resources
49      * and fast field access for some of the commonly used graphical images.
50      */

51     protected ImageRegistry createImageRegistry() {
52         /* Just to be sure that we don't access this
53          * plug-ins image registry.
54          */

55         Assert.isLegal(false);
56         return null;
57     }
58
59     public ImageRegistry getImageRegistry() {
60         /* Just to be sure that we don't access this
61          * plug-ins image registry.
62          */

63         Assert.isLegal(false);
64         return null;
65     }
66
67     /**
68      * Returns the default instance of the receiver. This represents the runtime plugin.
69      *
70      * @return UIPlugin the singleton instance of the receiver.
71      * @see AbstractUIPlugin for the typical implementation pattern for plugin classes.
72      */

73     public static UIPlugin getDefault() {
74         return inst;
75     }
76
77     /**
78      * Set default preference values.
79      * This method must be called whenever the preference store is initially loaded
80      * because the default values are not stored in the preference store.
81      */

82     protected void initializeDefaultPreferences(IPreferenceStore store) {
83         // Do nothing. This should not be called.
84
// Prefs are initialized in UIPreferenceInitializer.
85
}
86
87     /* (non-Javadoc)
88      * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
89      */

90     public void start(BundleContext context) throws Exception JavaDoc {
91         super.start(context);
92
93         // set a callback allowing the workbench plugin to obtain
94
// and save the UI plugin's preference store
95
PrefUtil.setUICallback(new PrefUtil.ICallback() {
96             public IPreferenceStore getPreferenceStore() {
97                 return UIPlugin.this.getPreferenceStore();
98             }
99
100             public void savePreferences() {
101                 UIPlugin.this.savePluginPreferences();
102             }
103         });
104     }
105 }
106
Popular Tags