Example usage for com.google.gwt.event.shared SimpleEventBus SimpleEventBus

List of usage examples for com.google.gwt.event.shared SimpleEventBus SimpleEventBus

Introduction

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

Prototype

SimpleEventBus

Source Link

Usage

From source file:com.alkacon.acacia.client.UndoRedoHandler.java

License:Open Source License

/**
 * Lazy initializing the handler manager.<p>
 * //from w  w w .ja  v  a  2 s  . c  o m
 * @return the handler manager
 */
private SimpleEventBus ensureHandlers() {

    if (m_eventBus == null) {
        m_eventBus = new SimpleEventBus();
    }
    return m_eventBus;
}

From source file:com.alkacon.geranium.client.ui.input.A_SelectBox.java

License:Open Source License

/**
 * Creates a new select box.<p>/*from   w w  w  .jav  a  2s  . c  om*/
 */
public A_SelectBox() {

    m_eventBus = new SimpleEventBus();
    m_panel = uiBinder.createAndBindUi(this);
    initWidget(m_panel);
    m_selectBoxState = new StyleVariable(m_opener);
    m_selectBoxState.setValue(I_LayoutBundle.INSTANCE.generalCss().cornerAll());

    m_selectorState = new StyleVariable(m_selector);
    m_selectorState.setValue(I_LayoutBundle.INSTANCE.generalCss().cornerBottom());

    m_opener.addStyleName(CSS.selectBoxSelected());
    addHoverHandlers(m_opener);

    m_openClose = new PushButton(I_ImageBundle.INSTANCE.style().triangleRight(),
            I_ImageBundle.INSTANCE.style().triangleDown());
    m_openClose.setButtonStyle(ButtonStyle.TRANSPARENT, null);
    m_openClose.addStyleName(CSS.selectIcon());
    m_panel.add(m_openClose);
    m_openClose.addClickHandler(new ClickHandler() {

        /**
         * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
         */
        public void onClick(ClickEvent event) {

            if (m_popup.isShowing()) {
                close();
            } else {
                open();
            }
        }
    });

    m_popup.setWidget(m_selector);
    m_popup.addStyleName(CSS.selectorPopup());
    m_popup.addAutoHidePartner(m_panel.getElement());

    m_selector.setStyleName(CSS.selectBoxSelector());
    m_selector.addStyleName(I_LayoutBundle.INSTANCE.generalCss().cornerBottom());
    m_selector.addStyleName(I_LayoutBundle.INSTANCE.generalCss().textMedium());
    m_popup.addCloseHandler(new CloseHandler<PopupPanel>() {

        /**
         * @see CloseHandler#onClose(CloseEvent)
         */
        public void onClose(CloseEvent<PopupPanel> e) {

            close();
        }
    });
    initOpener();
}

From source file:com.alkacon.geranium.client.ui.input.RadioButtonGroupWidget.java

License:Open Source License

/**
 * Internal method for initializing the widget with a list of select options.<p>
 * //from  www  . j ava 2  s  .  co m
 * @param items the list of select options 
 */
protected void init(Map<String, String> items) {

    initWidget(m_panel);
    m_eventBus = new SimpleEventBus();
    m_radioButtons = new HashMap<String, RadioButton>();
    for (Map.Entry<String, String> entry : items.entrySet()) {

        final RadioButton button = new RadioButton(entry.getKey(), entry.getValue());
        button.setGroup(m_group);
        m_radioButtons.put(entry.getKey(), button);
        FlowPanel wrapper = new FlowPanel();
        wrapper.add(button);
        m_panel.add(wrapper);
    }
    m_panel.add(m_error);
    m_panel.setStyleName(I_InputLayoutBundle.INSTANCE.inputCss().radioButtonGroup());
    m_panel.addStyleName(I_LayoutBundle.INSTANCE.generalCss().textMedium());
    m_group.setValueChangeTarget(this);
}

From source file:com.dingziran.effective.client.Showcase.java

License:Apache License

/**
   * This is the entry point method./* www  .  java2s  .  co m*/
   */
public void onModuleLoad() {
    factory = GWT.create(Factory.class);
    eventBus = new SimpleEventBus();
    factory.initialize(eventBus);
    // Inject global styles.
    injectThemeStyleSheet();
    images.css().ensureInjected();

    // Initialize the constants.
    ShowcaseConstants constants = GWT.create(ShowcaseConstants.class);

    // Create the application shell.
    final SingleSelectionModel<ContentWidget> selectionModel = new SingleSelectionModel<ContentWidget>();
    final MainMenuTreeViewModel treeModel = new MainMenuTreeViewModel(constants, selectionModel);
    Set<ContentWidget> contentWidgets = treeModel.getAllContentWidgets();
    shell = new ShowcaseShell(treeModel);
    RootLayoutPanel.get().add(shell);

    final CellTree mainMenu = shell.getMainMenu();
    /*
        // Prefetch examples when opening the Category tree nodes.
        final List<Category> prefetched = new ArrayList<Category>();
        mainMenu.addOpenHandler(new OpenHandler<TreeNode>() {
          public void onOpen(OpenEvent<TreeNode> event) {
            Object value = event.getTarget().getValue();
            if (!(value instanceof Category)) {
              return;
            }
            
            Category category = (Category) value;
            if (!prefetched.contains(category)) {
              prefetched.add(category);
              Prefetcher.prefetch(category.getSplitPoints());
            }
          }
        });
            
        // Always prefetch.
        Prefetcher.start();
    */
    // Change the history token when a main menu item is selected.
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            ContentWidget selected = selectionModel.getSelectedObject();
            if (selected != null) {
                History.newItem(getContentWidgetToken(selected), true);
            }
        }
    });

    // Setup a history handler to reselect the associate menu item.
    final ValueChangeHandler<String> historyHandler = new ValueChangeHandler<String>() {
        public void onValueChange(ValueChangeEvent<String> event) {
            // Get the content widget associated with the history token.
            ContentWidget contentWidget = treeModel.getContentWidgetForToken(event.getValue());
            if (contentWidget == null) {
                return;
            }

            // Expand the tree node associated with the content.
            Category category = treeModel.getCategoryForContentWidget(contentWidget);
            TreeNode node = mainMenu.getRootTreeNode();
            int childCount = node.getChildCount();
            for (int i = 0; i < childCount; i++) {
                if (node.getChildValue(i) == category) {
                    node.setChildOpen(i, true, true);
                    break;
                }
            }

            // Select the node in the tree.
            selectionModel.setSelected(contentWidget, true);

            // Display the content widget.
            displayContentWidget(contentWidget);
        }
    };
    History.addValueChangeHandler(historyHandler);

    // Show the initial example.
    if (History.getToken().length() > 0) {
        History.fireCurrentHistoryState();
    } else {
        // Use the first token available.
        TreeNode root = mainMenu.getRootTreeNode();
        TreeNode category = root.setChildOpen(0, true);
        ContentWidget content = (ContentWidget) category.getChildValue(0);
        selectionModel.setSelected(content, true);
    }

    // Generate a site map.
    createSiteMap(contentWidgets);
}

From source file:com.emitrom.easygwt.wf.client.events.EventsBus.java

License:Open Source License

public static SimpleEventBus getEventBus() {

    if (eventBus == null) {
        eventBus = new SimpleEventBus();
    }

    return eventBus;

}

From source file:com.ephesoft.gxt.core.client.DCMAEntryPoint.java

License:Open Source License

@Override
public final void onModuleLoad() {
    eventBus = new SimpleEventBus();
    rpcService = this.createRpcService();
    String urlPath = Window.Location.getPath();
    int urlSeparatorIndex = urlPath.lastIndexOf(CoreCommonConstant.URL_SEPARATOR);
    if (urlSeparatorIndex != -1) {
        BASE_URL = urlPath.substring(0, urlSeparatorIndex);
    }/*from w ww . jav  a 2  s. c  o m*/
    screenNavigator = new ScreenNavigator();
    if (getScreenType() != null) {
        RootPanel.get().add(screenNavigator);
        screenNavigator.setBaseURL(BASE_URL);
    }
    // initialize("");
    preprocess();
}

From source file:com.gafactory.core.shared.loader.Loader.java

License:sencha.com license

SimpleEventBus ensureHandler() {
    return eventBus == null ? eventBus = new SimpleEventBus() : eventBus;
}

From source file:com.google.api.gwt.samples.calendar.client.CalendarEntryPoint.java

License:Apache License

@Override
public void onModuleLoad() {
    calendar.initialize(new SimpleEventBus(), new GoogleApiRequestTransport(APPLICATION_NAME, API_KEY));

    final Button b = new Button("Authenticate to insert, update and delete an event");
    b.addClickHandler(new ClickHandler() {
        @Override//from w ww  .  ja v  a2s  . c o  m
        public void onClick(ClickEvent e) {
            login();
            b.setVisible(false);
        }
    });
    RootPanel.get().add(b);
}

From source file:com.google.api.gwt.samples.plus.client.PlusEntryPoint.java

License:Apache License

@Override
public void onModuleLoad() {
    plus.initialize(new SimpleEventBus(), new GoogleApiRequestTransport(APPLICATION_NAME, API_KEY));

    final Button b = new Button("Authenticate to get public activities");
    b.addClickHandler(new ClickHandler() {
        @Override/*from  w  w w.j a  va  2 s .  c o m*/
        public void onClick(ClickEvent e) {
            login();
            b.setVisible(false);
        }
    });
    RootPanel.get().add(b);
}

From source file:com.google.api.gwt.samples.urlshortener.client.UrlshortenerEntryPoint.java

License:Apache License

/** Demonstrates initialization of the RequestTransport. */
private void initialize(String accessToken) {
    new ClientGoogleApiRequestTransport().setApiAccessKey(API_KEY).setApplicationName(APPLICATION_NAME)
            .setAccessToken(accessToken).create(new Receiver<GoogleApiRequestTransport>() {
                @Override/*from  w ww .  j a va 2s.c  o m*/
                public void onSuccess(GoogleApiRequestTransport transport) {
                    urlShortener.initialize(new SimpleEventBus(), transport);

                    expand();
                }

                @Override
                public void onFailure(ServerFailure error) {
                    Window.alert("Failed to initialize Transport");
                }
            });
}