public void switchSection(String token) { popup.hide(); tokenHistory.add(token); Map<String, String> parameters = getHistoryTokenParameters(token); AppPlace place = getPlace(token); if (mainPresenter != null) { mainPresenter.clearNotifications(); } if (ClientSessionUtil.checkSession()) { switch (place) { case HOME: HomePresenter homePresenter = new HomePresenter(new HomeView(), eventBus); homePresenter.bind(); getLayout().clear(); getLayout().add(homePresenter.getDisplay().asWidget()); break; case REQUEST: RequestPresenter requestPresenter = new RequestPresenter(new RequestView(), eventBus); requestPresenter.bind(); getLayout().clear(); getLayout().add(requestPresenter.getDisplay().asWidget()); break; case LOGOUT: ClientSessionUtil.destroySession(); eventBus.fireEvent(new LoginRequiredEvent()); break; case REQUESTSTATUS: try { Integer requestId = Integer.parseInt(parameters.get("requestId")); RequestStatusPresenter requestStatusPresenter = new RequestStatusPresenter(new RequestStatusView(), eventBus); requestStatusPresenter.bind(); requestStatusPresenter.showRequest(requestId); getLayout().clear(); getLayout().add(requestStatusPresenter.getDisplay().asWidget()); } catch (Exception e) { showNotification( "Id incorrecta: No se puede cargar la solicitud", NotificationEventType.ERROR); } break; case EDITREQUEST: try { Integer requestId = Integer.parseInt(parameters.get("requestId")); RequestEditPresenter editPresenter = new RequestEditPresenter(new RequestEditView(), eventBus); editPresenter.bind(); editPresenter.showRequest(requestId); getLayout().clear(); getLayout().add(editPresenter.getDisplay().asWidget()); } catch (Exception e) { showNotification( "Id incorrecta: No se puede cargar la solicitud", NotificationEventType.ERROR); } break; case RESPONSE: try { Integer requestId = Integer.parseInt(parameters.get("requestId")); RequestResponsePresenter requestResponsePresenter = new RequestResponsePresenter(new RequestResponseView(), eventBus); requestResponsePresenter.bind(); requestResponsePresenter.showRequest(requestId); getLayout().clear(); getLayout().add(requestResponsePresenter.getDisplay().asWidget()); } catch (Exception e) { showNotification( "Id incorrecta: No se puede cargar la solicitud", NotificationEventType.ERROR); } break; case LIST: try { String listType = parameters.get("type"); RequestListPresenter requestListPresenter = new RequestListPresenter(new RequestListView(), eventBus); requestListPresenter.bind(); requestListPresenter.loadRequests(0, 100, listType); getLayout().clear(); getLayout().add(requestListPresenter.getDisplay().asWidget()); } catch (Exception e) { showNotification( "Tipo de lista incorrecto: No se puede cargar la lista", NotificationEventType.ERROR); } break; case STATISTICS: StatisticsPresenter statistics = new StatisticsPresenter(new StatisticsView(), eventBus); statistics.bind(); getLayout().clear(); getLayout().add(statistics.getDisplay().asWidget()); break; case ABOUTPROJECT: AboutProjectPresenter aboutProjectPresenter = new AboutProjectPresenter(new AboutProjectView(), eventBus); aboutProjectPresenter.bind(); getLayout().clear(); getLayout().add(aboutProjectPresenter.getDisplay().asWidget()); break; case ASOCIATES: AsociatesPresenter asociatesPresenter = new AsociatesPresenter(new AsociatesView(), eventBus); asociatesPresenter.bind(); getLayout().clear(); getLayout().add(asociatesPresenter.getDisplay().asWidget()); break; case USERPROFILE: UserProfileEditPresenter userProfilePresenter = new UserProfileEditPresenter(new UserProfileEditView(), eventBus); userProfilePresenter.bind(); getLayout().clear(); getLayout().add(userProfilePresenter.getDisplay().asWidget()); break; default: History.newItem(AppPlace.HOME.toString()); } } else { switch (place) { case HOME: HomePresenter homePresenter = new HomePresenter(new HomeView(), eventBus); homePresenter.bind(); getLayout().clear(); getLayout().add(homePresenter.getDisplay().asWidget()); break; case REQUEST: case LOGIN: LoginPresenter loginPresenter = new LoginPresenter(new LoginView(), eventBus); loginPresenter.bind(); popup.setModal(true); popup.setGlassEnabled(true); popup.clear(); popup.add(loginPresenter.getDisplay().asWidget()); popup.center(); break; case REGISTER: RegisterPresenter registerPresenter = new RegisterPresenter(new RegisterView(), eventBus); registerPresenter.bind(); getLayout().clear(); getLayout().add(registerPresenter.getDisplay().asWidget()); break; case RESPONSE: try { Integer requestId = Integer.parseInt(parameters.get("requestId")); RequestResponsePresenter requestResponsePresenter = new RequestResponsePresenter(new RequestResponseView(), eventBus); requestResponsePresenter.bind(); requestResponsePresenter.showRequest(requestId); getLayout().clear(); getLayout().add(requestResponsePresenter.getDisplay().asWidget()); } catch (Exception e) { showNotification( "Id incorrecta: No se puede cargar la solicitud", NotificationEventType.ERROR); } break; case LIST: try { String listType = parameters.get("type"); RequestListPresenter requtesListPresenter = new RequestListPresenter(new RequestListView(), eventBus); requtesListPresenter.bind(); requtesListPresenter.loadRequests(0, 100, listType); getLayout().clear(); getLayout().add(requtesListPresenter.getDisplay().asWidget()); } catch (Exception e) { showNotification( "Tipo de lista incorrecto: No se puede cargar la lista", NotificationEventType.ERROR); } break; case STATISTICS: StatisticsPresenter statistics = new StatisticsPresenter(new StatisticsView(), eventBus); statistics.bind(); getLayout().clear(); getLayout().add(statistics.getDisplay().asWidget()); break; case ABOUTPROJECT: AboutProjectPresenter aboutProjectPresenter = new AboutProjectPresenter(new AboutProjectView(), eventBus); aboutProjectPresenter.bind(); getLayout().clear(); getLayout().add(aboutProjectPresenter.getDisplay().asWidget()); break; case ASOCIATES: AsociatesPresenter asociatesPresenter = new AsociatesPresenter(new AsociatesView(), eventBus); asociatesPresenter.bind(); getLayout().clear(); getLayout().add(asociatesPresenter.getDisplay().asWidget()); break; case PASSWORDRECOVERY: PasswordRecoveryPresenter passwordRecoveryPresenter = new PasswordRecoveryPresenter(new PasswordRecoveryView(), eventBus); passwordRecoveryPresenter.bind(); getLayout().clear(); getLayout().add(passwordRecoveryPresenter.getDisplay().asWidget()); break; default: History.newItem(AppPlace.HOME.toString()); } } }
public static String getPreviousHistoryToken() { if (getHistoryTokenList().size() > 2) { return getHistoryTokenList().get(getHistoryTokenList().size() - 2); } return AppPlace.HOME.getToken(); }