Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebViewer, enhance parameter display options with date picker (#1356) #1359

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,35 +98,61 @@ public static String getCustormFormatPattern(String custormCategory, ULocale loc
}

/**
* Retrieves format pattern from arrays given format type categorys.
* Retrieves format pattern from arrays given format type categories.
*
* @param category Given format type category.
* @return The corresponding format pattern string.
*/

public static String getPatternForCategory(String category) {
String pattern;
if (DesignChoiceConstants.DATETIEM_FORMAT_TYPE_GENERAL_DATE.equals(category)
if (DesignChoiceConstants.DATETIME_FORMAT_TYPE_GENERAL_DATE.equals(category)
|| DesignChoiceConstants.DATE_FORMAT_TYPE_GENERAL_DATE.equals(category)) {
pattern = "General Date"; //$NON-NLS-1$
} else if (DesignChoiceConstants.DATETIEM_FORMAT_TYPE_LONG_DATE.equals(category)
|| DesignChoiceConstants.DATE_FORMAT_TYPE_LONG_DATE.equals(category)) {

} else if (DesignChoiceConstants.DATETIME_FORMAT_TYPE_LONG_DATE.equals(category)
|| DesignChoiceConstants.DATE_FORMAT_TYPE_LONG_DATE.equals(category)
) {
pattern = "Long Date"; //$NON-NLS-1$
} else if (DesignChoiceConstants.DATETIEM_FORMAT_TYPE_MUDIUM_DATE.equals(category)
|| DesignChoiceConstants.DATE_FORMAT_TYPE_MUDIUM_DATE.equals(category)) {
} else if (DesignChoiceConstants.DATETIME_FORMAT_TYPE_MEDIUM_DATE.equals(category)
|| DesignChoiceConstants.DATE_FORMAT_TYPE_MEDIUM_DATE.equals(category)
) {
pattern = "Medium Date"; //$NON-NLS-1$
} else if (DesignChoiceConstants.DATETIEM_FORMAT_TYPE_SHORT_DATE.equals(category)

} else if (DesignChoiceConstants.DATETIME_FORMAT_TYPE_SHORT_DATE.equals(category)
|| DesignChoiceConstants.DATE_FORMAT_TYPE_SHORT_DATE.equals(category)) {
pattern = "Short Date"; //$NON-NLS-1$
} else if (DesignChoiceConstants.DATETIEM_FORMAT_TYPE_LONG_TIME.equals(category)

} else if (DesignChoiceConstants.DATETIME_FORMAT_TYPE_LONG_TIME.equals(category)
|| DesignChoiceConstants.TIME_FORMAT_TYPE_LONG_TIME.equals(category)) {
pattern = "Long Time"; //$NON-NLS-1$
} else if (DesignChoiceConstants.DATETIEM_FORMAT_TYPE_MEDIUM_TIME.equals(category)
|| DesignChoiceConstants.TIME_FORMAT_TYPE_MEDIUM_TIME.equals(category)) {

} else if (DesignChoiceConstants.DATETIME_FORMAT_TYPE_MEDIUM_TIME.equals(category)
|| DesignChoiceConstants.TIME_FORMAT_TYPE_MEDIUM_TIME.equals(category)
) {
pattern = "Medium Time"; //$NON-NLS-1$
} else if (DesignChoiceConstants.DATETIEM_FORMAT_TYPE_SHORT_TIME.equals(category)
|| DesignChoiceConstants.TIME_FORMAT_TYPE_SHORT_TIME.equals(category)) {

} else if (DesignChoiceConstants.DATETIME_FORMAT_TYPE_SHORT_TIME.equals(category)
|| DesignChoiceConstants.TIME_FORMAT_TYPE_SHORT_TIME.equals(category)
) {
pattern = "Short Time"; //$NON-NLS-1$

} else if (DesignChoiceConstants.TIME_FORMAT_TYPE_TIME_PICKER_SHORT_TIME.equals(category)) {
pattern = "HH:mm"; //$NON-NLS-1$

} else if (DesignChoiceConstants.TIME_FORMAT_TYPE_TIME_PICKER_MEDIUM_TIME.equals(category)) {
pattern = "HH:mm:ss"; //$NON-NLS-1$

} else if (DesignChoiceConstants.DATE_FORMAT_TYPE_DATE_PICKER.equals(category)
|| DesignChoiceConstants.DATETIME_FORMAT_TYPE_DATE_PICKER.equals(category)) {
pattern = "yyyy-MM-dd"; //$NON-NLS-1$

} else if (DesignChoiceConstants.DATETIME_FORMAT_TYPE_DATE_TIME_PICKER_SHORT_TIME.equals(category)) {
pattern = "yyyy-MM-dd HH:mm"; //$NON-NLS-1$

} else if (DesignChoiceConstants.DATETIME_FORMAT_TYPE_DATE_TIME_PICKER_MEDIUM_TIME.equals(category)) {
pattern = "yyyy-MM-dd HH:mm:ss"; //$NON-NLS-1$

} else {
// default, unformatted.
pattern = ""; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class FormatUtil {
private static boolean isCustom(String formatCategory) {
if (DesignChoiceConstants.STRING_FORMAT_TYPE_CUSTOM.equals(formatCategory)
|| DesignChoiceConstants.NUMBER_FORMAT_TYPE_CUSTOM.equals(formatCategory)
|| DesignChoiceConstants.DATETIEM_FORMAT_TYPE_CUSTOM.equals(formatCategory)) {
|| DesignChoiceConstants.DATETIME_FORMAT_TYPE_CUSTOM.equals(formatCategory)) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ public abstract class FormatAdapter {
public static String getLocaleDisplayName(ULocale locale) {
if (locale == null) {
return NONE;
} else {
return locale.getDisplayName();
}
return locale.getDisplayName();
}

public static String[] getLocaleDisplayNames() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class FormatChangeEvent extends EventObject {
* <code>null</code>)
* @param newCategory the new category of the format
* @param newPattern the new pattern of the format
* @param newLocale
*/
public FormatChangeEvent(Object source, String name, String newCategory, String newPattern, String newLocale) {
super(source);
Expand All @@ -61,6 +62,11 @@ public FormatChangeEvent(Object source, String name, String newCategory, String
this.locale = newLocale;
}

/**
* Get the locale
*
* @return Return the locale
*/
public String getLocale() {
return locale;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants;
import org.eclipse.birt.report.model.api.elements.structures.DateFormatValue;
import org.eclipse.birt.report.model.api.elements.structures.DateTimeFormatValue;
import org.eclipse.birt.report.model.api.elements.structures.FormatValue;
import org.eclipse.birt.report.model.api.elements.structures.TimeFormatValue;

import com.ibm.icu.util.ULocale;
Expand All @@ -32,15 +33,15 @@
*/
public final class FormatDateTimeAdapter extends FormatAdapter {

private static final String[] DATETIME_FORMAT_TYPES = { DesignChoiceConstants.DATETIEM_FORMAT_TYPE_GENERAL_DATE,
DesignChoiceConstants.DATETIEM_FORMAT_TYPE_LONG_DATE,
DesignChoiceConstants.DATETIEM_FORMAT_TYPE_MUDIUM_DATE,
DesignChoiceConstants.DATETIEM_FORMAT_TYPE_SHORT_DATE, DesignChoiceConstants.DATETIEM_FORMAT_TYPE_LONG_TIME,
DesignChoiceConstants.DATETIEM_FORMAT_TYPE_MEDIUM_TIME,
DesignChoiceConstants.DATETIEM_FORMAT_TYPE_SHORT_TIME };
private static final String[] DATETIME_FORMAT_TYPES = { DesignChoiceConstants.DATETIME_FORMAT_TYPE_GENERAL_DATE,
DesignChoiceConstants.DATETIME_FORMAT_TYPE_LONG_DATE,
DesignChoiceConstants.DATETIME_FORMAT_TYPE_MEDIUM_DATE,
DesignChoiceConstants.DATETIME_FORMAT_TYPE_SHORT_DATE, DesignChoiceConstants.DATETIME_FORMAT_TYPE_LONG_TIME,
DesignChoiceConstants.DATETIME_FORMAT_TYPE_MEDIUM_TIME,
DesignChoiceConstants.DATETIME_FORMAT_TYPE_SHORT_TIME };

private static final String[] DATE_FORMAT_TYPES = { DesignChoiceConstants.DATE_FORMAT_TYPE_GENERAL_DATE,
DesignChoiceConstants.DATE_FORMAT_TYPE_LONG_DATE, DesignChoiceConstants.DATE_FORMAT_TYPE_MUDIUM_DATE,
DesignChoiceConstants.DATE_FORMAT_TYPE_LONG_DATE, DesignChoiceConstants.DATE_FORMAT_TYPE_MEDIUM_DATE,
DesignChoiceConstants.DATE_FORMAT_TYPE_SHORT_DATE };

private static final String[] TIME_FORMAT_TYPES = { DesignChoiceConstants.TIME_FORMAT_TYPE_LONG_TIME,
Expand All @@ -56,6 +57,11 @@ public final class FormatDateTimeAdapter extends FormatAdapter {

private String[] formatTypes = null;

/**
* Constructor
*
* @param type date time type
*/
public FormatDateTimeAdapter(int type) {
this.type = type;
init();
Expand All @@ -64,10 +70,9 @@ public FormatDateTimeAdapter(int type) {
private void init() {
switch (type) {
case FormatBuilder.DATETIME:
UNFORMATTED_DISPLAYNAME = DesignChoiceConstants.DATETIEM_FORMAT_TYPE_UNFORMATTED;
CUSTOM = DesignChoiceConstants.DATETIEM_FORMAT_TYPE_CUSTOM;
UNFORMATTED_DISPLAYNAME = DesignChoiceConstants.DATETIME_FORMAT_TYPE_UNFORMATTED;
CUSTOM = DesignChoiceConstants.DATETIME_FORMAT_TYPE_CUSTOM;
UNFORMATTED_NAME = DateFormatter.DATETIME_UNFORMATTED;

break;
case FormatBuilder.DATE:
UNFORMATTED_DISPLAYNAME = DesignChoiceConstants.DATE_FORMAT_TYPE_UNFORMATTED;
Expand All @@ -82,6 +87,11 @@ private void init() {
}
}

/**
* Method to return the date time format types
*
* @return Return the date time format types
*/
public String[] getSimpleDateTimeFormatTypes() {
if (type == FormatBuilder.DATETIME) {
return DATETIME_FORMAT_TYPES;
Expand All @@ -96,19 +106,21 @@ public String[] getSimpleDateTimeFormatTypes() {

/**
* Returns the choiceArray of this choice element from model.
*
* @return Return the choiceArray of this choice element from model.
*/
public String[][] getFormatTypeChoiceSet() {
String structName, property;

if (type == FormatBuilder.DATETIME) {
structName = DateTimeFormatValue.FORMAT_VALUE_STRUCT;
property = DateTimeFormatValue.CATEGORY_MEMBER;
property = FormatValue.CATEGORY_MEMBER;
} else if (type == FormatBuilder.DATE) {
structName = DateFormatValue.FORMAT_VALUE_STRUCT;
property = DateFormatValue.CATEGORY_MEMBER;
property = FormatValue.CATEGORY_MEMBER;
} else {
structName = TimeFormatValue.FORMAT_VALUE_STRUCT;
property = TimeFormatValue.CATEGORY_MEMBER;
property = FormatValue.CATEGORY_MEMBER;
}

return getChoiceArray(structName, property);
Expand All @@ -121,15 +133,15 @@ public String[][] initChoiceArray() {
case FormatBuilder.DATETIME:
default:
categoryChoiceArray = getChoiceArray(DateTimeFormatValue.FORMAT_VALUE_STRUCT,
DateTimeFormatValue.CATEGORY_MEMBER);
FormatValue.CATEGORY_MEMBER);
break;
case FormatBuilder.DATE:
categoryChoiceArray = getChoiceArray(DateFormatValue.FORMAT_VALUE_STRUCT,
DateFormatValue.CATEGORY_MEMBER);
FormatValue.CATEGORY_MEMBER);
break;
case FormatBuilder.TIME:
categoryChoiceArray = getChoiceArray(TimeFormatValue.FORMAT_VALUE_STRUCT,
TimeFormatValue.CATEGORY_MEMBER);
FormatValue.CATEGORY_MEMBER);
break;
}
}
Expand All @@ -151,7 +163,7 @@ public String getCategory4DisplayName(String displayName) {
@Override
public String getDisplayName4Category(String category) {
return ChoiceSetFactory.getStructDisplayName(DateTimeFormatValue.FORMAT_VALUE_STRUCT,
DateTimeFormatValue.CATEGORY_MEMBER, category);
FormatValue.CATEGORY_MEMBER, category);
}

@Override
Expand All @@ -162,7 +174,8 @@ public String[] getFormatTypes(ULocale locale) {
for (int i = 0; i < categoryChoiceArray.length; i++) {
String fmtStr = ""; //$NON-NLS-1$
String category = categoryChoiceArray[i][1];
if (category.equals(CUSTOM) || category.equals(UNFORMATTED_DISPLAYNAME)) {
if (category.equals(CUSTOM) || category.equals(UNFORMATTED_DISPLAYNAME)
|| category.startsWith("Date Picker") || category.startsWith("Time Picker")) {
fmtStr = categoryChoiceArray[i][0];
} else {
// uses UI specified display names.
Expand Down Expand Up @@ -194,18 +207,27 @@ public int getIndexOfCategory(String category) {
@Override
public String getPattern4DisplayName(String displayName, ULocale locale) {
String category = ChoiceSetFactory.getStructPropValue(DateTimeFormatValue.FORMAT_VALUE_STRUCT,
DateTimeFormatValue.CATEGORY_MEMBER, displayName);
FormatValue.CATEGORY_MEMBER, displayName);
return FormatDateTimePattern.getPatternForCategory(category);
}

/**
* @return
*/
public String getUnformattedCategoryDisplayName() {
return UNFORMATTED_DISPLAYNAME;
}

/**
* @return
*/
public String getCustomCategoryName() {
return CUSTOM;
}

/**
* @return
*/
public String getUnformattedCategoryName() {
return UNFORMATTED_NAME;
}
Expand Down