mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-01 18:03:59 +00:00
Added WelcomeWidget to the LeaderboardGroupPanel
This commit is contained in:
1 parent
11aa5b9d97
commit
0b9a30df23
4 files changed
+44
-16
No files matched your search
+4
-2
@@ -7,6 +7,7 @@ import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
|
||||
public class ClosableWelcomeWidget extends SimpleWelcomeWidget {
|
||||
|
||||
private StringMessages stringConstants;
|
||||
private Button closeButton;
|
||||
private boolean closable;
|
||||
|
||||
@@ -20,10 +21,11 @@ public class ClosableWelcomeWidget extends SimpleWelcomeWidget {
|
||||
* @param horizontalAlignment The alignment of the header and the welcomen component
|
||||
*/
|
||||
public ClosableWelcomeWidget(boolean closable, String headerText, String welcomeText, HorizontalAlignmentConstant horizontalAlignment, StringMessages stringConstants) {
|
||||
super(headerText, welcomeText, horizontalAlignment, stringConstants);
|
||||
super(headerText, welcomeText, horizontalAlignment);
|
||||
this.stringConstants = stringConstants;
|
||||
this.closable = closable;
|
||||
|
||||
closeButton = new Button(stringConstants.close());
|
||||
closeButton = new Button(this.stringConstants.close());
|
||||
closeButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
+2
-6
@@ -4,11 +4,9 @@ import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
|
||||
public class SimpleWelcomeWidget extends VerticalPanel implements WelcomeWidget {
|
||||
|
||||
private StringMessages stringConstants;
|
||||
private Label welcomeHeader;
|
||||
private HTML welcomeText;
|
||||
|
||||
@@ -18,12 +16,10 @@ public class SimpleWelcomeWidget extends VerticalPanel implements WelcomeWidget
|
||||
* @param welcomeText The text of the welcome message
|
||||
* @param horizontalAlignment The alignment of the components in the VerticalPanel
|
||||
*/
|
||||
public SimpleWelcomeWidget(String headerText, String welcomeText, HorizontalAlignmentConstant horizontalAlignment, StringMessages stringConstants) {
|
||||
public SimpleWelcomeWidget(String headerText, String welcomeText, HorizontalAlignmentConstant horizontalAlignment) {
|
||||
super();
|
||||
this.stringConstants = stringConstants;
|
||||
|
||||
setHorizontalAlignment(horizontalAlignment);
|
||||
welcomeHeader = new Label(this.stringConstants.welcomeToSailingAnalytics());
|
||||
welcomeHeader = new Label(headerText);
|
||||
add(welcomeHeader);
|
||||
this.welcomeText = new HTML(new SafeHtmlBuilder().appendEscapedLines(welcomeText).toSafeHtml());
|
||||
add(this.welcomeText);
|
||||
|
||||
+27
-6
@@ -19,6 +19,7 @@ import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.google.gwt.view.client.NoSelectionModel;
|
||||
import com.sap.sailing.domain.common.EventNameAndRaceName;
|
||||
import com.sap.sailing.gwt.ui.adminconsole.LeaderboardConfigPanel.AnchorCell;
|
||||
@@ -28,8 +29,9 @@ import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.LeaderboardDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RaceInLeaderboardDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.components.HasWelcomeWidget;
|
||||
|
||||
public class LeaderboardGroupPanel extends FormPanel {
|
||||
public class LeaderboardGroupPanel extends FormPanel implements HasWelcomeWidget {
|
||||
|
||||
interface AnchorTemplates extends SafeHtmlTemplates {
|
||||
@SafeHtmlTemplates.Template("<a href=\"{0}\">{1}</a>")
|
||||
@@ -44,13 +46,19 @@ public class LeaderboardGroupPanel extends FormPanel {
|
||||
private ErrorReporter errorReporter;
|
||||
private LeaderboardGroupDTO group;
|
||||
|
||||
private VerticalPanel mainPanel;
|
||||
private Widget welcomeWidget = null;
|
||||
|
||||
public LeaderboardGroupPanel(SailingServiceAsync sailingService, StringMessages stringConstants,
|
||||
ErrorReporter errorReporter, final String groupName) {
|
||||
super();
|
||||
this.sailingService = sailingService;
|
||||
this.stringConstants = stringConstants;
|
||||
this.errorReporter = errorReporter;
|
||||
|
||||
|
||||
mainPanel = new VerticalPanel();
|
||||
mainPanel.setWidth("95%");
|
||||
add(mainPanel);
|
||||
final Runnable buildGUI = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -81,10 +89,6 @@ public class LeaderboardGroupPanel extends FormPanel {
|
||||
}
|
||||
|
||||
private void buildGUI() {
|
||||
VerticalPanel mainPanel = new VerticalPanel();
|
||||
mainPanel.setWidth("95%");
|
||||
add(mainPanel);
|
||||
|
||||
//Create group details GUI
|
||||
HorizontalPanel groupDetailsPanel = new HorizontalPanel();
|
||||
groupDetailsPanel.setSpacing(8);
|
||||
@@ -209,4 +213,21 @@ public class LeaderboardGroupPanel extends FormPanel {
|
||||
return b.toSafeHtml();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWelcomeWidgetVisible(boolean isVisible) {
|
||||
if (welcomeWidget != null) {
|
||||
welcomeWidget.setVisible(isVisible);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWelcomeWidget(Widget welcome) {
|
||||
boolean needsToBeInserted = welcomeWidget == null;
|
||||
welcomeWidget = welcome;
|
||||
welcomeWidget.setWidth("100%");
|
||||
if (needsToBeInserted) {
|
||||
mainPanel.insert(welcomeWidget, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+11
-2
@@ -8,6 +8,8 @@ import com.sap.sailing.gwt.ui.client.AbstractEntryPoint;
|
||||
import com.sap.sailing.gwt.ui.client.EventRefresher;
|
||||
import com.sap.sailing.gwt.ui.client.LogoAndTitlePanel;
|
||||
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.components.ClosableWelcomeWidget;
|
||||
import com.sap.sailing.gwt.ui.shared.components.SimpleWelcomeWidget;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -46,8 +48,15 @@ public class SpectatorEntryPoint extends AbstractEntryPoint implements EventRefr
|
||||
rootPanel.add(logoAndTitlePanel);
|
||||
|
||||
//TODO Create LeaderboardGroupPanel if groupName is filled
|
||||
FormPanel panelToDisplay = groupName == null ? new OverviewEventPanel(sailingService, this, this, stringMessages) :
|
||||
new LeaderboardGroupPanel(sailingService, stringMessages, this, groupName);
|
||||
FormPanel panelToDisplay = null;
|
||||
if (groupName == null) {
|
||||
panelToDisplay = new OverviewEventPanel(sailingService, this, this, stringMessages);
|
||||
} else {
|
||||
panelToDisplay = new LeaderboardGroupPanel(sailingService, stringMessages, this, groupName);
|
||||
LeaderboardGroupPanel groupPanel = (LeaderboardGroupPanel) panelToDisplay;
|
||||
groupPanel.setWelcomeWidget(new ClosableWelcomeWidget(true, stringMessages.welcomeToSailingAnalytics(),
|
||||
"Ipsum lorum\nHello World!", SimpleWelcomeWidget.ALIGN_RIGHT, stringMessages));
|
||||
}
|
||||
panelToDisplay.setSize("100%", "100%");
|
||||
rootPanel.add(panelToDisplay);
|
||||
|
||||
|
||||
Reference in new issue
Block a user