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.server.i18n.I18n; 027 import org.apache.directory.shared.ldap.message.internal.InternalAbandonableRequest; 028 029 030 public class OutstandingRequestsModel implements TableModel 031 { 032 final String[] columns = new String[] 033 { "messageId", "type" }; 034 final Class<?>[] columnClasses = new Class[] 035 { Integer.class, String.class }; 036 final InternalAbandonableRequest[] requests; 037 038 039 OutstandingRequestsModel(InternalAbandonableRequest[] requests) 040 { 041 this.requests = requests; 042 } 043 044 045 InternalAbandonableRequest getAbandonableRequest( int row ) 046 { 047 return requests[row]; 048 } 049 050 051 public int getRowCount() 052 { 053 return requests.length; 054 } 055 056 057 public int getColumnCount() 058 { 059 return columns.length; 060 } 061 062 063 public String getColumnName( int columnIndex ) 064 { 065 return columns[columnIndex]; 066 } 067 068 069 public Class<?> getColumnClass( int columnIndex ) 070 { 071 return columnClasses[columnIndex]; 072 } 073 074 075 public boolean isCellEditable( int rowIndex, int columnIndex ) 076 { 077 return false; 078 } 079 080 081 public Object getValueAt( int rowIndex, int columnIndex ) 082 { 083 InternalAbandonableRequest req = requests[rowIndex]; 084 085 switch ( columnIndex ) 086 { 087 case ( 0 ): 088 return new Integer( req.getMessageId() ); 089 case ( 1 ): 090 return req.getType().toString(); 091 default: 092 throw new IndexOutOfBoundsException( I18n.err( I18n.ERR_658, ( columns.length - 1 ) ) ); 093 } 094 } 095 096 097 public void setValueAt( Object aValue, int rowIndex, int columnIndex ) 098 { 099 throw new UnsupportedOperationException(); 100 } 101 102 103 public void addTableModelListener( TableModelListener l ) 104 { 105 } 106 107 108 public void removeTableModelListener( TableModelListener l ) 109 { 110 } 111 }