KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > configurator > branding > AboutInfo


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.update.internal.configurator.branding;
12
13 import java.net.*;
14 import java.util.Hashtable JavaDoc;
15
16 import org.eclipse.core.runtime.*;
17
18
19 /**
20  * The information within this object is obtained from the about INI file.
21  * This file resides within an install configurations directory and must be a
22  * standard java property file.
23  * <p>
24  * This class is not intended to be instantiated or subclassed by clients.
25  * </p>
26  */

27 public final class AboutInfo {
28     private final static String JavaDoc INI_FILENAME = "about.ini"; //$NON-NLS-1$
29
private final static String JavaDoc PROPERTIES_FILENAME = "about.properties"; //$NON-NLS-1$
30
private final static String JavaDoc MAPPINGS_FILENAME = "about.mappings"; //$NON-NLS-1$
31

32     private String JavaDoc featureId;
33     private String JavaDoc versionId = ""; //$NON-NLS-1$
34
private String JavaDoc featurePluginLabel;
35     private String JavaDoc providerName;
36     private String JavaDoc appName;
37     private URL windowImageURL;
38     private URL[] windowImagesURLs;
39     private URL aboutImageURL;
40     private URL featureImageURL;
41     private URL welcomePageURL;
42     private String JavaDoc aboutText;
43     private String JavaDoc welcomePerspective;
44     private String JavaDoc tipsAndTricksHref;
45
46
47     /*
48      * Create a new about info for a feature with the given id.
49      */

50     /* package */ AboutInfo(String JavaDoc featureId) {
51         super();
52         this.featureId = featureId;
53     }
54
55     /**
56      * Returns the configuration information for the feature with the
57      * given id.
58      *
59      * @param featureId the feature id
60      * @param versionId the version id (of the feature)
61      * @param pluginId the plug-in id
62      * @return the configuration information for the feature
63      */

64     public static AboutInfo readFeatureInfo(String JavaDoc featureId, String JavaDoc versionId, String JavaDoc pluginId) {
65 // Assert.isNotNull(featureId);
66
// Assert.isNotNull(versionId);
67
// Assert.isNotNull(pluginId);
68
IniFileReader reader = new IniFileReader(featureId, pluginId, INI_FILENAME, PROPERTIES_FILENAME, MAPPINGS_FILENAME);
69         reader.load();
70 // bug 78031
71
// if (!status.isOK()) {
72
// //return null;
73
// return new AboutInfo(featureId); // dummy about info
74
// }
75

76         AboutInfo info = new AboutInfo(featureId);
77         Hashtable JavaDoc runtimeMappings = new Hashtable JavaDoc();
78         runtimeMappings.put("{featureVersion}", versionId); //$NON-NLS-1$
79
info.versionId = versionId;
80         info.featurePluginLabel = reader.getFeaturePluginLabel();
81         info.providerName = reader.getProviderName();
82         info.appName = reader.getString("appName", true, runtimeMappings); //$NON-NLS-1$
83
info.aboutText = reader.getString("aboutText", true, runtimeMappings); //$NON-NLS-1$
84
info.windowImageURL = reader.getURL("windowImage"); //$NON-NLS-1$
85
// look for the newer array, but if its not there then use the older,
86
// single image definition
87
info.windowImagesURLs = reader.getURLs("windowImages"); //$NON-NLS-1$
88
info.aboutImageURL = reader.getURL("aboutImage"); //$NON-NLS-1$
89
info.featureImageURL = reader.getURL("featureImage"); //$NON-NLS-1$
90
info.welcomePageURL = reader.getURL("welcomePage"); //$NON-NLS-1$
91
info.welcomePerspective = reader.getString("welcomePerspective", false, runtimeMappings); //$NON-NLS-1$
92
info.tipsAndTricksHref = reader.getString("tipsAndTricksHref", false, runtimeMappings); //$NON-NLS-1$
93
return info;
94     }
95     
96     /**
97      * Returns the URL for an image which can be shown in an "about" dialog
98      * for this product. Products designed to run "headless" typically would not
99      * have such an image.
100      *
101      * @return the URL for an about image, or <code>null</code> if none
102      */

103     public URL getAboutImageURL() {
104         return aboutImageURL;
105     }
106
107     /**
108      * Returns the URL for an image which can be shown in an "about features"
109      * dialog. Products designed to run "headless" typically would not have such an image.
110      *
111      * @return the URL for a feature image, or <code>null</code> if none
112      */

113     public URL getFeatureImageURL() {
114         return featureImageURL;
115     }
116
117     /**
118      * Returns the simple name of the feature image file.
119      *
120      * @return the simple name of the feature image file,
121      * or <code>null</code> if none
122      */

123     public String JavaDoc getFeatureImageName() {
124         if (featureImageURL != null) {
125             IPath path = new Path(featureImageURL.getPath());
126             return path.lastSegment();
127         }
128         return null;
129     }
130
131         
132     /**
133      * Returns a label for the feature plugn, or <code>null</code>.
134      */

135     public String JavaDoc getFeatureLabel() {
136         return featurePluginLabel;
137     }
138
139     /**
140      * Returns the id for this feature.
141      *
142      * @return the feature id
143      */

144     public String JavaDoc getFeatureId() {
145         return featureId;
146     }
147     
148     /**
149      * Returns the text to show in an "about" dialog for this product.
150      * Products designed to run "headless" typically would not have such text.
151      *
152      * @return the about text, or <code>null</code> if none
153      */

154     public String JavaDoc getAboutText() {
155         return aboutText;
156     }
157
158     /**
159      * Returns the application name or <code>null</code>.
160      * Note this is never shown to the user.
161      * It is used to initialize the SWT Display.
162      * <p>
163      * On Motif, for example, this can be used
164      * to set the name used for resource lookup.
165      * </p>
166      *
167      * @return the application name, or <code>null</code>
168      */

169     public String JavaDoc getAppName() {
170         return appName;
171     }
172
173     /**
174      * Returns the product name or <code>null</code>.
175      * This is shown in the window title and the About action.
176      *
177      * @return the product name, or <code>null</code>
178      */

179     public String JavaDoc getProductName() {
180         return featurePluginLabel;
181     }
182
183     /**
184      * Returns the provider name or <code>null</code>.
185      *
186      * @return the provider name, or <code>null</code>
187      */

188     public String JavaDoc getProviderName() {
189         return providerName;
190     }
191
192     /**
193      * Returns the feature version id.
194      *
195      * @return the version id of the feature
196      */

197     public String JavaDoc getVersionId() {
198         return versionId;
199     }
200
201     /**
202      * Returns a <code>URL</code> for the welcome page.
203      * Products designed to run "headless" typically would not have such an page.
204      *
205      * @return the welcome page, or <code>null</code> if none
206      */

207     public URL getWelcomePageURL() {
208         return welcomePageURL;
209     }
210
211     /**
212      * Returns the ID of a perspective in which to show the welcome page.
213      * May be <code>null</code>.
214      *
215      * @return the welcome page perspective id, or <code>null</code> if none
216      */

217     public String JavaDoc getWelcomePerspectiveId() {
218         return welcomePerspective;
219     }
220
221     /**
222      * Returns a <code>String</code> for the tips and trick href.
223      *
224      * @return the tips and tricks href, or <code>null</code> if none
225      */

226     public String JavaDoc getTipsAndTricksHref() {
227         return tipsAndTricksHref;
228     }
229
230     /**
231      * Returns the image url for the window image to use for this product.
232      * Products designed to run "headless" typically would not have such an image.
233      *
234      * @return the image url for the window image, or <code>null</code> if none
235      */

236     public URL getWindowImageURL() {
237         return windowImageURL;
238     }
239     
240     /**
241      * Return an array of image URLs for the window images to use for
242      * this product. The expectations is that the elements will be the same
243      * image rendered at different sizes. Products designed to run "headless"
244      * typically would not have such images.
245      *
246      * @return an array of the image descriptors for the window images, or
247      * <code>null</code> if none
248      * @since 3.0
249      */

250     public URL[] getWindowImagesURLs() {
251         return windowImagesURLs;
252     }
253 }
254
Popular Tags