home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.awt;
-
- import java.awt.Component;
- import java.awt.Event;
- import java.io.IOException;
- import symantec.itools.db.pro.ProjBinder;
- import symantec.itools.db.pro.ProjLink;
- import symantec.itools.db.pro.RelationView;
- import symjava.sql.SQLException;
-
- public class Checkbox extends java.awt.Checkbox implements ProjLink {
- private ProjBinder m_ProjBinder;
- private boolean m_currentState;
- private String m_trueValue = new String("true");
- private String m_falseValue = new String("false");
- private int m_treatBlankAs;
-
- public Checkbox(String label) {
- super(label);
- }
-
- public Checkbox() {
- }
-
- public void setTrueValue(String trueValue) {
- this.m_trueValue = new String(trueValue);
- }
-
- public void setFalseValue(String falseValue) {
- this.m_falseValue = new String(falseValue);
- }
-
- public void init(ProjBinder binder) {
- this.m_ProjBinder = binder;
- this.setEditable(this.m_ProjBinder);
- }
-
- public void setTreatBlankAs(String blank) {
- if ((new String(blank)).toUpperCase().equals("DEFAULT")) {
- this.m_treatBlankAs = 0;
- } else if ((new String(blank)).toUpperCase().equals("NULL")) {
- this.m_treatBlankAs = 1;
- } else {
- if ((new String(blank)).toUpperCase().equals("EMPTY")) {
- this.m_treatBlankAs = 2;
- }
-
- }
- }
-
- public void setBinding(RelationView relView, String projection) {
- try {
- int projectionNumber = relView.findProjByName(projection);
- relView.bindProj(projectionNumber, this);
- } catch (SQLException Ex) {
- this.raiseException("SQLException from Checkbox.setBinding: " + ((Throwable)Ex).getMessage());
- }
- }
-
- public void notifyDataChange(ProjBinder binder) {
- try {
- if (this.m_trueValue.equals(binder.getStringValue())) {
- ((java.awt.Checkbox)this).setState(true);
- } else {
- ((java.awt.Checkbox)this).setState(false);
- }
- } catch (SQLException Ex) {
- this.raiseException("SQLException from Checkbox.notifyDataChange: " + ((Throwable)Ex).getMessage());
- } catch (IOException Ex) {
- this.raiseException("IOException from Checkbox.notifyDataChange: " + ((Throwable)Ex).getMessage());
- }
- }
-
- public boolean notifySetData(ProjBinder binder) throws SQLException {
- return this.notifyStateChange();
- }
-
- boolean notifyStateChange() {
- try {
- if (this.m_ProjBinder != null && this.m_ProjBinder.isWritable()) {
- if (((java.awt.Checkbox)this).getState()) {
- this.m_ProjBinder.setValueFromString(this.m_trueValue, 0, this.m_treatBlankAs);
- } else {
- this.m_ProjBinder.setValueFromString(this.m_falseValue, 0, this.m_treatBlankAs);
- }
- }
-
- return true;
- } catch (SQLException Ex) {
- this.raiseException("SQLException from Checkbox.notifyStateChange: " + ((Throwable)Ex).getMessage());
- return false;
- } catch (IOException Ex) {
- this.raiseException("IOException from Checkbox.notifyStateChange: " + ((Throwable)Ex).getMessage());
- return false;
- }
- }
-
- public boolean handleEvent(Event evt) {
- try {
- this.notifySetData(this.m_ProjBinder);
- } catch (SQLException Ex) {
- this.raiseException("SQLException from Checkbox.handleEvent: " + ((Throwable)Ex).getMessage());
- }
-
- return super.handleEvent(evt);
- }
-
- void setEditable(ProjBinder binder) {
- ((Component)this).disable();
-
- try {
- if (binder != null) {
- RelationView rv = binder.getRelationView();
- if (rv != null && rv.getCurrentRecordState() != 105) {
- ((Component)this).enable();
- return;
- }
- }
- } catch (SQLException Ex) {
- this.raiseException("SQLException from Checkbox.setEditable: " + ((Throwable)Ex).getMessage());
- }
-
- }
-
- public boolean gotFocus(Event evt, Object what) {
- return super.gotFocus(evt, what);
- }
-
- void raiseException(String text) {
- System.out.println(text);
- }
- }
-