KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > designer > model > PermissionsTableModel


1 package com.opensymphony.workflow.designer.model;
2
3 import com.opensymphony.workflow.loader.PermissionDescriptor;
4 import com.opensymphony.workflow.designer.ResourceManager;
5
6 /**
7  * @author Hani Suleiman (hani@formicary.net)
8  * Date: May 20, 2003
9  * Time: 11:04:16 AM
10  */

11 public class PermissionsTableModel extends ListTableModel
12 {
13   private String JavaDoc[] header = new String JavaDoc[]{ResourceManager.getString("id"), ResourceManager.getString("name")};
14
15   public PermissionsTableModel()
16   {
17   }
18
19   public boolean isCellEditable(int rowIndex, int columnIndex)
20   {
21     return true;
22   }
23
24   public void setValueAt(Object JavaDoc aValue, int rowIndex, int columnIndex)
25   {
26     PermissionDescriptor permission = (PermissionDescriptor)list.get(rowIndex);
27     switch(columnIndex)
28     {
29       case 0:
30         if(aValue!=null)
31           permission.setId(((Integer JavaDoc)aValue).intValue());
32         break;
33       case 1:
34         permission.setName(aValue!=null ? aValue.toString() : null);
35     }
36   }
37
38   public int getColumnCount()
39   {
40     return header.length;
41   }
42
43   public String JavaDoc getColumnName(int column)
44   {
45     return header[column];
46   }
47
48   public Class JavaDoc getColumnClass(int columnIndex)
49   {
50     switch(columnIndex)
51     {
52       case 0:
53         return Integer JavaDoc.class;
54       case 1:
55         return String JavaDoc.class;
56       default:
57         return String JavaDoc.class;
58     }
59   }
60
61   public Object JavaDoc getValueAt(int rowIndex, int columnIndex)
62   {
63     PermissionDescriptor permission = (PermissionDescriptor)list.get(rowIndex);
64     switch(columnIndex)
65     {
66       case 0:
67         return new Integer JavaDoc(permission.getId());
68       case 1:
69         return permission.getName();
70       default:
71         return "";
72     }
73   }
74 }
75
Popular Tags