/** * Internal function to get the user-settable properties from the DTProperties, if they exist, and * to ensure that defaults are set if the properties have not yet been created. * * <p>This method may be called from different places depending on whether an instance of this * class is created before the user brings up the Session Properties window. In either case, the * data is static and is set only the first time we are called. */ private static void loadProperties() { // set the property values // Note: this may have already been done by another instance of // this DataType created to handle a different column. if (propertiesAlreadyLoaded == false) { // get parameters previously set by user, or set default values useJavaDefaultFormat = true; // set to use the Java default String useJavaDefaultFormatString = DTProperties.get(thisClassName, "useJavaDefaultFormat"); if (useJavaDefaultFormatString != null && useJavaDefaultFormatString.equals("false")) useJavaDefaultFormat = false; // get which locale-dependent format to use localeFormat = DateFormat.SHORT; // set to use the Java default String localeFormatString = DTProperties.get(thisClassName, "localeFormat"); if (localeFormatString != null) localeFormat = Integer.parseInt(localeFormatString); // use lenient input or force user to enter exact format lenient = true; // set to allow less stringent input String lenientString = DTProperties.get(thisClassName, "lenient"); if (lenientString != null && lenientString.equals("false")) lenient = false; /* * After loading the properties, we must initialize the dateFormat. * See Bug 3086444 */ initDateFormat(localeFormat, lenient); } }
/** User has clicked OK in the surrounding JPanel, so save the current state of all variables */ public void ok() { // get the values from the controls and set them in the static properties useJavaDefaultFormat = useJavaDefaultFormatChk.isSelected(); DTProperties.put( thisClassName, "useJavaDefaultFormat", Boolean.valueOf(useJavaDefaultFormat).toString()); localeFormat = dateFormatTypeDrop.getValue(); dateFormat = new ThreadSafeDateFormat(localeFormat, true); // lenient is set next DTProperties.put(thisClassName, "localeFormat", Integer.toString(localeFormat)); lenient = lenientChk.isSelected(); dateFormat.setLenient(lenient); DTProperties.put(thisClassName, "lenient", Boolean.valueOf(lenient).toString()); initDateFormat(localeFormat, lenient); }