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 / ToolbarAdapter.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  4.3 KB  |  117 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. package symantec.itools.db.awt.event;
  33.  
  34. import java.awt.event.*;
  35. import java.awt.*;
  36. import symantec.itools.db.awt.*;
  37.  
  38. /**
  39.  * Adapter class for TableView toolbar components. Usually, the TableView
  40.  * will only be concerned with action events generated by the toolbar
  41.  * components, most of which are buttons or TextFields. Consequently,
  42.  * constructors are provided for automatically registering the adapter
  43.  * with these types of components. Whenever a component fires an action
  44.  * event, the adapter calls TableView.toolbarActionPerformed().
  45.  */
  46. public class ToolbarAdapter implements ActionListener {
  47.     /**
  48.      * The TableView this adapter notifies when toolbar event occurs.
  49.      */
  50.     protected TableView view;
  51.  
  52.     /**
  53.      * Constucts a ToolbarAdapter instance that will fire a notification
  54.      * to the TableView each time another component fires an action event.
  55.      * It is the responsibility of the creating object to register this
  56.      * adapter with the Component that will fire the action events. This
  57.      * constructor is usually utilized by subclasses for Components not supported
  58.      * by one of the other constuctors.
  59.      */
  60.     public ToolbarAdapter(TableView v) {
  61.         view = v;
  62.     }
  63.  
  64.     /**
  65.      * Constucts a ToolbarAdapter instance that will fire a notification
  66.      * to the TableView each time the Button fires an action event.
  67.      */
  68.     public ToolbarAdapter(Button b, TableView v) {
  69.         view = v;
  70.         b.addActionListener(this);
  71.     }
  72.  
  73.     /**
  74.      * Constucts a ToolbarAdapter instance that will fire a notification
  75.      * to the TableView each time the TextField fires an action event.
  76.      */
  77.     public ToolbarAdapter(java.awt.TextField tf, TableView v) {
  78.         view = v;
  79.         tf.addActionListener(this);
  80.     }
  81.  
  82.     /**
  83.      * Adds this instance as an action listener to a Button.
  84.      */
  85.     public void add(Button b) {
  86.         b.addActionListener(this);
  87.     }
  88.  
  89.     /**
  90.      * Removes this instance as an action listener to a Button.
  91.      */
  92.     public void remove(Button b) {
  93.         b.removeActionListener(this);
  94.     }
  95.  
  96.     /**
  97.      * Adds this instance as an action listener to a TextField.
  98.      */
  99.     public void add(java.awt.TextField tf) {
  100.         tf.addActionListener(this);
  101.     }
  102.  
  103.     /**
  104.      * Removes this instance as an action listener to a TextField.
  105.      */
  106.     public void remove(java.awt.TextField tf) {
  107.         tf.removeActionListener(this);
  108.     }
  109.  
  110.     /**
  111.      * Implements the method defined in ActionListener. Calls the TableView
  112.      * method toolbarActionPerformed().
  113.      */
  114.     public void actionPerformed(ActionEvent e) {
  115.         view.toolbarActionPerformed(e);
  116.     }
  117. }