public class BannerPresenter {
private BannerView bannerView = new BannerViewImpl();
public BannerPresenter() {
final ProjectActionBar projectActionBar = bannerView.getProjectActionBar();
projectActionBar.setProjectId(Application.get().getActiveProject());
projectActionBar.setShowShareSettingsHandler(new ShareSettingsHandlerImpl());
projectActionBar.setShowFreshEntitySettingsHandler(new ShowFreshEntitySettingsHandlerImpl());
projectActionBar.setShowProjectDetailsHandler(new ShowProjectDetailsHandlerImpl());
final ApplicationActionBar w = bannerView.getApplicationActionBar();
w.setSignedInUser(Application.get().getUserId());
w.setSignInRequestHandler(new SignInRequestHandlerImpl());
w.setSignOutRequestHandler(new SignOutRequestHandlerImpl());
w.setSignUpForAccountHandler(new SignUpForAccountHandlerImpl());
w.setChangePasswordHandler(new ChangePasswordHandlerImpl());
w.setChangeEmailAddressHandler(new ChangeEmailAddressHandlerImpl());
w.setShowAboutBoxHandler(new ShowAboutBoxHandlerImpl());
w.setShowUserGuideHandler(new ShowUserGuideHandlerImpl());
Boolean accountCreationEnabled = Application.get().getClientApplicationProperty(
WebProtegePropertyName.USER_ACCOUNT_CREATION_ENABLED, true);
GWT.log("Account creation enabled: " + accountCreationEnabled);
w.setSignUpForAccountVisible(accountCreationEnabled);
EventBusManager.getManager().registerHandler(ActiveProjectChangedEvent.TYPE, new ActiveProjectChangedHandler() {
@Override
public void handleActiveProjectChanged(ActiveProjectChangedEvent event) {
projectActionBar.setProjectId(event.getProjectId());
}
});
EventBusManager.getManager().registerHandler(UserLoggedInEvent.TYPE, new UserLoggedInHandler() {
@Override
public void handleUserLoggedIn(UserLoggedInEvent event) {
w.setSignedInUser(event.getUserId());
projectActionBar.setProjectId(Application.get().getActiveProject());
}
});
EventBusManager.getManager().registerHandler(UserLoggedOutEvent.TYPE, new UserLoggedOutHandler() {
@Override
public void handleUserLoggedOut(UserLoggedOutEvent event) {
w.setSignedInUser(UserId.getGuest());
projectActionBar.setProjectId(Application.get().getActiveProject());
}
});
}