Last active
October 20, 2015 04:55
-
-
Save Elrhino/790c0db185c563993c9e to your computer and use it in GitHub Desktop.
Code snippets from toaster launcher part 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.inject.Inject; | |
import com.google.web.bindery.event.shared.EventBus; | |
import com.gwtplatform.mvp.client.HasUiHandlers; | |
import com.gwtplatform.mvp.client.Presenter; | |
import com.gwtplatform.mvp.client.View; | |
import com.gwtplatform.mvp.client.annotations.NameToken; | |
import com.gwtplatform.mvp.client.annotations.NoGatekeeper; | |
import com.gwtplatform.mvp.client.annotations.ProxyStandard; | |
import com.gwtplatform.mvp.client.proxy.ProxyPlace; | |
import com.projectname.project.client.application.ApplicationPresenter; | |
import com.projectname.project.client.application.CurrentUser; | |
import com.projectname.project.client.place.NameTokens; | |
public class LoginPresenter extends Presenter<LoginPresenter.MyView, LoginPresenter.MyProxy> | |
implements LoginUiHandlers { | |
@ProxyStandard | |
@NameToken(NameTokens.LOGIN) | |
@NoGatekeeper | |
interface MyProxy extends ProxyPlace<LoginPresenter> { | |
} | |
interface MyView extends View, HasUiHandlers<LoginUiHandlers> { | |
} | |
// Credentials are stored here for demo purpose only. | |
private static final String USERNAME = "s3cr3t"; | |
private static final String PASSWORD = "p4ssw0rd"; | |
private CurrentUser currentUser; | |
@Inject | |
LoginPresenter( | |
EventBus eventBus, | |
MyView view, | |
MyProxy proxy, | |
CurrentUser currentUser) { | |
super(eventBus, view, proxy, ApplicationPresenter.SLOT_MAIN); | |
this.currentUser = currentUser; | |
getView().setUiHandlers(this); | |
} | |
@Override | |
public void confirm(String username, String password) { | |
if (validateCredentials(username, password)) { | |
currentUser.setLoggedIn(true); | |
// TODO: Navigate to the home page | |
} | |
} | |
private boolean validateCredentials(String username, String password) { | |
return username.equals(USERNAME) && password.equals(PASSWORD); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment