KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > ui > wizards > BannerPage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.ui.wizards;
12 import java.net.*;
13
14 import org.eclipse.jface.wizard.*;
15 import org.eclipse.swt.*;
16 import org.eclipse.swt.graphics.*;
17 import org.eclipse.swt.layout.*;
18 import org.eclipse.swt.widgets.*;
19 import org.eclipse.update.internal.ui.*;
20
21 public abstract class BannerPage extends WizardPage {
22     private Image bannerImage;
23     private boolean bannerVisible = false;
24     public BannerPage(String JavaDoc name) {
25         super(name);
26     }
27
28     public void createControl(Composite parent) {
29         Composite client = new Composite(parent, SWT.NULL);
30         GridLayout layout = new GridLayout();
31         layout.numColumns = 2;
32         layout.horizontalSpacing = 10;
33         client.setLayout(layout);
34
35         if (bannerVisible) {
36             Label label = new Label(client, SWT.NULL);
37             label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
38             label.setImage(getBannerImage());
39         }
40
41         Control contents = createContents(client);
42         contents.setLayoutData(new GridData(GridData.FILL_BOTH));
43         setControl(client);
44     }
45
46     public void setBannerVisible(boolean visible) {
47         this.bannerVisible = visible;
48     }
49     public boolean isBannedVisible() {
50         return bannerVisible;
51     }
52
53     protected URL getBannerImageURL() {
54         return null;
55     }
56     private Image getBannerImage() {
57         URL imageURL = getBannerImageURL();
58         Image image = null;
59         if (imageURL == null) {
60             // use default
61
bannerImage =
62                 UpdateUIImages.DESC_INSTALL_BANNER.createImage();
63             image = bannerImage;
64         }
65         return image;
66     }
67
68     public void dispose() {
69         if (bannerImage != null) {
70             bannerImage.dispose();
71         }
72         super.dispose();
73     }
74
75     protected abstract Control createContents(Composite parent);
76 }
77
Popular Tags