Search in sources :

Example 56 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler in project gwt-test-utils by gwt-test-utils.

the class GridTest method click_ClickHandler_NestedWidget.

@Test
public void click_ClickHandler_NestedWidget() {
    // Given
    // Grids must be sized explicitly, though they can be resized later.
    Grid g = new Grid(1, 1);
    Button b = new Button();
    b.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            clicked = !clicked;
        }
    });
    // add the button
    g.setWidget(0, 0, b);
    // Preconditions
    assertThat(clicked).isEqualTo(false);
    // When
    Browser.click(g.getWidget(0, 0));
    // Then
    assertThat(clicked).isEqualTo(true);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Test(org.junit.Test)

Example 57 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler in project rstudio by rstudio.

the class ConnectionsPane method installConnectionExplorerToolbar.

private void installConnectionExplorerToolbar(final Connection connection) {
    toolbar_.removeAllWidgets();
    toolbar_.addLeftWidget(backToConnectionsButton_);
    toolbar_.addLeftSeparator();
    toolbar_.addLeftWidget(connectMenuButton_);
    toolbar_.addLeftSeparator();
    if (isConnected(connection.getId()) && connection.getActions() != null) {
        // if we have any actions, create a toolbar button for each one
        for (int i = 0; i < connection.getActions().length(); i++) {
            final ConnectionAction action = connection.getActions().get(i);
            // use the supplied base64 icon data if it was provided
            Image icon = StringUtil.isNullOrEmpty(action.getIconData()) ? null : new Image(action.getIconData());
            // force to 20x18
            if (icon != null) {
                icon.setWidth("20px");
                icon.setHeight("18px");
            }
            ToolbarButton button = new ToolbarButton(action.getName(), // left image
            icon, // right image
            null, // invoke the action when the button is clicked
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    fireEvent(new ExecuteConnectionActionEvent(connection.getId(), action.getName()));
                }
            });
            // none was supplied
            if (StringUtil.isNullOrEmpty(action.getIconData()))
                button.getElement().getStyle().setMarginTop(-5, Unit.PX);
            toolbar_.addLeftWidget(button);
            toolbar_.addLeftSeparator();
        }
    }
    toolbar_.addLeftWidget(commands_.disconnectConnection().createToolbarButton());
    toolbar_.addRightWidget(commands_.removeConnection().createToolbarButton());
    toolbar_.addRightWidget(commands_.refreshConnection().createToolbarButton());
    connectionName_.setText(connection.getDisplayName());
    setSecondaryToolbarVisible(true);
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ExecuteConnectionActionEvent(org.rstudio.studio.client.workbench.views.connections.events.ExecuteConnectionActionEvent) ConnectionAction(org.rstudio.studio.client.workbench.views.connections.model.ConnectionAction) Image(com.google.gwt.user.client.ui.Image)

Example 58 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler in project rstudio by rstudio.

the class ConnectionsPane method createMainToolbar.

@Override
protected Toolbar createMainToolbar() {
    toolbar_ = new Toolbar();
    searchWidget_ = new SearchWidget(new SuggestOracle() {

        @Override
        public void requestSuggestions(Request request, Callback callback) {
            // no suggestions
            callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>()));
        }
    });
    backToConnectionsButton_ = new ToolbarButton(commands_.helpBack().getImageResource(), (ClickHandler) null);
    backToConnectionsButton_.setTitle("View all connections");
    // connect meuu
    ToolbarPopupMenu connectMenu = new ToolbarPopupMenu();
    connectMenu.addItem(connectMenuItem(commands_.historySendToConsole().getImageResource(), "R Console", ConnectionOptions.CONNECT_R_CONSOLE));
    connectMenu.addSeparator();
    connectMenu.addItem(connectMenuItem(commands_.newSourceDoc().getImageResource(), "New R Script", ConnectionOptions.CONNECT_NEW_R_SCRIPT));
    connectMenu.addItem(connectMenuItem(commands_.newRNotebook().getImageResource(), "New R Notebook", ConnectionOptions.CONNECT_NEW_R_NOTEBOOK));
    if (BrowseCap.INSTANCE.canCopyToClipboard()) {
        connectMenu.addSeparator();
        connectMenu.addItem(connectMenuItem(commands_.copyPlotToClipboard().getImageResource(), "Copy to Clipboard", ConnectionOptions.CONNECT_COPY_TO_CLIPBOARD));
    }
    connectMenuButton_ = new ToolbarButton("Connect", commands_.newConnection().getImageResource(), connectMenu);
    // manage connect menu visibility
    connectMenuButton_.setVisible(!commands_.disconnectConnection().isVisible());
    commands_.disconnectConnection().addVisibleChangedHandler(new VisibleChangedHandler() {

        @Override
        public void onVisibleChanged(AppCommand command) {
            connectMenuButton_.setVisible(!commands_.disconnectConnection().isVisible());
        }
    });
    installConnectionsToolbar();
    return toolbar_;
}
Also used : SearchWidget(org.rstudio.core.client.widget.SearchWidget) ArrayList(java.util.ArrayList) VisibleChangedHandler(org.rstudio.core.client.command.VisibleChangedHandler) ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) AppCommand(org.rstudio.core.client.command.AppCommand) AnimationCallback(com.google.gwt.layout.client.Layout.AnimationCallback) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) SuggestOracle(com.google.gwt.user.client.ui.SuggestOracle) Toolbar(org.rstudio.core.client.widget.Toolbar) SecondaryToolbar(org.rstudio.core.client.widget.SecondaryToolbar)

Example 59 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler in project rstudio by rstudio.

the class WorkbenchTabPanel method add.

private void add(final WorkbenchTab tab) {
    if (tab.isSuppressed())
        return;
    tabs_.add(tab);
    final Widget widget = tab.asWidget();
    tabPanel_.add(widget, tab.getTitle(), false, !tab.closeable() ? null : new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            tab.confirmClose(new Command() {

                @Override
                public void execute() {
                    tab.ensureHidden();
                }
            });
        }
    }, tab instanceof ProvidesBusy ? (ProvidesBusy) tab : null);
    tab.addEnsureVisibleHandler(new EnsureVisibleHandler() {

        public void onEnsureVisible(EnsureVisibleEvent event) {
            // First ensure that we ourselves are visible
            fireEvent(new EnsureVisibleEvent(event.getActivate()));
            if (event.getActivate())
                tabPanel_.selectTab(widget);
        }
    });
    tab.addEnsureHeightHandler(new EnsureHeightHandler() {

        @Override
        public void onEnsureHeight(EnsureHeightEvent event) {
            fireEvent(event);
        }
    });
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Command(com.google.gwt.user.client.Command) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Widget(com.google.gwt.user.client.ui.Widget) ProvidesBusy(org.rstudio.core.client.widget.model.ProvidesBusy)

Example 60 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler in project cuba by cuba-platform.

the class CubaCopyButtonExtensionConnector method extend.

@Override
protected void extend(ServerConnector target) {
    final VButton button = (VButton) ((ComponentConnector) target).getWidget();
    button.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (getState().copyTargetSelector != null) {
                boolean success = copyToClipboard(getState().copyTargetSelector.startsWith(".") ? getState().copyTargetSelector : "." + getState().copyTargetSelector);
                getRpcProxy(CubaCopyButtonExtensionServerRpc.class).copied(success);
            }
        }
    });
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) VButton(com.vaadin.client.ui.VButton) ClickEvent(com.google.gwt.event.dom.client.ClickEvent)

Aggregations

ClickHandler (com.google.gwt.event.dom.client.ClickHandler)447 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)437 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)168 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)143 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)129 ArrayList (java.util.ArrayList)128 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)110 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)79 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)48 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)47 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)41 PerunError (cz.metacentrum.perun.webgui.model.PerunError)38 HashMap (java.util.HashMap)37 Button (com.google.gwt.user.client.ui.Button)35 HTML (com.google.gwt.user.client.ui.HTML)34 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)33 Button (org.gwtbootstrap3.client.ui.Button)33 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)31 Image (com.google.gwt.user.client.ui.Image)30 Map (java.util.Map)27