Author: dongxu Date: Thu Sep 12 02:03:52 2013 New Revision: 1522109 URL: http://svn.apache.org/r1522109 Log: change the LOGIN progress using native MVP instead of gwt-presenter
Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaEvoCallback.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/HupaEvoClientModule.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/HupaEvoGinjector.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/InjectablePlaceController.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ActivityPlace.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppActivityMapper.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppPlaceFactory.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppPlaceHistoryMapper.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/place/LoginPlace.java Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/Hupa.gwt.xml james/hupa/trunk/client/src/main/java/org/apache/hupa/client/Hupa.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/LoginActivity.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/LoginView.java james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/LoginView.java Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/Hupa.gwt.xml URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/Hupa.gwt.xml?rev=1522109&r1=1522108&r2=1522109&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/Hupa.gwt.xml (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/Hupa.gwt.xml Thu Sep 12 02:03:52 2013 @@ -27,9 +27,11 @@ <inherits name='com.google.gwt.widgetideas.WidgetIdeas'/> <inherits name='com.google.gwt.gen2.commonwidget.CommonWidget' /> <inherits name='com.google.gwt.gen2.table.override.Override'/> - <inherits name='com.google.gwt.gen2.table.ScrollTable'/> + <inherits name='com.google.gwt.gen2.table.ScrollTable'/><!-- <inherits name='net.customware.gwt.dispatch.Dispatch' /> - <inherits name='net.customware.gwt.presenter.Presenter' /> + <inherits name='net.customware.gwt.presenter.Presenter' /> --> + <inherits name="com.google.gwt.activity.Activity"/> + <inherits name="com.google.gwt.place.Place"/> <inherits name="com.google.gwt.inject.Inject"/> <inherits name="gwtupload.GWTUpload"/> <inherits name="eu.maydu.gwt.validation.ValidationLibrary"/> Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/Hupa.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/Hupa.java?rev=1522109&r1=1522108&r2=1522109&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/Hupa.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/Hupa.java Thu Sep 12 02:03:52 2013 @@ -20,6 +20,7 @@ package org.apache.hupa.client; <<<<<<< HEAD +<<<<<<< HEAD import org.apache.hupa.client.ioc.AppGinjector; import com.google.gwt.core.client.EntryPoint; @@ -59,28 +60,64 @@ import net.customware.gwt.presenter.clie import org.apache.hupa.client.gin.HupaGinjector; import org.apache.hupa.client.mvp.AppPresenter; +======= +import org.apache.hupa.client.gin.HupaEvoGinjector; +import org.apache.hupa.client.mvp.AppPlaceFactory; +import org.apache.hupa.client.mvp.AppPlaceHistoryMapper; +import org.apache.hupa.client.place.LoginPlace; +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter +import com.google.gwt.activity.shared.ActivityManager; +import com.google.gwt.activity.shared.ActivityMapper; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.place.shared.PlaceController; +import com.google.gwt.place.shared.PlaceHistoryHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.SimplePanel; public class Hupa implements EntryPoint{ - private final HupaGinjector injector = GWT.create(HupaGinjector.class); +// private final HupaGinjector injector = GWT.create(HupaGinjector.class); + + private SimplePanel appWidget = new SimplePanel(); + private final HupaEvoGinjector injector = GWT.create(HupaEvoGinjector.class); public void onModuleLoad() { // remove the loading message from the browser com.google.gwt.user.client.Element loading = DOM.getElementById("loading"); DOM.removeChild(RootPanel.getBodyElement(), loading); - - AppPresenter aPres = injector.getAppPresenter(); - aPres.bind(); - - RootPanel.get().add(aPres.getDisplay().asWidget()); - - PlaceManager placeManager = injector.getPlaceManager(); - placeManager.fireCurrentPlace(); +// +// AppPresenter aPres = injector.getAppPresenter(); +// aPres.bind(); +// +// RootPanel.get().add(aPres.getDisplay().asWidget()); +// +// PlaceManager placeManager = injector.getPlaceManager(); +// placeManager.fireCurrentPlace(); + + EventBus eventBus = injector.getEventBus(); + PlaceController placeController = injector.getPlaceController(); + + + ActivityMapper activityMapper = injector.getActivityMapper(); + ActivityManager activityManager = new ActivityManager(activityMapper, eventBus); + activityManager.setDisplay(appWidget); + + AppPlaceFactory factory = injector.getAppPlaceFactory(); + LoginPlace defaultPlace = factory.getLoginPlace(); + + AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class); + historyMapper.setFactory(factory); + + PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); + historyHandler.register(placeController, eventBus, defaultPlace); + + RootPanel.get().add(appWidget); + + historyHandler.handleCurrentHistory(); } >>>>>>> first commit Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaEvoCallback.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaEvoCallback.java?rev=1522109&view=auto ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaEvoCallback.java (added) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HupaEvoCallback.java Thu Sep 12 02:03:52 2013 @@ -0,0 +1,102 @@ +package org.apache.hupa.client; + +import net.customware.gwt.dispatch.client.DispatchAsync; + +import org.apache.hupa.client.activity.LoginActivity.Display; +import org.apache.hupa.shared.events.LogoutEvent; +import org.apache.hupa.shared.events.ServerStatusEvent; +import org.apache.hupa.shared.events.ServerStatusEvent.ServerStatus; +import org.apache.hupa.shared.exception.InvalidSessionException; +import org.apache.hupa.shared.rpc.CheckSession; +import org.apache.hupa.shared.rpc.CheckSessionResult; + +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.inject.Inject; + +public abstract class HupaEvoCallback<T> implements AsyncCallback<T> { + + private DispatchAsync dispatcher = null; + private EventBus eventBus = null; + private ServerStatusEvent available = new ServerStatusEvent(ServerStatus.Available); + private ServerStatusEvent unavailable = new ServerStatusEvent(ServerStatus.Unavailable); + + @SuppressWarnings("unused") + private Display display = null; + + @Inject + public HupaEvoCallback(DispatchAsync dispatcher, EventBus bus, Display display) { + this(dispatcher, bus); + this.display = display; + + //this.display.startProcessing(); + } + + @Inject + public HupaEvoCallback(DispatchAsync dispatcher, EventBus bus) { + this.dispatcher = dispatcher; + this.eventBus = bus; + } + + /** + * If you override this method, remember to call super.onFailure() + */ + public void onFailure(final Throwable originalCaught) { + // Server's response is invalid due to: + // server unaccessible, session error or server exception + dispatcher.execute(new CheckSession(), new AsyncCallback<CheckSessionResult>() { + public void onFailure(Throwable caught) { + if (caught instanceof InvalidSessionException) { + eventBus.fireEvent(new LogoutEvent(null)); + } else { + // The server is unaccessible + eventBus.fireEvent(unavailable); + } + finish(); + } + public void onSuccess(CheckSessionResult result) { + if (!result.isValid()) { + // Server's connection is fine, but the user has not a valid session + eventBus.fireEvent(new LogoutEvent(null)); + } else { + // Server's connection is fine, and the user has a valid session + // So the original action failed because a server's exception + eventBus.fireEvent(available); + } + finish(); + } + + private void finish() { + callbackError(originalCaught); + //if (display != null) + //display.stopProcessing(); + } + }); + } + + /** + * If you override this method, remember to call super.onSuccess() + */ + public void onSuccess(T result) { + // Server's response is valid, + eventBus.fireEvent(available); + // Execute the original method + callback(result); + // If display is being used, stop it + //if (display != null) + //display.stopProcessing(); + } + + /** + * The callback code which the user has to implement + */ + public abstract void callback(T result); + + /** + * The callback code in the case of error + * Override this method, if you need this feature. + */ + public void callbackError(Throwable caught) { + System.out.println("HupaCallBack Error: " + caught); + } +} Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/LoginActivity.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/LoginActivity.java?rev=1522109&r1=1522108&r2=1522109&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/LoginActivity.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/activity/LoginActivity.java Thu Sep 12 02:03:52 2013 @@ -1,3 +1,4 @@ +<<<<<<< HEAD /**************************************************************** * Licensed to the Apache Software Foundation (ASF) under one * * or more contributor license agreements. See the NOTICE file * @@ -29,14 +30,33 @@ import org.apache.hupa.shared.events.Log import org.apache.hupa.shared.events.SessionExpireEvent; import org.apache.hupa.shared.events.SessionExpireEventHandler; +======= +package org.apache.hupa.client.activity; + +import net.customware.gwt.dispatch.client.DispatchAsync; + +import org.apache.hupa.client.HupaConstants; +import org.apache.hupa.client.HupaEvoCallback; +import org.apache.hupa.client.place.LoginPlace; +import org.apache.hupa.shared.rpc.LoginUser; +import org.apache.hupa.shared.rpc.LoginUserResult; + +import com.google.gwt.activity.shared.AbstractActivity; +import com.google.gwt.core.client.GWT; +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.HasClickHandlers; import com.google.gwt.event.shared.EventBus; +<<<<<<< HEAD +======= +import com.google.gwt.place.shared.PlaceController; +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.gwt.user.client.ui.Focusable; import com.google.gwt.user.client.ui.HasValue; +<<<<<<< HEAD import com.google.gwt.user.client.ui.IsWidget; import com.google.gwt.user.client.ui.RootLayoutPanel; import com.google.gwt.user.client.ui.Widget; @@ -48,11 +68,46 @@ public class LoginActivity extends AppBa @Inject private HupaLayoutable hupaLayout; +======= +import com.google.gwt.user.client.ui.Widget; +import com.google.inject.Inject; +import com.google.inject.Provider; + +public class LoginActivity extends AbstractActivity { + + private HupaConstants constants = GWT.create(HupaConstants.class); + + private LoginPlace place; + private final Display display; + private final EventBus eventBus; + // private final HupaEvoCallback loginRpcService; + private PlaceController placeController; + + private DispatchAsync dispatcher; + private Provider<LoginPlace> oldGoToPlaceProvider; + private Provider<LoginPlace> newGoToPlaceProvider; + + @Inject + public LoginActivity(Display display, EventBus eventBus, PlaceController placeController, DispatchAsync dispatcher, + Provider<LoginPlace> newGoToPlaceProvider) { + this.display = display; + this.eventBus = eventBus; + this.placeController = placeController; + this.dispatcher = dispatcher; + this.newGoToPlaceProvider = newGoToPlaceProvider; + // this.loginRpcService = loginRpcService; + } + + public void init(LoginPlace place) { + this.place = place; + } +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter @Override public void start(AcceptsOneWidget container, EventBus eventBus) { bind(); container.setWidget(display.asWidget()); +<<<<<<< HEAD display.setLoading(false); } @@ -68,11 +123,24 @@ public class LoginActivity extends AppBa eventBus.fireEvent(new FlashEvent(constants.sessionTimedOut(), 4000)); } }); +======= + + } + + public void bind() { + display.getLoginClick().addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + doLogin(); + } + }); + +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter } private void doLogin() { String user = display.getUserNameValue().getValue().trim(); String pass = display.getPasswordValue().getValue().trim(); +<<<<<<< HEAD if (user.isEmpty() || pass.isEmpty()) return; display.setLoading(true); @@ -90,6 +158,29 @@ public class LoginActivity extends AppBa public void onFailure(ServerFailure error) { Window.alert(error.getMessage());// TODO a more gentle way display.setLoading(false); +======= + + if (user.isEmpty() || pass.isEmpty()) + return; + + display.setLoading(true); + dispatcher.execute(new LoginUser(user, pass), new HupaEvoCallback<LoginUserResult>(dispatcher, eventBus, + display) { + public void callback(LoginUserResult result) { + display.setLoading(false); + Window.alert("success"); + // eventBus.fireEvent(new LoginEvent(result.getUser())); +// LoginActivity.this.placeController.goTo(newGoToPlaceProvider.get()); + doReset(); + } + + public void callbackError(Throwable caught) { + display.setLoading(false); + Window.alert("failure"); +// LoginActivity.this.placeController.goTo(newGoToPlaceProvider.get()); + // eventBus.fireEvent(new FlashEvent(constants.loginInvalid(), + // 4000)); +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter doReset(); } }); @@ -104,6 +195,7 @@ public class LoginActivity extends AppBa display.getUserNameFocus().setFocus(true); } +<<<<<<< HEAD @Inject private Displayable display; @Inject private HupaConstants constants; @@ -113,6 +205,21 @@ public class LoginActivity extends AppBa public HasValue<String> getPasswordValue(); public Focusable getUserNameFocus(); public void setLoading(boolean loading); +======= + public interface Display { + public HasClickHandlers getLoginClick(); + + public HasClickHandlers getResetClick(); + + public HasValue<String> getUserNameValue(); + + public HasValue<String> getPasswordValue(); + + public Focusable getUserNameFocus(); + + public void setLoading(boolean loading); + +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter public Widget asWidget(); } } Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/HupaEvoClientModule.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/HupaEvoClientModule.java?rev=1522109&view=auto ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/HupaEvoClientModule.java (added) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/HupaEvoClientModule.java Thu Sep 12 02:03:52 2013 @@ -0,0 +1,46 @@ +package org.apache.hupa.client.gin; + +import net.customware.gwt.dispatch.client.DefaultExceptionHandler; +import net.customware.gwt.dispatch.client.DispatchAsync; +import net.customware.gwt.dispatch.client.ExceptionHandler; + +import org.apache.hupa.client.CachingDispatchAsync; +import org.apache.hupa.client.activity.LoginActivity; +import org.apache.hupa.client.mvp.AppActivityMapper; +import org.apache.hupa.client.mvp.AppPlaceFactory; +import org.apache.hupa.client.ui.LoginView; + +import com.google.gwt.activity.shared.ActivityMapper; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.SimpleEventBus; +import com.google.gwt.inject.client.AbstractGinModule; +import com.google.gwt.place.shared.PlaceController; +import com.google.inject.Provides; +import com.google.inject.Singleton; + +public class HupaEvoClientModule extends AbstractGinModule { + + @Override + protected void configure() { + // bind the EventBus + bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class); + bind(PlaceController.class).to(InjectablePlaceController.class).in(Singleton.class); + + bind(AppPlaceFactory.class).in(Singleton.class); + + // bind the mapper + bind(ActivityMapper.class).to(AppActivityMapper.class).in(Singleton.class); + + // bind the views + bind(LoginActivity.Display.class).to(LoginView.class); + // Used by dispatch. Note that GWT 2.4 has its own ExceptionHandler etc in other namespace + bind(ExceptionHandler.class).to(DefaultExceptionHandler.class); + + } + @Provides + @Singleton + protected DispatchAsync provideDispatchAsync(ExceptionHandler exceptionHandler) { + return new CachingDispatchAsync( exceptionHandler ); + } + +} Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/HupaEvoGinjector.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/HupaEvoGinjector.java?rev=1522109&view=auto ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/HupaEvoGinjector.java (added) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/HupaEvoGinjector.java Thu Sep 12 02:03:52 2013 @@ -0,0 +1,21 @@ +package org.apache.hupa.client.gin; + +import org.apache.hupa.client.mvp.AppPlaceFactory; + +import com.google.gwt.activity.shared.ActivityMapper; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.inject.client.GinModules; +import com.google.gwt.inject.client.Ginjector; +import com.google.gwt.place.shared.PlaceController; + +@GinModules({HupaEvoClientModule.class}) +public interface HupaEvoGinjector extends Ginjector { + + ActivityMapper getActivityMapper(); + + PlaceController getPlaceController(); + + EventBus getEventBus(); + + AppPlaceFactory getAppPlaceFactory(); +} Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/InjectablePlaceController.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/InjectablePlaceController.java?rev=1522109&view=auto ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/InjectablePlaceController.java (added) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/gin/InjectablePlaceController.java Thu Sep 12 02:03:52 2013 @@ -0,0 +1,20 @@ +package org.apache.hupa.client.gin; + +import javax.inject.Inject; + +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.place.shared.PlaceController; + + +/** + * The injectable PlaceController to be able to inject the eventbus into + * + */ +public class InjectablePlaceController extends PlaceController { + + @Inject + public InjectablePlaceController(EventBus eventBus) { + super(eventBus); + } + +} Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ActivityPlace.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ActivityPlace.java?rev=1522109&view=auto ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ActivityPlace.java (added) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/ActivityPlace.java Thu Sep 12 02:03:52 2013 @@ -0,0 +1,35 @@ +package org.apache.hupa.client.mvp; + +import com.google.gwt.activity.shared.Activity; +import com.google.gwt.place.shared.Place; + +/** + * Mapping an Activity to a Place + * + * @author Mahamad El Tanahy + * + */ +public abstract class ActivityPlace<T extends Activity> extends Place { + + protected T activity; + + public ActivityPlace(T activity) { + this.activity = activity; + setPlaceName(""); + } + + public T getActivity() { + return activity; + } + + private String placeName; + + public void setPlaceName(String token) { + this.placeName = token; + } + + public String getPlaceName() { + return placeName; + } + +} Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppActivityMapper.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppActivityMapper.java?rev=1522109&view=auto ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppActivityMapper.java (added) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppActivityMapper.java Thu Sep 12 02:03:52 2013 @@ -0,0 +1,35 @@ +package org.apache.hupa.client.mvp; + +import javax.inject.Inject; + +import com.google.gwt.activity.shared.Activity; +import com.google.gwt.activity.shared.ActivityMapper; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.place.shared.Place; +import com.google.gwt.place.shared.PlaceController; + + +public class AppActivityMapper implements ActivityMapper { + + private EventBus eventBus; + private PlaceController placeController; + + @Inject + public AppActivityMapper(EventBus eventBus, PlaceController placeController) { + super(); + this.eventBus = eventBus; + this.placeController = placeController; + } + + @Override + public Activity getActivity(Place place) { + if (place instanceof ActivityPlace) { + Activity activity = ((ActivityPlace) place).getActivity(); + return activity; + } + + return null; + + } + +} Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppPlaceFactory.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppPlaceFactory.java?rev=1522109&view=auto ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppPlaceFactory.java (added) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppPlaceFactory.java Thu Sep 12 02:03:52 2013 @@ -0,0 +1,30 @@ +package org.apache.hupa.client.mvp; + +import org.apache.hupa.client.place.LoginPlace; + +import com.google.inject.Inject; +import com.google.inject.Provider; + +/** + * + * A place factory which knows about all the tokenizers in the app + * + */ +public class AppPlaceFactory { + + @Inject + LoginPlace.Tokenizer loginPlaceTokenizer; + + @Inject + Provider<LoginPlace> loginProvider; + + // contact place + public LoginPlace.Tokenizer getLoginPlaceTokenizer() { + return loginPlaceTokenizer; + } + + public LoginPlace getLoginPlace() { + return loginProvider.get(); + } + +} Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppPlaceHistoryMapper.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppPlaceHistoryMapper.java?rev=1522109&view=auto ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppPlaceHistoryMapper.java (added) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/AppPlaceHistoryMapper.java Thu Sep 12 02:03:52 2013 @@ -0,0 +1,13 @@ +package org.apache.hupa.client.mvp; + +import org.apache.hupa.client.place.LoginPlace; + +import com.google.gwt.place.shared.PlaceHistoryMapperWithFactory; +import com.google.gwt.place.shared.WithTokenizers; + +//@WithTokenizers({ LoginPlace.Tokenizer.class }) +public interface AppPlaceHistoryMapper extends PlaceHistoryMapperWithFactory<AppPlaceFactory> { + + // empty + +} Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/LoginView.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/LoginView.java?rev=1522109&r1=1522108&r2=1522109&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/LoginView.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/LoginView.java Thu Sep 12 02:03:52 2013 @@ -144,7 +144,7 @@ public class LoginView extends Composite * @see org.apache.hupa.client.mvp.LoginPresenter.Display#getLoginClick() */ public HasClickHandlers getLoginClick() { - return loginButton; + return submitButton; } /* Added: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/place/LoginPlace.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/place/LoginPlace.java?rev=1522109&view=auto ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/place/LoginPlace.java (added) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/place/LoginPlace.java Thu Sep 12 02:03:52 2013 @@ -0,0 +1,42 @@ +package org.apache.hupa.client.place; + +import org.apache.hupa.client.activity.LoginActivity; +import org.apache.hupa.client.mvp.ActivityPlace; + +import com.google.gwt.place.shared.PlaceTokenizer; +import com.google.gwt.place.shared.Prefix; +import com.google.inject.Inject; +import com.google.inject.Provider; + +public class LoginPlace extends ActivityPlace<LoginActivity> { + + @Inject + public LoginPlace(LoginActivity activity) { + super(activity); + } + + @Prefix("Login") + public static class Tokenizer implements PlaceTokenizer<LoginPlace> { + + private final Provider<LoginPlace> placeProvider; + + @Inject + public Tokenizer(Provider<LoginPlace> placeProvider) { + this.placeProvider = placeProvider; + } + + @Override + public LoginPlace getPlace(String token) { + LoginPlace place = placeProvider.get(); + place.setPlaceName(token); + return place; + } + + @Override + public String getToken(LoginPlace place) { + return place.getPlaceName(); + } + + } + +} Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/LoginView.java URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/LoginView.java?rev=1522109&r1=1522108&r2=1522109&view=diff ============================================================================== --- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/LoginView.java (original) +++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/LoginView.java Thu Sep 12 02:03:52 2013 @@ -1,3 +1,4 @@ +<<<<<<< HEAD /**************************************************************** * Licensed to the Apache Software Foundation (ASF) under one * * or more contributor license agreements. See the NOTICE file * @@ -23,15 +24,22 @@ import org.apache.hupa.client.activity.L import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Document; +======= +package org.apache.hupa.client.ui; + +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter import com.google.gwt.event.dom.client.HasClickHandlers; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; +<<<<<<< HEAD import com.google.gwt.resources.client.ClientBundle; import com.google.gwt.resources.client.CssResource; import com.google.gwt.resources.client.CssResource.NotStrict; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; +======= +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Composite; @@ -39,6 +47,7 @@ import com.google.gwt.user.client.ui.Fle import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Focusable; import com.google.gwt.user.client.ui.FormPanel; +<<<<<<< HEAD import com.google.gwt.user.client.ui.FormPanel.SubmitEvent; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HasValue; @@ -134,11 +143,78 @@ public class LoginView extends Composite formPanel.add(flexTable); innerBox.add(formPanel); +======= +import com.google.gwt.user.client.ui.HasValue; +import com.google.gwt.user.client.ui.Panel; +import com.google.gwt.user.client.ui.PasswordTextBox; +import com.google.gwt.user.client.ui.SubmitButton; +import com.google.gwt.user.client.ui.TextBox; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; +import com.google.gwt.user.client.ui.FormPanel.SubmitEvent; +import com.google.inject.Inject; + +import org.apache.hupa.client.HupaCSS; +import org.apache.hupa.client.HupaConstants; +import org.apache.hupa.client.activity.LoginActivity; +import org.apache.hupa.widgets.ui.Loading; +import org.apache.hupa.widgets.ui.RndPanel; + +public class LoginView extends Composite implements KeyUpHandler, LoginActivity.Display { + private Button loginButton = new Button(); + private SubmitButton submitButton; + private Button resetButton; + private Loading loading; + // We wrap login/password boxes with a form which must be in the html + // document, + // in this way, the browser knows that we are sending a login form and + // offers the save password dialog to the user + private TextBox usernameTextBox = TextBox.wrap(DOM.getElementById("email")); + private PasswordTextBox passwordTextBox = PasswordTextBox.wrap(DOM.getElementById("password")); + // wrap the form after inputs so as they are in the dom when are wrapped + final private FormPanel formPanel = FormPanel.wrap(DOM.getElementById("loginForm"), true); + + @Inject + public LoginView(HupaConstants constants) { + + VerticalPanel mainContainer = new VerticalPanel(); + RndPanel rPanel = new RndPanel(); + FlexTable flexTable = new FlexTable(); + Panel buttonBar = new FlowPanel(); + submitButton = new SubmitButton(constants.loginButton()); + resetButton = new Button(constants.resetButton()); + submitButton.getElement().setClassName(HupaCSS.C_button); + resetButton.getElement().setClassName(HupaCSS.C_button); + submitButton.getElement().setClassName(resetButton.getElement().getClassName()); + loading = new Loading(constants.loading()); + + mainContainer.setStyleName(HupaCSS.C_login_container); + flexTable.addStyleName(HupaCSS.C_login_form); + usernameTextBox.addStyleName(HupaCSS.C_login_box); + passwordTextBox.addStyleName(HupaCSS.C_login_box); + + buttonBar.add(submitButton); + buttonBar.add(resetButton); + + flexTable.setText(0, 0, constants.usernameLabel()); + flexTable.setWidget(0, 1, usernameTextBox); + flexTable.setText(1, 0, constants.passwordLabel()); + flexTable.setWidget(1, 1, passwordTextBox); + flexTable.getFlexCellFormatter().setColSpan(2, 0, 2); + flexTable.setWidget(2, 0, buttonBar); + + rPanel.add(formPanel); + formPanel.add(flexTable); + mainContainer.add(rPanel); + mainContainer.add(loading); + initWidget(mainContainer); +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter usernameTextBox.addKeyUpHandler(this); usernameTextBox.setFocus(true); passwordTextBox.addKeyUpHandler(this); +<<<<<<< HEAD /* * The user submits the form so as the browser detect it and displays * the save password dialog. Then we click on the hidden loginButton @@ -148,11 +224,23 @@ public class LoginView extends Composite public void onSubmit(SubmitEvent event) { if (!usernameTextBox.getValue().trim().isEmpty() && !passwordTextBox.getValue().trim().isEmpty()) { +======= + loading.hide(); + + // The user submits the form so as the browser detect it and displays + // the save password dialog. Then we click on the hidden loginButton + // which + // stores the presenter clickHandler. + formPanel.addSubmitHandler(new FormPanel.SubmitHandler() { + public void onSubmit(SubmitEvent event) { + if (!usernameTextBox.getValue().trim().isEmpty() && !passwordTextBox.getValue().trim().isEmpty()) { +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter loginButton.click(); } // event.cancel(); } }); +<<<<<<< HEAD innerBox.add(loginButton); loginButton.setVisible(false); setLoading(false); @@ -177,6 +265,11 @@ public class LoginView extends Composite public PPanel() { super(Document.get().createPElement()); } +======= + // loginButton must be in the document to handle the click() method + mainContainer.add(loginButton); + loginButton.setVisible(false); +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter } @Override @@ -198,6 +291,14 @@ public class LoginView extends Composite } @Override +<<<<<<< HEAD +======= + public HasClickHandlers getResetClick() { + return resetButton; + } + + @Override +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter public HasValue<String> getUserNameValue() { return usernameTextBox; } @@ -212,6 +313,7 @@ public class LoginView extends Composite return usernameTextBox; } +<<<<<<< HEAD // FIXME the ajax loader will not hidden after normal logout @Override public void setLoading(boolean load) { @@ -223,6 +325,16 @@ public class LoginView extends Composite message.removeStyleName(style.display()); message.addStyleName(style.hidden()); } +======= + @Override + public void setLoading(boolean load) { + if (load) { + loading.show(); + } else { + loading.hide(); + } + +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter } @Override @@ -230,10 +342,13 @@ public class LoginView extends Composite return this; } +<<<<<<< HEAD interface LoginViewUiBinder extends UiBinder<FlowPanel, LoginView> { } private static LoginViewUiBinder binder = GWT .create(LoginViewUiBinder.class); +======= +>>>>>>> change the LOGIN progress using native MVP instead of gwt-presenter } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org