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 / NervousText.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  6.2 KB  |  231 lines

  1. /*
  2.  * @(#NervousText.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.util.*;
  12. import java.sql.*;
  13. import java.lang.*;
  14. import symantec.itools.db.net.*;
  15. import symantec.itools.db.pro.*;
  16. import java.beans.*;
  17. import symantec.itools.db.beans.binding.Name;
  18.  
  19. /**
  20.  * A dbAWARE NervousText component.
  21.  * <p>
  22.  * This component is similar to the basic NervousText component, but can also
  23.  * be "bound" to a projection within a relation view
  24.  * so that it automatically gets the values in that relation.
  25.  * <p>
  26.  *
  27.  * @see symantec.itools.multimedia.NervousText
  28.  */
  29. public class NervousText extends symantec.itools.multimedia.NervousText implements ProjectionBean
  30. {
  31.     /**
  32.      * A constant value indicating how an empty string will be saved in the database.
  33.      */
  34.     public final static int Default    =  0;
  35.     /**
  36.      * A constant value indicating how an empty string will be saved in the database.
  37.      */
  38.     public final static int Null       =  1;
  39.     /**
  40.      * A constant value indicating how an empty string will be saved in the database.
  41.      */
  42.     public final static int Blank      =  2;
  43.  
  44.     private ProjectionBeanHelper m_Helper;
  45.     /**
  46.      * Controls when the component commits its changes.
  47.      * Takes no action, as this is a read-only component.
  48.      * @see #getDynamicUpdate
  49.      * @see #setDynamicUpdate
  50.      */
  51.     protected boolean m_DynamicUpdate=false;
  52.  
  53.     /**
  54.      * Constructs a new NervousText component.
  55.      */
  56.     public NervousText()
  57.     {
  58.         super();
  59.         m_Helper = new ProjectionBeanHelper(this);
  60.     }
  61.  
  62.     /**
  63.      * Binds this component to a given projection within the specified
  64.      * relation view.
  65.      *
  66.      * @param relView the relation view to bind with
  67.      * @param projection the projection in relView to bind with
  68.      */
  69.     public void setBinding(RelationView relView, String projection)
  70.     {
  71.         m_Helper.setBinding(relView, projection);
  72.     }
  73.  
  74.     /**
  75.      * Returns the projection in the RelationView that this component is bound with.
  76.      * @see #setBinding
  77.      * @see #setProjection
  78.      */
  79.     public String getProjection() {
  80.         return m_Helper.getProjection();
  81.     }
  82.  
  83.     /**
  84.      * Binds this component to the given projection within the RelationView
  85.      * the component is currently bound with.
  86.      * @see #setBinding
  87.      * @see #getProjection
  88.      * @see #getRelationView
  89.      */
  90.     public void setProjection(String projection) {
  91.         m_Helper.setProjection(projection);
  92.     }
  93.  
  94.     /**
  95.      * Gets the RelationView that this component is bound with.
  96.      * @return the RelationView currently bound with
  97.      * @see #setRelationView
  98.      * @see #setBinding
  99.      * @see #getProjection
  100.      */
  101.     public RelationView getRelationView() {
  102.         return m_Helper.getRelationView();
  103.     }
  104.  
  105.     /**
  106.      * Sets the RelationView that this component is bound with.
  107.      * @param rv the RelationView to bind with
  108.      * @see #getRelationView
  109.      * @see #setBinding
  110.      * @see #setProjection
  111.      */
  112.     public void setRelationView(RelationView rv) {
  113.         m_Helper.setRelationView(rv);
  114.     }
  115.  
  116.     /**
  117.      * Specifies how an empty string will be set when updating data on
  118.      * the dbANYWHERE server.
  119.      *
  120.      * @param blank one of "DEFAULT", "NULL", or "BLANK"
  121.      *
  122.      * @see symantec.itools.db.pro.ProjBinder#setValueFromString(java.lang.String, int, int)
  123.      */
  124.     public void setTreatBlankAs(int value) {
  125.         m_Helper.setTreatBlankAs(value);
  126.     }
  127.  
  128.     /**
  129.      * Indicates when the component commits its changes.
  130.      * @see #setDynamicUpdate
  131.      */
  132.     public boolean getDynamicUpdate() {
  133.        return m_DynamicUpdate;
  134.     }
  135.  
  136.     /**
  137.      * Sets when the component commits its changes.
  138.      * @param value the new dynamic update mode value
  139.      * @see #getDynamicUpdate
  140.      */
  141.     public void setDynamicUpdate(boolean value) {
  142.  
  143.  
  144.         m_DynamicUpdate = value;
  145.     }
  146.  
  147.     /**
  148.      * Sets whether the data value of this component may be modified.
  149.      * @param value <code>true</code> if the value may not be modified,
  150.      * <code>false</code>if the value may be modified
  151.      */
  152.     public void setReadOnly(boolean value) {
  153.     }
  154.  
  155.     /**
  156.      * Sets the value of this component to the given value.
  157.      * @param value the new component value
  158.      * @see #getData
  159.      */
  160.     public void setData(Object value) {
  161.         try {
  162.             if(isPaused())
  163.             {
  164.                 setPaused(false);
  165.                 setText(value.toString());
  166.                 super.setPaused(true);
  167.                 repaint();
  168.  
  169.             }
  170.             else setText(value.toString());
  171.  
  172.         }
  173.         catch (Exception ex) {
  174.             m_Helper.raiseException(ex);
  175.         }
  176.     }
  177.  
  178.     /**
  179.      * Gets the value of this component.
  180.      * @return the current component value
  181.      * @see #setData
  182.      */
  183.     public Object getData() {
  184.         return getText();
  185.     }
  186.  
  187.     /**
  188.      * Gets whether this component saves its value as a text String.
  189.      * @return <code>true</code> if the value is saved as text,
  190.      * <code>false</code> otherwise
  191.      */
  192.     public boolean isTextBased() {
  193.         return true;
  194.     }
  195.  
  196.     /**
  197.      * Gets the number of digits to the right of the decimal point for
  198.      * this component's value.
  199.      * @return the number of digits to the right of the decimal point
  200.      */
  201.     public int getScale() {
  202.         return ProjBinder.DEFAULTSCALE;
  203.     }
  204.  
  205.     /**
  206.      * Registers the standard event listener(s) for this component.
  207.      */
  208.     public void registerListeners() {
  209.     }
  210.     /**
  211.      * Sets the name of the data item to bind this component to.
  212.      * @param name the data item name, like "MyTable@MyColumn"
  213.      * @see #getDataBinding
  214.      */
  215.     public void setDataBinding(String name)
  216.     {
  217.         m_Helper.setDataBinding(new Name(name));
  218.     }
  219.  
  220.     /**
  221.      * Gets the name of the data item this component is bound to.
  222.      * @returns the data item name, like "MyTable@MyColumn"
  223.      * @see #setDataBinding
  224.      */
  225.     public String getDataBinding()
  226.     {
  227.         return  m_Helper.getDataBinding().getFullName();
  228.     }
  229.  
  230. }
  231.