Example usage for com.google.gwt.event.logical.shared CloseEvent fire

List of usage examples for com.google.gwt.event.logical.shared CloseEvent fire

Introduction

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

Prototype

public static <T> void fire(HasCloseHandlers<T> source, T target) 

Source Link

Document

Fires a close event on all registered handlers in the handler manager.

Usage

From source file:cc.kune.common.client.ui.dialogs.CustomModalHeader.java

License:GNU Affero Public License

public CustomModalHeader() {
    super();//  ww w . j  a  v a2  s .  c  o  m
    // We remove and override the default closable button
    super.setClosable(false);
    closeButton.setDataDismiss(ButtonDismiss.MODAL);
    add(closeButton);
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent evt) {
            CloseEvent.fire(CustomModalHeader.this, CustomModalHeader.this);
        }
    });
    heading = new IconLabel();
    add(heading);

    // TODO
    // private final Heading heading = new Heading(HeadingSize.H4);

    setStyleName(Styles.MODAL_HEADER);
    heading.setStyleName(Styles.MODAL_TITLE);
    heading.addStyleName("k-modal-header");
}

From source file:com.alkacon.geranium.client.ui.FieldSet.java

License:Open Source License

/**
 * Adds a click handler to the image icon of this fieldset.<p>
 * //  www  .j a va2  s  .co m
 * On click the 
 * 
 * @param e the event
 */
@UiHandler("m_image")
protected void handleClick(ClickEvent e) {

    if (m_animation != null) {
        m_animation.cancel();
    }
    if (!m_opened) {

        // show content
        setOpen(true);

        m_animation = SlideAnimation.slideIn(m_content.getElement(), new Command() {

            /**
             * @see com.google.gwt.user.client.Command#execute()
             */
            public void execute() {

                OpenEvent.fire(FieldSet.this, FieldSet.this);
            }
        }, m_animationDuration);
    } else {

        // hide content
        m_animation = SlideAnimation.slideOut(m_content.getElement(), new Command() {

            /**
             * @see com.google.gwt.user.client.Command#execute()
             */
            public void execute() {

                setOpen(false);
                CloseEvent.fire(FieldSet.this, FieldSet.this);
            }
        }, m_animationDuration);
    }
}

From source file:com.geocento.webapps.eobroker.common.client.widgets.material.MaterialSearch.java

License:Apache License

public MaterialSearch() {

    super(new TextBox());

    setType(InputType.SEARCH);//  w  w w.  j a  v a 2  s  .c om

    iconSearch.setLayoutPosition(Style.Position.ABSOLUTE);
    iconSearch.setLeft(10);
    insert(iconSearch, 0);

    iconLoading.setLayoutPosition(Style.Position.ABSOLUTE);
    iconLoading.setLeft(10);
    insert(iconLoading, 0);

    label.getElement().setAttribute("for", "search");
    add(label);

    add(iconClose);
    iconClose.addMouseDownHandler(mouseDownEvent -> CloseEvent.fire(MaterialSearch.this, getText()));

    // populate the lists of search result on search panel
    searchResult = new MaterialSearchResult();
    add(searchResult);
    addKeyUpHandler(new KeyUpHandler() {

        private Timer fetchTimer;
        private String currentText = "";

        @Override
        public void onKeyUp(KeyUpEvent event) {
            // Apply selected search
            switch (event.getNativeEvent().getKeyCode()) {
            case KeyCodes.KEY_ENTER: {
                if (getCurSel() == -1) {
                    hideListSearches();
                    presenter.textSelected(getText());
                } else {
                    MaterialLink selLink = getSelectedLink();
                    reset(selLink.getText());
                    selLink.fireEvent(new GwtEvent<ClickHandler>() {
                        @Override
                        public com.google.gwt.event.shared.GwtEvent.Type<ClickHandler> getAssociatedType() {
                            return ClickEvent.getType();
                        }

                        @Override
                        protected void dispatch(ClickHandler handler) {
                            handler.onClick(null);
                        }
                    });
                }
                event.stopPropagation();
            }
                break;
            case KeyCodes.KEY_DOWN: {
                int totalItems = searchResult.getWidgetCount();
                if (curSel >= totalItems) {
                    setCurSel(getCurSel());
                    applyHighlightedItem((MaterialLink) searchResult.getWidget(curSel - 1));
                } else {
                    setCurSel(getCurSel() + 1);
                    applyHighlightedItem((MaterialLink) searchResult.getWidget(curSel));
                }
                event.stopPropagation();
            }
                break;
            case KeyCodes.KEY_UP: {
                if (curSel <= -1) {
                    setCurSel(-1);
                    applyHighlightedItem((MaterialLink) searchResult.getWidget(curSel));
                } else {
                    setCurSel(getCurSel() - 1);
                    applyHighlightedItem((MaterialLink) searchResult.getWidget(curSel));
                }
                event.stopPropagation();
            }
                break;
            default:
                if (fetchTimer != null) {
                    fetchTimer.cancel();
                    fetchTimer = null;
                }
                // create a timer to make sure we don't query too soon
                fetchTimer = new Timer() {

                    @Override
                    public void run() {
                        // make sure we don't refresh options if the text hasn't changed
                        String text = getText();
                        if (text.contentEquals(currentText)) {
                            return;
                        }
                        currentText = text;
                        presenter.textChanged(currentText);
                        fetchTimer = null;
                    }
                };
                // start the timer to make sure we waited long enough
                fetchTimer.schedule(300);
                break;
            }
        }
    });
    addCloseHandler(new CloseHandler<String>() {
        @Override
        public void onClose(CloseEvent<String> event) {
            reset("");
            presenter.textSelected("");
            setFocus(true);
        }
    });
    addBlurHandler(new BlurHandler() {
        @Override
        public void onBlur(BlurEvent event) {
            new Timer() {

                @Override
                public void run() {
                    hideListSearches();
                }
            }.schedule(300);
        }
    });
    hideListSearches();
    setLoading(false);
}

From source file:com.github.gwt.user.client.ui.DateTimePicker.java

License:Apache License

private void bindCloseOnSelectMinute() {
    minutesPanel.addSelectionHandler(new SelectionHandler<Date>() {
        private Date previousSelected;

        @Override/* w  w w.  ja v a 2  s.com*/
        public void onSelection(final SelectionEvent<Date> event) {
            setSelectedValue(event.getSelectedItem());

            if (!secondClickToDrill) {
                CloseEvent.fire(DateTimePicker.this, DateTimePicker.this);
            } else if (previousSelected != null && previousSelected.equals(event.getSelectedItem())) {
                CloseEvent.fire(DateTimePicker.this, DateTimePicker.this);
            }
            previousSelected = event.getSelectedItem();
        }
    });
}

From source file:com.github.gwtbootstrap.client.ui.base.AlertBase.java

License:Apache License

/**
 * This method is called immediately when the widget's close method is
 * executed.//from w w w. j av  a2 s . c om
 */
// TODO: Get the source element from javascript
protected void onClose() {
    CloseEvent.fire(this, this);
}

From source file:com.google.code.guidatv.client.ui.widget.imported.DisclosurePanel.java

License:Apache License

private void fireEvent() {
    if (isOpen) {
        OpenEvent.fire(this, this);
    } else {//from  w  ww . java2 s .  co  m
        CloseEvent.fire(this, this);
    }
}

From source file:com.google.gerrit.client.admin.GroupReferenceBox.java

License:Apache License

public GroupReferenceBox() {
    suggestions = new DefaultSuggestionDisplay();
    textBox = new NpTextBox();
    oracle = new AccountGroupSuggestOracle();
    suggestBox = new SuggestBox( //
            new RPCSuggestOracle(oracle), //
            textBox, //
            suggestions);// w ww .  j a v  a 2s .c  om
    initWidget(suggestBox);

    textBox.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            submitOnSelection = false;

            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                if (suggestions.isSuggestionListShowing()) {
                    submitOnSelection = true;
                } else {
                    SelectionEvent.fire(GroupReferenceBox.this, getValue());
                }
            }
        }
    });
    suggestBox.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
                suggestBox.setText("");
                CloseEvent.fire(GroupReferenceBox.this, GroupReferenceBox.this);
            }
        }
    });
    suggestBox.addSelectionHandler(new SelectionHandler<Suggestion>() {
        @Override
        public void onSelection(SelectionEvent<Suggestion> event) {
            if (submitOnSelection) {
                submitOnSelection = false;
                SelectionEvent.fire(GroupReferenceBox.this, getValue());
            }
        }
    });
}

From source file:com.google.gerrit.client.ui.RemoteSuggestBox.java

License:Apache License

public RemoteSuggestBox(SuggestOracle oracle) {
    remoteSuggestOracle = new RemoteSuggestOracle(oracle);
    remoteSuggestOracle.setServeSuggestions(true);
    display = new DefaultSuggestionDisplay();

    textBox = new HintTextBox();
    textBox.addKeyDownHandler(new KeyDownHandler() {
        @Override/*from ww w.ja v a 2 s  .c o  m*/
        public void onKeyDown(KeyDownEvent e) {
            submitOnSelection = false;
            if (e.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
                CloseEvent.fire(RemoteSuggestBox.this, RemoteSuggestBox.this);
            } else if (e.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                if (display.isSuggestionListShowing()) {
                    if (textBox.getValue().equals(remoteSuggestOracle.getLast())) {
                        submitOnSelection = true;
                    } else {
                        display.hideSuggestions();
                    }
                } else {
                    SelectionEvent.fire(RemoteSuggestBox.this, getText());
                }
            }
        }
    });

    suggestBox = new SuggestBox(remoteSuggestOracle, textBox, display);
    suggestBox.addSelectionHandler(new SelectionHandler<Suggestion>() {
        @Override
        public void onSelection(SelectionEvent<Suggestion> event) {
            if (submitOnSelection) {
                SelectionEvent.fire(RemoteSuggestBox.this, getText());
            }
            remoteSuggestOracle.cancelOutstandingRequest();
            display.hideSuggestions();
        }
    });
    initWidget(suggestBox);
}

From source file:com.googlecode.mgwt.ui.client.widget.menu.swipe.SwipeMenu.java

License:Apache License

private void closeMenu() {
    CloseEvent.fire(this, this);
    wrap.addStyleName(appearance.css().closed());
    wrap.removeStyleName(appearance.css().opened());
    CssUtil.resetTransForm(wrap.getElement());
}

From source file:com.kk_electronic.kkportal.core.rpc.Comet.java

License:Open Source License

/**
 * Closes the current connection//from  w w w.  j a va2 s .  co m
 */
@Override
public void close() {
    //TODO: Abort tx and rx
    status = WebSocketStatus.CLOSED;
    rxUrl = null;
    CloseEvent.fire(this, this);
}