Merge branch 'gwt' of ssh://kielweek.web4sap.com/home/trac/git into gwt

This commit is contained in:
Marcus Kammer committed 2012-02-07 13:19:59 +01:00
commit 547cd88d3a
22 files changed
+217 -62

No files matched your search

@@ -29,6 +29,8 @@ import com.sap.sailing.gwt.ui.client.RaceSelectionProvider;
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.client.TimeListener;
import com.sap.sailing.gwt.ui.client.Timer;
import com.sap.sailing.gwt.ui.client.Timer.PlayModes;
import com.sap.sailing.gwt.ui.shared.WindDTO;
import com.sap.sailing.gwt.ui.shared.WindInfoForRaceDTO;
import com.sap.sailing.gwt.ui.shared.WindTrackInfoDTO;
@@ -47,6 +49,7 @@ public class WindChart implements Component<WindChartSettings>, RaceSelectionCha
private final ErrorReporter errorReporter;
private final SailingServiceAsync sailingService;
private final Chart chart;
private final Timer timer;
/**
* @param raceSelectionProvider
@@ -55,13 +58,14 @@ public class WindChart implements Component<WindChartSettings>, RaceSelectionCha
* server and displayed in this chart. If no race is selected, the chart is cleared.
*/
public WindChart(SailingServiceAsync sailingService, RaceSelectionProvider raceSelectionProvider,
WindChartSettings settings, StringMessages stringMessages, ErrorReporter errorReporter) {
Timer timer, WindChartSettings settings, StringMessages stringMessages, ErrorReporter errorReporter) {
super();
this.sailingService = sailingService;
this.stringMessages = stringMessages;
this.errorReporter = errorReporter;
this.windSourceSeries = new HashMap<WindSource, Series>();
this.windSourcesToDisplay = new HashSet<WindSource>();
this.timer = timer;
chart = new Chart()
.setZoomType(Chart.ZoomType.X)
.setSpacingRight(20)
@@ -206,6 +210,12 @@ public class WindChart implements Component<WindChartSettings>, RaceSelectionCha
@Override
public void timeChanged(Date date) {
if (timer.getPlayMode() == PlayModes.Live) {
// TODO fetch missing pieces from cache
} else {
// assuming play mode is replay / non-live
// TODO fetch all if not yet fetched
}
// TODO implement timeChanged by loading missing wind data and adding to series
}
}
@@ -47,6 +47,8 @@ import com.sap.sailing.gwt.ui.client.RaceSelectionModel;
import com.sap.sailing.gwt.ui.client.RaceSelectionProvider;
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.client.Timer;
import com.sap.sailing.gwt.ui.client.Timer.PlayModes;
import com.sap.sailing.gwt.ui.shared.EventDTO;
import com.sap.sailing.gwt.ui.shared.WindDTO;
import com.sap.sailing.gwt.ui.shared.WindInfoForRaceDTO;
@@ -173,7 +175,7 @@ public class WindPanel extends FormPanel implements EventDisplayer, WindShower,
windSourceSelectionPanel.add(showConfigAnchor);
grid.setWidget(1, 0, windSourceSelectionPanel);
windChart = new WindChart(sailingService, /* race selection provider */ raceSelectionProvider,
new WindChartSettings(WindSource.values()), stringMessages, errorReporter);
new Timer(PlayModes.Replay), new WindChartSettings(WindSource.values()), stringMessages, errorReporter);
grid.setWidget(2, 0, windChart.getEntryWidget());
grid.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
this.setWidget(grid);
@@ -3,7 +3,7 @@ package com.sap.sailing.gwt.ui.client;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
interface ClientResources extends ClientBundle {
public interface ClientResources extends ClientBundle {
@Source("com/sap/sailing/gwt/ui/client/images/settings.png")
ImageResource settingsIcon();
@@ -0,0 +1,11 @@
package com.sap.sailing.gwt.ui.client;
public interface UserAgentChecker {
public enum UserAgentTypes{ DESKTOP, MOBILE }
public final UserAgentCheckerImpl INSTANCE = new UserAgentCheckerImpl();
public UserAgentTypes checkUserAgent(String userAgent);
}
@@ -0,0 +1,25 @@
package com.sap.sailing.gwt.ui.client;
public class UserAgentCheckerImpl implements UserAgentChecker {
private static final String[] MOBILE_SPECIFIC_SUBSTRING = { "iPhone", "Android", "MIDP", "Opera Mobi", "iPad",
"Opera Mini", "BlackBerry", "HP iPAQ", "IEMobile", "MSIEMobile", "Windows Phone", "HTC", "LG", "MOT",
"Nokia", "Symbian", "Fennec", "Maemo", "Tear", "Midori", "armv", "Windows CE", "WindowsCE", "Smartphone",
"240x320", "176x220", "320x320", "160x160", "webOS", "Palm", "Sagem", "Samsung", "SGH", "SIE",
"SonyEricsson", "MMP", "UCWEB" };
@Override
public UserAgentTypes checkUserAgent(String userAgent) {
UserAgentTypes agentType = UserAgentTypes.DESKTOP;
for (String mobile : MOBILE_SPECIFIC_SUBSTRING) {
if (userAgent.contains(mobile) || userAgent.contains(mobile.toUpperCase())
|| userAgent.contains(mobile.toLowerCase())) {
agentType = UserAgentTypes.MOBILE;
break;
}
}
return agentType;
}
}
@@ -36,9 +36,10 @@ import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.user.client.ui.FlowPanel;
@@ -53,6 +54,7 @@ import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.domain.common.DetailType;
import com.sap.sailing.domain.common.RaceIdentifier;
import com.sap.sailing.domain.common.impl.Util.Pair;
import com.sap.sailing.gwt.ui.client.ClientResources;
import com.sap.sailing.gwt.ui.client.CompetitorSelectionChangeListener;
import com.sap.sailing.gwt.ui.client.CompetitorSelectionProvider;
import com.sap.sailing.gwt.ui.client.DetailTypeFormatter;
@@ -61,11 +63,16 @@ import com.sap.sailing.gwt.ui.client.RaceSelectionChangeListener;
import com.sap.sailing.gwt.ui.client.RaceSelectionProvider;
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.client.TimeListener;
import com.sap.sailing.gwt.ui.client.Timer;
import com.sap.sailing.gwt.ui.client.Timer.PlayModes;
import com.sap.sailing.gwt.ui.shared.CompetitorDTO;
import com.sap.sailing.gwt.ui.shared.CompetitorInRaceDTO;
import com.sap.sailing.gwt.ui.shared.CompetitorsAndTimePointsDTO;
import com.sap.sailing.gwt.ui.shared.components.Component;
import com.sap.sailing.gwt.ui.shared.components.SettingsDialog;
import com.sap.sailing.gwt.ui.shared.panels.BusyIndicator;
import com.sap.sailing.gwt.ui.shared.panels.SimpleBusyIndicator;
/**
* ChartPanel is a GWT panel that can show one sort of competitor data (e.g. current speed over ground, windward distance to
@@ -80,7 +87,7 @@ import com.sap.sailing.gwt.ui.shared.components.SettingsDialog;
*
*/
public abstract class AbstractChartPanel<SettingsType extends ChartSettings> extends SimplePanel
implements CompetitorSelectionChangeListener, RaceSelectionChangeListener {
implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeListener {
private CompetitorInRaceDTO chartData;
private CompetitorsAndTimePointsDTO competitorsAndTimePointsDTO = null;
private final SailingServiceAsync sailingService;
@@ -102,18 +109,21 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener {
private final HashMap<CompetitorDTO, Widget> competitorLabels;
private final HashMap<String, String> markPassingBuoyName;
private int width, height;
private final Timer timer;
private DetailType dataToShow;
private AbsolutePanel loadingPanel;
private final CompetitorSelectionProvider competitorSelectionProvider;
private static final ClientResources resources = GWT.create(ClientResources.class);
public AbstractChartPanel(SailingServiceAsync sailingService,
CompetitorSelectionProvider competitorSelectionProvider, RaceSelectionProvider raceSelectionProvider,
final StringMessages stringMessages, int chartWidth, int chartHeight, ErrorReporter errorReporter,
DetailType dataToShow, boolean showRaceSelector) {
Timer timer, final StringMessages stringMessages, int chartWidth, int chartHeight,
ErrorReporter errorReporter, DetailType dataToShow, boolean showRaceSelector) {
width = chartWidth;
height = chartHeight;
this.dataToShow = dataToShow;
this.timer = timer;
this.competitorSelectionProvider = competitorSelectionProvider;
competitorSelectionProvider.addCompetitorSelectionChangeListener(this);
this.errorReporter = errorReporter;
@@ -140,9 +150,8 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener {
}
loadingPanel = new AbsolutePanel();
loadingPanel.setSize(width + "px", height + "px");
Anchor a = new Anchor(new SafeHtmlBuilder().appendHtmlConstant("<img src=\"/gwt/images/ajax-loader.gif\"/>")
.toSafeHtml());
loadingPanel.add(a, width / 2 - 32 / 2, height / 2 - 32 - 2);
BusyIndicator busyIndicator = new SimpleBusyIndicator(true, 1);
loadingPanel.add(busyIndicator, width / 2 - 32 / 2, height / 2 - 32 - 2);
chartPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
chartPanel.setSpacing(5);
legendPanel = new FlowPanel();
@@ -154,8 +163,8 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener {
chart.showWidget(0);
chartPanel.add(chart);
mainPanel.add(chartPanel);
Anchor showConfigAnchor = new Anchor(new SafeHtmlBuilder().appendHtmlConstant(
"<img class=\"linkNoBorder\" src=\"/gwt/images/settings.png\"/>").toSafeHtml());
ImageResource settingsIcon = resources.settingsIcon();
Anchor showConfigAnchor = new Anchor(AbstractImagePrototype.create(settingsIcon).getSafeHtml());
showConfigAnchor.setTitle(stringMessages.configuration());
showConfigAnchor.addClickHandler(new ClickHandler() {
@Override
@@ -754,4 +763,12 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener {
return new Pair<Boolean, Boolean>(everyPassingInRange, twoPassingsInRangeBeforeError);
}
@Override
public void timeChanged(Date date) {
if (timer.getPlayMode() == PlayModes.Live) {
// TODO fetch parts missing so far from cache
} else {
// TODO check if fetched already; if not, fetch all
}
}
}
@@ -6,6 +6,7 @@ import com.sap.sailing.gwt.ui.client.ErrorReporter;
import com.sap.sailing.gwt.ui.client.RaceSelectionProvider;
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.client.Timer;
import com.sap.sailing.gwt.ui.shared.components.Component;
import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
@@ -24,10 +25,10 @@ import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
public class ChartPanel extends AbstractChartPanel<ChartSettings> implements Component<ChartSettings> {
public ChartPanel(SailingServiceAsync sailingService, CompetitorSelectionProvider competitorSelectionProvider,
RaceSelectionProvider raceSelectionProvider, DetailType dataToShow, StringMessages stringMessages, int chartWidth,
int chartHeight, ErrorReporter errorReporter, boolean showRaceSelector) {
super(sailingService, competitorSelectionProvider, raceSelectionProvider, stringMessages, chartWidth, chartHeight,
errorReporter, dataToShow, showRaceSelector);
RaceSelectionProvider raceSelectionProvider, Timer timer, DetailType dataToShow, StringMessages stringMessages,
int chartWidth, int chartHeight, ErrorReporter errorReporter, boolean showRaceSelector) {
super(sailingService, competitorSelectionProvider, raceSelectionProvider, timer, stringMessages, chartWidth,
chartHeight, errorReporter, dataToShow, showRaceSelector);
}
@Override
@@ -21,6 +21,7 @@ import com.sap.sailing.gwt.ui.client.RaceSelectionModel;
import com.sap.sailing.gwt.ui.client.RaceSelectionProvider;
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.client.Timer;
import com.sap.sailing.gwt.ui.leaderboard.AbstractChartPanel.DataLoadedEvent;
import com.sap.sailing.gwt.ui.leaderboard.AbstractChartPanel.DataLoadedHandler;
@@ -34,14 +35,14 @@ public class CompareCompetitorsChartDialog extends DialogBox {
private Anchor closeAnchor;
public CompareCompetitorsChartDialog(SailingServiceAsync sailingService,
List<RaceIdentifier> races, final CompetitorSelectionProvider competitorSelectionProvider, StringMessages stringConstants,
ErrorReporter errorReporter) {
List<RaceIdentifier> races, final CompetitorSelectionProvider competitorSelectionProvider, Timer timer,
StringMessages stringConstants, ErrorReporter errorReporter) {
super(false);
RaceSelectionProvider raceSelectionProvider = new RaceSelectionModel();
raceSelectionProvider.setAllRaces(races);
final MultiChartPanel ccp = new MultiChartPanel(sailingService, competitorSelectionProvider, raceSelectionProvider,
stringConstants, (int) (Window.getClientWidth() - 350), (int) (Window.getClientHeight() - 170),
errorReporter, /* showRaceSelector */ true);
timer, stringConstants, (int) (Window.getClientWidth() - 350),
(int) (Window.getClientHeight() - 170), errorReporter, /* showRaceSelector */ true);
ccp.addDataLoadedHandler(new DataLoadedHandler() {
@Override
public void onDataLoaded(DataLoadedEvent event) {
@@ -4,6 +4,7 @@ import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.ActionCell;
import com.google.gwt.cell.client.ActionCell.Delegate;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.EventTarget;
import com.google.gwt.dom.client.NativeEvent;
@@ -12,6 +13,7 @@ import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
public class ExpandCollapseButtonCell extends AbstractCell<SafeHtml> {
private static final LeaderboardResources RESOURCES = GWT.create(LeaderboardResources.class);
private final SafeHtml html;
private final Delegate<SafeHtml> delegate;
@@ -27,8 +29,10 @@ public class ExpandCollapseButtonCell extends AbstractCell<SafeHtml> {
super("click", "keydown");
this.column = column;
this.delegate = delegate;
String src = column.isExpanded() ? RESOURCES.magnifierSlashedIcon().getSafeUri().asString() : RESOURCES.magnifierIcon().getSafeUri().asString();
this.html = new SafeHtmlBuilder().appendHtmlConstant(
"<input class=\"valignMiddle magnifier\" type=\"image\" src=\"/gwt/images/"+(column.isExpanded()?"magnifier_slashed":"magnifier")+".png\" />").toSafeHtml();
"<input class=\"valignMiddle magnifier\" type=\"image\" src=\"" + src + "\" />").toSafeHtml();
}
@Override
@@ -145,11 +145,13 @@ public abstract class ExpandableSortableColumn<C> extends SortableColumn<Leaderb
*/
public void toggleExpansion() {
if (isExpansionEnabled()) {
getLeaderboardPanel().getBusyIndicator().setBusy(true);
final CellTable<LeaderboardRowDTO> table = getLeaderboardPanel().getLeaderboardTable();
if (isExpanded()) {
for (SortableColumn<LeaderboardRowDTO, ?> column : getAllVisibleChildren()) {
getLeaderboardPanel().removeColumn(column); // removes only the children currently displayed
}
getLeaderboardPanel().getBusyIndicator().setBusy(false);
// important: toggle expanded state after asking for all visible children
setExpanded(!isExpanded());
} else {
@@ -168,6 +170,7 @@ public abstract class ExpandableSortableColumn<C> extends SortableColumn<Leaderb
}
getLeaderboardPanel().getLeaderboardTable().redraw();
}
getLeaderboardPanel().getBusyIndicator().setBusy(false);
}
});
}
@@ -66,6 +66,8 @@ import com.sap.sailing.gwt.ui.shared.components.Component;
import com.sap.sailing.gwt.ui.shared.components.IsEmbeddableComponent;
import com.sap.sailing.gwt.ui.shared.components.SettingsDialog;
import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
import com.sap.sailing.gwt.ui.shared.panels.BusyIndicator;
import com.sap.sailing.gwt.ui.shared.panels.SimpleBusyIndicator;
/**
* A leaderboard essentially consists of a table widget that in its columns displays the entries.
@@ -174,6 +176,8 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
private final ImageResource pauseIcon;
private final ImageResource playIcon;
private final BusyIndicator busyIndicator;
private class SettingsClickHandler implements ClickHandler {
private final StringMessages stringConstants;
@@ -847,10 +851,19 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
listHandler = new ListHandler<LeaderboardRowDTO>(getData().getList());
getLeaderboardTable().addColumnSortHandler(listHandler);
loadCompleteLeaderboard(getLeaderboardDisplayDate());
if(preSelectedRace == null) {
isEmbedded = false;
} else {
isEmbedded = true;
}
contentPanel = new VerticalPanel();
headerPanel = new DockPanel();
DockPanel toolbarPanel = new DockPanel();
busyIndicator = new SimpleBusyIndicator(false, 0.8f);
if (!isEmbedded) {
toolbarPanel.add(busyIndicator, DockPanel.WEST);
}
headerPanel.setWidth("100%");
headerPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
toolbarPanel.setWidth("100%");
@@ -901,11 +914,9 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
refreshAndSettingsPanel.add(refreshPanel);
refreshAndSettingsPanel.add(settingsAnchor);
toolbarPanel.add(refreshAndSettingsPanel, DockPanel.EAST);
if(preSelectedRace == null) {
if(!isEmbedded) {
contentPanel.add(headerPanel);
contentPanel.add(toolbarPanel);
} else {
isEmbedded = true;
}
contentPanel.add(getLeaderboardTable());
setWidget(contentPanel);
@@ -1462,7 +1473,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
private void compareCompetitors() {
List<RaceIdentifier> races = getTrackedRacesIdentifiers();
CompareCompetitorsChartDialog chartDialog = new CompareCompetitorsChartDialog(sailingService, races,
competitorSelectionProvider, stringConstants, errorReporter);
competitorSelectionProvider, timer, stringConstants, errorReporter);
chartDialog.show();
}
@@ -1524,4 +1535,14 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
leaderboardSelectionModel.setSelected(row, false);
}
}
@Override
public BusyIndicator getBusyIndicator() {
return busyIndicator;
}
@Override
public boolean hasBusyIndicator() {
return true;
}
}
@@ -16,4 +16,10 @@ interface LeaderboardResources extends ClientBundle {
@Source("com/sap/sailing/gwt/ui/client/images/chart.png")
ImageResource chartIcon();
@Source("com/sap/sailing/gwt/ui/client/images/magnifier.png")
ImageResource magnifierIcon();
@Source("com/sap/sailing/gwt/ui/client/images/magnifier_slashed.png")
ImageResource magnifierSlashedIcon();
}
@@ -6,6 +6,7 @@ import com.sap.sailing.gwt.ui.client.ErrorReporter;
import com.sap.sailing.gwt.ui.client.RaceSelectionProvider;
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.client.Timer;
import com.sap.sailing.gwt.ui.shared.components.Component;
import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
@@ -23,10 +24,10 @@ import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
*/
public class MultiChartPanel extends AbstractChartPanel<MultiChartSettings> implements Component<MultiChartSettings> {
public MultiChartPanel(SailingServiceAsync sailingService, CompetitorSelectionProvider competitorSelectionProvider,
RaceSelectionProvider raceSelectionProvider, final StringMessages stringMessages, int chartWidth, int chartHeight,
ErrorReporter errorReporter, boolean showRaceSelector) {
super(sailingService, competitorSelectionProvider, raceSelectionProvider, stringMessages, chartWidth, chartHeight,
errorReporter, /* show initially: */ DetailType.WINDWARD_DISTANCE_TO_OVERALL_LEADER, showRaceSelector);
RaceSelectionProvider raceSelectionProvider, Timer timer, final StringMessages stringMessages, int chartWidth,
int chartHeight, ErrorReporter errorReporter, boolean showRaceSelector) {
super(sailingService, competitorSelectionProvider, raceSelectionProvider, timer, stringMessages, chartWidth,
chartHeight, errorReporter, /* show initially: */ DetailType.WINDWARD_DISTANCE_TO_OVERALL_LEADER, showRaceSelector);
}
@Override
@@ -120,7 +120,7 @@ public class RaceBoardPanel extends FormPanel implements EventDisplayer, RaceSel
boolean showWindChart = true;
if(showWindChart) {
WindChartSettings windChartSettings = new WindChartSettings();
WindChart windChart = new WindChart(sailingService, raceSelectionProvider, windChartSettings, stringMessages, errorReporter);
WindChart windChart = new WindChart(sailingService, raceSelectionProvider, timer, windChartSettings, stringMessages, errorReporter);
CollapsableComponentViewer<WindChartSettings> windChartViewer = new CollapsableComponentViewer<WindChartSettings>(
windChart, "600px", "500px", stringMessages);
windChart.onRaceSelectionChange(raceSelectionProvider.getSelectedRaces());
@@ -45,37 +45,7 @@ public final class CollapsablePanel extends Composite implements HasWidgets.ForI
HasOpenHandlers<CollapsablePanel>, HasCloseHandlers<CollapsablePanel> {
private static ComponentResources resources = GWT.create(ComponentResources.class);
/**
* Used to wrap widgets in the header to provide click support. Effectively wraps the widget in an
* <code>anchor</code> to get automatic keyboard access.
*/
/*
private final class ClickableHeader extends SimplePanel {
private ClickableHeader() {
// Anchor is used to allow keyboard access.
super(DOM.createAnchor());
Element elem = getElement();
DOM.setElementProperty(elem, "href", "javascript:void(0);");
// Avoids layout problems from having blocks in inlines.
DOM.setStyleAttribute(elem, "display", "block");
sinkEvents(Event.ONCLICK);
setStyleName(STYLENAME_HEADER);
}
@Override
public void onBrowserEvent(Event event) {
// no need to call super.
switch (DOM.eventGetType(event)) {
case Event.ONCLICK:
// Prevent link default action.
DOM.eventPreventDefault(event);
setOpen(!isOpen);
}
}
}
*/
/**
* An {@link Animation} used to open the content.
*/
@@ -1,6 +1,7 @@
package com.sap.sailing.gwt.ui.shared.components;
import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.gwt.ui.shared.panels.BusyIndicator;
public interface IsEmbeddableComponent {
@@ -10,7 +11,11 @@ public interface IsEmbeddableComponent {
Widget getToolbarWidget();
BusyIndicator getBusyIndicator();
boolean isEmbedded();
boolean hasToolbar();
boolean hasBusyIndicator();
}
@@ -0,0 +1,27 @@
package com.sap.sailing.gwt.ui.shared.panels;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.FlowPanel;
/**
* A widget to show if something is currently busy.
* @author Lennart Hensler (D054527)
*/
public abstract class BusyIndicator extends FlowPanel {
protected final static String STYLE_NAME_PREFIX = "busyIndicator-";
protected final static SharedPanelsResources RESOURCES = GWT.create(SharedPanelsResources.class);
protected boolean busy;
/**
* Sets the <code>busy</code> state of the BusyIndicator, which displays or hides the busy indicator.
* @param busy The new <code>busy</code> state
*/
public abstract void setBusy(boolean busy);
public boolean isBusy() {
return busy;
}
}
@@ -0,0 +1,11 @@
package com.sap.sailing.gwt.ui.shared.panels;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
public interface SharedPanelsResources extends ClientBundle {
@Source("com/sap/sailing/gwt/ui/client/images/busy_indicator_circle.gif")
ImageResource busyIndicatorCircle();
}
@@ -0,0 +1,40 @@
package com.sap.sailing.gwt.ui.shared.panels;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.Image;
public class SimpleBusyIndicator extends BusyIndicator {
private Image busyIndicator;
/**
* Creates a new SimpleBusyIndicator with the <code>busy</code> state <code>false</code>.<br />
* The busy indicator component is a circling GIF.
*/
public SimpleBusyIndicator() {
this(false, 1.0f);
}
/**
* Creates a new SimpleBusyIndicator with a custom <code>busy</code> state.<br />
* The busy indicator component is a circling GIF.
*
* @param busy Sets the busy state of the BusyIndicator
* @param scale Scales the displayed image. 1.0 is 100%, 0.50 is 50%, ...
*/
public SimpleBusyIndicator(boolean busy, float scale) {
ImageResource resource = RESOURCES.busyIndicatorCircle();
busyIndicator = new Image(resource.getSafeUri());
busyIndicator.setStyleName(STYLE_NAME_PREFIX + "busyIndicatorCircle");
busyIndicator.setPixelSize((int) (resource.getWidth() * scale), (int) (resource.getHeight() * scale));
add(busyIndicator);
setBusy(busy);
}
@Override
public void setBusy(boolean busy) {
this.busy = busy;
busyIndicator.setVisible(busy);
}
}