KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > forms > FormWizardDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.forms;
12
13 import org.eclipse.jface.wizard.*;
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.widgets.*;
16 import org.eclipse.ui.forms.FormColors;
17
18 /**
19  * Modifies the standard wizard dialog to accept form wizards. Modification
20  * consists of adjusting colors and layout so that scrollable forms can be
21  * hosted.
22  *
23  * @since 3.0
24  */

25 public class FormWizardDialog extends WizardDialog {
26     protected FormColors colors;
27
28     /**
29      * Creats the wizard dialog. Colors are required to modify the dialog
30      * appearance to fit the forms.
31      *
32      * @param shell
33      * the parent shell
34      * @param wizard
35      * the wizard to host
36      * @param colors
37      * the colors to use
38      */

39     public FormWizardDialog(
40         Shell shell,
41         FormWizard wizard,
42         FormColors colors) {
43         super(shell, wizard);
44         setShellStyle(getShellStyle() | SWT.RESIZE);
45         this.colors = colors;
46     }
47     /**
48      * Extends the parent method by adjusting the colors and margins to fit the
49      * forms.
50      *
51      * @param the
52      * dialog area parent
53      * @return the dialog area
54      */

55     protected Control createDialogArea(Composite parent) {
56         Composite c = (Composite) super.createDialogArea(parent);
57         setChildColors(c);
58         c.setBackground(colors.getBackground());
59         c.setForeground(colors.getForeground());
60         return c;
61     }
62     /**
63      * Extends the parent method by adjusting the colors of the button bar.
64      *
65      * @param parent
66      * the button bar parent
67      * @return the button bar
68      */

69     protected Control createButtonBar(Composite parent) {
70         Control bar = super.createButtonBar(parent);
71         bar.setBackground(colors.getBackground());
72         bar.setForeground(colors.getForeground());
73         parent.setBackground(colors.getBackground());
74         parent.setForeground(colors.getForeground());
75         return bar;
76     }
77
78     private void setChildColors(Composite parent) {
79         Control[] children = parent.getChildren();
80         for (int i = 0; i < children.length; i++) {
81             Control child = children[i];
82             child.setBackground(colors.getBackground());
83             if (child instanceof ProgressMonitorPart)
84                 setChildColors((ProgressMonitorPart) child);
85             if (child instanceof Composite) {
86                 Layout l = ((Composite) child).getLayout();
87                 if (l instanceof PageContainerFillLayout) {
88                     PageContainerFillLayout pl = (PageContainerFillLayout) l;
89                     pl.marginWidth = 0;
90                     pl.marginHeight = 0;
91                 }
92             }
93         }
94     }
95 }
96
Popular Tags