/** * Set up the default control for this field. * Calls setupDefaultView with this as the converter (Convenience method). * @param itsLocation Location of this component on screen (ie., GridBagConstraint). * @param targetScreen Where to place this component (ie., Parent screen or GridBagLayout). * @param iDisplayFieldDesc Display the label? (optional). * @return Return the component or ScreenField that is created for this field. */ public final ScreenComponent setupDefaultView(ScreenLoc itsLocation, ComponentParent targetScreen, int iDisplayFieldDesc) // Add this view to the list { return this.setupDefaultView(itsLocation, targetScreen, this, iDisplayFieldDesc, null); } /**
/** * AddColumn Method. */ public Object addColumn(Converter converter) { if (converter.getField() instanceof ReferenceField) return new SEditText(this.getNextLocation(ScreenConstants.NEXT_INPUT_LOCATION, ScreenConstants.SET_ANCHOR), this, converter, ScreenConstants.DEFAULT_DISPLAY); else return converter.setupDefaultView(this.getNextLocation(ScreenConstants.NEXT_LOGICAL, ScreenConstants.SET_ANCHOR), this, ScreenConstants.DEFAULT_DISPLAY); } /**
/** * Convert the date from UTF format and return it. */ public Date getPropertyDate(String strDate) { if ((strDate == null) || (strDate.length() == 0)) return null; Converter.initGlobals(); Date date = null; try { synchronized (Converter.gCalendar) { date = Converter.gGMTDateTimeFormat.parse(strDate); } } catch (ParseException ex) { ex.printStackTrace(); } return date; }
/** * 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) { return m_converterDest.setString(m_converterSource.toString(), bDisplayOption, iMoveMode); } }
/** * Do the physical move operation. * @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 moveSourceToDest(boolean bDisplayOption, int iMoveMode) { if (m_objValue instanceof String) return m_fldDest.setString((String)m_objValue, bDisplayOption, iMoveMode); else return m_fldDest.setData(m_objValue, bDisplayOption, iMoveMode); } }
/** * Do the physical move operation. * @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 moveSourceToDest(boolean bDisplayOption, int iMoveMode) { if (m_fldSource instanceof BaseField) return ((BaseField)m_fldDest.getField()).moveFieldToThis((BaseField)m_fldSource, bDisplayOption, iMoveMode); // Move dependent field to here else return m_fldDest.setString(m_fldSource.getString(), bDisplayOption, iMoveMode); // Move dependent field to here } /**
/** * Do the physical move operation. * @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 moveIt(boolean bDisplayOption, int iMoveMode) { if (m_bDontMoveNull) if (m_fldSource.getLength() == 0) // Only move if dest is null return DBConstants.NORMAL_RETURN; if (m_bClearIfThisNull) if (this.getOwner().getLength() == 0) // If this is null, clear the dest field return ((BaseField)m_fldDest.getField()).moveFieldToThis(this.getOwner(), bDisplayOption, iMoveMode); // Move dependent field to here if (m_bOnlyIfDestNull) if (m_fldDest.getLength() != 0) // Only move if dest is null return DBConstants.NORMAL_RETURN; int iErrorCode = this.moveSourceToDest(bDisplayOption, iMoveMode); if (iErrorCode == DBConstants.NORMAL_RETURN) if (m_fldDest == m_fldSource) return ((BaseField)m_fldDest.getField()).handleFieldChanged(bDisplayOption, iMoveMode); // Special case, move to yourself (Just want to call .FieldChanged()) return iErrorCode; } /**
/** * Add the screen controls to the second column of the grid. */ public JComponent createScreenComponent(Converter fieldInfo) { JComponent component = null; String strDefault = fieldInfo.toString(); if (strDefault == null) strDefault = Constants.BLANK; if (fieldInfo.getFieldName().equals(BookingPax.PAX_CATEGORY_ID)) { BaseApplet applet = this.getBaseApplet(); RemoteSession remoteSession = null; // Not needed since paxcat is already linked to a table JBookingPaxMainScreen mainScreen = (JBookingPaxMainScreen)this.getTargetScreen(this, JBookingPaxMainScreen.class); FieldList recPaxCategory = mainScreen.getPaxCategory(); component = new JRemoteComboBox(applet, remoteSession, recPaxCategory, applet.getString(BookingPaxGridModel.PAX_CATEGORY), PaxCategory.DESCRIPTION, BookingPaxGridModel.PAX_CATEGORY, false, Params.ID, null); } else if (fieldInfo.getFieldName().equals(BookingPax.SMOKER)) { component = new JThreeStateCheckBox(null); } else component = super.createScreenComponent(fieldInfo); return component; } /**
/** * String all the non-numeric characters from this string. * @param string input string. * @return The result string. */ public String stripNonNumeric(String string) { return Converter.stripNonNumber(string); } }
/** * Get this property from the map and convert it to the target class. * @param properties The map object to get the property from. * @param strKey The key of the property. * @param classData The target class to convert the property to. * @param objDefault The default value. * @return The data in the correct class. */ public static Object getAs(Map<String,Object> properties, String strKey, Class<?> classData, Object objDefault) { if (properties == null) return objDefault; Object objData = properties.get(strKey); try { return Converter.convertObjectToDatatype(objData, classData, objDefault); } catch (Exception ex) { return null; } } /**
/** * Free the dependent object. */ public void removeConverter() { if (m_converter != null) { Converter converter = m_converter; m_converter = null; // This keeps this from being called twice converter.removeComponent(null); // Just in case a converter was used (removes converter, leaves field!) if (m_converter instanceof BaseField) { // Special case - free this field if it is temporary and belongs to no records. if (((BaseField)m_converter).getRecord() == null) m_converter.free(); } } m_converter = null; } }
/** * Free this converter. */ public void free() { super.free(); m_converterNext = null; } /**
/** * Convert this string and set the data to this field (don't override this). * This calls setString with DISPLAY and SCREEN_MOVE. * @param string the string to set the data to. * @return The error code. */ public final int setString(String string) { return this.setString(string, Constants.DISPLAY, Constants.SCREEN_MOVE); } /**
/** * Do the physical move operation. * @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 moveSourceToDest(boolean bDisplayOption, int iMoveMode) { if (m_fldSource instanceof BaseField) return ((BaseField)m_fldDest.getField()).moveFieldToThis((BaseField)m_fldSource, bDisplayOption, iMoveMode); // Move dependent field to here else return m_fldDest.setString(m_fldSource.getString(), bDisplayOption, iMoveMode); // Move dependent field to here } /**
/** * 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) { return m_converterDest.setString(m_converterSource.toString(), bDisplayOption, iMoveMode); } }
/** * Do the physical move operation. * @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 moveIt(boolean bDisplayOption, int iMoveMode) { if (m_bDontMoveNull) if (m_fldSource.getLength() == 0) // Only move if dest is null return DBConstants.NORMAL_RETURN; if (m_bClearIfThisNull) if (this.getOwner().getLength() == 0) // If this is null, clear the dest field return ((BaseField)m_fldDest.getField()).moveFieldToThis(this.getOwner(), bDisplayOption, iMoveMode); // Move dependent field to here if (m_bOnlyIfDestNull) if (m_fldDest.getLength() != 0) // Only move if dest is null return DBConstants.NORMAL_RETURN; int iErrorCode = this.moveSourceToDest(bDisplayOption, iMoveMode); if (iErrorCode == DBConstants.NORMAL_RETURN) if (m_fldDest == m_fldSource) return ((BaseField)m_fldDest.getField()).handleFieldChanged(bDisplayOption, iMoveMode); // Special case, move to yourself (Just want to call .FieldChanged()) return iErrorCode; } /**