KickJava   Java API By Example, From Geeks To Geeks.

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


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  * CPPropertiesPanelPanel.java
21  *
22  * Created on October 8, 2003
23  */

24
25 package org.netbeans.modules.j2ee.sun.ide.sunresources.wizards;
26
27 import java.awt.Component JavaDoc;
28 import java.util.Vector JavaDoc;
29 import org.openide.util.HelpCtx;
30
31 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair;
32 import org.netbeans.modules.j2ee.sun.sunresources.beans.Wizard;
33
34 /** A single panel descriptor for a wizard.
35  * You probably want to make a wizard iterator to hold it.
36  *
37  * @author nityad
38  */

39 public class CPPropertiesPanelPanel extends ResourceWizardPanel {
40     
41     /** The visual component that displays this panel.
42      * If you need to access the component from this class,
43      * just use getComponent().
44      */

45     private CPPropertiesPanelVisualPanel component;
46     private ResourceConfigHelper helper;
47     private Wizard wizard;
48     
49     /** Create the wizard panel descriptor. */
50     public CPPropertiesPanelPanel(ResourceConfigHelper helper, Wizard wizard) {
51         this.helper = helper;
52         this.wizard = wizard;
53     }
54     
55     // Get the visual component for the panel. In this template, the component
56
// is kept separate. This can be more efficient: if the wizard is created
57
// but never displayed, or not all panels are displayed, it is better to
58
// create only those which really need to be visible.
59
public Component JavaDoc getComponent() {
60         if (component == null) {
61             component = new CPPropertiesPanelVisualPanel(this, this.helper, this.wizard);
62         }
63         return component;
64     }
65     
66     public void refreshFields(){
67         if(component != null){
68             component.refreshFields();
69             component.setInitialFocus();
70         }
71     }
72      
73     public HelpCtx getHelp() {
74         return new HelpCtx("AS_Wiz_ConnPool_props"); //NOI18N
75
}
76     
77     public boolean isValid() {
78         // If it is always OK to press Next or Finish, then:
79
setErrorMsg(bundle.getString("Empty_String"));
80         ResourceConfigData data = helper.getData();
81         Vector JavaDoc vec = data.getProperties();
82         for (int i = 0; i < vec.size(); i++) {
83             NameValuePair pair = (NameValuePair)vec.elementAt(i);
84             if (pair.getParamName() == null || pair.getParamValue() == null ||
85                     pair.getParamName().length() == 0 || pair.getParamValue().length() == 0){
86                 setErrorMsg(bundle.getString("Err_InvalidNameValue"));
87                 return false;
88             }
89         }
90         return true;
91     }
92     
93     protected final void fireChangeEvent (Object JavaDoc source) {
94        super.fireChange(this);
95     }
96     
97     public boolean isFinishPanel() {
98        return isValid();
99     }
100 }
101
Popular Tags