KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.eclipse.core.runtime.IProduct;
14 import org.eclipse.jface.resource.ImageDescriptor;
15
16 /**
17  * Stores information about the product. This class replaces the old AboutInfo.
18  * The product information is available as strings, but is needed as URLs, etc.
19  * This class manages that translation.
20  * @since 3.0
21  */

22 public class ProductInfo {
23     private IProduct product;
24
25     private String JavaDoc productName;
26
27     private String JavaDoc appName;
28
29     private ImageDescriptor[] windowImages;
30
31     private ImageDescriptor aboutImage;
32
33     private String JavaDoc aboutText;
34
35     public ProductInfo(IProduct product) {
36         this.product = product;
37     }
38
39     /**
40      * Returns the product name or <code>null</code>.
41      * This is shown in the window title and the About action.
42      *
43      * @return the product name, or <code>null</code>
44      */

45     public String JavaDoc getProductName() {
46         if (productName == null && product != null) {
47             productName = product.getName();
48         }
49         return productName;
50     }
51
52     /**
53      * Returns the application name or <code>null</code>. Note this is never
54      * shown to the user. It is used to initialize the SWT Display.
55      * <p>
56      * On Motif, for example, this can be used to set the name used
57      * for resource lookup.
58      * </p>
59      *
60      * @return the application name, or <code>null</code>
61      *
62      * @see org.eclipse.swt.widgets.Display#setAppName
63      */

64     public String JavaDoc getAppName() {
65         if (appName == null && product != null) {
66             appName = ProductProperties.getAppName(product);
67         }
68         return appName;
69     }
70
71     /**
72      * Returns the descriptor for an image which can be shown in an "about" dialog
73      * for this product. Products designed to run "headless" typically would not
74      * have such an image.
75      *
76      * @return the descriptor for an about image, or <code>null</code> if none
77      */

78     public ImageDescriptor getAboutImage() {
79         if (aboutImage == null && product != null) {
80             aboutImage = ProductProperties.getAboutImage(product);
81         }
82         return aboutImage;
83     }
84
85     /**
86      * Return an array of image descriptors for the window images to use for
87      * this product. The expectations is that the elements will be the same
88      * image rendered at different sizes. Products designed to run "headless"
89      * typically would not have such images.
90      *
91      * @return an array of the image descriptors for the window images, or
92      * <code>null</code> if none
93      */

94     public ImageDescriptor[] getWindowImages() {
95         if (windowImages == null && product != null) {
96             windowImages = ProductProperties.getWindowImages(product);
97         }
98         return windowImages;
99     }
100
101     /**
102      * Returns the text to show in an "about" dialog for this product.
103      * Products designed to run "headless" typically would not have such text.
104      *
105      * @return the about text, or <code>null</code> if none
106      */

107     public String JavaDoc getAboutText() {
108         if (aboutText == null && product != null) {
109             aboutText = ProductProperties.getAboutText(product);
110         }
111         return aboutText;
112     }
113 }
114
Popular Tags