View Javadoc

1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.server.ldap.gui;
21  
22  
23  import javax.swing.event.TableModelListener;
24  import javax.swing.table.TableModel;
25  
26  import org.apache.directory.shared.ldap.message.AbandonableRequest;
27  
28  
29  public class OutstandingRequestsModel implements TableModel
30  {
31      final String[] columns = new String[]
32          { "messageId", "type" };
33      final Class<?>[] columnClasses = new Class[]
34          { Integer.class, String.class };
35      final AbandonableRequest[] requests;
36  
37  
38      OutstandingRequestsModel(AbandonableRequest[] requests)
39      {
40          this.requests = requests;
41      }
42  
43  
44      AbandonableRequest getAbandonableRequest( int row )
45      {
46          return requests[row];
47      }
48  
49  
50      public int getRowCount()
51      {
52          return requests.length;
53      }
54  
55  
56      public int getColumnCount()
57      {
58          return columns.length;
59      }
60  
61  
62      public String getColumnName( int columnIndex )
63      {
64          return columns[columnIndex];
65      }
66  
67  
68      public Class<?> getColumnClass( int columnIndex )
69      {
70          return columnClasses[columnIndex];
71      }
72  
73  
74      public boolean isCellEditable( int rowIndex, int columnIndex )
75      {
76          return false;
77      }
78  
79  
80      public Object getValueAt( int rowIndex, int columnIndex )
81      {
82          AbandonableRequest req = requests[rowIndex];
83  
84          switch ( columnIndex )
85          {
86              case ( 0 ):
87                  return new Integer( req.getMessageId() );
88              case ( 1 ):
89                  return req.getType().toString();
90              default:
91                  throw new IndexOutOfBoundsException( "column index max is " + ( columns.length - 1 ) );
92          }
93      }
94  
95  
96      public void setValueAt( Object aValue, int rowIndex, int columnIndex )
97      {
98          throw new UnsupportedOperationException();
99      }
100 
101 
102     public void addTableModelListener( TableModelListener l )
103     {
104     }
105 
106 
107     public void removeTableModelListener( TableModelListener l )
108     {
109     }
110 }