List of usage examples for com.google.gwt.event.shared HandlerManager addHandler
public <H extends EventHandler> HandlerRegistration addHandler(GwtEvent.Type<H> type, final H handler)
From source file:com.google.mobile.trippy.web.client.presenter.DayListPresenter.java
License:Apache License
/** * Bind the presenter and the view.//from ww w . j av a2 s . co m * * Listen for user events on display and take action. Also listen for * appropriate application events and update display accordingly. * * Events fired : None * * Events listened : 1) TripUpdatedEvent 2)TripItemAddedEvent 3) * TripItemUpdatedEvent 4) TripItemDeletedEvent , When any of the above four * events are fired, the fetch the trip item and verify if the trip is same as * the current trip. If so, then recreate the day groups. */ @Override public void bind() { final HandlerManager eventBus = getEventBus(); handlers.add(display.getSaveButton().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ArrayList<IdDayDateTuple> itemIds = display.getReorderedItems(); final Toast toast = singletonComponents.getToast(); toast.showLoading(singletonComponents.getMessage().updating(Constants.TRIP_STR)); trip.setTripItemIds(new IdDayDateTupleList(itemIds)); try { singletonComponents.getTripService().updateTripItemsTuple(trip, new AsyncCallback<Trip>() { @Override public void onFailure(final Throwable caught) { if (caught instanceof AuthorizationException) { toast.hideLoading(); toast.showToast( singletonComponents.getMessage().unauthorizedEdit(Constants.TRIP_STR)); } if (caught instanceof AuthenticationException) { toast.hideLoading(); toast.showToast( singletonComponents.getMessage().unauthorizedEdit(Constants.TRIP_STR)); DefaultUtils.getInstance() .redirect(DefaultUtils.getInstance().getLoginUrl(Location.getHref())); } if (caught instanceof TripNotFoundException) { toast.hideLoading(); toast.showToast(singletonComponents.getMessage().tripNotFound()); DefaultUtils.getInstance() .redirect(DefaultUtils.getInstance().getLoginUrl(Location.getHref())); } if (caught instanceof TripVersionException) { toast.hideLoading(); toast.showToast(singletonComponents.getMessage().tripNotSynced()); } } @Override public void onSuccess(final Trip resultTrip) { toast.hideLoading(); if (resultTrip.getKey().equals(trip.getKey())) { setTrip(resultTrip); } } }); } catch (AuthorizationException e) { toast.hideLoading(); toast.showToast(singletonComponents.getMessage().unauthorizedEdit(Constants.TRIP_STR)); } } })); handlers.add(eventBus.addHandler(TripUpdatedEvent.getType(), new TripUpdatedEventHandler() { @Override public void onTripUpdated(TripUpdatedEvent event) { if (event.getTrip().getKey().equals(trip.getKey())) { setTrip(event.getTrip()); } } })); handlers.add(eventBus.addHandler(TripItemAddedEvent.getType(), new TripItemAddedEventHandler() { @Override public void onTripItemAdded(TripItemAddedEvent event) { if (event.getTripItem().getTripId().equals(trip.getKey())) { populateView(); } } })); handlers.add(eventBus.addHandler(TripItemUpdatedEvent.getType(), new TripItemUpdatedEventHandler() { @Override public void onTripItemUpdated(TripItemUpdatedEvent event) { if (event.getTripItem().getTripId().equals(trip.getKey())) { populateView(); } } })); handlers.add(eventBus.addHandler(TripItemDeletedEvent.getType(), new TripItemDeletedEventHandler() { @Override public void onTripItemDeleted(TripItemDeletedEvent event) { if (event.getTripItem().getTripId().equals(trip.getKey())) { populateView(); } } })); }
From source file:com.google.mobile.trippy.web.client.presenter.TripListItemPresenter.java
License:Apache License
/** * Bind the presenter and the view./*www . j a v a 2s . c o m*/ * * Listen for user events on display and take action. Also listen for * appropriate application events and update display accordingly * * Events fired : * 1) ShowTripScheduleEvent - Show the schedule page of this trip * * Events listened : * 1) TripUpdatedEvent -Check if the current trip has been * updated. If the current trip has been updated then Check if any of the * following attributes have been updated a) Trip name b) Start date b) End * date If trip name has been updated then update the display name If * Start/End date have been updated then update the display schedule. */ @Override public void bind() { tripOptionsPresenter.bind(false); // Do not bind another HW search key. final HandlerManager eventBus = singletonComponents.getEventBus(); handlers.add(display.getName().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { eventBus.fireEvent(new ShowTripScheduleEvent(trip)); } })); handlers.add(display.getOptions().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { tripOptionsPresenter.getMenuPresenter().showMenu(); } })); handlers.add(eventBus.addHandler(TripUpdatedEvent.getType(), new TripUpdatedEventHandler() { @Override public void onTripUpdated(TripUpdatedEvent event) { setTrip(event.getTrip()); } })); }
From source file:com.google.mobile.trippy.web.client.presenter.TripListPresenter.java
License:Apache License
/** * Bind the presenter and the view./*from w w w . j av a2s.co m*/ * * Listen for user events on display and take action. Also listen for * appropriate application events and update display accordingly * * Events fired : None * * Events listened : * 1) TripAddedEvent - Add the trip to the list and call the populateView(). * 2) TripUpdatedEvent - Identify the updated trip and its current location. * Check if start or end date has been modified. If start or end date has * been modified then resort the trip lists, if the location of the updated * trip is different the delete the display from view and * insert it at the correct location in the correct trip list * 3) TripDeletedEvent - Identify the trip that needs to be deleted. * Identify the trip list and the location, then delete that trip view * from the display. */ @Override public void bind() { final HandlerManager eventBus = singletonComponents.getEventBus(); handlers.add(display.getCreateTripButton().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { singletonComponents.getEventBus().fireEvent(new ShowCreateTripEvent()); } })); handlers.add(display.getRefreshButton().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { singletonComponents.getUtils().reload(); } })); handlers.add(eventBus.addHandler(TripAddedEvent.getType(), new TripAddedEventHandler() { @Override public void onTripAdded(TripAddedEvent event) { if (!hasTrip(event.getTrip())) { addTrip(event.getTrip()); } } })); handlers.add(eventBus.addHandler(TripUpdatedEvent.getType(), new TripUpdatedEventHandler() { @Override public void onTripUpdated(TripUpdatedEvent event) { if (hasTrip(event.getTrip())) { updateTrip(event.getTrip()); } else { addTrip(event.getTrip()); } } })); handlers.add(eventBus.addHandler(TripDeletedEvent.getType(), new TripDeletedEventHandler() { @Override public void onTripDeleted(TripDeletedEvent event) { if (hasTrip(event.getTrip())) { deleteTrip(event.getTrip()); } } })); }
From source file:com.kk_electronic.kkportal.examples.modules.Inotify.java
License:Open Source License
@Inject public Inotify(Display display, Debug debug, HandlerManager eventBus) { eventBus.addHandler(INotificationEvent.getType(), this); debug.inotify("server", new AsyncCallback<Object>() { @Override/*from www . jav a2 s .c om*/ public void onFailure(Throwable caught) { GWT.log("INOTIFY-Could not listen", caught); } @Override public void onSuccess(Object result) { GWT.log("INOTIFY-Listening"); } }); this.display = display; }
From source file:com.square.client.gwt.client.composant.popup.PopupFusion.java
License:Open Source License
/** * Constructeur.//w ww .jav a 2s .c om * @param eventBus le bus d'vnement. * @param nom le nom du doublon. * @param prenom le prnom du doublon. * @param dateNaissance la date de naissance du doublon. * @param idPersonneSelectionnee identifiant de la personne pr-selectionne dans la popup de fusion * @param deskBar deskBar */ public PopupFusion(final HandlerManager eventBus, String nom, String prenom, String dateNaissance, Long idPersonneSelectionnee, DeskBar deskBar) { super(popupConstants.titrePopup(), false, false, true); this.addStyleName(SquareResources.INSTANCE.css().popupFusion()); this.deskBar = deskBar; final VerticalPanel pConteneur = new VerticalPanel(); pConteneur.setWidth(PopupFusionConstants.LARGEUR_POPUP); pConteneur.setSpacing(5); final VerticalPanel pConteneurComposantFusion = new VerticalPanel(); pConteneurComposantFusion.setWidth(AppControllerConstants.POURCENT_100); final RechercheDoublonCritereModel criteres = new RechercheDoublonCritereModel(); criteres.setNom(nom); criteres.setPrenom(prenom); criteres.setDateNaissance(dateNaissance); final ComposantFusionPresenter composantFusionPresenter = new ComposantFusionPresenter(eventBus, criteres, idPersonneSelectionnee); composantFusionPresenter.showPresenter(pConteneurComposantFusion); final DecoratedButton btnFermer = new DecoratedButton(popupConstants.btnFermer()); btnFermer.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); // On met jour la recherche eventBus.fireEvent(new RafraichirRecherchePersonneEvent()); } }); btnReduire = new DecoratedButton(popupConstants.reduire()); eventBus.addHandler(EnableMinimizeWidgetEvent.TYPE, new EnableMinimizeWidgetEventHandler() { @Override public void enableMinimizeWidget(EnableMinimizeWidgetEvent event) { btnReduire.setEnabled(event.isEnabled()); } }); final HorizontalPanel conteneurBoutons = new HorizontalPanel(); conteneurBoutons.add(btnReduire); conteneurBoutons.add(btnFermer); conteneurBoutons.setSpacing(5); pConteneur.add(pConteneurComposantFusion); pConteneur.add(conteneurBoutons); pConteneur.setCellHorizontalAlignment(conteneurBoutons, HasAlignment.ALIGN_CENTER); this.setWidget(pConteneur, 0); }
From source file:com.square.composant.tarificateur.square.client.ComposantTarificateurModule.java
License:Open Source License
/** * {@inheritDoc}/*w ww. j a v a 2s.c o m*/ */ public void onModuleLoad() { final ComposantTarificateurConstants constants = GWT.create(ComposantTarificateurConstants.class); firefox3compatibility(); StyleInjector.inject(SquareLibResources.INSTANCE.css().getText()); final PersonneModel personne = getPersonneTest(); final Long eidOpportunite = 112624460L;// 125350001L; final Long eidCreateur = 4L; final Long eidAgence = 4L; final Long eidResponsable = 58L; final InfosOpportuniteModel infosOpportunite = new InfosOpportuniteModel(); infosOpportunite.setEidOpportunite(eidOpportunite); infosOpportunite.setEidCreateur(eidCreateur); infosOpportunite.setEidAgence(eidAgence); infosOpportunite.setEidResponsable(eidResponsable); infosOpportunite.setLoginUtilisateurConnecte("ymurg"); infosOpportunite.setPersonne(personne); final HandlerManager eventBus = new HandlerManager(null); eventBus.addHandler(MiseAJourOpportuniteEvent.TYPE, new MiseAJourOpportuniteEventHandler() { @Override public void mettreAJour(MiseAJourOpportuniteEvent event) { final PopupInfoConfiguration config = new PopupInfoConfiguration(constants.miseAJourHoportunite(), ComposantTarificateurConstants.NOTIFICATION_TIME_OUT); new DecoratedInfoPopup(config).show(); } }); eventBus.addHandler(SuccesImpressionEvent.TYPE, new SuccesImpressionEventHandler() { @Override public void onSuccess(SuccesImpressionEvent event) { final PopupInfoConfiguration config = new PopupInfoConfiguration(constants.succesImpression(), ComposantTarificateurConstants.NOTIFICATION_TIME_OUT); config.setCallback(new PopupCallback() { @Override public void onResult(boolean result) { // poste un evenement pour recharger l'opp eventBus.fireEvent(new RechargementOpportuniteEvent()); } }); new DecoratedInfoPopup(config).show(); } }); eventBus.addHandler(SuccesMajInfosAdhesionEvent.TYPE, new SuccesMajInfosAdhesionEventHandler() { @Override public void onSuccess(SuccesMajInfosAdhesionEvent event) { final PopupInfoConfiguration config = new PopupInfoConfiguration( constants.succesMiseJourInfoAdhesion(), ComposantTarificateurConstants.NOTIFICATION_TIME_OUT); new DecoratedInfoPopup(config).show(); } }); eventBus.addHandler(SuccesTransformationAiaEvent.TYPE, new SuccesTransformationAiaEventHandler() { @Override public void onSuccess(SuccesTransformationAiaEvent event) { final PopupInfoConfiguration config = new PopupInfoConfiguration( constants.succesTransformationAia(), ComposantTarificateurConstants.NOTIFICATION_TIME_OUT); new DecoratedInfoPopup(config).show(); } }); eventBus.addHandler(SuccesTransfertEvent.TYPE, new SuccesTransfertEventHandler() { @Override public void onSuccess(SuccesTransfertEvent event) { final PopupInfoConfiguration config = new PopupInfoConfiguration(constants.succesTransfert(), ComposantTarificateurConstants.NOTIFICATION_TIME_OUT); new DecoratedInfoPopup(config).show(); } }); final DeskBar deskBar = new DeskBar(0, eventBus); final ComposantTarificateur composantTarificateur = new ComposantTarificateur(eventBus, deskBar, infosOpportunite, true, true); composantTarificateur.getBtnAjouterDevisClickHandler().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { composantTarificateur.creerNouveauDevis(infosOpportunite); } }); composantTarificateur.getBtnVoirActionsClickHandler().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final PopupInfoConfiguration config = new PopupInfoConfiguration(constants.affichageActions(), ComposantTarificateurConstants.NOTIFICATION_TIME_OUT); new DecoratedInfoPopup(config).show(); } }); final VerticalPanel conteneurTarificateur = new VerticalPanel(); conteneurTarificateur.setWidth("944px"); composantTarificateur.showPresenter(conteneurTarificateur); final VerticalPanel conteneur = new VerticalPanel(); conteneur.setWidth("100%"); conteneur.add(conteneurTarificateur); conteneur.add(deskBar); RootPanel.get().add(conteneur); }
From source file:com.square.composants.graphiques.lib.client.popups.minimizable.DeskBar.java
License:Open Source License
/** * Constructeur./*from www. j a v a 2s .c o m*/ * @param maxItem nb d'item max autoris * @param eventBus bus d'evenement */ public DeskBar(final Integer maxItem, final HandlerManager eventBus) { this.eventBus = eventBus; this.maxItem = maxItem; eventBus.addHandler(MinimizePopupEvent.TYPE, new MinimizePopupEventHandler() { @Override public void minimizePopup(MinimizePopupEvent event) { if (maxItem == null || panel.getWidgetCount() < maxItem.intValue()) { addItem(event.getItem()); } } }); eventBus.addHandler(MaximizePopupEvent.TYPE, new MaximizePopupEventHandler() { @Override public void maximizePopup(MaximizePopupEvent event) { removeItem(event.getItem()); } }); panel = new FlowPanel(); final HorizontalPanel conteneur = new HorizontalPanel(); conteneur.setStylePrimaryName(SquareLibResources.INSTANCE.css().deskBar()); conteneur.add(panel); conteneur.setCellHorizontalAlignment(panel, HasHorizontalAlignment.ALIGN_RIGHT); initWidget(conteneur); }
From source file:edu.kit.ipd.sonar.client.GraphView.java
License:Open Source License
/** * Create a new GraphView.//from w w w. j a va 2 s . c o m * * Registers itself with the event bus. */ public GraphView() { super("<div id='" + JSXCONTAINER_ID + "' style='width:100%; " + "height:100%;'></div>"); setWidth("100%"); setHeight("100%"); HandlerManager hm = EventBus.getHandlerManager(); graphdrawer = new JSXGraphDrawer(JSXCONTAINER_ID); /* This handler is going to trigger if a new drawable graph is ready. * It will start a loading screen, call the graphdrawer to draw the * graph and then stop the loading screen */ hm.addHandler(DrawableGraphArrivedEvent.TYPE, new DrawableGraphArrivedEventHandler() { public void onDrawableGraphArrived(final DrawableGraphArrivedEvent event) { GWT.log("GraphView: got DrawableGraphArrivedEvent," + "start loading, start drawing", null); // start the loading screen EventBus.getHandlerManager().fireEvent(new StartLoadingEvent()); // draw the graph graphdrawer.drawDrawableGraph(event.getDrawableGraph()); GWT.log("GraphView: stop loading", null); // stop the loading screen EventBus.getHandlerManager().fireEvent(new FinishLoadingEvent()); } }); hm.addHandler(SuccessfulLogoutEvent.TYPE, new SuccessfulLogoutEventHandler() { public void onSuccessfulLogout(final SuccessfulLogoutEvent e) { GWT.log("GraphView: got logout event, reseting" + " board", null); graphdrawer.reset(); } }); }
From source file:edu.kit.ipd.sonar.client.GuiController.java
License:Open Source License
/** * This is the entry point method.//from ww w. ja v a 2 s. c o m */ public final void onModuleLoad() { new RPCHandler(EventBus.getHandlerManager(), (RPCServiceAsync) GWT.create(RPCService.class)); /* Init the LoadingPopup*/ LoadingPopup loadingPopup = new LoadingPopup(); /* show the loading screen */ EventBus.getHandlerManager().fireEvent(new StartLoadingEvent()); /* Init the ErrorPopup */ ErrorPopup errorPopup = new ErrorPopup(); /* Start the GraphConverter */ GraphConverter graphconverter = new GraphConverter(EventBus.getHandlerManager()); /* Do not change the order of this or our constants will break. */ deckPanel.add(new NormalScreen()); deckPanel.add(new LoginScreen()); deckPanel.showWidget(LOGIN_SCREEN); RootPanel.get().add(deckPanel); /* Register for Events */ HandlerManager hm = EventBus.getHandlerManager(); /* * When the user authenticated successfully, we need to hide the * login screen and show the normal screen instead. */ hm.addHandler(SuccessfulAuthenticationEvent.TYPE, new SuccessfulAuthenticationEventHandler() { public void onSuccessfulAuthentication(final SuccessfulAuthenticationEvent e) { GWT.log("GuiController: got auth event, switching" + " to normal screen", null); deckPanel.showWidget(NORMAL_SCREEN); } }); hm.addHandler(SuccessfulLogoutEvent.TYPE, new SuccessfulLogoutEventHandler() { public void onSuccessfulLogout(final SuccessfulLogoutEvent e) { GWT.log("GuiController: got logout event, switching" + " to login screen", null); deckPanel.showWidget(LOGIN_SCREEN); } }); /* hide the loading screen */ EventBus.getHandlerManager().fireEvent(new FinishLoadingEvent()); }
From source file:org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.java
License:Apache License
public DecisionServiceSVGShapeView addDividerDragHandler(final DragHandler dragHandler) { final HandlerManager handlerManager = getHandlerManager(); final HandlerRegistration dragStartRegistration = handlerManager.addHandler(MoveDividerStartEvent.TYPE, event -> dragHandler.start(buildDragEvent(event))); final HandlerRegistration dragStepRegistration = handlerManager.addHandler(MoveDividerStepEvent.TYPE, event -> dragHandler.handle(buildDragEvent(event))); final HandlerRegistration dragEndRegistration = handlerManager.addHandler(MoveDividerEndEvent.TYPE, event -> dragHandler.end(buildDragEvent(event))); final HandlerRegistration[] registrations = new HandlerRegistration[] { dragStartRegistration, dragStepRegistration, dragEndRegistration }; getEventHandlerManager().addHandlersRegistration(ViewEventType.DRAG, registrations); return this; }