RowChangeEvent.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:3k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: RowChangeEvent.java,v 1.4 2005/10/15 11:43:20 pdoubleya Exp $
  3.  *
  4.  * Copyright 2005 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  */
  21. package org.jdesktop.dataset.event;
  22. import java.util.EventObject;
  23. import org.jdesktop.dataset.DataColumn;
  24. import org.jdesktop.dataset.DataRow;
  25. /**
  26.  * A <CODE>RowChangeEvent</CODE> is broadcast by a data table to {@linkplain DataTableListener listeners} as {@linkplain DataRow rows} are changed, 
  27.  * on a per-row basis. An <CODE>EventType</CODE> enumeration identifies the type of change. A change to a column's value which affects row
  28.  * status results in two events being broadcast, one for the column change and one for the row status change.
  29.  * @author Richard Bair
  30.  * @author Patrick Wright
  31.  */
  32. public class RowChangeEvent extends EventObject {
  33.     public enum EventType {
  34.         ROW_STATUS_CHANGED,
  35.         CELL_CHANGED
  36.     };
  37.     
  38.     private EventType eventType;
  39.     private DataColumn columnAffected;
  40.     private Object priorColumnValue;
  41.     private DataRow.DataRowStatus priorRowStatus;
  42.     
  43.     private RowChangeEvent(DataRow source) {
  44.         super(source);
  45.     }
  46.     
  47.     public static RowChangeEvent newRowStatusChangeEvent(DataRow source, DataRow.DataRowStatus priorStatus) {
  48.         RowChangeEvent rce = new RowChangeEvent(source);
  49.         rce.eventType = EventType.ROW_STATUS_CHANGED;
  50.         rce.priorRowStatus = priorStatus;
  51.         return rce;
  52.     }
  53.     public static RowChangeEvent newCellChangedEvent(DataRow source, DataColumn col, Object priorValue) {
  54.         RowChangeEvent rce = new RowChangeEvent(source);
  55.         rce.eventType = EventType.CELL_CHANGED;
  56.         rce.columnAffected = col;
  57.         rce.priorColumnValue = priorValue;
  58.         return rce;
  59.     }
  60.     
  61.     /**
  62.      * The event classification.
  63.      **/
  64.     public EventType getEventType() {
  65.         return eventType;
  66.     }
  67.     
  68.     /** 
  69.      * The column whose value was updated or set to null; will be null if this event is a row
  70.      * status change. 
  71.      **/
  72.     public DataColumn getColumnAffected() {
  73.         return columnAffected;
  74.     }
  75.     
  76.     /** On a change to a column's value, the column's value before the change. */
  77.     public Object getPriorColumnValue() {
  78.         return priorColumnValue;
  79.     }
  80.     
  81.     /** On a row status change, the row status before the change. */
  82.     public DataRow.DataRowStatus getPriorRowStatus() {
  83.         return priorRowStatus;
  84.     }
  85. }