KickJava   Java API By Example, From Geeks To Geeks.

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


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  * ActivationCfgPropertyModel.java October 27, 2003, 6:12 PM
21  *
22  */

23
24 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule;
25
26 import java.util.ResourceBundle JavaDoc;
27
28 import org.netbeans.modules.j2ee.sun.dd.api.ejb.ActivationConfigProperty;
29 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.BeanTableModel;
30 import org.netbeans.modules.j2ee.sun.share.configbean.MDEjb;
31 import org.netbeans.modules.j2ee.sun.share.configbean.StorageBeanFactory;
32
33 /**
34  *
35  * @author Rajeshwar Patil
36  * @version %I%, %G%
37  */

38 public class ActivationCfgPropertyModel extends BeanTableModel {
39
40     /* A class implementation comment can go here. */
41
42     /** Creates a new instance of ActivationCfgPropertyModel */
43     public ActivationCfgPropertyModel(){
44         super();
45     }
46
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[] columnNames = {
53         bundle.getString("LBL_Activation_Config_Property_Name"), //NOI18N
54
bundle.getString("LBL_Activation_Config_Property_Value") //NOI18N
55
};
56
57
58     protected String JavaDoc[] getColumnNames() {
59         return columnNames;
60     }
61
62
63     public Object JavaDoc getValueAt(int row, int column){
64         Object JavaDoc retValue = null;
65         ActivationConfigProperty param =
66             (ActivationConfigProperty)getChildren().get(row);
67         if(param != null){
68             if (column == 0){
69                 retValue = param.getActivationConfigPropertyName();
70             } else {
71                 retValue = param.getActivationConfigPropertyValue();
72             }
73         }
74         return retValue;
75     }
76
77
78     //BeanTableModel Methods
79
public Object JavaDoc addRow(Object JavaDoc[] values){
80         StorageBeanFactory storageFactory = ((MDEjb) getParent()).getConfig().getStorageFactory();
81         ActivationConfigProperty param = storageFactory.createActivationConfigProperty();
82         param.setActivationConfigPropertyName((String JavaDoc)values[0]);
83         param.setActivationConfigPropertyValue((String JavaDoc)values[1]);
84         ((MDEjb)getParent()).addActivationConfigProperty(param);
85         getChildren().add(param);
86         fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1);
87         return param;
88     }
89
90
91     public void editRow(int row, Object JavaDoc[] values){
92         ActivationConfigProperty param =
93             (ActivationConfigProperty)getChildren().get(row);
94         if(param != null){
95             param.setActivationConfigPropertyName((String JavaDoc)values[0]);
96             param.setActivationConfigPropertyValue((String JavaDoc)values[1]);
97         }
98     }
99
100
101     public void removeRow(int row){
102         ((MDEjb)getParent()).removeActivationConfigProperty(
103             (ActivationConfigProperty)getChildren().get(row));
104         getChildren().remove(row);
105         fireTableRowsDeleted(row, row);
106     }
107
108
109     public Object JavaDoc[] getValues(int row){
110         Object JavaDoc[] values = new Object JavaDoc[2];
111         ActivationConfigProperty property =
112             (ActivationConfigProperty)getChildren().get(row);
113         if(property != null){
114             values[0] = (Object JavaDoc)property.getActivationConfigPropertyName();
115             values[1] = (Object JavaDoc)property.getActivationConfigPropertyValue();
116         }
117         return values;
118     }
119
120
121     //check whether the given object already exists.
122
public boolean alreadyExists(Object JavaDoc[] values){
123         boolean exists = false;
124
125         if(values != null){
126             String JavaDoc name = (String JavaDoc)values[0];
127             if(name != null){
128                 int count = getRowCount();
129                 ActivationConfigProperty property;
130                 for(int i=0; i<count; i++){
131                     property = (ActivationConfigProperty)getChildren().get(i);
132                     if(property != null){
133                         if(name.equals(
134                                 property.getActivationConfigPropertyName())){
135                             exists = true;
136                             break;
137                         }
138                     }
139                 }
140             }
141         }
142         return exists;
143     }
144 }
145
Popular Tags