Merge remote-tracking branch 'origin/master'

Conflicts:
	java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/spectator/LeaderboardGroupPanel.java
This commit is contained in:
fmittag committed 2012-06-16 22:28:59 +02:00
commit d08d9da133
10 files changed
+99 -70

No files matched your search

@@ -222,7 +222,7 @@ public interface DomainFactory {
* <code>timeoutInMilliseconds</code> in case no modifications happen on the set of races cached by this factory.
*
* @param timeoutInMilliseconds
* passing -1 means an infinite timeout; 0 means return immediately with <code>null</code> result if no
* passing -1 means an infinite timeout; 0 means return immediately with <code>null</code> as result if no
* race definition is found for <code>race</code>.
*/
RaceDefinition getAndWaitForRaceDefinition(Race race, long timeoutInMilliseconds);
@@ -7,7 +7,6 @@ import com.sap.sailing.domain.common.impl.Util.Triple;
import com.sap.sailing.domain.tracking.RaceTracker;
public interface TracTracRaceTracker extends RaceTracker {
/**
* returns the paramURL, liveURI and storedURI for the TracTrac connection maintained by this tracker
*/
@@ -8,6 +8,7 @@ import com.sap.sailing.domain.base.RaceDefinition;
import com.sap.sailing.domain.common.impl.Util.Triple;
import com.sap.sailing.domain.tracking.DynamicTrackedRace;
import com.sap.sailing.domain.tracking.DynamicTrackedRegatta;
import com.sap.sailing.domain.tracking.RaceTracker;
import com.sap.sailing.domain.tracking.TrackedRace;
import com.sap.sailing.domain.tracking.TrackedRegatta;
import com.sap.sailing.domain.tractracadapter.DomainFactory;
@@ -133,17 +134,23 @@ public abstract class AbstractReceiverWithQueue<A, B, C> implements Runnable, Re
protected abstract void handleEvent(Triple<A, B, C> event);
/**
* Tries to find a {@link TrackedRace} for <code>race</code> in the {@link com.sap.sailing.domain.base.Regatta} corresponding
* to {@link #tractracEvent}, as keyed by the {@link #domainFactory}. If the {@link RaceDefinition} for <code>race</code>
* is not found in the {@link com.sap.sailing.domain.base.Regatta}, <code>null</code> is returned. If the {@link TrackedRace}
* for <code>race</code> isn't found in the {@link TrackedRegatta}, <code>null</code> is returned, too.
* Tries to find a {@link TrackedRace} for <code>race</code> in the {@link com.sap.sailing.domain.base.Regatta}
* corresponding to {@link #tractracEvent}, as keyed by the {@link #domainFactory}. Waits for
* {@link RaceTracker#TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS} milliseconds for the
* {@link RaceDefinition} to show up. If it doesn't, <code>null</code> is returned. If the {@link RaceDefinition}
* for <code>race</code> is not found in the {@link com.sap.sailing.domain.base.Regatta}, <code>null</code> is
* returned. If the {@link TrackedRace} for <code>race</code> isn't found in the {@link TrackedRegatta},
* <code>null</code> is returned, too.
*/
protected DynamicTrackedRace getTrackedRace(Race race) {
DynamicTrackedRace result = null;
RaceDefinition raceDefinition = getDomainFactory().getAndWaitForRaceDefinition(race);
com.sap.sailing.domain.base.Regatta domainRegatta = trackedRegatta.getRegatta();
if (domainRegatta.getRaceByName(raceDefinition.getName()) != null) {
result = trackedRegatta.getTrackedRace(raceDefinition);
RaceDefinition raceDefinition = getDomainFactory().getAndWaitForRaceDefinition(race,
RaceTracker.TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS);
if (raceDefinition != null) {
com.sap.sailing.domain.base.Regatta domainRegatta = trackedRegatta.getRegatta();
if (domainRegatta.getRaceByName(raceDefinition.getName()) != null) {
result = trackedRegatta.getTrackedRace(raceDefinition);
}
}
return result;
}
@@ -226,7 +226,14 @@ public class DomainFactoryImpl implements DomainFactory {
boolean interrupted = false;
while ((timeoutInMilliseconds == -1 || System.currentTimeMillis()-start < timeoutInMilliseconds) && !interrupted && result == null) {
try {
raceCache.wait();
if (timeoutInMilliseconds == -1) {
raceCache.wait();
} else {
long timeToWait = timeoutInMilliseconds-(System.currentTimeMillis()-start);
if (timeToWait > 0) {
raceCache.wait(timeToWait);
}
}
result = raceCache.get(race);
} catch (InterruptedException e) {
interrupted = true;
@@ -312,7 +319,9 @@ public class DomainFactoryImpl implements DomainFactory {
@Override
public Iterable<Receiver> getUpdateReceivers(DynamicTrackedRegatta trackedRegatta,
com.tractrac.clientmodule.Event tractracEvent, TimePoint startOfTracking, TimePoint endOfTracking, long delayToLiveInMillis, WindStore windStore, DynamicRaceDefinitionSet raceDefinitionSetToUpdate, TrackedRegattaRegistry trackedRegattaRegistry) {
com.tractrac.clientmodule.Event tractracEvent, TimePoint startOfTracking, TimePoint endOfTracking,
long delayToLiveInMillis, WindStore windStore, DynamicRaceDefinitionSet raceDefinitionSetToUpdate,
TrackedRegattaRegistry trackedRegattaRegistry) {
return getUpdateReceivers(trackedRegatta, tractracEvent, windStore, startOfTracking, endOfTracking, delayToLiveInMillis,
raceDefinitionSetToUpdate, trackedRegattaRegistry, ReceiverType.RACECOURSE,
ReceiverType.MARKPASSINGS, ReceiverType.MARKPOSITIONS, ReceiverType.RACESTARTFINISH, ReceiverType.RAWPOSITIONS);
@@ -32,6 +32,13 @@ import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
*
*/
public interface RaceTracker {
/**
* By default, wait five minutes for race data; sometimes, a tracking provider's server may be under heavy load and
* may serve races one after another. If many races are requested concurrently, this can lead to a queue
* of several minutes length.
*/
static long TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS = 300000;
/**
* Stops tracking the races.
*/
@@ -232,7 +232,7 @@ public class MatchAndApplyScoreCorrectionsDialog extends DataEntryDialog<BulkSco
// apply the score correction of the cell:
String raceNameOrNumber = getSelectedString(raceNameOrNumberChoosers, raceColumn);
String officialSailID = getSelectedString(officialSailIDChoosers, competitor);
if (officialSailID != null) {
if (officialSailID != null && raceNameOrNumber != null) {
ScoreCorrectionEntryDTO officialCorrectionEntry = regattaScoreCorrection
.getScoreCorrectionsByRaceNameOrNumber().get(raceNameOrNumber).get(officialSailID);
result.addMaxPointsReasonUpdate(competitor, raceColumn,
@@ -287,7 +287,7 @@ public class MatchAndApplyScoreCorrectionsDialog extends DataEntryDialog<BulkSco
VerticalPanel cell = new VerticalPanel();
cell.add(new Label(entry.netPoints+"/"+entry.totalPoints+"/"+entry.reasonForMaxPoints+
(entry.discarded?"/discarded":"")));
if (officialSailID != null) {
if (officialSailID != null && raceNameOrNumber != null) {
ScoreCorrectionEntryDTO officialCorrectionEntry =
regattaScoreCorrection.getScoreCorrectionsByRaceNameOrNumber()
.get(raceNameOrNumber).get(officialSailID);
@@ -105,6 +105,7 @@ import com.sap.sailing.domain.tracking.GPSFixMoving;
import com.sap.sailing.domain.tracking.GPSFixTrack;
import com.sap.sailing.domain.tracking.Maneuver;
import com.sap.sailing.domain.tracking.MarkPassing;
import com.sap.sailing.domain.tracking.RaceTracker;
import com.sap.sailing.domain.tracking.RacesHandle;
import com.sap.sailing.domain.tracking.TrackedLeg;
import com.sap.sailing.domain.tracking.TrackedLegOfCompetitor;
@@ -214,13 +215,6 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
private static final long serialVersionUID = 9031688830194537489L;
/**
* Wait five minutes for race data; sometimes, a tracking provider's server may be under heavy load and
* may serve races one after another. If many races are requested concurrently, this can lead to a queue
* of several minutes length.
*/
private static final long TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS = 300000;
private final ServiceTracker<RacingEventService, RacingEventService> racingEventServiceTracker;
private final ServiceTracker<ReplicationService, ReplicationService> replicationServiceTracker;
@@ -622,14 +616,16 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
if (storedURI == null || storedURI.trim().length() == 0) {
storedURI = rr.storedURI;
}
final RacesHandle raceHandle = getService().addTracTracRace(regattaToAddTo, new URL(rr.paramURL), new URI(liveURI),
new URI(storedURI), new MillisecondsTimePoint(rr.trackingStartTime),
new MillisecondsTimePoint(rr.trackingEndTime), MongoWindStoreFactory.INSTANCE.getMongoWindStore(mongoObjectFactory, domainObjectFactory), TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS);
final RacesHandle raceHandle = getService().addTracTracRace(regattaToAddTo, new URL(rr.paramURL),
new URI(liveURI), new URI(storedURI), new MillisecondsTimePoint(rr.trackingStartTime),
new MillisecondsTimePoint(rr.trackingEndTime),
MongoWindStoreFactory.INSTANCE.getMongoWindStore(mongoObjectFactory, domainObjectFactory),
RaceTracker.TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS);
if (trackWind) {
new Thread("Wind tracking starter for race "+rr.regattaName+"/"+rr.name) {
public void run() {
try {
startTrackingWind(raceHandle, correctWindByDeclination, TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS);
startTrackingWind(raceHandle, correctWindByDeclination, RaceTracker.TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -1624,12 +1620,13 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
boolean canSendRequests, boolean trackWind, final boolean correctWindByDeclination) throws Exception {
final RacesHandle raceHandle = getService().addSwissTimingRace(regattaToAddTo, rr.ID, hostname, port,
canSendRequests,
MongoWindStoreFactory.INSTANCE.getMongoWindStore(mongoObjectFactory, domainObjectFactory), TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS);
MongoWindStoreFactory.INSTANCE.getMongoWindStore(mongoObjectFactory, domainObjectFactory),
RaceTracker.TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS);
if (trackWind) {
new Thread("Wind tracking starter for race "+rr.ID+"/"+rr.description) {
public void run() {
try {
startTrackingWind(raceHandle, correctWindByDeclination, TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS);
startTrackingWind(raceHandle, correctWindByDeclination, RaceTracker.TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -125,31 +125,29 @@ public class LeaderboardGroupPanel extends FormPanel implements HasWelcomeWidget
}
private void buildGUI() {
// Create breadcrumb panel
BreadcrumbPanel breadcrumbPanel = createBreadcrumbPanel();
if (breadcrumbPanel != null) {
mainPanel.add(breadcrumbPanel);
}
// Create group details GUI
FlowPanel groupDetailsPanel = new FlowPanel();
groupDetailsPanel.setStyleName(STYLE_NAME_PREFIX + "GroupDetailsPanel");
mainPanel.add(groupDetailsPanel);
Label groupNameLabel = new Label(group.name + ":");
groupNameLabel.setStyleName(STYLE_NAME_PREFIX + "GroupName");
groupDetailsPanel.add(groupNameLabel);
// Using HTML to display the line breaks in the description
HTML groupDescriptionLabel = new HTML(new SafeHtmlBuilder().appendEscapedLines(group.description).toSafeHtml());
groupDescriptionLabel.setStyleName(STYLE_NAME_PREFIX + "GroupDescription");
groupDetailsPanel.add(groupDescriptionLabel);
// Create group leaderboards GUI
Label leaderboardsTableLabel = new Label(stringConstants.leaderboards());
leaderboardsTableLabel.setStyleName(STYLE_NAME_PREFIX + "LeaderboardsTableLabel");
mainPanel.add(leaderboardsTableLabel);
if (!embedded) {
// Create breadcrumb panel
BreadcrumbPanel breadcrumbPanel = createBreadcrumbPanel();
if (breadcrumbPanel != null) {
mainPanel.add(breadcrumbPanel);
}
// Create group details GUI
FlowPanel groupDetailsPanel = new FlowPanel();
groupDetailsPanel.setStyleName(STYLE_NAME_PREFIX + "GroupDetailsPanel");
mainPanel.add(groupDetailsPanel);
Label groupNameLabel = new Label(group.name + ":");
groupNameLabel.setStyleName(STYLE_NAME_PREFIX + "GroupName");
groupDetailsPanel.add(groupNameLabel);
// Using HTML to display the line breaks in the description
HTML groupDescriptionLabel = new HTML(new SafeHtmlBuilder().appendEscapedLines(group.description)
.toSafeHtml());
groupDescriptionLabel.setStyleName(STYLE_NAME_PREFIX + "GroupDescription");
groupDetailsPanel.add(groupDescriptionLabel);
// Create group leaderboards GUI
Label leaderboardsTableLabel = new Label(stringConstants.leaderboards());
leaderboardsTableLabel.setStyleName(STYLE_NAME_PREFIX + "LeaderboardsTableLabel");
mainPanel.add(leaderboardsTableLabel);
}
if (group.leaderboards.size() <= MAX_COLUMNS_IN_ROW) {
LeaderboardGroupFullTableResources tableResources = GWT.create(LeaderboardGroupFullTableResources.class);
CellTable<Integer> leaderboardsTable = new CellTable<Integer>(200, tableResources);
@@ -204,10 +202,10 @@ public class LeaderboardGroupPanel extends FormPanel implements HasWelcomeWidget
+ "&leaderboardGroupName=" + group.name + "&root=" + root
+ (debugParam != null && !debugParam.isEmpty() ? "&gwt.codesvr=" + debugParam : ""));
if (embedded) {
return ANCHORTEMPLATE.anchor(link, stringConstants.overview(), STYLE_NAME_PREFIX + "ActiveLeaderboard");
} else {
return ANCHORTEMPLATE.anchorWithTarget(link, stringConstants.overview(), STYLE_NAME_PREFIX + "ActiveLeaderboard",
/* target */ "_blank");
} else {
return ANCHORTEMPLATE.anchor(link, stringConstants.overview(), STYLE_NAME_PREFIX + "ActiveLeaderboard");
}
}
};
@@ -280,7 +278,11 @@ public class LeaderboardGroupPanel extends FormPanel implements HasWelcomeWidget
if (viewMode != null && !viewMode.isEmpty()) {
link += "&viewMode=" + viewMode;
}
b.append(ANCHORTEMPLATE.anchor(link, linkText, STYLE_NAME_PREFIX + "ActiveRace"));
if (embedded) {
b.append(ANCHORTEMPLATE.anchorWithTarget(link, linkText, STYLE_NAME_PREFIX + "ActiveRace", "_blank"));
} else {
b.append(ANCHORTEMPLATE.anchor(link, linkText, STYLE_NAME_PREFIX + "ActiveRace"));
}
} else {
b.append(TEXTTEMPLATE.textWithClass(linkText, STYLE_NAME_PREFIX + "InactiveRace"));
}
@@ -341,7 +343,11 @@ public class LeaderboardGroupPanel extends FormPanel implements HasWelcomeWidget
if (viewMode != null && !viewMode.isEmpty()) {
link += "&viewMode=" + viewMode;
}
b.append(ANCHORTEMPLATE.anchor(link, linkText, STYLE_NAME_PREFIX + "ActiveRace"));
if (embedded) {
b.append(ANCHORTEMPLATE.anchorWithTarget(link, linkText, STYLE_NAME_PREFIX + "ActiveRace", "_blank"));
} else {
b.append(ANCHORTEMPLATE.anchor(link, linkText, STYLE_NAME_PREFIX + "ActiveRace"));
}
} else {
b.append(TEXTTEMPLATE.textWithClass(linkText, STYLE_NAME_PREFIX + "InactiveRace"));
}
@@ -1,6 +1,7 @@
package com.sap.sailing.gwt.ui.spectator;
import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -9,8 +10,8 @@ import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.sap.sailing.gwt.ui.client.AbstractEntryPoint;
import com.sap.sailing.gwt.ui.client.RegattaRefresher;
import com.sap.sailing.gwt.ui.client.LogoAndTitlePanel;
import com.sap.sailing.gwt.ui.client.RegattaRefresher;
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
import com.sap.sailing.gwt.ui.shared.panels.SimpleWelcomeWidget;
@@ -55,6 +56,9 @@ public class SpectatorEntryPoint extends AbstractEntryPoint implements RegattaRe
: stringMessages.overview(), stringMessages);
logoAndTitlePanel.addStyleName("LogoAndTitlePanel");
rootPanel.add(logoAndTitlePanel);
} else {
RootPanel.getBodyElement().getStyle().setPadding(0, Unit.PX);
RootPanel.getBodyElement().getStyle().setPaddingTop(20, Unit.PX);
}
if (groupName == null) {
FlowPanel groupOverviewPanel = new FlowPanel();
@@ -65,22 +69,22 @@ public class SpectatorEntryPoint extends AbstractEntryPoint implements RegattaRe
LeaderboardGroupPanel groupPanel = new LeaderboardGroupPanel(sailingService, stringMessages, this,
groupName, root, viewModeParamValue, embedded);
groupPanel.getElement().getStyle().setFloat(Style.Float.LEFT);
groupPanel.setWelcomeWidget(new SimpleWelcomeWidget( stringMessages.welcomeToSailingAnalytics(), stringMessages.welcomeToSailingAnalyticsBody()));
SimplePanel feedbackPanel = new SimplePanel();
feedbackPanel.getElement().getStyle().setProperty("clear", "right");
feedbackPanel.addStyleName("feedbackPanel");
Anchor feedbackLink = new Anchor(new SafeHtmlBuilder().appendHtmlConstant(
"<img class=\"linkNoBorder\" src=\"/gwt/images/feedbackPanel-bg.png\"/>").toSafeHtml());//TODO set image
feedbackLink.setHref("mailto:sailing_analytics%40sap.com?subject=[SAP Sailing] Feedback");
feedbackLink.addStyleName("feedbackLink");
feedbackPanel.add(feedbackLink);
groupAndFeedbackPanel.add(groupPanel);
groupAndFeedbackPanel.add(feedbackPanel);
if (!embedded) {
groupPanel.setWelcomeWidget(new SimpleWelcomeWidget(stringMessages.welcomeToSailingAnalytics(),
stringMessages.welcomeToSailingAnalyticsBody()));
SimplePanel feedbackPanel = new SimplePanel();
feedbackPanel.getElement().getStyle().setProperty("clear", "right");
feedbackPanel.addStyleName("feedbackPanel");
Anchor feedbackLink = new Anchor(new SafeHtmlBuilder().appendHtmlConstant(
"<img class=\"linkNoBorder\" src=\"/gwt/images/feedbackPanel-bg.png\"/>").toSafeHtml());// TODO set image
feedbackLink.setHref("mailto:sailing_analytics%40sap.com?subject=[SAP Sailing] Feedback");
feedbackLink.addStyleName("feedbackLink");
feedbackPanel.add(feedbackLink);
groupAndFeedbackPanel.add(feedbackPanel);
}
rootPanel.add(groupAndFeedbackPanel);
}
fillRegattas();
}