KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ddloaders > multiview > EjbHelper


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.ddloaders.multiview;
21
22 import org.netbeans.modules.j2ee.dd.api.common.EnvEntry;
23 import org.netbeans.modules.j2ee.dd.api.ejb.Ejb;
24
25 /**
26  * @author pfiala
27  */

28 public class EjbHelper {
29     private EjbJarMultiViewDataObject dataObject;
30     private Ejb ejb;
31
32     public EjbHelper(EjbJarMultiViewDataObject dataObject, Ejb ejb) {
33         this.dataObject = dataObject;
34         this.ejb = ejb;
35     }
36
37     public EnvEntryHelper getEnvEntryHelper(int rowIndex) {
38         return new EnvEntryHelper(ejb.getEnvEntry(rowIndex));
39     }
40
41     public int getEnvEntryCount() {
42         return ejb.getEnvEntry().length;
43     }
44
45     public EnvEntryHelper newEnvEntry() {
46         EnvEntry entry = ejb.newEnvEntry();
47         ejb.addEnvEntry(entry);
48         modelUpdatedFromUI();
49         return new EnvEntryHelper(entry);
50     }
51
52     public void removeEnvEntry(int row) {
53         ejb.removeEnvEntry(ejb.getEnvEntry(row));
54         modelUpdatedFromUI();
55     }
56
57     private void modelUpdatedFromUI() {
58         dataObject.modelUpdatedFromUI();
59     }
60
61     public class EnvEntryHelper {
62         private EnvEntry envEntry;
63
64         public EnvEntryHelper(EnvEntry envEntry) {
65             this.envEntry = envEntry;
66             modelUpdatedFromUI();
67         }
68
69         public void setEnvEntryName(String JavaDoc value) {
70             envEntry.setEnvEntryName(value);
71             modelUpdatedFromUI();
72         }
73
74         public void setEnvEntryType(String JavaDoc value) {
75             envEntry.setEnvEntryType(value);
76             modelUpdatedFromUI();
77         }
78
79         public void setEnvEntryValue(String JavaDoc value) {
80             envEntry.setEnvEntryValue(value);
81             modelUpdatedFromUI();
82         }
83
84         public void setDescription(String JavaDoc description) {
85             envEntry.setDescription(description);
86             modelUpdatedFromUI();
87         }
88
89         public String JavaDoc getEnvEntryName() {
90             return envEntry.getEnvEntryName();
91         }
92
93         public String JavaDoc getEnvEntryType() {
94             return envEntry.getEnvEntryType();
95         }
96
97         public String JavaDoc getEnvEntryValue() {
98             return envEntry.getEnvEntryValue();
99         }
100
101         public String JavaDoc getDefaultDescription() {
102             return envEntry.getDefaultDescription();
103         }
104     }
105 }
106
Popular Tags