Skip to content

Commit

Permalink
Fix warnings and typos which was detected at #1356 and #1360 (#1364)
Browse files Browse the repository at this point in the history
* WebViewer, enhance parameter display options with date picker (#1356)

* Added spaces before step="1" concat

* Activated the "dynamic" selection list for display type "Radio Button"
(#1360)

* Fixed warnings and typos of variable names which was detected at
PRs #1356 & #1360

---------

Co-authored-by: Ed Merks <Ed.Merks@gmail.com>
  • Loading branch information
speckyspooky and merks committed Jul 14, 2023
1 parent 85d0c2e commit 132b8b8
Show file tree
Hide file tree
Showing 9 changed files with 404 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,79 +18,123 @@

import com.ibm.icu.util.ULocale;

/**
* Class to handle the format pattern of date time
*
* @since 3.3
*/
public class FormatDateTimePattern {

public static final String DATETIEM_FORMAT_TYPE_YEAR = "datetiem_format_type_year"; //$NON-NLS-1$
public static final String DATETIEM_FORMAT_TYPE_SHORT_YEAR = "datetiem_format_type_short_year"; //$NON-NLS-1$
public static final String DATETIEM_FORMAT_TYPE_LONG_MONTH_YEAR = "datetiem_format_type_long_month_year"; //$NON-NLS-1$
public static final String DATETIEM_FORMAT_TYPE_SHOT_MONTH_YEAR = "datetiem_format_type_shot_month_year"; //$NON-NLS-1$
public static final String DATETIEM_FORMAT_TYPE_MONTH = "datetiem_format_type_month"; //$NON-NLS-1$
public static final String DATETIEM_FORMAT_TYPE_LONG_DAY_OF_WEEK = "datetiem_format_type_long_day_of_week"; //$NON-NLS-1$
public static final String DATETIEM_FORMAT_TYPE_DAY_OF_MONTH = "datetiem_format_type_day_of_month"; //$NON-NLS-1$
public static final String DATETIEM_FORMAT_TYPE_MEDIUM_DAY_OF_YEAR = "datetiem_format_type_medium_day_of_year"; //$NON-NLS-1$
public static final String DATETIEM_FORMAT_TYPE_MINUTES = "datetiem_format_type_minutes"; //$NON-NLS-1$
public static final String DATETIEM_FORMAT_TYPE_SECONTDS = "datetiem_format_type_secontds"; //$NON-NLS-1$
public static final String DATETIEM_FORMAT_TYPE_GENERAL_TIME = "datetiem_format_type_general_time"; //$NON-NLS-1$

private static final String[] customCategories = { DATETIEM_FORMAT_TYPE_YEAR, DATETIEM_FORMAT_TYPE_SHORT_YEAR,
DATETIEM_FORMAT_TYPE_LONG_MONTH_YEAR, DATETIEM_FORMAT_TYPE_SHOT_MONTH_YEAR, DATETIEM_FORMAT_TYPE_MONTH,
DATETIEM_FORMAT_TYPE_LONG_DAY_OF_WEEK, DATETIEM_FORMAT_TYPE_DAY_OF_MONTH,
DATETIEM_FORMAT_TYPE_MEDIUM_DAY_OF_YEAR, DATETIEM_FORMAT_TYPE_MINUTES, DATETIEM_FORMAT_TYPE_SECONTDS,
DATETIEM_FORMAT_TYPE_GENERAL_TIME, };
/** property: date time format of type year */
public static final String DATETIME_FORMAT_TYPE_YEAR = "datetiem_format_type_year"; //$NON-NLS-1$

/** property: date time format of type short year */
public static final String DATETIME_FORMAT_TYPE_SHORT_YEAR = "datetiem_format_type_short_year"; //$NON-NLS-1$

/** property: date time format of type long month year */
public static final String DATETIME_FORMAT_TYPE_LONG_MONTH_YEAR = "datetiem_format_type_long_month_year"; //$NON-NLS-1$

/** property: date time format of type short month year */
public static final String DATETIME_FORMAT_TYPE_SHORT_MONTH_YEAR = "datetiem_format_type_shot_month_year"; //$NON-NLS-1$

/** property: date time format of type month */
public static final String DATETIME_FORMAT_TYPE_MONTH = "datetiem_format_type_month"; //$NON-NLS-1$

/** property: date time format of type long day of week */
public static final String DATETIME_FORMAT_TYPE_LONG_DAY_OF_WEEK = "datetiem_format_type_long_day_of_week"; //$NON-NLS-1$

/** property: date time format of type day of month */
public static final String DATETIME_FORMAT_TYPE_DAY_OF_MONTH = "datetiem_format_type_day_of_month"; //$NON-NLS-1$

/** property: date time format of type medium day of year */
public static final String DATETIME_FORMAT_TYPE_MEDIUM_DAY_OF_YEAR = "datetiem_format_type_medium_day_of_year"; //$NON-NLS-1$

/** property: date time format of type minutes */
public static final String DATETIME_FORMAT_TYPE_MINUTES = "datetiem_format_type_minutes"; //$NON-NLS-1$

/** property: date time format of type seconds */
public static final String DATETIME_FORMAT_TYPE_SECONDS = "datetiem_format_type_secontds"; //$NON-NLS-1$

/** property: date time format of type general time */
public static final String DATETIME_FORMAT_TYPE_GENERAL_TIME = "datetiem_format_type_general_time"; //$NON-NLS-1$

private static final String[] customCategories = { DATETIME_FORMAT_TYPE_YEAR, DATETIME_FORMAT_TYPE_SHORT_YEAR,
DATETIME_FORMAT_TYPE_LONG_MONTH_YEAR, DATETIME_FORMAT_TYPE_SHORT_MONTH_YEAR, DATETIME_FORMAT_TYPE_MONTH,
DATETIME_FORMAT_TYPE_LONG_DAY_OF_WEEK, DATETIME_FORMAT_TYPE_DAY_OF_MONTH,
DATETIME_FORMAT_TYPE_MEDIUM_DAY_OF_YEAR, DATETIME_FORMAT_TYPE_MINUTES, DATETIME_FORMAT_TYPE_SECONDS,
DATETIME_FORMAT_TYPE_GENERAL_TIME, };

/**
* Get all categories of custom pattern
*
* @return Return all categories of custom pattern
*/
public static String[] getCustormPatternCategorys() {
return customCategories;
}

/**
* Get the display name for the custom category
*
* @param custormCategory custom category
* @return Return the display name for the custom category
*/
public static String getDisplayName4CustomCategory(String custormCategory) {
return Messages.getString("FormatDateTimePattern." + custormCategory); //$NON-NLS-1$
}

public static String getCustormFormatPattern(String custormCategory, ULocale locale) {
/**
* Get the custom format pattern
*
* @param customCategory custom category
* @param locale locale
* @return Return the custom format pattern
*/
public static String getCustomFormatPattern(String customCategory, ULocale locale) {
if (locale == null) {
locale = ULocale.getDefault();
}

if (DATETIEM_FORMAT_TYPE_GENERAL_TIME.equals(custormCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIEM_FORMAT_TYPE_GENERAL_TIME, //$NON-NLS-1$
if (DATETIME_FORMAT_TYPE_GENERAL_TIME.equals(customCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIME_FORMAT_TYPE_GENERAL_TIME, //$NON-NLS-1$
locale.toLocale());
}
if (DATETIEM_FORMAT_TYPE_YEAR.equals(custormCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIEM_FORMAT_TYPE_YEAR, locale.toLocale()); //$NON-NLS-1$
if (DATETIME_FORMAT_TYPE_YEAR.equals(customCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIME_FORMAT_TYPE_YEAR, locale.toLocale()); //$NON-NLS-1$
}
if (DATETIEM_FORMAT_TYPE_SHORT_YEAR.equals(custormCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIEM_FORMAT_TYPE_SHORT_YEAR, //$NON-NLS-1$
if (DATETIME_FORMAT_TYPE_SHORT_YEAR.equals(customCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIME_FORMAT_TYPE_SHORT_YEAR, //$NON-NLS-1$
locale.toLocale());
}
if (DATETIEM_FORMAT_TYPE_LONG_MONTH_YEAR.equals(custormCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIEM_FORMAT_TYPE_LONG_MONTH_YEAR, //$NON-NLS-1$
if (DATETIME_FORMAT_TYPE_LONG_MONTH_YEAR.equals(customCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIME_FORMAT_TYPE_LONG_MONTH_YEAR, //$NON-NLS-1$
locale.toLocale());
}
if (DATETIEM_FORMAT_TYPE_SHOT_MONTH_YEAR.equals(custormCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIEM_FORMAT_TYPE_SHOT_MONTH_YEAR, //$NON-NLS-1$
if (DATETIME_FORMAT_TYPE_SHORT_MONTH_YEAR.equals(customCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIME_FORMAT_TYPE_SHORT_MONTH_YEAR, //$NON-NLS-1$
locale.toLocale());
}
if (DATETIEM_FORMAT_TYPE_MONTH.equals(custormCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIEM_FORMAT_TYPE_MONTH, locale.toLocale()); //$NON-NLS-1$
if (DATETIME_FORMAT_TYPE_MONTH.equals(customCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIME_FORMAT_TYPE_MONTH, locale.toLocale()); //$NON-NLS-1$
}
if (DATETIEM_FORMAT_TYPE_LONG_DAY_OF_WEEK.equals(custormCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIEM_FORMAT_TYPE_LONG_DAY_OF_WEEK, //$NON-NLS-1$
if (DATETIME_FORMAT_TYPE_LONG_DAY_OF_WEEK.equals(customCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIME_FORMAT_TYPE_LONG_DAY_OF_WEEK, //$NON-NLS-1$
locale.toLocale());
}
if (DATETIEM_FORMAT_TYPE_DAY_OF_MONTH.equals(custormCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIEM_FORMAT_TYPE_DAY_OF_MONTH, //$NON-NLS-1$
if (DATETIME_FORMAT_TYPE_DAY_OF_MONTH.equals(customCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIME_FORMAT_TYPE_DAY_OF_MONTH, //$NON-NLS-1$
locale.toLocale());
}
if (DATETIEM_FORMAT_TYPE_MEDIUM_DAY_OF_YEAR.equals(custormCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIEM_FORMAT_TYPE_MEDIUM_DAY_OF_YEAR, //$NON-NLS-1$
if (DATETIME_FORMAT_TYPE_MEDIUM_DAY_OF_YEAR.equals(customCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIME_FORMAT_TYPE_MEDIUM_DAY_OF_YEAR, //$NON-NLS-1$
locale.toLocale());
}
if (DATETIEM_FORMAT_TYPE_MINUTES.equals(custormCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIEM_FORMAT_TYPE_MINUTES, //$NON-NLS-1$
if (DATETIME_FORMAT_TYPE_MINUTES.equals(customCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIME_FORMAT_TYPE_MINUTES, //$NON-NLS-1$
locale.toLocale());
}
if (DATETIEM_FORMAT_TYPE_SECONTDS.equals(custormCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIEM_FORMAT_TYPE_SECONTDS, //$NON-NLS-1$
if (DATETIME_FORMAT_TYPE_SECONDS.equals(customCategory)) {
return Messages.getString("FormatDateTimePattern.pattern." + DATETIME_FORMAT_TYPE_SECONDS, //$NON-NLS-1$
locale.toLocale());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
*/
public abstract class FormatAdapter {

/** property: label of NONE */
public static final String NONE = Messages.getString("FormatAdapter.DisplayName.None"); //$NON-NLS-1$

/** property: tree map of local table */
public final static TreeMap<String, ULocale> LOCALE_TABLE = new TreeMap<>(Collator.getInstance());

static {
Expand All @@ -46,13 +48,24 @@ public abstract class FormatAdapter {
}
}

/**
* Get locale display name
*
* @param locale locale for the display name
* @return Return the locale display name
*/
public static String getLocaleDisplayName(ULocale locale) {
if (locale == null) {
return NONE;
}
return locale.getDisplayName();
}

/**
* Get locale display name array
*
* @return Return the locale display name array
*/
public static String[] getLocaleDisplayNames() {
String[] oldNames = LOCALE_TABLE.keySet().toArray(new String[0]);
String[] newNames = new String[oldNames.length + 1];
Expand All @@ -61,13 +74,26 @@ public static String[] getLocaleDisplayNames() {
return newNames;
}

/**
* Get the locale of display name
*
* @param localeDisplayName the display name to get the locale
* @return Return the locale of the display name
*/
public static ULocale getLocaleByDisplayName(String localeDisplayName) {
if (NONE.equals(localeDisplayName) || localeDisplayName == null) {
return null;
}
return LOCALE_TABLE.get(localeDisplayName);
}

/**
* Get the matrix of choice like array
*
* @param structName structure name
* @param popertyName property name
* @return Return the matrix of choice like array
*/
public static String[][] getChoiceArray(String structName, String popertyName) {
IChoiceSet set = ChoiceSetFactory.getStructChoiceSet(structName, popertyName);
IChoice[] choices = set.getChoices();
Expand All @@ -90,21 +116,54 @@ public static String[][] getChoiceArray(String structName, String popertyName) {
return ca;
}

/**
* Get the init choice array
*
* @return Return the init choice array
*/
public abstract String[][] initChoiceArray();

/**
* Gets the format types for display names.
*
* @param locale locale of the format types
*
* @return Return the format types for display names.
*/
public abstract String[] getFormatTypes(ULocale locale);

/**
* Get the index of category
*
* @param name name to get the category index
* @return Return the index of category
*/
public abstract int getIndexOfCategory(String name);

/**
* Get the display name based on category
*
* @param category
* @return Return the display name based on category
*/
public abstract String getDisplayName4Category(String category);

/**
* Gets the corresponding category for given display name.
*
* @param displayName display name
*
* @return Return the corresponding category for given display name
*/
public abstract String getCategory4DisplayName(String displayName);

/**
* Gets the corresponding category for given display name locale based
*
* @param displayName display name
* @param locale locale of display name
*
* @return Return the corresponding category for given display name locale based
*/
public abstract String getPattern4DisplayName(String displayName, ULocale locale);
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,27 @@ public String getPattern4DisplayName(String displayName, ULocale locale) {
}

/**
* @return
* Get the display name of unformatted category
*
* @return Return the display name of unformatted category
*/
public String getUnformattedCategoryDisplayName() {
return UNFORMATTED_DISPLAYNAME;
}

/**
* @return
* Get the category name of custom
*
* @return Return the category name of custom
*/
public String getCustomCategoryName() {
return CUSTOM;
}

/**
* @return
* Get the category name of unformatted
*
* @return Return the category name of unformatted
*/
public String getUnformattedCategoryName() {
return UNFORMATTED_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ private String[][] getTableItems(ULocale locale) {
String[] customPatterns = FormatDateTimePattern.getCustormPatternCategorys();
for (int i = 0; i < customPatterns.length; i++) {
itemList.add(new String[] { FormatDateTimePattern.getDisplayName4CustomCategory(customPatterns[i]),
new DateFormatter(FormatDateTimePattern.getCustormFormatPattern(customPatterns[i], locale), locale)
new DateFormatter(FormatDateTimePattern.getCustomFormatPattern(customPatterns[i], locale), locale)
.format(defaultDate),
FormatDateTimePattern.getCustormFormatPattern(customPatterns[i], locale) });
FormatDateTimePattern.getCustomFormatPattern(customPatterns[i], locale) });
}
return itemList.toArray(new String[0][3]);
}
Expand Down

0 comments on commit 132b8b8

Please sign in to comment.