/** * Retrieve the value of this field in the registration database, as set the field to this value. * @return true If the value was retrieved from the registration database. */ public boolean retrieveValue() { PropertyOwner pRegistration = this.retrieveUserProperties(); if (pRegistration != null) if (pRegistration instanceof UserProperties) return ((UserProperties)pRegistration).retrieveField(this.getOwner()); return false; } /**
/** * Constructor. * @param field The field to add this handler to (usually pass null and call addListener()). */ public RegisterValueHandler(BaseField field) { this(); this.init(field); } /**
/** * The Field has Changed. * @param bDisplayOption If true, display the change. * @param iMoveMode The type of move being done (init/read/screen). * @return The error code (or NORMAL_RETURN if okay). */ public int fieldChanged(boolean bDisplayOption, int iMoveMode) { int iErrorCode = super.fieldChanged(bDisplayOption, iMoveMode); if (iErrorCode != DBConstants.NORMAL_RETURN) return iErrorCode; if (iMoveMode == DBConstants.INIT_MOVE) this.retrieveValue(); if (iMoveMode == DBConstants.SCREEN_MOVE) this.saveValue(); return iErrorCode; } /**
/** * Add all standard file & field behaviors. * Override this to add record listeners and filters. */ public void addListeners() { super.addListeners(); this.getField(LookupScreenRecord.BK_DISPLAY_TYPE).addListener(new SwitchBookingScreenHandler(null)); this.getField(LookupScreenRecord.BOOKING_LIST_FORMAT).addListener(new RegisterValueHandler(null)); int nCommandID = (int)this.getField(LookupScreenRecord.BOOKING_LIST_FORMAT).getValue(); this.getField(LookupScreenRecord.QUERY_KEY).addListener(new RegisterValueHandler(null)); this.getField(LookupScreenRecord.CURRENT_AGENT).addListener(new RegisterValueHandler(null)); this.getField(LookupScreenRecord.START_BK_DAYS).addListener(new RegisterValueHandler(null)); this.getField(LookupScreenRecord.START_BK_DATE).addListener(new InitDateOffsetHandler(this.getField(LookupScreenRecord.START_BK_DAYS), 0, 0, 0, false)); this.getField(LookupScreenRecord.START_BK_DATE).initField(DBConstants.DISPLAY); // Recompute new initial value this.getField(LookupScreenRecord.START_BK_DATE).addListener(new ReComputeTimeOffsetHandler(LookupScreenRecord.START_BK_DAYS)); this.getField(LookupScreenRecord.START_HDR_DAYS).addListener(new RegisterValueHandler(null)); this.getField(LookupScreenRecord.TOUR_HDR_START_DATE).addListener(new InitDateOffsetHandler(this.getField(LookupScreenRecord.START_HDR_DAYS), 0, 0, 0)); this.getField(LookupScreenRecord.TOUR_HDR_START_DATE).initField(DBConstants.DISPLAY); // Recompute new initial value this.getField(LookupScreenRecord.TOUR_HDR_START_DATE).addListener(new ReComputeTimeOffsetHandler(LookupScreenRecord.START_HDR_DAYS)); this.getField(LookupScreenRecord.END_HDR_DAYS).addListener(new RegisterValueHandler(null)); this.getField(LookupScreenRecord.TOUR_HDR_END_DATE).addListener(new ReComputeTimeOffsetHandler(LookupScreenRecord.END_HDR_DAYS)); } /**
/** * Set the field that owns this handler. * @param owner The field this listener was added to (or null if being removed). */ public void setOwner(ListenerOwner owner) { super.setOwner(owner); if (owner != null) this.retrieveValue(); } /**
/** * Get the owner of this property key. * The registration key is the screen's key. * The property key is the field name. * @return The owner of this property key. */ public PropertyOwner retrieveUserProperties() { Record record = this.getOwner().getRecord(); BasePanel screen = record.getScreen(); if (screen != null) return screen.retrieveUserProperties(); // Return the registration key else return null; // Must have a screen for this to work } }
((DateTimeField)this.getScreenRecord().getField(ApReportScreenRecord.END_DATE)).setCalendar(cal, true, DBConstants.INIT_MOVE); this.getScreenRecord().getField(ApReportScreenRecord.EXCLUDE_AMOUNT).addListener(new RegisterValueHandler(null)); this.getScreenRecord().getField(ApReportScreenRecord.TEMPLATE).addListener(new InitFieldHandler(this.getRecord(ApControl.AP_CONTROL_FILE).getField(ApControl.TEN_99_TEMPLATE)));
/** * Set the field that owns this handler. * @param owner The field this listener was added to (or null if being removed). */ public void setOwner(ListenerOwner owner) { super.setOwner(owner); if (owner != null) this.retrieveValue(); } /**
/** * Get the owner of this property key. * The registration key is the screen's key. * The property key is the field name. * @return The owner of this property key. */ public PropertyOwner retrieveUserProperties() { Record record = this.getOwner().getRecord(); BasePanel screen = record.getScreen(); if (screen != null) return screen.retrieveUserProperties(); // Return the registration key else return null; // Must have a screen for this to work } }
((DateTimeField)this.getScreenRecord().getField(ApReportScreenRecord.END_DATE)).setCalendar(cal, true, DBConstants.INIT_MOVE); this.getScreenRecord().getField(ApReportScreenRecord.EXCLUDE_AMOUNT).addListener(new RegisterValueHandler(null)); this.getScreenRecord().getField(ApReportScreenRecord.TEMPLATE).addListener(new InitFieldHandler(this.getRecord(ApControl.AP_CONTROL_FILE).getField(ApControl.TEN_99_TEMPLATE)));
/** * Save the current value of this field to the registration database. */ public void saveValue() { PropertyOwner pRegistration = this.retrieveUserProperties(); if (pRegistration != null) if (pRegistration instanceof UserProperties) ((UserProperties)pRegistration).saveField(this.getOwner()); } /**
/** * The Field has Changed. * @param bDisplayOption If true, display the change. * @param iMoveMode The type of move being done (init/read/screen). * @return The error code (or NORMAL_RETURN if okay). */ public int fieldChanged(boolean bDisplayOption, int iMoveMode) { int iErrorCode = super.fieldChanged(bDisplayOption, iMoveMode); if (iErrorCode != DBConstants.NORMAL_RETURN) return iErrorCode; if (iMoveMode == DBConstants.INIT_MOVE) this.retrieveValue(); if (iMoveMode == DBConstants.SCREEN_MOVE) this.saveValue(); return iErrorCode; } /**
/** * Constructor. * @param field The field to add this handler to (usually pass null and call addListener()). */ public RegisterValueHandler(BaseField field) { this(); this.init(field); } /**
/** * Set the field that owns this handler. * @param owner The field this listener was added to (or null if being removed). */ public void setOwner(ListenerOwner owner) { super.setOwner(owner); if (owner != null) this.retrieveValue(); } /**
/** * Get the owner of this property key. * The registration key is the screen's key. * The property key is the field name. * @return The owner of this property key. */ public PropertyOwner retrieveUserProperties() { Record record = this.getOwner().getRecord(); ComponentParent screen = null; if (record.getRecordOwner() instanceof ComponentParent) screen = (ComponentParent)record.getRecordOwner(); if (screen != null) return screen.retrieveUserProperties(); // Return the registration key else return null; // Must have a screen for this to work } }
/** * Add all the screen listeners. */ public void addListeners() { super.addListeners(); this.getScreenRecord().getField(AcctDetailScreenRecord.ACCOUNT_ID).setEnabled(true); this.getRecord(Account.ACCOUNT_FILE).getField(Account.ACCOUNT_NO).setEnabled(true); // Enable Key Field this.getScreenRecord().getField(AcctDetailScreenRecord.START_DATE).addListener(new RegisterValueHandler(null)); this.getScreenRecord().getField(AcctDetailScreenRecord.END_DATE).addListener(new RegisterValueHandler(null)); this.getScreenRecord().getField(AcctDetailScreenRecord.CALC_START).addListener(new RegisterValueHandler(null)); if ((this.getScreenRecord().getField(AcctDetailScreenRecord.START_DATE).isNull()) || (this.getScreenRecord().getField(AcctDetailScreenRecord.END_DATE).isNull())) { // If the starting and ending date haven't been set yet, set them to the current period start and end. Date date = new Date(); // Now Period recPeriod = new Period((RecordOwner)this.getParentScreen()); // Note: I Use READ_MOVE, because RegisterBehavior doesn't respond to it. if (this.getScreenRecord().getField(AcctDetailScreenRecord.START_DATE).isNull()) ((DateTimeField)this.getScreenRecord().getField(AcctDetailScreenRecord.START_DATE)).setDate(recPeriod.getPeriodStartDate(date), DBConstants.DISPLAY, DBConstants.READ_MOVE); if (this.getScreenRecord().getField(AcctDetailScreenRecord.END_DATE).isNull()) ((DateTimeField)this.getScreenRecord().getField(AcctDetailScreenRecord.END_DATE)).setDate(recPeriod.getPeriodEndDate(date), DBConstants.DISPLAY, DBConstants.READ_MOVE); recPeriod.free(); recPeriod = null; } this.getScreenRecord().getField(AcctDetailScreenRecord.START_DATE).setEnabled(true); this.getScreenRecord().getField(AcctDetailScreenRecord.END_DATE).setEnabled(true); this.getScreenRecord().getField(AcctDetailScreenRecord.CALC_START).setEnabled(true); } /**
/** * Retrieve the value of this field in the registration database, as set the field to this value. * @return true If the value was retrieved from the registration database. */ public boolean retrieveValue() { PropertyOwner pRegistration = this.retrieveUserProperties(); if (pRegistration != null) if (pRegistration instanceof UserProperties) return ((UserProperties)pRegistration).retrieveField(this.getOwner()); return false; } /**
/** * The Field has Changed. * @param bDisplayOption If true, display the change. * @param iMoveMode The type of move being done (init/read/screen). * @return The error code (or NORMAL_RETURN if okay). */ public int fieldChanged(boolean bDisplayOption, int iMoveMode) { int iErrorCode = super.fieldChanged(bDisplayOption, iMoveMode); if (iErrorCode != DBConstants.NORMAL_RETURN) return iErrorCode; if (iMoveMode == DBConstants.INIT_MOVE) this.retrieveValue(); if (iMoveMode == DBConstants.SCREEN_MOVE) this.saveValue(); return iErrorCode; } /**
/** * Constructor. * @param field The field to add this handler to (usually pass null and call addListener()). */ public RegisterValueHandler(BaseField field) { this(); this.init(field); } /**
/** * Add all the screen listeners. */ public void addListeners() { super.addListeners(); Vendor recVendor = (Vendor)this.getMainRecord(); Record recScreenRecord = this.getScreenRecord(); ((NumberField)recScreenRecord.getField(VendorScreenRecord.VENDOR_KEY)).setValue(0, DBConstants.DISPLAY, DBConstants.INIT_MOVE); recScreenRecord.getField(VendorScreenRecord.VENDOR_KEY).addListener(new RegisterValueHandler(null)); this.setEditing(false); SortOrderHandler keyBehavior = new SortOrderHandler(this); keyBehavior.setGridTable(Vendor.NAME_SORT_KEY, recVendor, 0); keyBehavior.setGridTable(Vendor.CODE_KEY, recVendor, 1); recScreenRecord.getField(VendorScreenRecord.VENDOR_KEY).addListener(keyBehavior); recVendor.addListener(new ExtractRangeFilter(Vendor.NAME_SORT, recScreenRecord.getField(VendorScreenRecord.VENDOR_NAME), ExtractRangeFilter.PAD_END_FIELD)); recVendor.addListener(new ExtractRangeFilter(Vendor.COUNTRY_ID, recScreenRecord.getField(VendorScreenRecord.VENDOR_COUNTRY), ExtractRangeFilter.PAD_END_FIELD)); recScreenRecord.getField(VendorScreenRecord.VENDOR_NAME).addListener(new FieldReSelectHandler(this)); recScreenRecord.getField(VendorScreenRecord.VENDOR_COUNTRY).addListener(new FieldReSelectHandler(this)); } /**