KickJava   Java API By Example, From Geeks To Geeks.

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


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  * JmsPropertyPanel.java
21  *
22  * Created on December 12, 2002
23  */

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

45 public class JmsPropertyPanel extends ResourceWizardPanel {
46     
47     /** The visual component that displays this panel.
48      * If you need to access the component from this class,
49      * just use getComponent().
50      */

51     private JmsPropertyVisualPanel component;
52     private ResourceConfigHelper helper;
53     private Wizard wiz;
54         
55     /** Create the wizard panel descriptor. */
56     public JmsPropertyPanel(ResourceConfigHelper helper, Wizard wiz) {
57         this.helper = helper;
58         this.wiz = wiz;
59     }
60     
61     // Get the visual component for the panel. In this template, the component
62
// is kept separate. This can be more efficient: if the wizard is created
63
// but never displayed, or not all panels are displayed, it is better to
64
// create only those which really need to be visible.
65
public Component JavaDoc getComponent() {
66         if (component == null) {
67             component = new JmsPropertyVisualPanel(this);
68         }
69         return component;
70     }
71     
72     public void refreshFields(){
73         if(component != null){
74             component.refreshFields();
75             component.setInitialFocus();
76         }
77     }
78     
79     public FieldGroup getFieldGroup(String JavaDoc groupName) {
80         return FieldGroupHelper.getFieldGroup(wiz, groupName);
81     }
82     
83     public HelpCtx getHelp() {
84         return new HelpCtx("AS_Wiz_JMS_props"); //NOI18N
85
}
86     
87     public boolean isValid() {
88         setErrorMsg(bundle.getString("Empty_String"));
89         ResourceConfigData data = helper.getData();
90         Vector JavaDoc vec = data.getProperties();
91         String JavaDoc resType = data.getString(__ResType);
92         if (resType.equals("javax.jms.Queue")||resType.equals("javax.jms.Topic")) { //NO18N
93
HashMap JavaDoc map = getHashMap(vec);
94             if(! map.containsKey(WizardConstants.__AdminObjPropertyName)){
95                 setErrorMsg(bundle.getString("Err_AOName"));
96                 return false;
97             }
98         }
99         for (int i = 0; i < vec.size(); i++) {
100             NameValuePair pair = (NameValuePair)vec.elementAt(i);
101             if (pair.getParamName() == null || pair.getParamValue() == null ||
102                     pair.getParamName().length() == 0 || pair.getParamValue().length() == 0){
103                 setErrorMsg(bundle.getString("Err_InvalidNameValue"));
104                 return false;
105             }
106         }
107         return true;
108     }
109     
110     public ResourceConfigHelper getHelper() {
111         return helper;
112     }
113        
114     private HashMap JavaDoc getHashMap(Vector JavaDoc vec){
115         HashMap JavaDoc map = new HashMap JavaDoc();
116         for (int i = 0; i < vec.size(); i++) {
117             NameValuePair pair = (NameValuePair)vec.elementAt(i);
118             String JavaDoc paramName = pair.getParamName();
119             if (paramName != null && paramName.length() != 0)
120                 map.put(paramName, pair.getParamValue());
121         }
122         return map;
123     }
124 }
125
Popular Tags