KickJava   Java API By Example, From Geeks To Geeks.

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


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;
12
13 import java.net.URL JavaDoc;
14
15 import org.eclipse.core.runtime.IBundleGroup;
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.ui.branding.IBundleGroupConstants;
18
19 /**
20  * A class that converts the strings returned by
21  * <code>org.eclipse.core.runtime.IBundleGroup.getProperty</code> to the
22  * appropriate class. This implementation is tightly bound to the properties
23  * provided in IBundleGroupConstants. Clients adding their own properties could
24  * choose to subclass this.
25  *
26  * @see org.eclipse.ui.branding.IBundleGroupConstants
27  * @since 3.0
28  */

29 public class BundleGroupProperties extends BrandingProperties implements
30         IBundleGroupConstants {
31
32     private final IBundleGroup bundleGroup;
33
34     private ImageDescriptor featureImageDescriptor;
35
36     private URL JavaDoc featureImageUrl;
37
38     private String JavaDoc tipsAndTricksHref;
39
40     private URL JavaDoc welcomePageUrl;
41
42     private String JavaDoc welcomePerspective;
43
44     private URL JavaDoc licenseUrl;
45
46     private String JavaDoc featureLabel;
47
48     private String JavaDoc featureId;
49
50     private String JavaDoc providerName;
51
52     private String JavaDoc versionId;
53
54     /**
55      * This instance will return properties from the given bundle group. The properties are
56      * retrieved in a lazy fashion and cached for later retrieval.
57      * @param bundleGroup must not be null
58      */

59     public BundleGroupProperties(IBundleGroup bundleGroup) {
60         if (bundleGroup == null) {
61             throw new IllegalArgumentException JavaDoc();
62         }
63         this.bundleGroup = bundleGroup;
64     }
65
66     /**
67      * An image which can be shown in an "about features" dialog (32x32).
68      */

69     public ImageDescriptor getFeatureImage() {
70         if (featureImageDescriptor == null) {
71             featureImageDescriptor = getFeatureImage(bundleGroup);
72         }
73         return featureImageDescriptor;
74     }
75
76     /**
77      * The URL to an image which can be shown in an "about features" dialog (32x32).
78      */

79     public URL JavaDoc getFeatureImageUrl() {
80         if (featureImageUrl == null) {
81             featureImageUrl = getFeatureImageUrl(bundleGroup);
82         }
83         return featureImageUrl;
84     }
85
86     /**
87      * A help reference for the feature's tips and tricks page (optional).
88      */

89     public String JavaDoc getTipsAndTricksHref() {
90         if (tipsAndTricksHref == null) {
91             tipsAndTricksHref = getTipsAndTricksHref(bundleGroup);
92         }
93         return tipsAndTricksHref;
94     }
95
96     /**
97      * A URL for the feature's welcome page (special XML-based format) ($nl$/
98      * prefix to permit locale-specific translations of entire file). Products
99      * designed to run "headless" typically would not have such a page.
100      */

101     public URL JavaDoc getWelcomePageUrl() {
102         if (welcomePageUrl == null) {
103             welcomePageUrl = getWelcomePageUrl(bundleGroup);
104         }
105         return welcomePageUrl;
106     }
107
108     /**
109      * The id of a perspective in which to show the welcome page (optional).
110      */

111     public String JavaDoc getWelcomePerspective() {
112         if (welcomePerspective == null) {
113             welcomePerspective = getWelcomePerspective(bundleGroup);
114         }
115         return welcomePerspective;
116     }
117
118     /**
119      * A URL for the feature's license page.
120      */

121     public URL JavaDoc getLicenseUrl() {
122         if (licenseUrl == null) {
123             licenseUrl = getLicenseUrl(bundleGroup);
124         }
125         return licenseUrl;
126     }
127
128     /**
129      * Returns a label for the feature plugn, or <code>null</code>.
130      */

131     public String JavaDoc getFeatureLabel() {
132         if (featureLabel == null) {
133             featureLabel = getFeatureLabel(bundleGroup);
134         }
135         return featureLabel;
136     }
137
138     /**
139      * Returns the id for this bundleGroup.
140      */

141     public String JavaDoc getFeatureId() {
142         if (featureId == null) {
143             featureId = getFeatureId(bundleGroup);
144         }
145         return featureId;
146     }
147
148     /**
149      * Returns the provider name.
150      */

151     public String JavaDoc getProviderName() {
152         if (providerName == null) {
153             providerName = getProviderName(bundleGroup);
154         }
155         return providerName;
156     }
157
158     /**
159      * Returns the feature version id.
160      */

161     public String JavaDoc getFeatureVersion() {
162         if (versionId == null) {
163             versionId = getFeatureVersion(bundleGroup);
164         }
165         return versionId;
166     }
167
168     /**
169      * An image which can be shown in an "about features" dialog (32x32).
170      */

171     public static ImageDescriptor getFeatureImage(IBundleGroup bundleGroup) {
172         return getImage(bundleGroup.getProperty(FEATURE_IMAGE), null);
173     }
174
175     /**
176      * The URL to an image which can be shown in an "about features" dialog (32x32).
177      */

178     public static URL JavaDoc getFeatureImageUrl(IBundleGroup bundleGroup) {
179         return getUrl(bundleGroup.getProperty(FEATURE_IMAGE), null);
180     }
181
182     /**
183      * A help reference for the feature's tips and tricks page (optional).
184      */

185     public static String JavaDoc getTipsAndTricksHref(IBundleGroup bundleGroup) {
186         return bundleGroup.getProperty(TIPS_AND_TRICKS_HREF);
187     }
188
189     /**
190      * A URL for the feature's welcome page (special XML-based format) ($nl$/
191      * prefix to permit locale-specific translations of entire file). Products
192      * designed to run "headless" typically would not have such a page.
193      */

194     public static URL JavaDoc getWelcomePageUrl(IBundleGroup bundleGroup) {
195         return getUrl(bundleGroup.getProperty(WELCOME_PAGE), null);
196     }
197
198     /**
199      * The id of a perspective in which to show the welcome page (optional).
200      */

201     public static String JavaDoc getWelcomePerspective(IBundleGroup bundleGroup) {
202         String JavaDoc property = bundleGroup.getProperty(WELCOME_PERSPECTIVE);
203         return property == null ? null : property;
204     }
205
206     /**
207      * A URL for the feature's license page.
208      */

209     public static URL JavaDoc getLicenseUrl(IBundleGroup bundleGroup) {
210         return getUrl(bundleGroup.getProperty(LICENSE_HREF), null);
211     }
212
213     /**
214      * Returns a label for the feature plugn, or <code>null</code>.
215      */

216     public static String JavaDoc getFeatureLabel(IBundleGroup bundleGroup) {
217         return bundleGroup.getName();
218     }
219
220     /**
221      * Returns the id for this bundleGroup.
222      */

223     public static String JavaDoc getFeatureId(IBundleGroup bundleGroup) {
224         return bundleGroup.getIdentifier();
225     }
226
227     /**
228      * Returns the provider name.
229      */

230     public static String JavaDoc getProviderName(IBundleGroup bundleGroup) {
231         return bundleGroup.getProviderName();
232     }
233
234     /**
235      * Returns the feature version id.
236      */

237     public static String JavaDoc getFeatureVersion(IBundleGroup bundleGroup) {
238         return bundleGroup.getVersion();
239     }
240 }
241
Popular Tags