KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > common > DelegatingWizardDescriptorPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.common;
21
22 import java.awt.Component JavaDoc;
23 import javax.swing.event.ChangeListener JavaDoc;
24 import org.netbeans.api.project.Project;
25 import org.netbeans.spi.project.ui.templates.support.Templates;
26 import org.openide.WizardDescriptor;
27 import org.openide.util.HelpCtx;
28 import org.openide.util.NbBundle;
29
30 /**
31  * A <code>WizardDescriptor.Panel</code> which delegates to another panel.
32  * It can be used to add further validation to e.g. a panel returned by
33  * <code>JavaTemplates.createPackageChooser()</code>.
34  *
35  * <p>This class currently only implements <code>WizardDescriptor.Panel</code>
36  * and <code>WizardDescriptor.FinishablePanel</code>. It will not delegate
37  * methods in other subinterfaces of <code>WizardDescriptor.Panel</code>.</p>
38  *
39  * @author Andrei Badea
40  *
41  * @since 1.9
42  */

43 public class DelegatingWizardDescriptorPanel implements WizardDescriptor.Panel, WizardDescriptor.FinishablePanel {
44
45     private final WizardDescriptor.Panel delegate;
46
47     private WizardDescriptor wizardDescriptor;
48     private Project project;
49
50     public DelegatingWizardDescriptorPanel(WizardDescriptor.Panel delegate) {
51         this.delegate = delegate;
52     }
53
54     public Component JavaDoc getComponent() {
55         return delegate.getComponent();
56     }
57
58     public HelpCtx getHelp() {
59         return delegate.getHelp();
60     }
61
62     public void readSettings(Object JavaDoc settings) {
63         if (wizardDescriptor == null) {
64             wizardDescriptor = (WizardDescriptor)settings;
65             project = Templates.getProject((WizardDescriptor)settings);
66         }
67         delegate.readSettings(settings);
68     }
69
70     public void storeSettings(Object JavaDoc settings) {
71         delegate.storeSettings(settings);
72     }
73
74     public boolean isValid() {
75         return delegate.isValid();
76     }
77
78     public void addChangeListener(ChangeListener JavaDoc l) {
79         delegate.addChangeListener(l);
80     }
81
82     public void removeChangeListener(ChangeListener JavaDoc l) {
83         delegate.removeChangeListener(l);
84     }
85
86     public boolean isFinishPanel() {
87         if (delegate instanceof WizardDescriptor.FinishablePanel) {
88             return ((WizardDescriptor.FinishablePanel)delegate).isFinishPanel();
89         }
90         return false;
91     }
92
93     protected WizardDescriptor getWizardDescriptor() {
94         return wizardDescriptor;
95     }
96
97     protected Project getProject() {
98         return project;
99     }
100 }
101
Popular Tags