KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > vfs > forms > ShowVfsLocksForm


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.vfs.forms;
21
22 import java.util.Collection JavaDoc;
23
24 import javax.servlet.http.HttpSession JavaDoc;
25
26 import com.sslexplorer.table.AbstractTableItemTableModel;
27 import com.sslexplorer.table.TableItem;
28 import com.sslexplorer.table.forms.AbstractPagerForm;
29 import com.sslexplorer.vfs.VFSFileLock;
30
31 /**
32  *
33  */

34 public final class ShowVfsLocksForm extends AbstractPagerForm {
35     /**
36      * Default constructor
37      */

38     public ShowVfsLocksForm() {
39         super(new VfsLockTableModel());
40     }
41
42     /**
43      * Initialise the form.
44      * @param session
45      * @param currentLocks
46      */

47     public void initialize(HttpSession JavaDoc session, Collection JavaDoc<VFSFileLock> currentLocks) {
48         super.initialize(session, "fileName");
49         for (VFSFileLock entry : currentLocks) {
50             getModel().addItem(new VfsLockTableItem(entry));
51         }
52         getPager().rebuild(getFilterText());
53     }
54
55     private static final class VfsLockTableModel extends AbstractTableItemTableModel {
56
57         public int getColumnWidth(int col) {
58             return 0;
59         }
60
61         public String JavaDoc getId() {
62             return "files";
63         }
64
65         public int getColumnCount() {
66             return 2;
67         }
68
69         public String JavaDoc getColumnName(int col) {
70             switch(col)
71             {
72                 case 0:
73                     return "fileName";
74                 case 1:
75                     return "isActive";
76             }
77             return "";
78         }
79
80         public Class JavaDoc getColumnClass(int col) {
81                 if(col==1)
82                     return Boolean JavaDoc.class;
83                 return String JavaDoc.class;
84         }
85     }
86
87     /**
88      *
89      */

90     public static final class VfsLockTableItem implements TableItem
91     {
92         private final VFSFileLock vfsFileLock_;
93         private VfsLockTableItem(VFSFileLock vfsFileLock)
94         {
95             vfsFileLock_ = vfsFileLock;
96         }
97         
98         public Object JavaDoc getColumnValue(int col) {
99             switch(col)
100             {
101                 case 0:
102                     return vfsFileLock_.getFileName();
103                 case 1:
104                     return vfsFileLock_.isActive();
105             }
106             return "";
107         }
108         
109         /**
110          * @return vfsFileLock
111          */

112         public VFSFileLock getVFSFileLock () {
113             return vfsFileLock_;
114         }
115     }
116 }
Popular Tags