home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / prosrc.bin / TableEvent.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  5.2 KB  |  160 lines

  1. /*
  2.  * Copyright (c) 1997 Krumel & Associates, Inc. All Rights Reserved.
  3.  *
  4.  * www.krumel.com - controls@krumel.com
  5.  *
  6.  * Permission is given to the buyer of this package for one software
  7.  * developer to use this software on one CPU (one workstation) and to make
  8.  * one backup copy.  You may uitilize and/or modify this class for use in your
  9.  * projects.  You may distribute or sell any executable which results from
  10.  * using this code in yur application, except a utility or class of similar
  11.  * nature to this product.  You may distribute this product in compiled
  12.  * form only, but soley to be used with your cmpiled executable product
  13.  * for the puposes of dynamic loading. You may NOT redistribute the source
  14.  * code in any form or make it accessible through a network or other
  15.  * distribution media to others. Please refer to the file "copyright.html"
  16.  * for further important copyright and licensing information.
  17.  *
  18.  * The source code is the confidential and proprietary information
  19.  * of Krumel & Associates, Inc. ("Confidential Information").  You shall
  20.  * not disclose such Confidential Information and shall use it only in
  21.  * accordance with the terms of the license agreement you entered into
  22.  * with Krumel & Associates, Inc..
  23.  
  24.  * KRUMEL & ASSOCIATES MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
  25.  * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
  26.  * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  27.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. KRUMEL & ASSOCIATES SHALL NOT
  28.  * BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
  29.  * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  30.  */
  31.  
  32.  
  33. package symantec.itools.db.awt.event;
  34.  
  35. import java.awt.*;
  36. import java.awt.event.*;
  37. import symantec.itools.db.awt.*;
  38.  
  39. /**
  40.  * The type of event when a user interact with the table view in a way that
  41.  * does not involve a specific cell, such as hitting a button on the toolbar.
  42.  * The original AWT event is maintained by an internal reference so the exact
  43.  * reason for the event can be determined and the TableView's behavior can
  44.  * be highly customized accordingly. All TableEvents are routed to the event
  45.  * handler, the data source, and finally to any registered objects.
  46.  */
  47. public class TableEvent extends AWTEvent {
  48.     /**
  49.      * The table view that generated the event.
  50.      */
  51.     TableView view;
  52.  
  53.     /**
  54.      * The AWT event that triggered this event.
  55.      */
  56.     AWTEvent event;
  57.  
  58.     /**
  59.      * The event ID.
  60.      */
  61.     int id;
  62.  
  63.     /**
  64.      * An arbitrary paramter.
  65.      */
  66.     Object param;
  67.  
  68. //-----------------------------------------------------------------------------
  69. //                          Event IDs
  70. //-----------------------------------------------------------------------------
  71.     /**
  72.      * Base table level event ID
  73.      */
  74.     public final static int TABLE_EVENT = 80;
  75.     /**
  76.      * TableView level event for when TableView got focus
  77.      */
  78.     public final static int GOT_FOCUS = TABLE_EVENT + 1;
  79.     /**
  80.      * TableView level event for when TableView lost focus
  81.      */
  82.     public final static int LOST_FOCUS = TABLE_EVENT + 2;
  83.     /**
  84.      * TableView level event for when row inserted
  85.      */
  86.     public final static int INSERT = TABLE_EVENT + 3;     //insert row above specified row
  87.     /**
  88.      * TableView level event for when row is deleted
  89.      */
  90.     public final static int DELETE = TABLE_EVENT + 4;     //delete specified row
  91.     /**
  92.      * TableView level event for when row is appended
  93.      */
  94.     public final static int APPEND = TABLE_EVENT + 5;     //add row to end of data
  95.     /**
  96.      * TableView level event for when row is undeleted
  97.      */
  98.     public final static int UNDELETE = TABLE_EVENT +6;
  99.     /**
  100.      * TableView level event for when row is undeleted
  101.      */
  102.     public final static int TOOLBAR_EVENT = TABLE_EVENT +7;
  103.     /**
  104.      * User table level event ID
  105.      */
  106.     public final static int USER_TABLE_EVENT = TABLE_EVENT +8;
  107.  
  108.     /**
  109.      * Constructs a TableEvent using any AWTEvent.
  110.      */
  111.     public TableEvent(TableView v, AWTEvent e, int id) {
  112.         super(v, id);
  113.         view = v;
  114.         this.id = id;
  115.         event = e;
  116.     }
  117.  
  118.     /**
  119.      * Inherited from java.awt.AWTEvent. Gets the ID of the event.
  120.      */
  121.     public int getID() { return id; }
  122.  
  123.     /**
  124.      * Sets the ID for the event.
  125.      */
  126.     public void setID(int id) {
  127.         this.id = id;
  128.     }
  129.  
  130.     /**
  131.      * Gets the TableView that generated the event. This is usually a TableView object.
  132.      */
  133.     public TableView getView() { return view; }
  134.  
  135.     public Component getToolbarSource() {
  136.         if (id == TOOLBAR_EVENT) {
  137.             return (Component)event.getSource();
  138.         }
  139.  
  140.         return null;
  141.     }
  142.  
  143.     /**
  144.      * Gets the AWTEvent that triggered the firing of the TableEvent.
  145.      */
  146.     public AWTEvent getAWTEvent() { return event; }
  147.  
  148.     /**
  149.      * Gets the paramater of the TableEvent.
  150.      */
  151.     public Object getParamater() { return param; }
  152.  
  153.     public void setParameter(Object o) { param = o; }
  154.  
  155.     public String toString() {
  156.         return "TableEvent: id=" + id + " parameter=" + param + "AWTEvent="
  157.                + event;
  158.     }
  159. }
  160.