Search in sources :

Example 21 with Widget

use of com.google.gwt.user.client.ui.Widget in project rstudio by rstudio.

the class FocusTransitionManager method register.

private void register(final Widget widget) {
    if (registration_.contains(widget))
        return;
    registration_.add(widget);
    widget.addDomHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) {
                boolean forward = !event.isShiftKeyDown();
                Widget target = get(widget, forward);
                if (target == null)
                    return;
                if (target instanceof CanFocus) {
                    event.stopPropagation();
                    event.preventDefault();
                    focus((CanFocus) target);
                } else if (target instanceof Focusable) {
                    event.stopPropagation();
                    event.preventDefault();
                    focus((Focusable) target);
                }
            }
        }
    }, KeyDownEvent.getType());
}
Also used : KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) CanFocus(org.rstudio.core.client.widget.CanFocus) Widget(com.google.gwt.user.client.ui.Widget) Focusable(com.google.gwt.user.client.ui.Focusable)

Example 22 with Widget

use of com.google.gwt.user.client.ui.Widget in project rstudio by rstudio.

the class AutoHidingSplitLayoutPanel method setWidgetHidden.

@Override
public void setWidgetHidden(Widget widget, boolean hidden) {
    LayoutData layoutData = (LayoutData) widget.getLayoutData();
    if (layoutData.direction != Direction.CENTER) {
        Widget splitter = getAssociatedSplitter(widget);
        super.setWidgetHidden(splitter, hidden);
    }
    super.setWidgetHidden(widget, hidden);
}
Also used : Widget(com.google.gwt.user.client.ui.Widget)

Example 23 with Widget

use of com.google.gwt.user.client.ui.Widget in project gwt-test-utils by gwt-test-utils.

the class UiBinderInvocationHandler method addHandlers.

@SuppressWarnings("unchecked")
private <H extends EventHandler> void addHandlers(Object owner) {
    Map<Method, UiHandler> uiHandlerMethods = GwtReflectionUtils.getAnnotatedMethod(owner.getClass(), UiHandler.class);
    for (Map.Entry<Method, UiHandler> entry : uiHandlerMethods.entrySet()) {
        for (String uiFieldName : entry.getValue().value()) {
            Widget uiField = GwtReflectionUtils.getPrivateFieldValue(owner, uiFieldName);
            GwtEvent.Type<H> eventType = (GwtEvent.Type<H>) getEventType(entry.getKey());
            H handler = (H) createHandler(uiField, entry.getKey(), owner);
            if (eventType instanceof DomEvent.Type) {
                uiField.addDomHandler(handler, (DomEvent.Type<H>) eventType);
            } else {
                if (uiField instanceof HasValueChangeHandlers && handler instanceof ValueChangeHandler) {
                    ((HasValueChangeHandlers<Object>) uiField).addValueChangeHandler((ValueChangeHandler<Object>) handler);
                } else {
                    uiField.addHandler(handler, eventType);
                }
            }
        }
    }
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) Method(java.lang.reflect.Method) UiHandler(com.google.gwt.uibinder.client.UiHandler) GwtEvent(com.google.gwt.event.shared.GwtEvent) HashMap(java.util.HashMap) Map(java.util.Map) HasValueChangeHandlers(com.google.gwt.event.logical.shared.HasValueChangeHandlers) DomEvent(com.google.gwt.event.dom.client.DomEvent)

Example 24 with Widget

use of com.google.gwt.user.client.ui.Widget in project gwt-test-utils by gwt-test-utils.

the class ButtonTest method click_ClickListener.

@Test
public void click_ClickListener() {
    // Given
    b.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            b.setHTML("clicked");
        }
    });
    // Preconditions
    assertThat(b.getHTML()).isEqualTo("");
    // When
    b.click();
    // Then
    assertThat(b.getHTML()).isEqualTo("clicked");
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) ClickListener(com.google.gwt.user.client.ui.ClickListener) Test(org.junit.Test)

Example 25 with Widget

use of com.google.gwt.user.client.ui.Widget in project gerrit by GerritCodeReview.

the class LinkMenuBar method add.

public void add(final Widget i) {
    if (body.getWidgetCount() > 0) {
        final Widget p = body.getWidget(body.getWidgetCount() - 1);
        p.addStyleName(Gerrit.RESOURCES.css().linkMenuItemNotLast());
    }
    body.add(i);
}
Also used : Widget(com.google.gwt.user.client.ui.Widget)

Aggregations

Widget (com.google.gwt.user.client.ui.Widget)56 FixedRatioWidget (org.rstudio.core.client.widget.FixedRatioWidget)5 PreWidget (org.rstudio.core.client.widget.PreWidget)5 Command (com.google.gwt.user.client.Command)4 HTML (com.google.gwt.user.client.ui.HTML)4 Timer (com.google.gwt.user.client.Timer)3 IsWidget (com.google.gwt.user.client.ui.IsWidget)3 SimplePanel (com.google.gwt.user.client.ui.SimplePanel)3 Test (org.junit.Test)3 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 JsArrayString (com.google.gwt.core.client.JsArrayString)2 Element (com.google.gwt.dom.client.Element)2 Style (com.google.gwt.dom.client.Style)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 JSONString (com.google.gwt.json.client.JSONString)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 Label (com.google.gwt.user.client.ui.Label)2 TabPanel (com.google.gwt.user.client.ui.TabPanel)2