/** * Constructor. * * @param eventBus the {@link EventBus}. * @param view the {@link MyView}. * @param proxy the {@link MyProxy}. * @param i18n the {@link I18nMessages}. */ @Inject public MainPagePresenter( final EventBus eventBus, final MyView view, final MyProxy proxy, final I18nMessages i18n) { super(eventBus, view, proxy); // prevent the application from directly reloading when the user press 'F5' or click on // 'refresh' Window.addWindowClosingHandler(new WindowClosingHandler(i18n)); Window.addCloseHandler(new WindowCloseHandler()); }
static { // On close it cancels all the pending requests except the "terminate" // request Window.addCloseHandler( new CloseHandler<Window>() { @Override public void onClose(final CloseEvent<Window> event) { int i = activeRequests.size() - 2; GWT.log("Cancelling " + (i + 1) + " pending requests."); for (; i >= 0; i--) { activeRequests.get(i).cancel(); } GWT.log("Cancelled all requests."); } }); }
/** Bind the various evt It's Mvp4g framework who call this function */ public void bindView() { view.onChangeSelectedLg() .addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { eventBus.changeTranslation(view.getIndexOfCurrentLg()); } }); view.setImageToolCommand( new Command() { public void execute() { changeState(PageState.manageImage); } }); view.setPageToolCommand( new Command() { public void execute() { changeState(PageState.display); } }); view.setUserSettingsCommand( new Command() { public void execute() { changeState(PageState.manageUser); } }); view.setTagSettingsCommand( new Command() { public void execute() { changeState(PageState.manageTag); } }); view.setTemplateSettingsCommand( new Command() { public void execute() { changeState(PageState.manageTemplate); } }); Window.addCloseHandler( new CloseHandler<Window>() { public void onClose(CloseEvent<Window> event) { disconnectUser(); } }); this.view .onLogOutClick() .addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { disconnectUser(); } }); this.view .upSpliterEvent() .addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { view.upRightSpliter(); } }); this.view .downSpliterEvent() .addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { view.downRightSpliter(); } }); }