001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.server.ldap.gui;
021
022
023 import javax.swing.event.TableModelListener;
024 import javax.swing.table.TableModel;
025
026 import org.apache.directory.shared.ldap.message.InternalAbandonableRequest;
027
028
029 public class OutstandingRequestsModel implements TableModel
030 {
031 final String[] columns = new String[]
032 { "messageId", "type" };
033 final Class<?>[] columnClasses = new Class[]
034 { Integer.class, String.class };
035 final InternalAbandonableRequest[] requests;
036
037
038 OutstandingRequestsModel(InternalAbandonableRequest[] requests)
039 {
040 this.requests = requests;
041 }
042
043
044 InternalAbandonableRequest getAbandonableRequest( int row )
045 {
046 return requests[row];
047 }
048
049
050 public int getRowCount()
051 {
052 return requests.length;
053 }
054
055
056 public int getColumnCount()
057 {
058 return columns.length;
059 }
060
061
062 public String getColumnName( int columnIndex )
063 {
064 return columns[columnIndex];
065 }
066
067
068 public Class<?> getColumnClass( int columnIndex )
069 {
070 return columnClasses[columnIndex];
071 }
072
073
074 public boolean isCellEditable( int rowIndex, int columnIndex )
075 {
076 return false;
077 }
078
079
080 public Object getValueAt( int rowIndex, int columnIndex )
081 {
082 InternalAbandonableRequest req = requests[rowIndex];
083
084 switch ( columnIndex )
085 {
086 case ( 0 ):
087 return new Integer( req.getMessageId() );
088 case ( 1 ):
089 return req.getType().toString();
090 default:
091 throw new IndexOutOfBoundsException( "column index max is " + ( columns.length - 1 ) );
092 }
093 }
094
095
096 public void setValueAt( Object aValue, int rowIndex, int columnIndex )
097 {
098 throw new UnsupportedOperationException();
099 }
100
101
102 public void addTableModelListener( TableModelListener l )
103 {
104 }
105
106
107 public void removeTableModelListener( TableModelListener l )
108 {
109 }
110 }