KickJava   Java API By Example, From Geeks To Geeks.

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


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  * CommonPropertyPanel.java
21  *
22  * Created on November 19, 2003, 12:33 PM
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
33 import org.netbeans.modules.j2ee.sun.sunresources.beans.FieldGroup;
34 import org.netbeans.modules.j2ee.sun.sunresources.beans.Wizard;
35 import org.netbeans.modules.j2ee.sun.sunresources.beans.FieldGroupHelper;
36
37 /**
38  *
39  * @author nityad
40  */

41 public class CommonPropertyPanel extends ResourceWizardPanel {
42     
43     private CommonPropertyVisualPanel component;
44     private ResourceConfigHelper helper;
45     private Wizard wiz;
46     boolean firstTime = false;
47     /** Creates a new instance of CommonPropertyPanel */
48     public CommonPropertyPanel(ResourceConfigHelper helper, Wizard wiz) {
49         this.helper = helper;
50         this.wiz = wiz;
51     }
52     
53      // Get the visual component for the panel. In this template, the component
54
// is kept separate. This can be more efficient: if the wizard is created
55
// but never displayed, or not all panels are displayed, it is better to
56
// create only those which really need to be visible.
57
public Component JavaDoc getComponent() {
58         if (component == null) {
59             component = new CommonPropertyVisualPanel(this);
60         }
61         return component;
62     }
63     
64     public void setInitialFocus(){
65         if(component != null) {
66             component.refreshFields();
67             component.setInitialFocus();
68         }
69     }
70     
71     public FieldGroup getFieldGroup(String JavaDoc groupName) {
72         return FieldGroupHelper.getFieldGroup(wiz, groupName);
73     }
74     
75     public ResourceConfigHelper getHelper() {
76         return helper;
77     }
78     
79     public HelpCtx getHelp() {
80         if (wiz.getName().equals(__JdbcResource)) {
81             return new HelpCtx("AS_Wiz_DataSource_props"); //NOI18N
82
}else if (wiz.getName().equals(__PersistenceManagerFactoryResource)) {
83             return new HelpCtx("AS_Wiz_PMF_props"); //NOI18N
84
}else {
85             return HelpCtx.DEFAULT_HELP;
86         }
87     }
88     
89     public boolean isValid() {
90         setErrorMsg(bundle.getString("Empty_String"));
91         ResourceConfigData data = helper.getData();
92         Vector JavaDoc vec = data.getProperties();
93         for (int i = 0; i < vec.size(); i++) {
94             NameValuePair pair = (NameValuePair)vec.elementAt(i);
95             if (pair.getParamName() == null || pair.getParamValue() == null ||
96                 pair.getParamName().length() == 0 || pair.getParamValue().length() == 0){
97                 setErrorMsg(bundle.getString("Err_InvalidNameValue"));
98                 return false;
99             }
100         }
101         return true;
102     }
103     
104     
105 }
106
Popular Tags