Example usage for com.google.gwt.event.shared HandlerManager fireEvent

List of usage examples for com.google.gwt.event.shared HandlerManager fireEvent

Introduction

In this page you can find the example usage for com.google.gwt.event.shared HandlerManager fireEvent.

Prototype

public void fireEvent(GwtEvent<?> event) 

Source Link

Document

Fires the given event to the handlers listening to the event's type.

Usage

From source file:com.sencha.gxt.widget.core.client.event.CellSelectionEvent.java

License:sencha.com license

public static <T> CellSelectionEvent<T> fire(HandlerManager manager, Context context, T item) {
    if (manager.isEventHandled(SelectionEvent.getType())) {
        CellSelectionEvent<T> event = new CellSelectionEvent<T>(context, item);
        manager.fireEvent(event);
        return event;
    }/*from   w  w w.j  a  va 2  s.  c o  m*/
    return null;
}

From source file:com.square.client.gwt.client.composant.popup.PopupFusion.java

License:Open Source License

/**
 * Constructeur.//ww w.  j  a  va 2 s.c  o m
 * @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 w  w  . j  a  va2  s.  co 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:lh.api.showcase.client.BasicAbstractPresenter.java

License:Apache License

public BasicAbstractPresenter(final HandlerManager eventBus, BasicDisplay display) {
    super();//w w  w .j a  v  a 2 s . c  o m
    this.eventBus = eventBus;

    // back button
    if (display.getBackHandler() != null) {
        display.getBackHandler().addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {

                eventBus.fireEvent(new MenuEvent(MenuEvent.MenuSelection.BACK));
            }
        });
    }
}

From source file:org.jboss.wise.gwt.client.Main.java

License:Open Source License

public void onModuleLoad() {
    MainServiceAsync rpcService = GWT.create(MainService.class);
    HandlerManager eventBus = new HandlerManager(null);
    AppController appViewer = new AppController(rpcService, eventBus);

    //rootLogger.log(Level.INFO, "Main: href: " + Window.Location.getHref());
    //rootLogger.log(Level.INFO, "Main: queryString: " + Window.Location.getQueryString());

    String hRef = Window.Location.getHref();
    String qStr = Window.Location.getQueryString();
    if (qStr != null && qStr.length() > 0) {
        int indx = hRef.indexOf(qStr);
        if (indx > 0) {

            // extract and send the URL's query parameter to the start page
            String wsdlParam = Window.Location.getParameter("wsdl");
            if (wsdlParam != null) {
                String decodedWsdl = URL.decodeQueryString(wsdlParam);
                eventBus.fireEvent(new InputWsdlEvent(decodedWsdl));
            }//from w  ww  . j ava  2 s .co m
        }
    }

    appViewer.go(RootPanel.get());
}

From source file:org.openremote.web.console.event.press.PressMoveReleaseHandlerImpl.java

License:Open Source License

private void processPressRelease(PressEvent<?> event) {
    HandlerManager eventBus = ConsoleUnitEventManager.getInstance().getEventBus();
    double duration = (event.getTime() - pressStartEvent.getTime());
    int moveDistanceX = 0;
    int moveDistanceY = 0;
    boolean moveOccurred = false;
    Widget releasedWidget = null;//from  w w  w.jav  a2  s  .  c  o m
    boolean tapOccurred = false;
    boolean sameWidgetPressedAndReleased = false;

    // Determine what objects were involved
    if (pressStartEvent.getSource() instanceof Widget) {
        pressedWidget = (Widget) pressStartEvent.getSource();
    }

    if (event.getSource() instanceof Widget) {
        releasedWidget = (Widget) event.getSource();
    }

    if (pressedWidget == releasedWidget) {
        sameWidgetPressedAndReleased = true;
    }

    // Check if we have movement
    if (pressMoveEvent != null) {
        moveDistanceX = pressMoveEvent.getClientX() - pressStartEvent.getClientX();
        moveDistanceY = pressMoveEvent.getClientY() - pressStartEvent.getClientY();
        moveOccurred = true;
    }

    // If movement occurred determine if there is correct movement for a swipe event
    // and whether swipe was on specific widget or entire display
    if (moveOccurred) {
        SwipeEvent swipeEvent = null;

        // Check for swipe gesture on pressed widget
        if (sameWidgetPressedAndReleased && isMovementWithinWidgetBounds(pressedWidget)) {
            swipeEvent = checkAndCreateSwipeEvent(pressedWidget, moveDistanceX, moveDistanceY);
        }
        //Check for swipe gesture on the console display
        if (swipeEvent == null) {
            ConsoleUnit consoleUnit = WebConsole.getConsoleUnit();
            if (consoleUnit != null) {
                swipeEvent = checkAndCreateSwipeEvent(consoleUnit.getConsoleDisplay(), moveDistanceX,
                        moveDistanceY);
            }
        }

        // If a swipe event has been created then fire it
        if (swipeEvent != null) {
            eventBus.fireEvent(swipeEvent);
            return;
        }
    }

    // Gestures below can only be performed if same widget pressed and released
    if (!sameWidgetPressedAndReleased) {
        return;
    }

    // Check for hold gesture
    if (duration >= HoldEvent.MIN_HOLD_TIME_MILLISECONDS) {
        eventBus.fireEvent(
                new HoldEvent(pressStartEvent.getClientX(), pressStartEvent.getClientY(), pressedWidget));
        return;
    }

    // Check for tap or double tap gesture
    if (pressMoveEvent != null) {
        if (Math.abs(pressMoveEvent.getClientX() - pressStartEvent.getClientX()) < TapEvent.TAP_X_TOLERANCE
                || Math.abs(pressMoveEvent.getClientY()
                        - pressStartEvent.getClientY()) < TapEvent.TAP_Y_TOLERANCE) {
            tapOccurred = true;
        }
    } else {
        tapOccurred = true;
    }
    if (tapOccurred) {
        if (pressedWidget == null) {
            return;
        }
        if (event.getTime() - lastTapTime < DoubleTapEvent.MAX_TIME_BETWEEN_TAPS_MILLISECONDS
                && lastTappedWidget == pressedWidget) {
            pressedWidget.fireEvent(new DoubleTapEvent(pressStartEvent.getClientX(),
                    pressStartEvent.getClientY(), pressedWidget));
        } else {
            pressedWidget.fireEvent(
                    new TapEvent(pressStartEvent.getClientX(), pressStartEvent.getClientY(), pressedWidget));
        }
        lastTapTime = event.getTime();
        lastTappedWidget = pressedWidget;
        return;
    }
}

From source file:org.openremote.web.console.service.LocalDataServiceImpl.java

License:Open Source License

private void setData(String dataName, String data) {
    String oldData = getObjectString(dataName);
    if (oldData == null || !data.equals(oldData)) {
        String dataNamePath = buildPathString(dataName);
        try {/*  ww w . j a v  a2 s. c  o m*/
            if (dataStore != null) {
                dataStore.removeItem(dataNamePath);
                dataStore.setItem(dataNamePath, data);
            } else {
                Cookies.setCookie(dataNamePath, data,
                        new Date(new Date().getTime() + (1000 * 60 * 60 * 24 * 365 * 100)));
            }
        } catch (Exception e) {
        }
        HandlerManager eventBus = ConsoleUnitEventManager.getInstance().getEventBus();
        BindingDataChangeEvent event = new BindingDataChangeEvent(dataName);
        eventBus.fireEvent(event);
    }
}

From source file:org.openremote.web.console.unit.ConsoleUnit.java

License:Open Source License

@Override
public void onSwipe(SwipeEvent event) {
    Gesture gesture = gestureMap.get(event.getDirection());
    boolean gestureHandled = false;
    Navigate navigate = null;// w  ww.j a v  a 2  s  .c  o m
    Boolean hasControlCommand = null;
    Integer commandId = null;

    if (gesture != null) {
        navigate = gesture.getNavigate();
        hasControlCommand = gesture.getHasControlCommand();
        commandId = gesture.getId();
        HandlerManager eventBus = ConsoleUnitEventManager.getInstance().getEventBus();

        if (navigate != null) {
            if (navigate.getTo() != null) {
                if (navigate.getTo().equalsIgnoreCase("previousscreen")) {
                    gestureHandled = true;
                    Screen prevScreen = panelService.getPreviousScreen(currentGroupId, currentScreenId);
                    if (prevScreen != null) {
                        loadDisplay(prevScreen, null);
                    }
                } else if (navigate.getTo().equalsIgnoreCase("nextscreen")) {
                    gestureHandled = true;
                    Screen nextScreen = panelService.getNextScreen(currentGroupId, currentScreenId);
                    if (nextScreen != null) {
                        loadDisplay(nextScreen, null);
                    }
                }
            }
            if (!gestureHandled
                    && (navigate.getToGroup() != currentGroupId || navigate.getToScreen() != currentScreenId)) {
                gestureHandled = true;
                eventBus.fireEvent(new NavigateEvent(navigate));
            }
        } else if (hasControlCommand != null && hasControlCommand) {
            gestureHandled = true;
            eventBus.fireEvent(new CommandSendEvent(commandId, "swipe", null));
        }
    }

    if (gestureHandled) {
        return;
    }

    switch (event.getDirection()) {
    case LEFT:
        Screen nextScreen = panelService.getNextScreen(currentGroupId, currentScreenId);
        if (nextScreen != null) {
            loadDisplay(nextScreen, null);
        }
        break;
    case RIGHT:
        Screen prevScreen = panelService.getPreviousScreen(currentGroupId, currentScreenId);
        if (prevScreen != null) {
            loadDisplay(prevScreen, null);
        }
        break;
    }
}

From source file:org.rstudio.core.client.widget.ToolbarButton.java

License:Open Source License

public <T extends EventHandler> ToolbarButton(String text, ImageResource leftImg, final HandlerManager eventBus,
        final GwtEvent<? extends T> targetEvent) {
    this(text, leftImg, new ClickHandler() {
        public void onClick(ClickEvent event) {
            eventBus.fireEvent(targetEvent);
        }//from   w w w .j  a v  a2 s  .c  o m
    });
}

From source file:org.thechiselgroup.biomixer.client.core.util.event.PrioritizedHandlerManager.java

License:Apache License

private Set<Throwable> doFire(HandlerManager handlers, GwtEvent<?> event, Set<Throwable> causes) {

    try {/*from  w ww.  java 2 s . c  o m*/
        handlers.fireEvent(event);
    } catch (Exception e) {
        if (causes == null) {
            causes = new HashSet<Throwable>();
        }

        if (e instanceof UmbrellaException) {
            causes.addAll(((UmbrellaException) e).getCauses());
        } else {
            causes.add(e);
        }
    }

    return causes;
}