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);
}
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);
}
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_;
}
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);
}
});
}
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);
}
}
});
}
Aggregations