/** * Set up the screen input fields. */ public void setupFields() { FieldInfo field = null; field = new FieldInfo(this, ID, Constants.DEFAULT_FIELD_LENGTH, null, null); field.setDataClass(Integer.class); field.setHidden(true); field = new FieldInfo(this, LAST_CHANGED, Constants.DEFAULT_FIELD_LENGTH, null, null); field.setDataClass(Date.class); field.setHidden(true); field = new FieldInfo(this, DELETED, 10, null, new Boolean(false)); field.setDataClass(Boolean.class); field.setHidden(true); field = new FieldInfo(this, END_PERIOD, 12, null, null); field.setDataClass(Date.class); field.setScale(Constants.DATE_ONLY); field = new FieldInfo(this, PERIOD_CLOSED, 12, null, null); field.setDataClass(Date.class); field.setScale(Constants.DATE_ONLY); } /**
/** * Get the status of this object. */ public int getStatus() { Integer intStatus = (Integer)this.getField(BookingDetail.STATUS_SUMMARY).getData(); if (intStatus == null) return 0; return intStatus.intValue(); } /**
/** * Get the menu name. */ public String getMenuName(FieldList record) { return record.getField(Tour.DESCRIPTION).toString(); } /**
/** * Set this field back to the original value. * @param bDisplayOption If true, display the data. * @return The error code. */ public int initField(boolean bDisplayOption) // Init this field override for other value { if ((this.getDefault() == null) || (this.getDefault() instanceof String)) return this.setString((String)this.getDefault(), bDisplayOption, Constants.INIT_MOVE); // zero out the field return this.setData(this.getDefault(), bDisplayOption, Constants.INIT_MOVE); } /**
/** * Set up the screen input fields. */ public void setupFields() { FieldInfo field = null; field = new FieldInfo(this, ID, Constants.DEFAULT_FIELD_LENGTH, null, null); field.setDataClass(Integer.class); field = new FieldInfo(this, KEY, 128, null, null); field = new FieldInfo(this, VALUE, 255, null, null); field = new FieldInfo(this, COMMENT, 255, null, null); } /**
/** * Set up the screen input fields. */ public void setupFields() { FieldInfo field = null; field = new FieldInfo(this, ID, Constants.DEFAULT_FIELD_LENGTH, null, null); field.setDataClass(Integer.class); field.setHidden(true); field = new FieldInfo(this, LAST_CHANGED, Constants.DEFAULT_FIELD_LENGTH, null, null); field.setDataClass(Date.class); field.setHidden(true); field = new FieldInfo(this, DELETED, 10, null, new Boolean(false)); field.setDataClass(Boolean.class); field.setHidden(true); } /**
/** * */ private FieldList cloneFieldList(FieldList item) { FieldList fieldList = new FieldList(null); for (int i = 0; i < item.getFieldCount(); i++) { FieldInfo fldSource = item.getField(i); FieldInfo fldDest = new FieldInfo(fieldList, fldSource.getFieldName(), fldSource.getMaxLength(), fldSource.getFieldDesc(), fldSource.getDefault()); fldDest.setDataClass(fldSource.getDataClass()); } return fieldList; } /**
/** * Set up the screen input fields. */ public void setupFields() { FieldInfo field = null; field = new FieldInfo(this, "HotelID", Constants.DEFAULT_FIELD_LENGTH, null, null); field.setDataClass(Long.class); field = new FieldInfo(this, "HotelRate", Constants.DEFAULT_FIELD_LENGTH, null, null); field.setDataClass(Long.class); field = new FieldInfo(this, "HotelClass", Constants.DEFAULT_FIELD_LENGTH, null, null); field.setDataClass(Long.class); field = new FieldInfo(this, "StartDate", 12, null, null); field.setDataClass(Date.class); field.setScale(Constants.DATE_ONLY); field = new FieldInfo(this, "RoomPrice", 18, null, new Double(123456789.01)); field.setDataClass(Double.class); } }
/** * Move the data in this record to the thin version. * @param fieldInfo The destination thin field. * @param field The source field (or null to auto-find) * @param record The source record (or null if field supplied) */ public void moveFieldToThin(FieldInfo fieldInfo, BaseField field, Record record) { if ((field == null) || (!field.getFieldName().equals(fieldInfo.getFieldName()))) { field = null; if (record != null) field = record.getField(fieldInfo.getFieldName()); } if (field != null) { if (field.getDataClass() == fieldInfo.getDataClass()) fieldInfo.setData(field.getData()); else fieldInfo.setString(field.toString()); } } /**
/** * Set the data in this field to true or false. */ public int setState(boolean bState, boolean bDisplayOption, int iMoveMode) { Boolean objData = new Boolean(bState); if (this.getDataClass() == Boolean.class) return this.setData(objData, bDisplayOption, iMoveMode); else if (Number.class.isAssignableFrom(this.getDataClass())) return this.setValue(objData.booleanValue() ? 1 : 0, bDisplayOption, iMoveMode); else if (this.getDataClass() == String.class) return this.setString(objData.booleanValue() ? Constants.TRUE : Constants.FALSE, bDisplayOption, iMoveMode); return super.setState(bState, bDisplayOption, iMoveMode); } /**
/** * A field changed on this screen. */ public void propertyChange(PropertyChangeEvent evt) { String strFieldName = evt.getPropertyName(); FieldList fieldList = this.getFieldList(); FieldInfo field = fieldList.getField(strFieldName); if (field != null) { if (BookingHotel.NIGHTS.equals(field.getFieldName())) { Short shNights = (Short)field.getData(); Date date = (Date)fieldList.getField(BookingDetail.DETAIL_DATE).getData(); if (date != null) if (shNights != null) { Converter.initGlobals(); Calendar calendar = Converter.gCalendar; calendar.setTime(date); calendar.add(Calendar.DATE, shNights.shortValue()); fieldList.getField(BookingDetail.DETAIL_END_DATE).setData(calendar.getTime()); } } } super.propertyChange(evt); } }
/** * Get the next field and fill it with data from this buffer. * You must override this method. * @param field The field to set. * @param bDisplayOption The display option for setting the field. * @param iMoveMove The move mode for setting the field. * @return The error code. */ public int getNextField(FieldInfo field, boolean bDisplayOption, int iMoveMode) // Must be to call right Get calls { String string = this.getNextString(); if (string == null) return Constants.ERROR_RETURN; if (string == DATA_SKIP) return Constants.NORMAL_RETURN; // Don't set this field return field.setString(string, bDisplayOption, iMoveMode); } /**
/** * Retrieve (in string format) from this field. * @return This field converted to a string. */ public String getString() { try { return Converter.formatObjectToString(this.getData(), this.getDataClass(), this.getDefault()); } catch (Exception ex) { return null; } } /**
/** * Convert and move string to this field. * Override this method to convert the String to the actual Physical Data Type. * @param bState the state to set the data to. * @param bDisplayOption Display the data on the screen if true. * @param iMoveMode INIT, SCREEN, or READ move mode. * @return The error code (or NORMAL_RETURN). */ public int setString(String strString, boolean bDisplayOption, int iMoveMode) // init this field override for other value { try { Object objData = Converter.convertObjectToDatatype(strString, this.getDataClass(), null, m_ibScale); if (objData == null) if (this.getDataClass() != Boolean.class) if (!(Number.class.isAssignableFrom(this.getDataClass()))) if (this.getDataClass() != java.util.Date.class) objData = Constants.BLANK; // To set a null internally, you must call setData directly return this.setData(objData, bDisplayOption, iMoveMode); } catch (Exception ex) { String strError = ex.getMessage(); if (strError == null) strError = ex.getClass().getName(); if (this.getRecord() != null) if (this.getRecord().getTask() != null) return this.getRecord().getTask().setLastError(strError); return Constants.ERROR_RETURN; } } /**
/** * Get the state of this boolean field. * @return true if true, false if not boolean or null. */ public boolean getState() // init this field override for other value { if (this.getDataClass() == Boolean.class) { Boolean objData = (Boolean)this.getData(); if (objData != null) return objData.booleanValue(); } return false; } /**
/** * Get the next field and fill it with data from this buffer. * You must override this method. * @param field The field to set. * @param bDisplayOption The display option for setting the field. * @param iMoveMove The move mode for setting the field. * @return The error code. */ public int getNextField(FieldInfo field, boolean bDisplayOption, int iMoveMode) // Must be to call right Get calls { Object objNext = this.getNextData(); if (DATA_ERROR.equals(objNext)) return Constants.ERROR_RETURN; // EOF if (DATA_EOF.equals(objNext)) return Constants.ERROR_RETURN; // EOF if (DATA_SKIP.equals(objNext)) return Constants.NORMAL_RETURN; // Don't set this field return field.setData(objNext, bDisplayOption, iMoveMode); } /**
/** * Get the long field description tip. * Look in the resource for the long description, if not found, return the field desc. * @return The field tip. */ public String getFieldTip() { String strTipKey = this.getFieldName() + Constants.TIP; String strFieldTip = strTipKey; if (this.getRecord() != null) strFieldTip = this.getRecord().getString(strTipKey); if (strFieldTip == strTipKey) return this.getFieldDesc(); return strFieldTip; } /**
/** * Move data to this field from another field. * If the data types are the same data is moved, otherwise a string conversion is done. * @param field The source field. * @param bDisplayOption If true, display changes. * @param iMoveMode The move mode. * @return The error code (or NORMAL_RETURN). */ public int moveFieldToThis(FieldInfo field, boolean bDisplayOption, int iMoveMode) { // Copy a field to this if (this.isSameType(field)) { // Same type, just move the info Object data = field.getData(); return this.setData(data, bDisplayOption, iMoveMode); } else { // Different type... convert to text first String tempString = field.getString(); return this.setString(tempString, bDisplayOption, iMoveMode); } } /**