001: /*******************************************************************************
002: * Copyright (c) 2004, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal;
011:
012: import org.eclipse.core.runtime.IProduct;
013: import org.eclipse.jface.resource.ImageDescriptor;
014:
015: /**
016: * Stores information about the product. This class replaces the old AboutInfo.
017: * The product information is available as strings, but is needed as URLs, etc.
018: * This class manages that translation.
019: * @since 3.0
020: */
021: public class ProductInfo {
022: private IProduct product;
023:
024: private String productName;
025:
026: private String appName;
027:
028: private ImageDescriptor[] windowImages;
029:
030: private ImageDescriptor aboutImage;
031:
032: private String aboutText;
033:
034: public ProductInfo(IProduct product) {
035: this .product = product;
036: }
037:
038: /**
039: * Returns the product name or <code>null</code>.
040: * This is shown in the window title and the About action.
041: *
042: * @return the product name, or <code>null</code>
043: */
044: public String getProductName() {
045: if (productName == null && product != null) {
046: productName = product.getName();
047: }
048: return productName;
049: }
050:
051: /**
052: * Returns the application name or <code>null</code>. Note this is never
053: * shown to the user. It is used to initialize the SWT Display.
054: * <p>
055: * On Motif, for example, this can be used to set the name used
056: * for resource lookup.
057: * </p>
058: *
059: * @return the application name, or <code>null</code>
060: *
061: * @see org.eclipse.swt.widgets.Display#setAppName
062: */
063: public String getAppName() {
064: if (appName == null && product != null) {
065: appName = ProductProperties.getAppName(product);
066: }
067: return appName;
068: }
069:
070: /**
071: * Returns the descriptor for an image which can be shown in an "about" dialog
072: * for this product. Products designed to run "headless" typically would not
073: * have such an image.
074: *
075: * @return the descriptor for an about image, or <code>null</code> if none
076: */
077: public ImageDescriptor getAboutImage() {
078: if (aboutImage == null && product != null) {
079: aboutImage = ProductProperties.getAboutImage(product);
080: }
081: return aboutImage;
082: }
083:
084: /**
085: * Return an array of image descriptors for the window images to use for
086: * this product. The expectations is that the elements will be the same
087: * image rendered at different sizes. Products designed to run "headless"
088: * typically would not have such images.
089: *
090: * @return an array of the image descriptors for the window images, or
091: * <code>null</code> if none
092: */
093: public ImageDescriptor[] getWindowImages() {
094: if (windowImages == null && product != null) {
095: windowImages = ProductProperties.getWindowImages(product);
096: }
097: return windowImages;
098: }
099:
100: /**
101: * Returns the text to show in an "about" dialog for this product.
102: * Products designed to run "headless" typically would not have such text.
103: *
104: * @return the about text, or <code>null</code> if none
105: */
106: public String getAboutText() {
107: if (aboutText == null && product != null) {
108: aboutText = ProductProperties.getAboutText(product);
109: }
110: return aboutText;
111: }
112: }
|