home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 3.0 KB | 108 lines |
- /*
- * @(#RecordNumberLabel.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 current record number
- * of the RelationView it is bound with.
- */
- public class RecordNumberLabel extends java.awt.Label
- {
- symantec.itools.db.beans.binding.Mediator m_Mediator;
- private String[] m_GetMethods={"getText()"};
- private String[] m_SetMethods={"setData(Value)"};
-
- /**
- * Constructs a new RecordNumberLabel.
- * By default its label will read: "<Record Number Label>".
- * <p>
- * Call setRelationView() to bind this component to a RelationView and
- * auto-set the label text.
- *
- * @see #setRelationView
- */
- public RecordNumberLabel()
- {
- super("<Record Number 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,"RowNumber");
- 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;
- }
- /**
- * Sets the value of this component to the given value.
- * @param value the new component value
- */
- public void setData(Object o)
- {
- setText(o.toString());
- }
- }
-