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 / Label.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  5.6 KB  |  209 lines

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