KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > sunresources > wizards > ResourceWizardPanel


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.sun.ide.sunresources.wizards;
21
22 import java.text.MessageFormat JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.ResourceBundle JavaDoc;
25 import javax.swing.event.ChangeEvent JavaDoc;
26 import javax.swing.event.ChangeListener JavaDoc;
27 import org.netbeans.modules.j2ee.sun.sunresources.beans.WizardConstants;
28
29 import org.openide.util.HelpCtx;
30 import org.openide.WizardDescriptor;
31 import org.openide.util.NbBundle;
32
33 public abstract class ResourceWizardPanel extends javax.swing.JPanel JavaDoc implements WizardDescriptor.FinishablePanel, WizardConstants {
34
35     private ArrayList JavaDoc list;
36
37     /** Default preferred width of the panel - should be the same for all panels within one wizard */
38     private static final int DEFAULT_WIDTH = 600;
39     /** Default preferred height of the panel - should be the same for all panels within one wizard */
40     private static final int DEFAULT_HEIGHT = 390;
41    
42     public WizardDescriptor wizDescriptor;
43     public ResourceBundle JavaDoc bundle = NbBundle.getBundle("org.netbeans.modules.j2ee.sun.ide.sunresources.wizards.Bundle"); //NOI18N
44

45     public ResourceWizardPanel() {
46         list = new ArrayList JavaDoc();
47     }
48
49     /** @return preferred size of the wizard panel - it should be the same for all panels within one Wizard
50     * so that the wizard dialog does not change its size when switching between panels */

51     public java.awt.Dimension JavaDoc getPreferredSize () {
52         return new java.awt.Dimension JavaDoc (DEFAULT_WIDTH, DEFAULT_HEIGHT);
53     }
54
55     public HelpCtx getHelp() {
56         return null; // HelpCtx.DEFAULT_HELP;
57
}
58
59     public java.awt.Component JavaDoc getComponent() {
60         return this;
61     }
62
63     public void fireChange (Object JavaDoc source) {
64         ArrayList JavaDoc lst;
65
66         synchronized (this) {
67             lst = (ArrayList JavaDoc) this.list.clone();
68         }
69
70         ChangeEvent JavaDoc event = new ChangeEvent JavaDoc(source);
71         for (int i=0; i< lst.size(); i++){
72             ChangeListener JavaDoc listener = (ChangeListener JavaDoc) lst.get(i);
73             listener.stateChanged(event);
74         }
75     }
76
77     public synchronized void addChangeListener (ChangeListener JavaDoc listener) {
78         list.add(listener);
79     }
80
81     public synchronized void removeChangeListener (ChangeListener JavaDoc listener) {
82         list.remove(listener);
83     }
84     
85     public boolean isFinishPanel() {
86         return false;
87     }
88     
89     public void setErrorMsg(String JavaDoc message) {
90         if (this.wizDescriptor != null) {
91             this.wizDescriptor.putProperty("WizardPanel_errorMessage", message); //NOI18N
92
}
93     }
94     
95     public void setErrorMessage(String JavaDoc msg, String JavaDoc value){
96         String JavaDoc message = MessageFormat.format(msg, new Object JavaDoc[] {value});
97         setErrorMsg(message);
98     }
99     
100     public void readSettings(Object JavaDoc settings) {
101         this.wizDescriptor = (WizardDescriptor)settings;
102     }
103     
104     public void storeSettings(Object JavaDoc settings) {
105     }
106     
107 }
108
Popular Tags