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 / RecordStateLabel.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  3.4 KB  |  112 lines

  1. /*
  2.  * @(#RecordStateLabel.java
  3.  *
  4.  * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
  5.  *
  6.  */
  7.  
  8.  
  9. package symantec.itools.db.awt;
  10.  
  11. // import java.awt.*;
  12. import java.util.*;
  13. import java.sql.*;
  14. import java.lang.*;
  15. import symantec.itools.db.net.*;
  16. import symantec.itools.db.pro.*;
  17. import symantec.itools.db.beans.binding.Name;
  18.  
  19. /**
  20.  * A dbAWARE Label that automatically displays the state of the
  21.  * current record in the RelationView it is bound with.
  22.  * <p>
  23.  * The state can be one of the following values:
  24.  * <UL>
  25.  * <DT>"Existing"              The record exists in database</DT>
  26.  * <DT>"Modified"              The record has been modified</DT>
  27.  * <DT>"New"                   The record has no data and doesn't exist in database</DT>
  28.  * <DT>"Marked for Deletion"   The record is marked for deletion</DT>
  29.  * <DT>"Deleted"               The record has been deleted</DT>
  30.  * <DT>"Invalid"               The record is in an undefined state</DT>
  31.  * <DT>"New Modified"          The record is new with data</DT>
  32.  * </UL>
  33.  */
  34. public class RecordStateLabel extends java.awt.Label
  35. {
  36.     symantec.itools.db.beans.binding.Mediator m_Mediator;
  37.     private String[] m_GetMethods={"getText()"};
  38.     private String[] m_SetMethods={"setText(Value)"};
  39.  
  40.     /**
  41.      * Constructs a new RecordNumberLabel.
  42.      * By default its label will read: "<Record State Label>".
  43.      * <p>
  44.      * Call setRelationView() to bind this component to a RelationView and
  45.      * auto-set the label text.
  46.      *
  47.      * @see #setRelationView
  48.      */
  49.     public RecordStateLabel()
  50.     {
  51.         super("<Record State Label>");
  52.         m_Mediator=new symantec.itools.db.beans.binding.Mediator();
  53.         if (java.beans.Beans.isDesignTime()) {
  54.             return;
  55.         }
  56.         m_Mediator.setOutput(this);
  57.         m_Mediator.setSetMethods(m_SetMethods);
  58.         m_Mediator.setGetMethods(m_GetMethods);
  59.     }
  60.  
  61.     /**
  62.      * Sets the data source that this component is bound with.
  63.      * @param Tname the name of the data source to bind with
  64.      * @see #getDataSource
  65.      */
  66.     public void setDataSource(String Tname)
  67.     {
  68.         Name name = new Name(Tname,"RowState");
  69.        m_Mediator.setDataBinding(name.getFullName());
  70.     }
  71.  
  72.     /**
  73.      * Gets the data source that this component is bound with.
  74.      * @return name of the data source to bind with
  75.      * @see #setDataSource
  76.      */
  77.     public String getDataSource()
  78.     {
  79.         Name name = new Name(m_Mediator.getDataBinding());
  80.        return name.getTableName();
  81.     }
  82.  
  83.     // For backwards compatbilty only
  84.  
  85.     private RelationView m_RelationView;
  86.     /**
  87.      * Sets the RelationView that this component is bound with.
  88.      * @param rv the RelationView to bind with
  89.      * @see #getRelationView
  90.      */
  91.     public void setRelationView (RelationView rv)
  92.     {
  93.         m_RelationView = rv;
  94.         try {
  95.             setDataSource(rv.getName());
  96.         }
  97.         catch (java.sql.SQLException ex) {
  98.             // According to the RelationView class this method may
  99.             // throw an exception.  We don't believe it will happen.
  100.         }
  101.     }
  102.     /**
  103.      * Gets the RelationView that this component is bound with.
  104.      * @return the RelationView currently bound with
  105.      * @see #setRelationView
  106.      */
  107.     public RelationView getRelationView()
  108.     {
  109.         return m_RelationView;
  110.     }
  111. }
  112.