KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > ejbmodule > PropertyDialog


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  * PropertyDialog.java
21  *
22  * Created on October 13, 2003, 11:36 AM
23  */

24
25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule;
26
27 import java.util.ArrayList JavaDoc;
28 import java.util.Collection JavaDoc;
29 import java.util.ResourceBundle JavaDoc;
30
31 import javax.swing.JPanel JavaDoc;
32
33 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.BeanInputDialog;
34
35 /**
36  *
37  * @author Rajeshwar Patil
38  * @version %I%, %G%
39  */

40
41 public class PropertyDialog extends BeanInputDialog{
42     /* A class implementation comment can go here. */
43     String JavaDoc name;
44     String JavaDoc value;
45     PropertyDialogPanel propertyDlgPanel;
46     String JavaDoc helpId;
47
48     static final ResourceBundle JavaDoc bundle =
49         ResourceBundle.getBundle(
50             "org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.Bundle"); // NOI18N
51

52     private static final String JavaDoc ACTIVATION_CONFIG_PROPERTY = "AS_CFG_Activation_Config_Property"; //NOI18N
53

54
55     /** Creates a new instance of PropertyDialog */
56     public PropertyDialog(ActivationCfgPropertyPanel parent,
57             String JavaDoc title, Object JavaDoc[] values){
58         super(parent, title, true, values);
59         name = (String JavaDoc)values[0];
60         value = (String JavaDoc)values[1];
61         helpId = ACTIVATION_CONFIG_PROPERTY;
62     }
63
64
65     public PropertyDialog(ActivationCfgPropertyPanel parent,
66             String JavaDoc title){
67         super(parent, title, true);
68         helpId = ACTIVATION_CONFIG_PROPERTY;
69     }
70
71
72     public String JavaDoc getHelpId() {
73         return helpId;
74     }
75
76
77     protected JPanel JavaDoc getDialogPanel(Object JavaDoc[] values){
78         //called in case of EDIT operation
79
//create panel
80
//initialize all the components in the panel
81
//provide handlers for all the components; these handlers will update
82
// name and value.
83
propertyDlgPanel = new PropertyDialogPanel(values);
84         return propertyDlgPanel;
85     }
86
87
88     protected JPanel JavaDoc getDialogPanel(){
89         //called in case of ADD operation
90
//create panel
91
//initialize all the components in the panel
92
//provide handlers for all the components; these handlers will update
93
// name and value.
94
propertyDlgPanel = new PropertyDialogPanel();
95         return propertyDlgPanel;
96     }
97
98
99     protected Object JavaDoc[] getValues(){
100         Object JavaDoc[] values = new Object JavaDoc[2];
101         values[0] = (Object JavaDoc)propertyDlgPanel.getName();
102         values[1] = (Object JavaDoc)propertyDlgPanel.getValue();
103         return values;
104     }
105
106
107     protected Collection JavaDoc getErrors(){
108         ArrayList JavaDoc errors = new ArrayList JavaDoc();
109
110         //perform validation for name and value.
111
if(validationSupport == null) assert(false);
112
113         String JavaDoc property = propertyDlgPanel.getName();
114         errors.addAll(validationSupport.validate(property,
115             "/sun-ejb-jar/enterprise-beans/cmp-resource/property/name", //NOI18N
116
bundle.getString("LBL_Name"))); //NOI18N
117

118         property = propertyDlgPanel.getValue();
119         errors.addAll(validationSupport.validate(property,
120             "/sun-ejb-jar/enterprise-beans/cmp-resource/property/value",//NOI18N
121
bundle.getString("LBL_Value"))); //NOI18N
122

123         return errors;
124     }
125
126
127     // returns number of elements in this dialog
128
protected int getNOofFields() {
129         return 2;
130     }
131 }
132
Popular Tags