KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > persistence > wizard > 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.persistence.wizard;
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
29 /**
30  * A <code>WizardDescriptor.Panel</code> which delegates to another panel.
31  * It can be used to add further validation to e.g. a panel returned by
32  * <code>JavaTemplates.createPackageChooser()</code>.
33  *
34  * <p>This class currently only implements <code>WizardDescriptor.Panel</code>
35  * and <code>WizardDescriptor.FinishablePanel</code>. It will not delegate
36  * methods in other subinterfaces of <code>WizardDescriptor.Panel</code>.</p>
37  *
38  *<p>
39  *<i>Copied from the <code>j2ee/utilities</code> module, on which j2ee/persistence
40  * can't depend. Should be removed when a more appropriate location within the ide cluster
41  * is found for the original class. </i>
42  * </p>
43  *
44  * @author Andrei Badea
45  *
46  * @since 1.9
47  */

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