mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-15 16:51:07 +00:00
bug4312 Introduced abstraction for desktop and mobile version of
MoreLoginInformation activity and view
This commit is contained in:
1 parent
127eb568d1
commit
cd87c1981a
9 files changed
+122
-107
No files matched your search
-31
@@ -1,31 +0,0 @@
|
||||
package com.sap.sailing.gwt.home.desktop.places.morelogininformation;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.DOM;
|
||||
import com.google.gwt.user.client.Event;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
/**
|
||||
* Desktop page that shows the benefits of logging in on sapsailing.com.
|
||||
*/
|
||||
public class MoreLoginInformation extends Composite {
|
||||
|
||||
private static MoreLoginInformationUiBinder uiBinder = GWT.create(MoreLoginInformationUiBinder.class);
|
||||
|
||||
interface MoreLoginInformationUiBinder extends UiBinder<Widget, MoreLoginInformation> {
|
||||
}
|
||||
|
||||
@UiField
|
||||
Element registerControl;
|
||||
|
||||
public MoreLoginInformation(Runnable onRegisterClick) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
DOM.sinkEvents(registerControl, Event.ONCLICK);
|
||||
Event.setEventListener(registerControl, event -> onRegisterClick.run());
|
||||
}
|
||||
|
||||
}
|
||||
+4
-31
@@ -1,42 +1,15 @@
|
||||
package com.sap.sailing.gwt.home.desktop.places.morelogininformation;
|
||||
|
||||
import com.google.gwt.activity.shared.Activity;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.place.shared.Place;
|
||||
import com.google.gwt.user.client.ui.AcceptsOneWidget;
|
||||
import com.sap.sailing.gwt.home.desktop.app.DesktopClientFactory;
|
||||
import com.sap.sailing.gwt.home.shared.places.morelogininformation.AbstractMoreLoginInformationActivity;
|
||||
import com.sap.sse.security.ui.authentication.AuthenticationRequestEvent;
|
||||
|
||||
public class MoreLoginInformationActivity implements Activity {
|
||||
private DesktopClientFactory clientFactory;
|
||||
public class MoreLoginInformationActivity extends AbstractMoreLoginInformationActivity {
|
||||
|
||||
public MoreLoginInformationActivity(Place place, DesktopClientFactory clientFactory) {
|
||||
this.clientFactory = clientFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mayStop() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(AcceptsOneWidget panel, EventBus eventBus) {
|
||||
panel.setWidget(new MoreLoginInformation(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
clientFactory.getEventBus().fireEvent(new AuthenticationRequestEvent(true));
|
||||
}
|
||||
}));
|
||||
super(clientFactory, new MoreLoginInformationDesktop(
|
||||
() -> clientFactory.getEventBus().fireEvent(new AuthenticationRequestEvent(true))));
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.sap.sailing.gwt.home.desktop.places.morelogininformation;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.home.shared.places.morelogininformation.AbstractMoreLoginInformation;
|
||||
|
||||
/**
|
||||
* Desktop page that shows the benefits of logging in on sapsailing.com.
|
||||
*/
|
||||
public class MoreLoginInformationDesktop extends AbstractMoreLoginInformation {
|
||||
|
||||
private static MoreLoginInformationUiBinder uiBinder = GWT.create(MoreLoginInformationUiBinder.class);
|
||||
|
||||
interface MoreLoginInformationUiBinder extends UiBinder<Widget, AbstractMoreLoginInformation> {
|
||||
}
|
||||
|
||||
public MoreLoginInformationDesktop(Runnable registerCallback) {
|
||||
super(uiBinder, registerCallback);
|
||||
}
|
||||
|
||||
}
|
||||
File renamed without changes.
+4
-31
@@ -1,41 +1,14 @@
|
||||
package com.sap.sailing.gwt.home.mobile.places.morelogininformation;
|
||||
|
||||
import com.google.gwt.activity.shared.Activity;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.place.shared.Place;
|
||||
import com.google.gwt.user.client.ui.AcceptsOneWidget;
|
||||
import com.sap.sailing.gwt.home.mobile.app.MobileApplicationClientFactory;
|
||||
import com.sap.sailing.gwt.home.shared.places.morelogininformation.AbstractMoreLoginInformationActivity;
|
||||
|
||||
public class MoreLoginInformationActivity implements Activity {
|
||||
private MobileApplicationClientFactory clientFactory;
|
||||
public class MoreLoginInformationActivity extends AbstractMoreLoginInformationActivity {
|
||||
|
||||
public MoreLoginInformationActivity(Place place, MobileApplicationClientFactory clientFactory) {
|
||||
this.clientFactory = clientFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mayStop() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(AcceptsOneWidget panel, EventBus eventBus) {
|
||||
panel.setWidget(new MoreLoginInformationMobile(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
clientFactory.getNavigator().getSignInNavigation(true).goToPlace();
|
||||
}
|
||||
}));
|
||||
super(clientFactory, new MoreLoginInformationMobile(
|
||||
() -> clientFactory.getNavigator().getSignInNavigation(true).goToPlace()));
|
||||
}
|
||||
|
||||
}
|
||||
+5
-14
@@ -1,31 +1,22 @@
|
||||
package com.sap.sailing.gwt.home.mobile.places.morelogininformation;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.DOM;
|
||||
import com.google.gwt.user.client.Event;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.home.shared.places.morelogininformation.AbstractMoreLoginInformation;
|
||||
|
||||
/**
|
||||
* Mobile page that shows the benefits of logging in on sapsailing.com.
|
||||
*/
|
||||
public class MoreLoginInformationMobile extends Composite {
|
||||
public class MoreLoginInformationMobile extends AbstractMoreLoginInformation {
|
||||
|
||||
private static MoreLoginInformationUiBinder uiBinder = GWT.create(MoreLoginInformationUiBinder.class);
|
||||
|
||||
interface MoreLoginInformationUiBinder extends UiBinder<Widget, MoreLoginInformationMobile> {
|
||||
interface MoreLoginInformationUiBinder extends UiBinder<Widget, AbstractMoreLoginInformation> {
|
||||
}
|
||||
|
||||
@UiField
|
||||
public Element registerControl;
|
||||
|
||||
public MoreLoginInformationMobile(Runnable onRegisterClick) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
DOM.sinkEvents(registerControl, Event.ONCLICK);
|
||||
Event.setEventListener(registerControl, event -> onRegisterClick.run());
|
||||
public MoreLoginInformationMobile(Runnable registerCallback) {
|
||||
super(uiBinder, registerCallback);
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.sap.sailing.gwt.home.shared.places.morelogininformation;
|
||||
|
||||
import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.DOM;
|
||||
import com.google.gwt.user.client.Event;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.UIObject;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
public class AbstractMoreLoginInformation extends Composite implements MoreLoginInformationView {
|
||||
|
||||
@UiField
|
||||
public Element registerControl;
|
||||
|
||||
protected AbstractMoreLoginInformation(UiBinder<Widget, AbstractMoreLoginInformation> uiBinder,
|
||||
Runnable registerCallback) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
DOM.sinkEvents(registerControl, Event.ONCLICK);
|
||||
Event.setEventListener(registerControl, event -> registerCallback.run());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setRegisterControlVisible(boolean visible) {
|
||||
UIObject.setVisible(registerControl, visible);
|
||||
}
|
||||
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.sap.sailing.gwt.home.shared.places.morelogininformation;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.gwt.activity.shared.AbstractActivity;
|
||||
import com.google.gwt.activity.shared.Activity;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.user.client.ui.AcceptsOneWidget;
|
||||
import com.sap.sse.security.ui.authentication.WithUserService;
|
||||
import com.sap.sse.security.ui.client.UserService;
|
||||
import com.sap.sse.security.ui.client.UserStatusEventHandler;
|
||||
|
||||
/**
|
||||
* Abstract {@link Activity activity} implementation for {@link MoreLoginInformationView}s.
|
||||
*/
|
||||
public class AbstractMoreLoginInformationActivity extends AbstractActivity {
|
||||
|
||||
private final WithUserService clientFactory;
|
||||
private final MoreLoginInformationView view;
|
||||
|
||||
/**
|
||||
* Creates new {@link AbstractMoreLoginInformationActivity} instance for the provided view using the given factory.
|
||||
*
|
||||
* @param clientFactory
|
||||
* {@link WithUserService client factory} providing access to the {@link UserService}
|
||||
* @param view
|
||||
* the {@link MoreLoginInformationView} to show
|
||||
*/
|
||||
protected AbstractMoreLoginInformationActivity(WithUserService clientFactory, MoreLoginInformationView view) {
|
||||
this.clientFactory = clientFactory;
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void start(AcceptsOneWidget panel, EventBus eventBus) {
|
||||
final UserStatusEventHandler handler = user -> view.setRegisterControlVisible(Objects.isNull(user));
|
||||
this.clientFactory.getUserService().addUserStatusEventHandler(handler, true);
|
||||
panel.setWidget(view);
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.sap.sailing.gwt.home.shared.places.morelogininformation;
|
||||
|
||||
import com.google.gwt.user.client.ui.IsWidget;
|
||||
|
||||
/**
|
||||
* Interface for views containing information about benefits of signing in on SAP Sailing Analytics.
|
||||
*/
|
||||
public interface MoreLoginInformationView extends IsWidget {
|
||||
|
||||
/**
|
||||
* Show or hide the control leading to register form (usually based on login state).
|
||||
*
|
||||
* @param visible
|
||||
* <code>true</code> to show register control, <code>false</code> to hide
|
||||
*/
|
||||
void setRegisterControlVisible(boolean visible);
|
||||
}
|
||||
Reference in new issue
Block a user