KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ddloaders > web > multiview > ErrorPagesTableModel


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.web.multiview;
21
22 // Netbeans
23
import org.netbeans.modules.j2ee.dd.api.web.ErrorPage;
24 import org.netbeans.modules.j2ee.dd.api.web.WebApp;
25 import org.netbeans.modules.j2ee.dd.api.common.CommonDDBean;
26 import org.openide.util.NbBundle;
27
28 public class ErrorPagesTableModel extends DDBeanTableModel
29 {
30     private static final String JavaDoc[] columnNames = {
31             NbBundle.getMessage(ErrorPagesTableModel.class,"TTL_ErrorPageLocation"),
32             NbBundle.getMessage(ErrorPagesTableModel.class,"TTL_ErrorCode"),
33             NbBundle.getMessage(ErrorPagesTableModel.class,"TTL_ExceptionType")
34         };
35
36         protected String JavaDoc[] getColumnNames() {
37             return columnNames;
38         }
39
40     public void setValueAt(Object JavaDoc value, int row, int column)
41     {
42         ErrorPage page = (ErrorPage)getChildren().get(row);
43         if (column == 0) page.setLocation((String JavaDoc)value);
44         else if (column == 1) page.setErrorCode((Integer JavaDoc)value);
45         else page.setExceptionType((String JavaDoc)value);
46     }
47
48
49     public Object JavaDoc getValueAt(int row, int column)
50     {
51         ErrorPage page = (ErrorPage)getChildren().get(row);
52
53         if (column == 0) return page.getLocation();
54         else if (column == 1) return page.getErrorCode();
55         else return page.getExceptionType();
56     }
57         
58     public CommonDDBean addRow(Object JavaDoc[] values)
59     {
60             try {
61                 ErrorPage page = (ErrorPage)((WebApp)getParent()).createBean("ErrorPage"); //NOI18N
62
page.setLocation((String JavaDoc)values[0]);
63                 if (values[1]!=null) page.setErrorCode((Integer JavaDoc)values[1]);;
64                 if (values[2]!=null) page.setExceptionType((String JavaDoc)values[2]);
65                 ((WebApp)getParent()).addErrorPage(page);
66                 getChildren().add(page);
67                 fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1);
68                 return page;
69             } catch (ClassNotFoundException JavaDoc ex) {}
70             return null;
71     }
72
73
74     public void editRow(int row, Object JavaDoc[] values)
75     {
76                 ErrorPage page = (ErrorPage)getChildren().get(row);
77         page.setLocation((String JavaDoc)values[0]);
78                 page.setErrorCode((Integer JavaDoc)values[1]);
79                 page.setExceptionType((String JavaDoc)values[2]);
80                 fireTableRowsUpdated(row,row);
81     }
82         
83     public void removeRow(int row)
84     {
85             ((WebApp)getParent()).removeErrorPage((ErrorPage)getChildren().get(row));
86             getChildren().remove(row);
87             fireTableRowsDeleted(row, row);
88             
89     }
90 }
Popular Tags