Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 722c25093dfb26018d9eea06dc9b61e2fc027d6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*******************************************************************************
 * Copyright (c) 2004, 2009 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.ui.internal;

import java.net.URL;

import org.eclipse.core.runtime.IBundleGroup;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.branding.IBundleGroupConstants;

/**
 * A class that converts the strings returned by
 * <code>org.eclipse.core.runtime.IBundleGroup.getProperty</code> to the
 * appropriate class. This implementation is tightly bound to the properties
 * provided in IBundleGroupConstants. Clients adding their own properties could
 * choose to subclass this.
 * 
 * @see org.eclipse.ui.branding.IBundleGroupConstants
 * @since 3.0
 */
public class BundleGroupProperties extends BrandingProperties implements
        IBundleGroupConstants {

    private final IBundleGroup bundleGroup;

    private ImageDescriptor featureImageDescriptor;

    private URL featureImageUrl;

    private String tipsAndTricksHref;

    private URL welcomePageUrl;

    private String welcomePerspective;

    private URL licenseUrl;

    private String featureLabel;

    private String featureId;

    private String providerName;

    private String versionId;

	private String brandingId;

	private String brandingVersion;

    /**
     * This instance will return properties from the given bundle group.  The properties are
     * retrieved in a lazy fashion and cached for later retrieval.
     * @param bundleGroup must not be null
     */
    public BundleGroupProperties(IBundleGroup bundleGroup) {
        if (bundleGroup == null) {
			throw new IllegalArgumentException();
		}
        this.bundleGroup = bundleGroup;
    }

    /**
     * An image which can be shown in an "about features" dialog (32x32).
     */
    public ImageDescriptor getFeatureImage() {
        if (featureImageDescriptor == null) {
			featureImageDescriptor = getFeatureImage(bundleGroup);
		}
        return featureImageDescriptor;
    }

    /**
     * The URL to an image which can be shown in an "about features" dialog (32x32).
     */
    public URL getFeatureImageUrl() {
        if (featureImageUrl == null) {
			featureImageUrl = getFeatureImageUrl(bundleGroup);
		}
        return featureImageUrl;
    }

    /**
     * A help reference for the feature's tips and tricks page (optional).
     */
    public String getTipsAndTricksHref() {
        if (tipsAndTricksHref == null) {
			tipsAndTricksHref = getTipsAndTricksHref(bundleGroup);
		}
        return tipsAndTricksHref;
    }

    /**
     * A URL for the feature's welcome page (special XML-based format) ($nl$/
     * prefix to permit locale-specific translations of entire file). Products
     * designed to run "headless" typically would not have such a page.
     */
    public URL getWelcomePageUrl() {
        if (welcomePageUrl == null) {
			welcomePageUrl = getWelcomePageUrl(bundleGroup);
		}
        return welcomePageUrl;
    }

    /**
     * The id of a perspective in which to show the welcome page (optional).
     */
    public String getWelcomePerspective() {
        if (welcomePerspective == null) {
			welcomePerspective = getWelcomePerspective(bundleGroup);
		}
        return welcomePerspective;
    }

    /**
     * A URL for the feature's license page.
     */
    public URL getLicenseUrl() {
        if (licenseUrl == null) {
			licenseUrl = getLicenseUrl(bundleGroup);
		}
        return licenseUrl;
    }

    /**
     * Returns a label for the feature plugn, or <code>null</code>.
     */
    public String getFeatureLabel() {
        if (featureLabel == null) {
			featureLabel = getFeatureLabel(bundleGroup);
		}
        return featureLabel;
    }

    /**
     * Returns the id for this bundleGroup.
     */
    public String getFeatureId() {
        if (featureId == null) {
			featureId = getFeatureId(bundleGroup);
		}
        return featureId;
    }

    /**
     * Returns the provider name.
     */
    public String getProviderName() {
        if (providerName == null) {
			providerName = getProviderName(bundleGroup);
		}
        return providerName;
    }

    /**
     * Returns the feature version id.
     */
    public String getFeatureVersion() {
        if (versionId == null) {
			versionId = getFeatureVersion(bundleGroup);
		}
        return versionId;
    }
    
	/**
	 * @return the branding plugin id, or <code>null</code>
	 */
	public String getBrandingBundleId() {
		if (brandingId == null) {
			brandingId = getBrandingBundleId(bundleGroup);
		}
		return brandingId;
	}

	/**
	 * @return the branding plugin version, or <code>null</code>
	 */
	public String getBrandingBundleVersion() {
		if (brandingVersion == null) {
			brandingVersion = getBrandingBundleVersion(bundleGroup);
		}
		return brandingVersion;
	}

    /**
     * An image which can be shown in an "about features" dialog (32x32).
     */
    public static ImageDescriptor getFeatureImage(IBundleGroup bundleGroup) {
        return getImage(bundleGroup.getProperty(FEATURE_IMAGE), null);
    }

    /**
     * The URL to an image which can be shown in an "about features" dialog (32x32).
     */
    public static URL getFeatureImageUrl(IBundleGroup bundleGroup) {
        return getUrl(bundleGroup.getProperty(FEATURE_IMAGE), null);
    }

    /**
     * A help reference for the feature's tips and tricks page (optional).
     */
    public static String getTipsAndTricksHref(IBundleGroup bundleGroup) {
        return bundleGroup.getProperty(TIPS_AND_TRICKS_HREF);
    }

    /**
     * A URL for the feature's welcome page (special XML-based format) ($nl$/
     * prefix to permit locale-specific translations of entire file). Products
     * designed to run "headless" typically would not have such a page.
     */
    public static URL getWelcomePageUrl(IBundleGroup bundleGroup) {
        return getUrl(bundleGroup.getProperty(WELCOME_PAGE), null);
    }

    /**
     * The id of a perspective in which to show the welcome page (optional).
     */
    public static String getWelcomePerspective(IBundleGroup bundleGroup) {
        String property = bundleGroup.getProperty(WELCOME_PERSPECTIVE);
        return property == null ? null : property;
    }

    /**
     * A URL for the feature's license page.
     */
    public static URL getLicenseUrl(IBundleGroup bundleGroup) {
        return getUrl(bundleGroup.getProperty(LICENSE_HREF), null);
    }

    /**
     * Returns a label for the feature plugn, or <code>null</code>.
     */
    public static String getFeatureLabel(IBundleGroup bundleGroup) {
        return bundleGroup.getName();
    }

    /**
     * Returns the id for this bundleGroup.
     */
    public static String getFeatureId(IBundleGroup bundleGroup) {
        return bundleGroup.getIdentifier();
    }

    /**
     * Returns the provider name.
     */
    public static String getProviderName(IBundleGroup bundleGroup) {
        return bundleGroup.getProviderName();
    }

    /**
     * Returns the feature version id.
     */
    public static String getFeatureVersion(IBundleGroup bundleGroup) {
        return bundleGroup.getVersion();
    }
    
	/**
	 * A Feature's branding plugin id.
	 * 
	 * @param bundleGroup
	 * @return the ID or <code>null</code> if not provided.
	 */
	public static String getBrandingBundleId(IBundleGroup bundleGroup) {
		return bundleGroup.getProperty(BRANDING_BUNDLE_ID);
	}

	/**
	 * A Feature's branding plugin version.
	 * 
	 * @param bundleGroup
	 * @return the version, or <code>null</code> if not provided.
	 */
	public static String getBrandingBundleVersion(IBundleGroup bundleGroup) {
		return bundleGroup.getProperty(BRANDING_BUNDLE_VERSION);
	}
}

Back to the top