001 /* 002 * This program is free software; you can redistribute it and/or modify 003 * it under the terms of the GNU General Public License as published by 004 * the Free Software Foundation; version 2 of the License. 005 * 006 * This program is distributed in the hope that it will be useful, 007 * but WITHOUT ANY WARRANTY; without even the implied warranty of 008 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 009 * GNU General Public License for more details. 010 * 011 * You should have received a copy of the GNU General Public License along 012 * with this program; if not, write to the Free Software Foundation, Inc., 013 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 014 */ 015 package org.tastybug.bugwerk.bugtrail.widget.incident; 016 017 import javax.swing.JTable; 018 import javax.swing.ListSelectionModel; 019 020 import org.tastybug.bugwerk.blueprint.event.IncidentChangeListener; 021 import org.tastybug.bugwerk.blueprint.model.Incident; 022 023 /** 024 * This table displays the content of a given <code>Incident</code>, including the attachments. 025 * <br> 026 * The table is not editable but displayes incident property/attachment changes. 027 * 028 * <hr> 029 * Copyright 2006 Philipp Bartsch.<br> 030 * <a href="http://www.tastybug.com">www.tastybug.com</a><br> 031 * <hr> 032 * Created on Feb 9, 2006<br> 033 * @author Philipp Bartsch, philipp.bartsch{at}tastybug{dot}com</a> 034 */ 035 public class IncidentTable extends JTable implements IncidentChangeListener { 036 037 /**The <code>serialVersionUID</code>*/ 038 private static final long serialVersionUID = -3850895701195378195L; 039 040 private IncidentTableModel tableModel; 041 private IncidentTableRenderer tableRenderer; 042 043 /** 044 * Creates the table upon <code>incident</code>. 045 * 046 * @param _incident the incident that is to be displayed 047 */ 048 public IncidentTable (Incident _incident) { 049 setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 050 tableModel = new IncidentTableModel(_incident); 051 tableRenderer = new IncidentTableRenderer(); 052 053 setModel(tableModel); 054 setDefaultRenderer(String.class, tableRenderer); 055 } 056 057 /** 058 * Updates the table model, repaints the UI. 059 * 060 * @see org.tastybug.bugwerk.blueprint.event.IncidentChangeListener#performAttachementAddedEvent(org.tastybug.bugwerk.blueprint.event.IncidentChangeListener.AttachmentEvent) 061 */ 062 public void performAttachementAddedEvent(AttachmentEvent arg0) { 063 tableModel.update(arg0.getIncident()); 064 updateUI(); 065 } 066 067 /** 068 * Updates the table model, repaints the UI. 069 * 070 * @see org.tastybug.bugwerk.blueprint.event.IncidentChangeListener#performAttachmentRemovedEvent(org.tastybug.bugwerk.blueprint.event.IncidentChangeListener.AttachmentEvent) 071 */ 072 public void performAttachmentRemovedEvent(AttachmentEvent arg0) { 073 tableModel.update(arg0.getIncident()); 074 updateUI(); 075 } 076 077 /** 078 * Updates the table model, repaints the UI. 079 * 080 * @see org.tastybug.bugwerk.blueprint.event.IncidentChangeListener#performIncidentChangedEvent(org.tastybug.bugwerk.blueprint.event.IncidentChangeListener.IncidentChangeEvent) 081 */ 082 public void performIncidentChangedEvent(IncidentChangeEvent arg0) { 083 tableModel.update(arg0.getIncident()); 084 updateUI(); 085 } 086 }