/** * This method gets called when a bound property is changed. * This is required to listen to changes by the date popup control. * @param evt A PropertyChangeEvent object describing the event source and the property that has changed. */ public void propertyChange(PropertyChangeEvent evt) { if (JCalendarPopup.DATE_PARAM.equalsIgnoreCase(evt.getPropertyName())) if (evt.getNewValue() instanceof java.util.Date) this.setDateTime((java.util.Date)evt.getNewValue(), true, DBConstants.SCREEN_MOVE); } }
/** * This method gets called when a bound property is changed. * This is required to listen to changes by the date popup control. * @param evt A PropertyChangeEvent object describing the event source and the property that has changed. */ public void propertyChange(PropertyChangeEvent evt) { if (JCalendarPopup.DATE_PARAM.equalsIgnoreCase(evt.getPropertyName())) if (evt.getNewValue() instanceof java.util.Date) this.setDateTime((java.util.Date)evt.getNewValue(), true, DBConstants.SCREEN_MOVE); } }
/** * This method gets called when a bound property is changed. * This is required to listen to changes by the date popup control. * @param evt A PropertyChangeEvent object describing the event source and the property that has changed. */ public void propertyChange(PropertyChangeEvent evt) { if (MenuConstants.DATE.equalsIgnoreCase(evt.getPropertyName())) if (evt.getNewValue() instanceof java.util.Date) this.setDateTime((java.util.Date)evt.getNewValue(), true, DBConstants.SCREEN_MOVE); } }
/** * Decode date time value and set the field value. * @param field * @return */ public static int decodeDateTime(DateTimeField field, String strValue) { Date date = null; try { if (strValue != null) { if (field instanceof TimeField) date = timeFormat.parse(strValue); else if (field instanceof DateField) date = dateFormat.parse(strValue); else // if (field instanceof DateTimeField) date = dateTimeFormat.parse(strValue); } } catch (ParseException e) { e.printStackTrace(); return DBConstants.ERROR_RETURN; } return field.setDateTime(date, Constants.DISPLAY, Constants.SCREEN_MOVE); } /**
/** * Decode date time value and set the field value. * @param field * @return */ public static int decodeDateTime(DateTimeField field, String strValue) { Date date = null; try { if (strValue != null) { if (field instanceof TimeField) date = timeFormat.parse(strValue); else if (field instanceof DateField) date = dateFormat.parse(strValue); else // if (field instanceof DateTimeField) date = dateTimeFormat.parse(strValue); } } catch (ParseException e) { e.printStackTrace(); return DBConstants.ERROR_RETURN; } return field.setDateTime(date, Constants.DISPLAY, Constants.SCREEN_MOVE); } /**
/** * Decode date time value and set the field value. * @param field * @return */ public static int decodeDateTime(DateTimeField field, String strValue) { Date date = null; try { if (strValue != null) { if (field instanceof TimeField) date = timeFormat.parse(strValue); else if (field instanceof DateField) date = dateFormat.parse(strValue); else // if (field instanceof DateTimeField) date = dateTimeFormat.parse(strValue); } } catch (ParseException e) { e.printStackTrace(); return DBConstants.ERROR_RETURN; } return field.setDateTime(date, Constants.DISPLAY, Constants.SCREEN_MOVE); } /**
/** * Called when a valid record is read from the table/query. * @param bDisplayOption If true, display any changes. */ public void doValidRecord(boolean bDisplayOption) { super.doValidRecord(bDisplayOption); Date dateSrc = m_fldSourceDate.getDateTime(); Date dateDest = this.calcDate(dateSrc); m_fldDestDate.setDateTime(dateDest, bDisplayOption, DBConstants.SCREEN_MOVE); }
/** * Set the start date for this item. * This is here so you can do an action when the user changes the start date. * The StartDateHandler is added automatically to this class. */ public Date setStartDate(Date time) { ((DateTimeField)this.getField(BookingDetail.DETAIL_DATE)).setDateTime(time, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE); return ((DateTimeField)this.getField(BookingDetail.DETAIL_DATE)).getDateTime(); } /**
/** * Set the start date for this item. * This is here so you can do an action when the user changes the start date. * The StartDateHandler is added automatically to this class. */ public Date setStartDate(Date time) { ((DateTimeField)this.getField(BookingDetail.DETAIL_DATE)).setDateTime(time, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE); return ((DateTimeField)this.getField(BookingDetail.DETAIL_DATE)).getDateTime(); } /**
/** * FieldChanged Method. */ public int fieldChanged(boolean bDisplayOption, int iMoveMode) { BaseField fldDays = this.getOwner(); BookingCar recBookingCar = (BookingCar)fldDays.getRecord(); DateTimeField fldStartDate = (DateTimeField)recBookingCar.getField(BookingCar.DETAIL_DATE); if ((!fldStartDate.isNull()) && (fldDays.getValue() > 0)) { Date dateStart = fldStartDate.getDateTime(); float fDays = (float)fldDays.getValue(); Date dateEnd = new Date(dateStart.getTime() + (long)(fDays * DBConstants.KMS_IN_A_DAY)); Calendar calendar = DateTimeField.m_calendar; calendar.setTime(dateEnd); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); dateEnd = calendar.getTime(); DateTimeField fldEndDate = (DateTimeField)recBookingCar.getField(BookingCar.DETAIL_END_DATE); return fldEndDate.setDateTime(dateEnd, bDisplayOption, iMoveMode); } return super.fieldChanged(bDisplayOption, iMoveMode); }
/** * FieldChanged Method. */ public int fieldChanged(boolean bDisplayOption, int iMoveMode) { BaseField fldDays = this.getOwner(); BookingCar recBookingCar = (BookingCar)fldDays.getRecord(); DateTimeField fldStartDate = (DateTimeField)recBookingCar.getField(BookingCar.DETAIL_DATE); if ((!fldStartDate.isNull()) && (fldDays.getValue() > 0)) { Date dateStart = fldStartDate.getDateTime(); float fDays = (float)fldDays.getValue(); Date dateEnd = new Date(dateStart.getTime() + (long)(fDays * DBConstants.KMS_IN_A_DAY)); Calendar calendar = DateTimeField.m_calendar; calendar.setTime(dateEnd); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); dateEnd = calendar.getTime(); DateTimeField fldEndDate = (DateTimeField)recBookingCar.getField(BookingCar.DETAIL_END_DATE); return fldEndDate.setDateTime(dateEnd, bDisplayOption, iMoveMode); } return super.fieldChanged(bDisplayOption, iMoveMode); }
/** * Move the date field (or the current time) to the target date field. */ public void moveDateToTarget() { DateTimeField fldHistoryDateTarget = (DateTimeField)this.getHistoryRecord().getField(m_iHistoryDateSeq); if ((this.getHistorySourceDate() != null) && (!this.getHistorySourceDate().isNull())) fldHistoryDateTarget.moveFieldToThis(this.getHistorySourceDate()); else fldHistoryDateTarget.setDateTime(new Date(), DBConstants.DISPLAY, DBConstants.SCREEN_MOVE); // Need seconds } /**
/** * Move the date field (or the current time) to the target date field. */ public void moveDateToTarget() { DateTimeField fldHistoryDateTarget = (DateTimeField)this.getHistoryRecord().getField(m_iHistoryDateSeq); if ((this.getHistorySourceDate() != null) && (!this.getHistorySourceDate().isNull())) fldHistoryDateTarget.moveFieldToThis(this.getHistorySourceDate()); else fldHistoryDateTarget.setDateTime(new Date(), DBConstants.DISPLAY, DBConstants.SCREEN_MOVE); // Need seconds } /**
/** * SetScreenFields Method. */ public void setScreenFields(Map<String,Object> properties) { Record recProduct = this.getMainRecord(); this.addThisRecordFilter(properties, City.CITY_FILE, JTreePanel.LOCATION, Product.CITY_ID, ProductScreenRecord.CITY_ID); Date date = this.getPropertyDate((String)properties.get(SearchConstants.DATE)); if (date != null) ((DateTimeField)this.getScreenRecord().getField(ProductScreenRecord.DETAIL_DATE)).setDateTime(date, DBConstants.DONT_DISPLAY, DBConstants.SCREEN_MOVE); String strSearchText = (String)properties.get(SearchConstants.SEARCH_TEXT); if ((strSearchText != null) && (strSearchText.length() > 0)) this.getScreenRecord().getField(ProductScreenRecord.DESCRIPTION).setString(strSearchText.toUpperCase()); String strPax = (String)properties.get(SearchConstants.PAX); if ((strPax == null) || (strPax.length() == 0) || (strPax.equals("0"))) // Pax will be correct when pax are in a booking. strPax = "2"; this.getScreenRecord().getField(ProductScreenRecord.PAX).setString(strPax); // For now: this.getScreenRecord().getField(ProductScreenRecord.REMOTE_QUERY_ENABLED).setState(true); } /**
/** * Move the date field (or the current time) to the target date field. */ public void moveDateToTarget() { DateTimeField fldHistoryDateTarget = (DateTimeField)this.getHistoryRecord().getField(m_iHistoryDateSeq); if ((this.getHistorySourceDate() != null) && (!this.getHistorySourceDate().isNull())) fldHistoryDateTarget.moveFieldToThis(this.getHistorySourceDate()); else fldHistoryDateTarget.setDateTime(new Date(), DBConstants.DISPLAY, DBConstants.SCREEN_MOVE); // Need seconds } /**
/** * SetScreenFields Method. */ public void setScreenFields(Map<String,Object> properties) { Record recProduct = this.getMainRecord(); this.addThisRecordFilter(properties, City.CITY_FILE, JTreePanel.LOCATION, Product.CITY_ID, ProductScreenRecord.CITY_ID); Date date = this.getPropertyDate((String)properties.get(SearchConstants.DATE)); if (date != null) ((DateTimeField)this.getScreenRecord().getField(ProductScreenRecord.DETAIL_DATE)).setDateTime(date, DBConstants.DONT_DISPLAY, DBConstants.SCREEN_MOVE); String strSearchText = (String)properties.get(SearchConstants.SEARCH_TEXT); if ((strSearchText != null) && (strSearchText.length() > 0)) this.getScreenRecord().getField(ProductScreenRecord.DESCRIPTION).setString(strSearchText.toUpperCase()); String strPax = (String)properties.get(SearchConstants.PAX); if ((strPax == null) || (strPax.length() == 0) || (strPax.equals("0"))) // Pax will be correct when pax are in a booking. strPax = "2"; this.getScreenRecord().getField(ProductScreenRecord.PAX).setString(strPax); // For now: this.getScreenRecord().getField(ProductScreenRecord.REMOTE_QUERY_ENABLED).setState(true); } /**
/** * Setup the detail key, given this tour detail record. */ public int setupDetailKey(TourSub recTourHeaderDetail, Booking recBooking, Tour recTour, BaseField fldPaxID, BaseField fldQaID, BaseField fldModID, Date dateStart) { Date date = this.setupStartDate(recTourHeaderDetail, recBooking, recTour, fldPaxID, fldQaID, fldModID, dateStart); ((DateTimeField)this.getField(BookingDetail.DETAIL_DATE)).setDateTime(date, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE); this.getField(BookingDetail.PRODUCT_TYPE_ID).moveFieldToThis(recTourHeaderDetail.getField(TourHeaderDetail.PRODUCT_TYPE_ID)); int iErrorCode = super.setupDetailKey(recTourHeaderDetail, recBooking, recTour, fldPaxID, fldQaID, fldModID, dateStart); return iErrorCode; } /**
/** * Setup the detail key, given this tour detail record. */ public int setupDetailKey(TourSub recTourHeaderDetail, Booking recBooking, Tour recTour, BaseField fldPaxID, BaseField fldQaID, BaseField fldModID, Date dateStart) { Date date = this.setupStartDate(recTourHeaderDetail, recBooking, recTour, fldPaxID, fldQaID, fldModID, dateStart); ((DateTimeField)this.getField(BookingDetail.DETAIL_DATE)).setDateTime(date, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE); this.getField(BookingDetail.PRODUCT_TYPE_ID).moveFieldToThis(recTourHeaderDetail.getField(TourHeaderDetail.PRODUCT_TYPE_ID)); int iErrorCode = super.setupDetailKey(recTourHeaderDetail, recBooking, recTour, fldPaxID, fldQaID, fldModID, dateStart); return iErrorCode; } /**
/** * Setup the detail key, given this tour detail record. */ public int setupDetailKey(TourSub recTourHeaderDetail, Booking recBooking, Tour recTour, BaseField fldPaxID, BaseField fldQaID, BaseField fldModID, Date dateStart) { this.getField(BookingSub.BOOKING_ID).moveFieldToThis(recBooking.getField(Booking.ID), DBConstants.DISPLAY, DBConstants.INIT_MOVE); this.getField(BookingSub.BOOKING_PAX_ID).setValue(0, DBConstants.DISPLAY, DBConstants.INIT_MOVE); if (fldPaxID != null) if (fldPaxID.getValue() != 0) this.getField(BookingSub.BOOKING_PAX_ID).moveFieldToThis(fldPaxID, DBConstants.DISPLAY, DBConstants.INIT_MOVE); if (fldModID != null) this.getField(BookingSub.MODULE_ID).moveFieldToThis(fldModID, DBConstants.DISPLAY, DBConstants.INIT_MOVE); else this.getField(BookingSub.MODULE_ID).setValue(0, DBConstants.DISPLAY, DBConstants.INIT_MOVE); if (recTourHeaderDetail == null) this.getField(BookingSub.TOUR_HEADER_DETAIL_ID).initField(DBConstants.DISPLAY); else this.getField(BookingSub.TOUR_HEADER_DETAIL_ID).moveFieldToThis(recTourHeaderDetail.getField(TourHeaderDetail.ID), DBConstants.DISPLAY, DBConstants.INIT_MOVE); ((DateTimeField)this.getField(BookingSub.MODULE_START_DATE)).setDateTime(dateStart, DBConstants.DISPLAY, DBConstants.INIT_MOVE); return DBConstants.NORMAL_RETURN; } /**
/** * Setup the detail key, given this tour detail record. */ public int setupDetailKey(TourSub recTourHeaderDetail, Booking recBooking, Tour recTour, BaseField fldPaxID, BaseField fldQaID, BaseField fldModID, Date dateStart) { this.getField(BookingSub.BOOKING_ID).moveFieldToThis(recBooking.getField(Booking.ID), DBConstants.DISPLAY, DBConstants.INIT_MOVE); this.getField(BookingSub.BOOKING_PAX_ID).setValue(0, DBConstants.DISPLAY, DBConstants.INIT_MOVE); if (fldPaxID != null) if (fldPaxID.getValue() != 0) this.getField(BookingSub.BOOKING_PAX_ID).moveFieldToThis(fldPaxID, DBConstants.DISPLAY, DBConstants.INIT_MOVE); if (fldModID != null) this.getField(BookingSub.MODULE_ID).moveFieldToThis(fldModID, DBConstants.DISPLAY, DBConstants.INIT_MOVE); else this.getField(BookingSub.MODULE_ID).setValue(0, DBConstants.DISPLAY, DBConstants.INIT_MOVE); if (recTourHeaderDetail == null) this.getField(BookingSub.TOUR_HEADER_DETAIL_ID).initField(DBConstants.DISPLAY); else this.getField(BookingSub.TOUR_HEADER_DETAIL_ID).moveFieldToThis(recTourHeaderDetail.getField(TourHeaderDetail.ID), DBConstants.DISPLAY, DBConstants.INIT_MOVE); ((DateTimeField)this.getField(BookingSub.MODULE_START_DATE)).setDateTime(dateStart, DBConstants.DISPLAY, DBConstants.INIT_MOVE); return DBConstants.NORMAL_RETURN; } /**