mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-24 22:48:34 +00:00
introduced AbstractEntryPoint in SSE, adding Selenium AJAX call support generally
This commit is contained in:
+2
-25
@@ -1,13 +1,10 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.debug.client.DebugInfo;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.logical.shared.AttachEvent;
|
||||
import com.google.gwt.event.logical.shared.AttachEvent.Handler;
|
||||
import com.google.gwt.resources.client.TextResource;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.ServiceDefTarget;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
@@ -18,20 +15,15 @@ import com.google.gwt.user.client.ui.RootPanel;
|
||||
import com.google.gwt.user.client.ui.TabLayoutPanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.sap.sse.gwt.client.EntryPointHelper;
|
||||
import com.sap.sse.gwt.client.async.MarkedAsyncCallback;
|
||||
import com.sap.sse.gwt.client.async.PendingAjaxCallMarker;
|
||||
import com.sap.sse.gwt.client.useragent.UserAgentDetails;
|
||||
import com.sap.sse.gwt.shared.DebugConstants;
|
||||
import com.sap.sse.security.ui.client.UserService;
|
||||
import com.sap.sse.security.ui.shared.UserManagementService;
|
||||
import com.sap.sse.security.ui.shared.UserManagementServiceAsync;
|
||||
|
||||
public abstract class AbstractEntryPoint implements EntryPoint, ErrorReporter, WindowSizeDetector {
|
||||
public abstract class AbstractEntryPoint extends com.sap.sse.gwt.client.AbstractEntryPoint implements ErrorReporter, WindowSizeDetector {
|
||||
private DialogBox errorDialogBox;
|
||||
private HTML serverResponseLabel;
|
||||
private Button dialogCloseButton;
|
||||
protected StringMessages stringMessages;
|
||||
protected UserAgentDetails userAgent;
|
||||
protected Label persistentAlertLabel;
|
||||
private UserService userService;
|
||||
private UserManagementServiceAsync userManagementService;
|
||||
@@ -43,28 +35,13 @@ public abstract class AbstractEntryPoint implements EntryPoint, ErrorReporter, W
|
||||
private static final String SERVER_ERROR = "An error occurred while " //$NON-NLS-1$
|
||||
+ "attempting to contact the server. Please check your network " + "connection and try again."; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
@Override
|
||||
public final void onModuleLoad() {
|
||||
if (DebugInfo.isDebugIdEnabled()) {
|
||||
PendingAjaxCallBundle bundle = GWT.create(PendingAjaxCallBundle.class);
|
||||
TextResource script = bundle.ajaxSemaphoreJS();
|
||||
JavaScriptInjector.inject(script.getText());
|
||||
DebugInfo.setDebugIdAttribute(DebugConstants.DEBUG_ID_ATTRIBUTE, false);
|
||||
DebugInfo.setDebugIdPrefix(DebugConstants.DEBUG_ID_PREFIX);
|
||||
}
|
||||
doOnModuleLoad();
|
||||
if (DebugInfo.isDebugIdEnabled()) {
|
||||
PendingAjaxCallMarker.decrementPendingAjaxCalls(MarkedAsyncCallback.CATEGORY_GLOBAL);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doOnModuleLoad() {
|
||||
super.doOnModuleLoad();
|
||||
userManagementService = GWT.create(UserManagementService.class);
|
||||
EntryPointHelper.registerASyncService((ServiceDefTarget) userManagementService, com.sap.sse.security.ui.client.RemoteServiceMappingConstants.userManagementServiceRemotePath);
|
||||
userService = new UserService(userManagementService);
|
||||
stringMessages = GWT.create(StringMessages.class);
|
||||
errorDialogBox = createErrorDialog(); /* TODO: Make this more generic (e.g. make it support all kinds of messages) */
|
||||
userAgent = new UserAgentDetails(Window.Navigator.getUserAgent());
|
||||
persistentAlertLabel = new Label("");
|
||||
persistentAlertLabel.setStyleName("global-alert-message");
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.sap.sailing.selenium.pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import com.sap.sailing.selenium.core.BySeleniumId;
|
||||
import com.sap.sailing.selenium.core.FindBy;
|
||||
|
||||
public class LoginPage extends HostPage {
|
||||
@FindBy(how = BySeleniumId.class, using = "username")
|
||||
private WebElement usernameField;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "password")
|
||||
private WebElement passwordField;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "login")
|
||||
private WebElement loginButton;
|
||||
|
||||
public LoginPage(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
public void login(String username, String password) {
|
||||
usernameField.clear();
|
||||
usernameField.sendKeys(username);
|
||||
passwordField.clear();
|
||||
passwordField.sendKeys(password);
|
||||
loginButton.click();
|
||||
}
|
||||
}
|
||||
+5
@@ -12,6 +12,7 @@ import com.sap.sailing.selenium.core.BySeleniumId;
|
||||
import com.sap.sailing.selenium.core.ElementSearchConditions;
|
||||
import com.sap.sailing.selenium.core.FindBy;
|
||||
import com.sap.sailing.selenium.pages.HostPage;
|
||||
import com.sap.sailing.selenium.pages.LoginPage;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfigurationPanelPO;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardGroupConfigurationPanelPO;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaStructureManagementPanelPO;
|
||||
@@ -70,6 +71,10 @@ public class AdminConsolePage extends HostPage {
|
||||
*/
|
||||
public static AdminConsolePage goToPage(WebDriver driver, String root) {
|
||||
driver.get(root + "gwt/AdminConsole.html?" + getGWTCodeServer()); //$NON-NLS-1$
|
||||
if (driver.getTitle().contains("Login")) {
|
||||
// we god re-directed to the login form; log in and hope we get re-directed accordingly
|
||||
new LoginPage(driver).login("admin", "admin");
|
||||
}
|
||||
|
||||
// TODO: As soon as the security API is available in Selenium we should use it to login into the admin console.
|
||||
// FluentWait<WebDriver> wait = createFluentWait(driver, 5, 100);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.sap.sse.gwt.client;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.debug.client.DebugInfo;
|
||||
import com.google.gwt.event.logical.shared.AttachEvent;
|
||||
import com.google.gwt.event.logical.shared.AttachEvent.Handler;
|
||||
import com.google.gwt.resources.client.TextResource;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.TabLayoutPanel;
|
||||
import com.sap.sse.gwt.client.async.MarkedAsyncCallback;
|
||||
import com.sap.sse.gwt.client.async.PendingAjaxCallMarker;
|
||||
import com.sap.sse.gwt.client.useragent.UserAgentDetails;
|
||||
import com.sap.sse.gwt.shared.DebugConstants;
|
||||
|
||||
public abstract class AbstractEntryPoint implements EntryPoint {
|
||||
protected UserAgentDetails userAgent;
|
||||
|
||||
@Override
|
||||
public final void onModuleLoad() {
|
||||
if (DebugInfo.isDebugIdEnabled()) {
|
||||
PendingAjaxCallBundle bundle = GWT.create(PendingAjaxCallBundle.class);
|
||||
TextResource script = bundle.ajaxSemaphoreJS();
|
||||
JavaScriptInjector.inject(script.getText());
|
||||
DebugInfo.setDebugIdAttribute(DebugConstants.DEBUG_ID_ATTRIBUTE, false);
|
||||
DebugInfo.setDebugIdPrefix(DebugConstants.DEBUG_ID_PREFIX);
|
||||
}
|
||||
doOnModuleLoad();
|
||||
if (DebugInfo.isDebugIdEnabled()) {
|
||||
PendingAjaxCallMarker.decrementPendingAjaxCalls(MarkedAsyncCallback.CATEGORY_GLOBAL);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doOnModuleLoad() {
|
||||
userAgent = new UserAgentDetails(Window.Navigator.getUserAgent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of the tab panel when the tab panel is attached to the DOM
|
||||
*/
|
||||
protected void setTabPanelSize(final TabLayoutPanel advancedTabPanel, final String width, final String height) {
|
||||
advancedTabPanel.addAttachHandler(new Handler() {
|
||||
@Override
|
||||
public void onAttachOrDetach(AttachEvent event) {
|
||||
advancedTabPanel.getElement().getParentElement().getStyle().setProperty("width", width);
|
||||
advancedTabPanel.getElement().getParentElement().getStyle().setProperty("height", height);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
package com.sap.sse.gwt.client;
|
||||
|
||||
import com.google.gwt.dom.client.Document;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
package com.sap.sse.gwt.client;
|
||||
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
import com.google.gwt.resources.client.TextResource;
|
||||
+6
-3
@@ -1,6 +1,5 @@
|
||||
package com.sap.sse.security.ui.login;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.user.client.Window;
|
||||
@@ -17,6 +16,7 @@ import com.google.gwt.user.client.ui.RootLayoutPanel;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
import com.google.gwt.user.client.ui.SubmitButton;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.sap.sse.gwt.client.AbstractEntryPoint;
|
||||
import com.sap.sse.gwt.client.EntryPointHelper;
|
||||
import com.sap.sse.security.ui.client.RemoteServiceMappingConstants;
|
||||
import com.sap.sse.security.ui.client.Resources;
|
||||
@@ -27,13 +27,13 @@ import com.sap.sse.security.ui.shared.SuccessInfo;
|
||||
import com.sap.sse.security.ui.shared.UserManagementService;
|
||||
import com.sap.sse.security.ui.shared.UserManagementServiceAsync;
|
||||
|
||||
public class LoginEntryPoint implements EntryPoint {
|
||||
public class LoginEntryPoint extends AbstractEntryPoint {
|
||||
private final StringMessages stringMessages = GWT.create(StringMessages.class);
|
||||
private UserManagementServiceAsync userManagementService;
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public void onModuleLoad() {
|
||||
public void doOnModuleLoad() {
|
||||
userManagementService = GWT.create(UserManagementService.class);
|
||||
EntryPointHelper.registerASyncService((ServiceDefTarget) userManagementService,
|
||||
RemoteServiceMappingConstants.userManagementServiceRemotePath);
|
||||
@@ -48,12 +48,15 @@ public class LoginEntryPoint implements EntryPoint {
|
||||
Label nameLabel = new Label(stringMessages.name()+": ");
|
||||
fp.add(nameLabel);
|
||||
final TextBox nameText = new TextBox();
|
||||
nameText.ensureDebugId("username");
|
||||
fp.add(nameText);
|
||||
Label pwLabel = new Label(stringMessages.password()+": ");
|
||||
pwLabel.ensureDebugId("password");
|
||||
fp.add(pwLabel);
|
||||
final PasswordTextBox pwText = new PasswordTextBox();
|
||||
fp.add(pwText);
|
||||
SubmitButton submit = new SubmitButton(stringMessages.signIn());
|
||||
submit.ensureDebugId("login");
|
||||
fp.add(submit);
|
||||
FormPanel formPanel = new FormPanel();
|
||||
formPanel.addSubmitHandler(new SubmitHandler() {
|
||||
|
||||
Reference in New Issue
Block a user