/** * Constructor. * @param iFieldSeq Sequence of the user id field. * @param iFirstTimeOnly Set it on the an add (not on update) only? */ public SetUserIDHandler(String userIdFieldName, boolean bFirstTimeOnly) { this(); this.init(null, userIdFieldName, bFirstTimeOnly); } /**
/** * Called when a new blank record is required for the table/query. * @param bDisplayOption If true, display any changes. */ public void doNewRecord(boolean bDisplayOption) // init this field override for other value { this.setUserID(DBConstants.INIT_MOVE, bDisplayOption); super.doNewRecord(bDisplayOption); } /**
break; case DBConstants.ADD_TYPE: iErrorCode = this.setUserID(iChangeType, bDisplayOption); if (iErrorCode != DBConstants.NORMAL_RETURN) return iErrorCode; break; case DBConstants.FIELD_CHANGED_TYPE: if ((this.getOwner().getEditMode() == DBConstants.EDIT_ADD) && (this.getOwner().getField(m_iFieldSeq).getValue() == -1)) iErrorCode = this.setUserID(iChangeType, bDisplayOption); if (iErrorCode != DBConstants.NORMAL_RETURN) return iErrorCode;
/** * Add all standard file & field behaviors. * Override this to add record listeners and filters. */ public void addListeners() { super.addListeners(); this.addListener(new DateChangedHandler(Person.kDateChanged)); this.addListener(new SetUserIDHandler(Person.kChangedID, false)); this.getField(Person.kName).addListener(new CopyLastHandler(Person.kNameSort)); // Only if dest is null (ie., company name is null) this.getField(Person.kNameSort).addListener(new FieldToUpperHandler(null)); this.getField(Person.kPostalCode).addListener(new CopyFieldHandler(Person.kPostalCodeSort)); } /**
/** * Set the user ID. * @param iChangeType * @param bDisplayOption The display option. * @return The error code. */ public int setUserID(int iChangeType, boolean bDisplayOption) { int iErrorCode = DBConstants.NORMAL_RETURN; int iUserID = -1; if (this.getOwner().getRecordOwner() != null) if (((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()) != null) if (((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()).getUserID() != null) if (((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()).getUserID().length() > 0) iUserID = Integer.parseInt(((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()).getUserID()); boolean bOldModified = this.getOwner().getField(userIdFieldName).isModified(); boolean[] rgbEnabled = null; if (iChangeType == DBConstants.INIT_MOVE) rgbEnabled = this.getOwner().getField(userIdFieldName).setEnableListeners(false); iErrorCode = this.getOwner().getField(userIdFieldName).setValue(iUserID, bDisplayOption, iChangeType); if (iChangeType == DBConstants.INIT_MOVE) { // Don't change the record on an init this.getOwner().getField(userIdFieldName).setEnableListeners(rgbEnabled); this.getOwner().getField(userIdFieldName).setModified(bOldModified); } return iErrorCode; } }
break; case DBConstants.ADD_TYPE: iErrorCode = this.setUserID(iChangeType, bDisplayOption); if (iErrorCode != DBConstants.NORMAL_RETURN) return iErrorCode; break; case DBConstants.FIELD_CHANGED_TYPE: if ((this.getOwner().getEditMode() == DBConstants.EDIT_ADD) && (this.getOwner().getField(m_iFieldSeq).getValue() == -1)) iErrorCode = this.setUserID(iChangeType, bDisplayOption); if (iErrorCode != DBConstants.NORMAL_RETURN) return iErrorCode;
/** * Add all standard file & field behaviors. * Override this to add record listeners and filters. */ public void addListeners() { super.addListeners(); this.addListener(new DateChangedHandler((DateTimeField)this.getField(Person.DATE_CHANGED))); this.addListener(new SetUserIDHandler(Person.CHANGED_ID, false)); this.getField(Person.NAME).addListener(new CopyLastHandler(this.getField(Person.NAME_SORT))); // Only if dest is null (ie., company name is null) this.getField(Person.NAME_SORT).addListener(new FieldToUpperHandler(null)); this.getField(Person.POSTAL_CODE).addListener(new CopyFieldHandler(this.getField(Person.POSTAL_CODE_SORT))); } /**
/** * Set the user ID. * @param iChangeType * @param bDisplayOption The display option. * @return The error code. */ public int setUserID(int iChangeType, boolean bDisplayOption) { int iErrorCode = DBConstants.NORMAL_RETURN; IntegerField thisField = (IntegerField)this.getOwner().getField(m_iFieldSeq); int iUserID = -1; if (this.getOwner().getRecordOwner() != null) if (((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()) != null) if (((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()).getUserID() != null) if (((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()).getUserID().length() > 0) iUserID = Integer.parseInt(((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()).getUserID()); boolean bOldModified = thisField.isModified(); boolean[] rgbEnabled = null; if (iChangeType == DBConstants.INIT_MOVE) rgbEnabled = thisField.setEnableListeners(false); iErrorCode = thisField.setValue(iUserID, bDisplayOption, iChangeType); if (iChangeType == DBConstants.INIT_MOVE) { // Don't change the record on an init thisField.setEnableListeners(rgbEnabled); thisField.setModified(bOldModified); } return iErrorCode; } }
break; case DBConstants.ADD_TYPE: iErrorCode = this.setUserID(iChangeType, bDisplayOption); if (iErrorCode != DBConstants.NORMAL_RETURN) return iErrorCode; break; case DBConstants.FIELD_CHANGED_TYPE: if ((this.getOwner().getEditMode() == DBConstants.EDIT_ADD) && (this.getOwner().getField(userIdFieldName).getValue() == -1)) iErrorCode = this.setUserID(iChangeType, bDisplayOption); if (iErrorCode != DBConstants.NORMAL_RETURN) return iErrorCode;
this.addListener(new SetUserIDHandler(Booking.EMPLOYEE_ID, true)); this.addListener(new SetUserIDHandler(Booking.EMPLOYEE_MOD_ID, false));
/** * Constructor. * @param iFieldSeq Sequence of the user id field. * @param iFirstTimeOnly Set it on the an add (not on update) only? */ public SetUserIDHandler(int iFieldSeq, boolean bFirstTimeOnly) { this(); this.init(null, iFieldSeq, bFirstTimeOnly); } /**
/** * Called when a new blank record is required for the table/query. * @param bDisplayOption If true, display any changes. */ public void doNewRecord(boolean bDisplayOption) // init this field override for other value { this.setUserID(DBConstants.INIT_MOVE, bDisplayOption); super.doNewRecord(bDisplayOption); } /**
/** * Set the user ID. * @param iChangeType * @param bDisplayOption The display option. * @return The error code. */ public int setUserID(int iChangeType, boolean bDisplayOption) { int iErrorCode = DBConstants.NORMAL_RETURN; IntegerField thisField = (IntegerField)this.getOwner().getField(m_iFieldSeq); int iUserID = -1; if (this.getOwner().getRecordOwner() != null) if (((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()) != null) if (((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()).getUserID() != null) if (((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()).getUserID().length() > 0) iUserID = Integer.parseInt(((BaseApplication)this.getOwner().getRecordOwner().getTask().getApplication()).getUserID()); boolean bOldModified = thisField.isModified(); boolean[] rgbEnabled = null; if (iChangeType == DBConstants.INIT_MOVE) rgbEnabled = thisField.setEnableListeners(false); iErrorCode = thisField.setValue(iUserID, bDisplayOption, iChangeType); if (iChangeType == DBConstants.INIT_MOVE) { // Don't change the record on an init thisField.setEnableListeners(rgbEnabled); thisField.setModified(bOldModified); } return iErrorCode; } }
this.addListener(new SetUserIDHandler(Booking.EMPLOYEE_ID, true)); this.addListener(new SetUserIDHandler(Booking.EMPLOYEE_MOD_ID, false));
/** * Constructor. * @param iFieldSeq Sequence of the user id field. * @param iFirstTimeOnly Set it on the an add (not on update) only? */ public SetUserIDHandler(int iFieldSeq, boolean bFirstTimeOnly) { this(); this.init(null, iFieldSeq, bFirstTimeOnly); } /**
/** * Called when a new blank record is required for the table/query. * @param bDisplayOption If true, display any changes. */ public void doNewRecord(boolean bDisplayOption) // init this field override for other value { this.setUserID(DBConstants.INIT_MOVE, bDisplayOption); super.doNewRecord(bDisplayOption); } /**