mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Add location/description, I believe. Update for GWT 2.x
git-svn-id: https://zxing.googlecode.com/svn/trunk@1305 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
2e9afb3673
commit
d85cd8f70e
Binary file not shown.
|
@ -59,6 +59,8 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
CheckBox summerTime = new CheckBox();
|
CheckBox summerTime = new CheckBox();
|
||||||
ListBox timeZones = new ListBox();
|
ListBox timeZones = new ListBox();
|
||||||
Date timePicker1PreviousDate = null;
|
Date timePicker1PreviousDate = null;
|
||||||
|
TextBox location = new TextBox();
|
||||||
|
TextBox description = new TextBox();
|
||||||
|
|
||||||
public CalendarEventGenerator(final ChangeListener listener,
|
public CalendarEventGenerator(final ChangeListener listener,
|
||||||
KeyPressHandler keyListener) {
|
KeyPressHandler keyListener) {
|
||||||
|
@ -116,7 +118,7 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
}
|
}
|
||||||
datePicker1.getDatePicker().setSelectedDate(new Date());
|
datePicker1.getDatePicker().setSelectedDate(new Date());
|
||||||
datePicker2.getDatePicker().setSelectedDate(new Date());
|
datePicker2.getDatePicker().setSelectedDate(new Date());
|
||||||
table = new Grid(8, 2);
|
table = new Grid(10, 2);
|
||||||
|
|
||||||
table.setText(0, 0, "All day event");
|
table.setText(0, 0, "All day event");
|
||||||
table.setWidget(0, 1, fullDay);
|
table.setWidget(0, 1, fullDay);
|
||||||
|
@ -142,6 +144,12 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
table.setText(7, 0, "Daylight savings");
|
table.setText(7, 0, "Daylight savings");
|
||||||
table.setWidget(7, 1, summerTime);
|
table.setWidget(7, 1, summerTime);
|
||||||
|
|
||||||
|
table.setText(8, 0, "Location");
|
||||||
|
table.setWidget(8, 1, location);
|
||||||
|
|
||||||
|
table.setText(9, 0, "Description");
|
||||||
|
table.setWidget(9, 1, description);
|
||||||
|
|
||||||
table.getRowFormatter().getElement(3).setId(FULL_DAY_ONLY_IDS[0]);
|
table.getRowFormatter().getElement(3).setId(FULL_DAY_ONLY_IDS[0]);
|
||||||
table.getRowFormatter().getElement(5).setId(FULL_DAY_ONLY_IDS[1]);
|
table.getRowFormatter().getElement(5).setId(FULL_DAY_ONLY_IDS[1]);
|
||||||
table.getRowFormatter().getElement(6).setId(FULL_DAY_ONLY_IDS[2]);
|
table.getRowFormatter().getElement(6).setId(FULL_DAY_ONLY_IDS[2]);
|
||||||
|
@ -157,7 +165,7 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFullDay(boolean fullDay) {
|
private static void setFullDay(boolean fullDay) {
|
||||||
for (String s : FULL_DAY_ONLY_IDS) {
|
for (String s : FULL_DAY_ONLY_IDS) {
|
||||||
Element element = DOM.getElementById(s);
|
Element element = DOM.getElementById(s);
|
||||||
String style = fullDay ? "none" : "";
|
String style = fullDay ? "none" : "";
|
||||||
|
@ -168,10 +176,14 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
public String getText() throws GeneratorException {
|
public String getText() throws GeneratorException {
|
||||||
String eventName = getEventNameField();
|
String eventName = getEventNameField();
|
||||||
String dates = getDateTimeFields();
|
String dates = getDateTimeFields();
|
||||||
|
String location = getLocationField();
|
||||||
|
String description = getDescriptionField();
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
output.append("BEGIN:VEVENT\r\n");
|
output.append("BEGIN:VEVENT\r\n");
|
||||||
output.append(eventName);
|
output.append(eventName);
|
||||||
output.append(dates);
|
output.append(dates);
|
||||||
|
output.append(location);
|
||||||
|
output.append(description);
|
||||||
output.append("END:VEVENT\r\n");
|
output.append("END:VEVENT\r\n");
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
|
@ -195,6 +207,30 @@ public class CalendarEventGenerator implements GeneratorSource {
|
||||||
return getDateTimeValues();
|
return getDateTimeValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getLocationField() throws GeneratorException {
|
||||||
|
String locationString = location.getText();
|
||||||
|
if (locationString.length() < 1) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (locationString.contains("\n")) {
|
||||||
|
throw new GeneratorException(
|
||||||
|
"Location should not contain \\n characters.");
|
||||||
|
}
|
||||||
|
return "LOCATION:" + locationString + "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDescriptionField() throws GeneratorException {
|
||||||
|
String descriptionString = description.getText();
|
||||||
|
if (descriptionString.length() < 1) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (descriptionString.contains("\n")) {
|
||||||
|
throw new GeneratorException(
|
||||||
|
"Description should not contain \\n characters.");
|
||||||
|
}
|
||||||
|
return "DESCRIPTION:" + descriptionString + "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
private String getFullDayDateFields() throws GeneratorException {
|
private String getFullDayDateFields() throws GeneratorException {
|
||||||
Date date1 = datePicker1.getDatePicker().getSelectedDate();
|
Date date1 = datePicker1.getDatePicker().getSelectedDate();
|
||||||
Date date2 = datePicker2.getDatePicker().getSelectedDate();
|
Date date2 = datePicker2.getDatePicker().getSelectedDate();
|
||||||
|
|
Loading…
Reference in a new issue