Merge branch 'master' into bug4476

This commit is contained in:
Kai Börnert committed 2018-05-14 12:23:45 +02:00
commit 845ed2a17a
16 files changed
+135 -71

No files matched your search

@@ -12,10 +12,8 @@ import com.sap.sailing.domain.base.Leg;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.Wind;
import com.sap.sailing.domain.common.tracking.GPSFixMoving;
import com.sap.sailing.domain.leaderboard.Leaderboard;
import com.sap.sailing.domain.tracking.BravoFixTrack;
import com.sap.sailing.domain.tracking.GPSFixTrack;
import com.sap.sailing.domain.tracking.TrackedLeg;
import com.sap.sailing.domain.tracking.TrackedLegOfCompetitor;
import com.sap.sailing.domain.tracking.TrackedRace;
@@ -1541,8 +1541,10 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
} else if (eventClass.equals(RaceLogPassChangeEvent.class.getSimpleName())) {
resultEvent = loadRaceLogPassChangeEvent(createdAt, author, logicalTimePoint, id, passId, competitors);
} else if (eventClass.equals(RaceLogCourseDesignChangedEvent.class.getSimpleName())) {
resultEvent = loadRaceLogCourseDesignChangedEvent(createdAt, author, logicalTimePoint, id, passId, competitors,
dbObject);
final Pair<RaceLogCourseDesignChangedEvent, Optional<DBObject>> resultPair = loadRaceLogCourseDesignChangedEvent(
createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
resultEvent = resultPair.getA();
dbObjectForUpdate = resultPair.getB();
} else if (eventClass.equals(RaceLogFinishPositioningListChangedEvent.class.getSimpleName())) {
resultEvent = loadRaceLogFinishPositioningListChangedEvent(createdAt, author, logicalTimePoint, id, passId,
competitors, dbObject);
@@ -1815,17 +1817,21 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
return new RaceLogPassChangeEventImpl(createdAt, logicalTimePoint, author, id, passId);
}
private RaceLogCourseDesignChangedEvent loadRaceLogCourseDesignChangedEvent(TimePoint createdAt,
/**
* @return the second pair component has a DBObject in case migration was performed and the updated race log event's
* DBObject representation shall be updated to the DB
*/
private Pair<RaceLogCourseDesignChangedEvent, Optional<DBObject>> loadRaceLogCourseDesignChangedEvent(TimePoint createdAt,
AbstractLogEventAuthor author, TimePoint logicalTimePoint, Serializable id, Integer passId,
List<Competitor> competitors, DBObject dbObject) {
String courseName = (String) dbObject.get(FieldNames.RACE_LOG_COURSE_DESIGN_NAME.name());
CourseBase courseData = loadCourseData((BasicDBList) dbObject.get(FieldNames.RACE_LOG_COURSE_DESIGN.name()),
Pair<CourseBase, Boolean> courseData = loadCourseData((BasicDBList) dbObject.get(FieldNames.RACE_LOG_COURSE_DESIGN.name()),
courseName);
final String courseDesignerModeName = (String) dbObject.get(FieldNames.RACE_LOG_COURSE_DESIGNER_MODE.name());
final CourseDesignerMode courseDesignerMode = courseDesignerModeName == null ? null
: CourseDesignerMode.valueOf(courseDesignerModeName);
return new RaceLogCourseDesignChangedEventImpl(createdAt, logicalTimePoint, author, id, passId, courseData,
courseDesignerMode);
return new Pair<>(new RaceLogCourseDesignChangedEventImpl(createdAt, logicalTimePoint, author, id, passId, courseData.getA(),
courseDesignerMode), courseData.getB() ? /* migrated */ Optional.of(dbObject) : Optional.empty());
}
private RaceLogEvent loadRaceLogFixedMarkPassingEvent(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
@@ -2313,9 +2319,12 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
* field is loaded, the value of PASSINGSIDE is used and then migrated to PASSINGINSTRUCTION. If the first or last
* Waypoint has the PassingInstructions Gate, it is transfered to Line.
*
* @return the second component tells if migration was performed; in this case the {@code dbCourseList} passed has
* been edited "in place" to describe the migration that has happened
*/
@SuppressWarnings("deprecation") // Used to migrate from PASSINGSIDE to the new PASSINGINSTRUCTIONS
private CourseBase loadCourseData(BasicDBList dbCourseList, String courseName) {
private Pair<CourseBase, Boolean> loadCourseData(BasicDBList dbCourseList, String courseName) {
boolean migrated = false;
if (courseName == null) {
courseName = "Course";
}
@@ -2338,25 +2347,31 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
}
dbObject.put(FieldNames.WAYPOINT_PASSINGINSTRUCTIONS.name(), waypointPassingInstruction);
dbObject.removeField(FieldNames.WAYPOINT_PASSINGSIDE.name());
migrated = true;
}
}
if (waypointPassingInstruction != null) {
passingInstructions = PassingInstruction.valueOfIgnoringCase(waypointPassingInstruction);
}
ControlPoint controlPoint = loadControlPoint((DBObject) dbObject.get(FieldNames.CONTROLPOINT.name()));
Pair<ControlPoint, Boolean> controlPoint = loadControlPoint((DBObject) dbObject.get(FieldNames.CONTROLPOINT.name()));
migrated = migrated || controlPoint.getB();
if (passingInstructions == null) {
waypoint = new WaypointImpl(controlPoint);
waypoint = new WaypointImpl(controlPoint.getA());
} else {
waypoint = new WaypointImpl(controlPoint, passingInstructions);
waypoint = new WaypointImpl(controlPoint.getA(), passingInstructions);
}
courseData.addWaypoint(i++, waypoint);
}
return courseData;
return new Pair<>(courseData, migrated);
}
private ControlPoint loadControlPoint(DBObject dbObject) {
/**
* @return second component tells whether migration was performed on {@code dbObject} in place
*/
private Pair<ControlPoint, Boolean> loadControlPoint(DBObject dbObject) {
String controlPointClass = (String) dbObject.get(FieldNames.CONTROLPOINT_CLASS.name());
ControlPoint controlPoint = null;
boolean migrated = false;
if (controlPointClass != null) {
if (controlPointClass.equals(Mark.class.getSimpleName())) {
Mark mark = loadMark((DBObject) dbObject.get(FieldNames.CONTROLPOINT_VALUE.name()));
@@ -2366,13 +2381,14 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
(DBObject) dbObject.get(FieldNames.CONTROLPOINT_VALUE.name()));
dbObject.put(FieldNames.CONTROLPOINT_CLASS.name(), ControlPointWithTwoMarks.class.getSimpleName());
controlPoint = cpwtm;
migrated = true;
} else if (controlPointClass.equals(ControlPointWithTwoMarks.class.getSimpleName())) {
ControlPointWithTwoMarks cpwtm = loadControlPointWithTwoMarks(
(DBObject) dbObject.get(FieldNames.CONTROLPOINT_VALUE.name()));
controlPoint = cpwtm;
}
}
return controlPoint;
return new Pair<>(controlPoint, migrated);
}
/**
@@ -114,8 +114,7 @@ public abstract class AbstractLeaderboardImpl extends AbstractSimpleLeaderboardI
@Override
public Boat getBoatOfCompetitor(Competitor competitor, RaceColumn raceColumn, Fleet fleet) {
RaceDefinition raceDefinition = raceColumn.getRaceDefinition(fleet);
return raceDefinition != null ? raceDefinition.getBoatOfCompetitor(competitor) : null;
return raceColumn.getAllCompetitorsAndTheirBoats(fleet).get(competitor);
}
@Override
@@ -93,9 +93,10 @@ public class CompetitorTableWrapper<S extends RefreshableSelectionModel<Competit
};
competitorNameColumn.setSortable(true);
competitorColumnListHandler.setComparator(competitorNameColumn, new Comparator<CompetitorDTO>() {
private final NaturalComparator comparator = new NaturalComparator(/*case sensitive*/ false);
@Override
public int compare(CompetitorDTO o1, CompetitorDTO o2) {
return o1.getName().compareTo(o2.getName());
return comparator.compare(o1.getName(), o2.getName());
}
});
@@ -126,7 +127,7 @@ public class CompetitorTableWrapper<S extends RefreshableSelectionModel<Competit
@Override
public int compare(CompetitorDTO o1, CompetitorDTO o2) {
BoatDTO boat1 = o1.hasBoat() ? ((CompetitorWithBoatDTO) o1).getBoat() : null;
BoatDTO boat2 = o1.hasBoat() ? ((CompetitorWithBoatDTO) o1).getBoat() : null;
BoatDTO boat2 = o2.hasBoat() ? ((CompetitorWithBoatDTO) o2).getBoat() : null;
if (boat1 == null && boat2 == null) {
return 0;
} else if (boat1 != null && boat2 == null) {
@@ -162,6 +163,14 @@ public class CompetitorTableWrapper<S extends RefreshableSelectionModel<Competit
return sb.toSafeHtml();
}
};
flagImageColumn.setSortable(true);
competitorColumnListHandler.setComparator(flagImageColumn, new Comparator<CompetitorDTO>() {
private final NaturalComparator comparator = new NaturalComparator(/* case sensitive */ false);
@Override
public int compare(CompetitorDTO o1, CompetitorDTO o2) {
return comparator.compare(o1.getThreeLetterIocCountryCode(), o2.getThreeLetterIocCountryCode());
}
});
TextColumn<CompetitorDTO> sailIdColumn = new TextColumn<CompetitorDTO>() {
@Override
@@ -175,7 +184,7 @@ public class CompetitorTableWrapper<S extends RefreshableSelectionModel<Competit
@Override
public int compare(CompetitorDTO o1, CompetitorDTO o2) {
BoatDTO boat1 = o1.hasBoat() ? ((CompetitorWithBoatDTO) o1).getBoat() : null;
BoatDTO boat2 = o1.hasBoat() ? ((CompetitorWithBoatDTO) o1).getBoat() : null;
BoatDTO boat2 = o2.hasBoat() ? ((CompetitorWithBoatDTO) o2).getBoat() : null;
if (boat1 == null && boat2 == null) {
return 0;
} else if (boat1 != null && boat2 == null) {
@@ -656,44 +656,41 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
@Override
public void fillLeaderboards(Iterable<StrippedLeaderboardDTO> leaderboards) {
availableLeaderboards.clear();
leaderboardsProvider.getList().clear();
if (leaderboards != null) {
Util.addAll(leaderboards, availableLeaderboards);
}
leaderboardsFilterablePanel.updateAll(availableLeaderboards);
final LeaderboardGroupDTO selectedGroup = getSelectedGroup();
if(selectedGroup != null) {
leaderboardsProvider.getList().addAll(availableLeaderboards);
leaderboardsProvider.getList().removeAll(selectedGroup.leaderboards);
leaderboardsFilterablePanel.updateAll(leaderboardsProvider.getList());
refreshableLeaderboardsSelectionModel.clear();
final Set<StrippedLeaderboardDTO> selectedLeaderboards = refreshableLeaderboardsSelectionModel.getSelectedSet();
for (StrippedLeaderboardDTO leaderboard : selectedLeaderboards) {
refreshableLeaderboardsSelectionModel.setSelected(leaderboard, true);
}
}
}
/**
* If no leaderboard group is selected or more than one is selected, this method is a no-op because the
* leaderboard list displayed is defined to the be list of all leaderboards available, excluding those
* leaderboards that are already assigned to <em>the</em> selected leaderboard group. In other words,
* the leaderboard list is only well-defined in case a single leaderboard group is selected.
* If no leaderboard group is selected or more than one is selected, this method is a no-op because the leaderboard
* list displayed is defined to the be list of all leaderboards available, excluding those leaderboards that are
* already assigned to <em>the</em> selected leaderboard group. In other words, the leaderboard list is only
* well-defined in case a single leaderboard group is selected.
*/
private void refreshLeaderboardsList() {
final LeaderboardGroupDTO selectedGroup = getSelectedGroup();
final Set<StrippedLeaderboardDTO> selectedLeaderboards = refreshableLeaderboardsSelectionModel.getSelectedSet();
if (isSingleGroupSelected && selectedGroup != null) {
if (isSingleGroupSelected && getSelectedGroup() != null) {
sailingService.getLeaderboards(new MarkedAsyncCallback<List<StrippedLeaderboardDTO>>(
new AsyncCallback<List<StrippedLeaderboardDTO>>() {
@Override
public void onFailure(Throwable t) {
errorReporter.reportError("Error trying to obtain list of leaderboards: " + t.getMessage());
}
@Override
public void onSuccess(List<StrippedLeaderboardDTO> leaderboards) {
availableLeaderboards.clear();
if (leaderboards != null) {
availableLeaderboards.addAll(leaderboards);
}
leaderboardsProvider.getList().clear();
leaderboardsProvider.getList().addAll(availableLeaderboards);
leaderboardsProvider.getList().removeAll(selectedGroup.leaderboards);
leaderboardsFilterablePanel.getTextBox().setText("");
leaderboardsFilterablePanel.updateAll(availableLeaderboards);
refreshableLeaderboardsSelectionModel.clear();
for (StrippedLeaderboardDTO leaderboard : selectedLeaderboards) {
refreshableLeaderboardsSelectionModel.setSelected(leaderboard, true);
}
fillLeaderboards(leaderboards);
}
}));
}
@@ -903,7 +900,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
}
updateGroup(selectedGroup);
//Refilters the leaderboards list (hides the moved leaderboards if they don't fit to the filter) and resorts the list
leaderboardsFilterablePanel.updateAll(availableLeaderboards);
leaderboardsFilterablePanel.updateAll(leaderboardsProvider.getList());
}
}
@@ -73,6 +73,7 @@ public abstract class VideoDialog extends DataEntryDialog<VideoDTO> {
mimeTypeListBox.addItem(MimeType.aac.name());
mimeTypeListBox.addItem(MimeType.mp4.name());
mimeTypeListBox.addItem(MimeType.mp4panorama.name());
mimeTypeListBox.addItem(MimeType.mp4panoramaflip.name());
mimeTypeListBox.addItem(MimeType.ogg.name());
mimeTypeListBox.addItem(MimeType.ogv.name());
mimeTypeListBox.addItem(MimeType.qt.name());
@@ -322,7 +322,7 @@ public class NewMediaDialog extends DataEntryDialog<MediaTrack> {
infoLabel.setWidget(new Label(mediaTrack.url));
} else {
infoLabelLabel.setText(stringMessages.mimeType() + ":");
if (mediaTrack.mimeType == MimeType.mp4 || mediaTrack.mimeType == MimeType.mp4panorama) {
if (mediaTrack.mimeType == MimeType.mp4 || mediaTrack.mimeType == MimeType.mp4panorama || mediaTrack.mimeType == MimeType.mp4panoramaflip) {
if (!remoteMp4WasStarted) {
processMp4(mediaTrack);
} else if (remoteMp4WasFinished) {
@@ -454,6 +454,7 @@ public class NewMediaDialog extends DataEntryDialog<MediaTrack> {
ListBox mimeTypeListBox = createListBox(false);
mimeTypeListBox.addItem(MimeType.mp4.name());
mimeTypeListBox.addItem(MimeType.mp4panorama.name());
mimeTypeListBox.addItem(MimeType.mp4panoramaflip.name());
mimeTypeListBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
@@ -7,6 +7,7 @@ import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.SourceElement;
import com.google.gwt.dom.client.VideoElement;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Timer;
@@ -26,8 +27,16 @@ public class VideoJSPlayer extends Widget implements RequiresResize {
interface VideoJSPlayerUiBinder extends UiBinder<Element, VideoJSPlayer> {
}
interface VideoJSStyle extends CssResource {
String invertedVideoPlayer();
}
@UiField VideoElement videoElement;
@UiField
VideoJSStyle style;
@UiField
VideoElement videoElement;
private final String elementId;
private JavaScriptObject player;
@@ -63,17 +72,20 @@ public class VideoJSPlayer extends Widget implements RequiresResize {
}
public void setVideo(MimeType mimeType, String source) {
if (mimeType == null || mimeType.mediaType != MediaType.video) {
return;
}
this.panorama = mimeType.isPanorama();
if (this.panorama) {
videoElement.setAttribute("crossorigin", "anonymous");
}
if (mimeType.isFlippedPanorama()) {
videoElement.addClassName(style.invertedVideoPlayer());
}
if (isAttached()) {
_onLoad(autoplay, panorama, StringMessages.INSTANCE.threeSixtyVideoHint());
resizeChecker.scheduleRepeating(RESIZE_CHECK);
}
if (mimeType == null || mimeType.mediaType != MediaType.video) {
return;
}
String type = null;
if (mimeType.mediaSubType == MediaSubType.youtube) {
type = "video/youtube";
@@ -1,6 +1,6 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder">
<ui:style>
<ui:style type="com.sap.sailing.gwt.ui.client.media.VideoJSPlayer.VideoJSStyle" ui:field="style">
@external vjs-big-play-button;
.vjs-big-play-button {
display: none !important;
@@ -10,6 +10,10 @@
height: 100%;
min-height: 230px;
}
.invertedVideoPlayer canvas{
transform: rotate(180deg) translateX(50%) translateZ(0) !important;
}
</ui:style>
<div class="{style.player}">
<video class="{style.player} video-js vjs-default-skin vjs-big-play-centered" ui:field="videoElement" preload="auto"></video>
@@ -470,7 +470,7 @@ public class EditMarkPassingsPanel extends AbstractCompositeComponent<AbstractSe
@Override
public String getLocalizedShortName() {
return null;
return stringMessages.editMarkPassings();
}
@Override
@@ -529,7 +529,7 @@ public class EditMarkPositionPanel extends AbstractRaceChart<AbstractSettings> i
public void resetPointColor(int index) {
Point[] points = markSeries.getPoints();
if (points.length > index) {
if (points.length > index && selectedMark != null) {
points[index].setMarker(new Marker().setFillColor(selectedMark.color==null?null:selectedMark.color.getAsHtml()));
setSeriesPoints(markSeries, points, /* manageZoom */ true);
}
@@ -783,7 +783,7 @@ public class EditMarkPositionPanel extends AbstractRaceChart<AbstractSettings> i
@Override
public String getLocalizedShortName() {
return null;
return stringMessages.editMarkPositions();
}
@Override
@@ -24,7 +24,7 @@ public class WindChartLifecycle implements ComponentLifecycle<WindChartSettings>
@Override
public String getLocalizedShortName() {
return stringMessages.wind();
return stringMessages.windChart();
}
@Override
@@ -243,7 +243,7 @@ public class TouchSplitLayoutPanel extends DockLayoutPanel {
this.reverse = reverse;
this.associatedComponent = associatedComponent;
this.hasToggleButtonsAssociated = false;
this.splitterToggleButton = new Button(target.getTitle());
this.splitterToggleButton = new Button(associatedComponent.getLocalizedShortName());
}
public Component<?> getAssociatedComponent() {
@@ -31,7 +31,7 @@ public final class MediaConstants {
public static final List<String> imageTagSuggestions = Arrays.asList(new String[] { MediaTagConstants.BIGSCREEN,MediaTagConstants.STAGE, MediaTagConstants.TEASER,
MediaTagConstants.SPONSOR, MediaTagConstants.LOGO, MediaTagConstants.GALLERY });
public static final List<String> videoTagSuggestions = Arrays.asList(new String[] { MediaTagConstants.BIGSCREEN,MediaTagConstants.LIVESTREAM, MediaTagConstants.HIGHLIGHT, MediaTagConstants.FEATURED, MediaTagConstants.STAGE });
public static final Set<MimeType> SUPPORTED_VIDEO_TYPES = new HashSet<>(Arrays.asList(MimeType.youtube, MimeType.vimeo, MimeType.mp4, MimeType.mp4panorama));
public static final Set<MimeType> SUPPORTED_VIDEO_TYPES = new HashSet<>(Arrays.asList(MimeType.youtube, MimeType.vimeo, MimeType.mp4, MimeType.mp4panorama, MimeType.mp4panoramaflip));
private MediaConstants() {
}
@@ -6,7 +6,7 @@ public enum MimeType {
MediaSubType.quicktime), mp3(MediaType.audio, MediaSubType.mpeg), ogg(MediaType.audio, MediaSubType.ogg), aac(
MediaType.audio, MediaSubType.aac), webm(MediaType.video, MediaSubType.webm), youtube(MediaType.video,
MediaSubType.youtube), vimeo(MediaType.video, MediaSubType.vimeo), image(MediaType.image,
MediaSubType.unknown), unknown(MediaType.unknown, MediaSubType.unknown), mp4panorama(MediaType.video, MediaSubType.mp4);
MediaSubType.unknown), unknown(MediaType.unknown, MediaSubType.unknown), mp4panorama(MediaType.video, MediaSubType.mp4), mp4panoramaflip(MediaType.video, MediaSubType.mp4);
public final MediaType mediaType;
public final MediaSubType mediaSubType;
@@ -17,7 +17,11 @@ public enum MimeType {
}
public boolean isPanorama(){
return this == mp4panorama;
return this == mp4panorama || this == mp4panoramaflip;
}
public boolean isFlippedPanorama(){
return this == mp4panoramaflip;
}
@Override
@@ -1,6 +1,9 @@
package com.sap.sse.gwt.client.controls.datetime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import com.google.gwt.dom.client.Document;
@@ -26,7 +29,7 @@ class NativeDateTimeInput extends Widget implements DateTimeInput {
* @return the newly created instance as {@link DateTimeInput} abstraction
*/
static DateTimeInput date() {
return new NativeDateTimeInput(DateTimeInputType.DATE, "", Accuracy.getDateFormat());
return new NativeDateTimeInput(DateTimeInputType.DATE, "", Accuracy.getDateFormat(), Collections.emptyList());
}
/**
@@ -38,7 +41,16 @@ class NativeDateTimeInput extends Widget implements DateTimeInput {
* @return the newly created instance as {@link DateTimeInput} abstraction
*/
static DateTimeInput time(Accuracy accuracy) {
return new NativeDateTimeInput(DateTimeInputType.TIME, accuracy.getStep(), accuracy.getTimeFormat());
final List<DateTimeFormat> additionalFormats = new ArrayList<>();
switch (accuracy) {
case MILLISECONDS:
additionalFormats.add(Accuracy.SECONDS.getTimeFormat());
case SECONDS:
additionalFormats.add(Accuracy.MINUTES.getTimeFormat());
default:
break;
}
return new NativeDateTimeInput(DateTimeInputType.TIME, accuracy.getStep(), accuracy.getTimeFormat(), additionalFormats);
}
/**
@@ -50,14 +62,25 @@ class NativeDateTimeInput extends Widget implements DateTimeInput {
* @return the newly created instance as {@link DateTimeInput} abstraction
*/
static DateTimeInput datetimeLocale(Accuracy accuracy) {
final List<DateTimeFormat> additionalFormats = new ArrayList<>();
switch (accuracy) {
case MILLISECONDS:
additionalFormats.add(Accuracy.SECONDS.getDatetimeFormat());
case SECONDS:
additionalFormats.add(Accuracy.MINUTES.getDatetimeFormat());
default:
break;
}
return new NativeDateTimeInput(DateTimeInputType.DATETIME_LOCAL, accuracy.getStep(),
accuracy.getDatetimeFormat());
accuracy.getDatetimeFormat(), additionalFormats);
}
private final DateTimeFormat format;
private final InputElement input;
private final List<DateTimeFormat> additionalFormatsForParsing;
private NativeDateTimeInput(DateTimeInputType inputType, String step, DateTimeFormat format) {
private NativeDateTimeInput(DateTimeInputType inputType, String step, DateTimeFormat format, List<DateTimeFormat> additionalFormatsForParsing) {
this.additionalFormatsForParsing = additionalFormatsForParsing;
this.input = Document.get().createElement(InputElement.TAG).cast();
this.input.setAttribute(ATTR_TYPE, inputType.getType());
this.input.setAttribute(ATTR_STEP, step);
@@ -79,19 +102,19 @@ class NativeDateTimeInput extends Widget implements DateTimeInput {
@Override
public final Date getValue() {
final String value = input.getValue();
if (value == null || value.isEmpty()) {
return null;
}
try {
return this.format.parse(input.getValue());
return this.format.parse(value);
} catch (IllegalArgumentException exc) {
try {
// at least Google Chrome omits the seconds, if they are 00 in input field
if (format == Accuracy.SECONDS.getDatetimeFormat()) {
return Accuracy.MINUTES.getDatetimeFormat().parse(input.getValue());
for (DateTimeFormat additionalFormat : additionalFormatsForParsing) {
try {
// at least Google Chrome omits the seconds, if they are 00 in input field
return additionalFormat.parse(value);
} catch (IllegalArgumentException exc2) {
}
if (format == Accuracy.SECONDS.getTimeFormat()) {
return Accuracy.MINUTES.getTimeFormat().parse(input.getValue());
}
} catch (IllegalArgumentException exc2) {
return null;
}
}
return null;