home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 3.4 KB | 112 lines |
- /*
- * @(#RecordStateLabel.java
- *
- * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
- *
- */
-
-
- package symantec.itools.db.awt;
-
- // import java.awt.*;
- import java.util.*;
- import java.sql.*;
- import java.lang.*;
- import symantec.itools.db.net.*;
- import symantec.itools.db.pro.*;
- import symantec.itools.db.beans.binding.Name;
-
- /**
- * A dbAWARE Label that automatically displays the state of the
- * current record in the RelationView it is bound with.
- * <p>
- * The state can be one of the following values:
- * <UL>
- * <DT>"Existing" The record exists in database</DT>
- * <DT>"Modified" The record has been modified</DT>
- * <DT>"New" The record has no data and doesn't exist in database</DT>
- * <DT>"Marked for Deletion" The record is marked for deletion</DT>
- * <DT>"Deleted" The record has been deleted</DT>
- * <DT>"Invalid" The record is in an undefined state</DT>
- * <DT>"New Modified" The record is new with data</DT>
- * </UL>
- */
- public class RecordStateLabel extends java.awt.Label
- {
- symantec.itools.db.beans.binding.Mediator m_Mediator;
- private String[] m_GetMethods={"getText()"};
- private String[] m_SetMethods={"setText(Value)"};
-
- /**
- * Constructs a new RecordNumberLabel.
- * By default its label will read: "<Record State Label>".
- * <p>
- * Call setRelationView() to bind this component to a RelationView and
- * auto-set the label text.
- *
- * @see #setRelationView
- */
- public RecordStateLabel()
- {
- super("<Record State Label>");
- m_Mediator=new symantec.itools.db.beans.binding.Mediator();
- if (java.beans.Beans.isDesignTime()) {
- return;
- }
- m_Mediator.setOutput(this);
- m_Mediator.setSetMethods(m_SetMethods);
- m_Mediator.setGetMethods(m_GetMethods);
- }
-
- /**
- * Sets the data source that this component is bound with.
- * @param Tname the name of the data source to bind with
- * @see #getDataSource
- */
- public void setDataSource(String Tname)
- {
- Name name = new Name(Tname,"RowState");
- m_Mediator.setDataBinding(name.getFullName());
- }
-
- /**
- * Gets the data source that this component is bound with.
- * @return name of the data source to bind with
- * @see #setDataSource
- */
- public String getDataSource()
- {
- Name name = new Name(m_Mediator.getDataBinding());
- return name.getTableName();
- }
-
- // For backwards compatbilty only
-
- private RelationView m_RelationView;
- /**
- * Sets the RelationView that this component is bound with.
- * @param rv the RelationView to bind with
- * @see #getRelationView
- */
- public void setRelationView (RelationView rv)
- {
- m_RelationView = rv;
- try {
- setDataSource(rv.getName());
- }
- catch (java.sql.SQLException ex) {
- // According to the RelationView class this method may
- // throw an exception. We don't believe it will happen.
- }
- }
- /**
- * Gets the RelationView that this component is bound with.
- * @return the RelationView currently bound with
- * @see #setRelationView
- */
- public RelationView getRelationView()
- {
- return m_RelationView;
- }
- }
-