001: //** Copyright Statement ***************************************************
002: //The Salmon Open Framework for Internet Applications (SOFIA)
003: // Copyright (C) 1999 - 2002, Salmon LLC
004: //
005: // This program is free software; you can redistribute it and/or
006: // modify it under the terms of the GNU General Public License version 2
007: // as published by the Free Software Foundation;
008: //
009: // This program is distributed in the hope that it will be useful,
010: // but WITHOUT ANY WARRANTY; without even the implied warranty of
011: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: // GNU General Public License for more details.
013: //
014: // You should have received a copy of the GNU General Public License
015: // along with this program; if not, write to the Free Software
016: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: //
018: // For more information please visit http://www.salmonllc.com
019: //** End Copyright Statement ***************************************************
020: package com.salmonllc.swing.events;
021:
022: /////////////////////////
023: //$Archive: /SOFIA/SourceCode/com/salmonllc/swing/events/ValueChangedEvent.java $
024: //$Author: Dan $
025: //$Revision: 5 $
026: //$Modtime: 6/11/03 4:29p $
027: /////////////////////////
028:
029: import com.salmonllc.sql.*;
030:
031: /**
032: * This object will be created and passed to every value changed event method.
033: * @see ValueChangedListener
034: */
035:
036: public class ValueChangedEvent extends java.awt.AWTEvent {
037: String _oldValue;
038: String _newValue;
039: int _row;
040: int _column;
041: boolean _acceptValue = true;
042: DataStoreBuffer _ds;
043:
044: public static final int PROCESSING_DISCARD_CHANGE = 1;
045: public static final int PROCESSING_MOVE_CHANGE_TO_TEMP = 2;
046: public static final int PROCESSING_COMMIT_CHANGE = 3;
047:
048: public int _processingInstruction = PROCESSING_COMMIT_CHANGE;
049:
050: /**
051: * Constructs a new event
052: */
053: public ValueChangedEvent(Object comp, String oldValue,
054: String newValue, DataStoreBuffer ds, int row, int column) {
055: super (comp, 0);
056: _oldValue = oldValue;
057: _newValue = newValue;
058: _row = row;
059: _column = column;
060: _ds = ds;
061: try {
062: _processingInstruction = PROCESSING_COMMIT_CHANGE;
063: if (newValue != null && newValue.length() > 0) {
064: if (!_ds.isFormattedStringValid(column, newValue)) {
065: _processingInstruction = PROCESSING_MOVE_CHANGE_TO_TEMP;
066: }
067: }
068: } catch (DataStoreException ex) {
069: }
070: }
071:
072: /**
073: * Use this method to inform the framework how to treat the change
074: * @param inst Valid values are:
075: * PROCESSING_DISCARD_CHANGE - discard the change
076: * PROCESSING_MOVE_CHANGE_TO_TEMP - Move the change to the temp area of the DataStore
077: * PROCESSING_COMMIT_CHANGE - copy the change to the datastore
078: */
079: public void setAcceptValue(int inst) {
080: _processingInstruction = inst;
081: }
082:
083: /**
084: * Returns the accept value as an integer
085: * @see #setAcceptValue(int inst)
086: */
087: public int getAcceptValueInt() {
088: return _processingInstruction;
089: }
090:
091: /**
092: * This method returns the column number in the data store that had a value changed.
093: */
094: public int getColumn() {
095: return _column;
096: }
097:
098: /**
099: * This method returns the data store buffer that had a value changed.
100: */
101: public DataStoreBuffer getDataStore() {
102: return _ds;
103: }
104:
105: /**
106: * This method returns the new value for the component
107: */
108: public String getNewValue() {
109: return _newValue;
110: }
111:
112: /**
113: * This method returns the old value for the component
114: */
115: public String getOldValue() {
116: return _oldValue;
117: }
118:
119: /**
120: * This method returns the row number in the data store that had a value changed.
121: */
122: public int getRow() {
123: return _row;
124: }
125:
126: /**
127: * Sets the value for new value
128: * @param newValue
129: */
130: public void setNewValue(String newValue) {
131: _newValue = newValue;
132: }
133:
134: }
|