com.google.gwt.user.client.ui.Composite Java Examples

The following examples show how to use com.google.gwt.user.client.ui.Composite. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuestionFieldGroup.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
protected void lookForChildren(Widget parent) {
    Widget result = parent;
    if (parent instanceof Composite) {
        Composite composite = (Composite) parent;
        result = composite.asWidget();
    }

    if (result instanceof HasWidgets) {
        for (Widget widget : ((HasWidgets) result)) {
            if (widget instanceof QuestionItem) {
                ((QuestionItem) widget).setAllowBlank(false);
                questions.add((QuestionItem) widget);
            } else {
                lookForChildren(widget);
            }
        }
    }
}
 
Example #2
Source File: GwtMockitoTest.java    From gwtmockito with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldCallNativeMethodsWithoutFailures() throws Exception {
  class SomeComposite extends Composite {
    public SomeComposite() {
      // initWidget relies on native calls
      initWidget(mock(Widget.class));
    }
    private native boolean runNativeMethod() /*-{
      return true;
    }-*/;
  }

  // Note that the result will be false even though the native method should return true - we
  // can't run the actual javascript and have to return a default value
  assertFalse(new SomeComposite().runNativeMethod());
}
 
Example #3
Source File: Modal.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Widget getContainerWidget() {
	if (containerWidget == null) {
		if (getParent() instanceof HasWidgets) {
			containerWidget = this;
		} else if (getParent() instanceof Composite) {
			containerWidget = getParent();
		}
	}
	return containerWidget;
}
 
Example #4
Source File: GwtMockitoTestRunner.java    From gwtmockito with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a collection of classes whose non-abstract methods should always be replaced with
 * no-ops. By default, this list includes {@link Composite}, {@link DOM} {@link UIObject},
 * {@link Widget}, {@link Image}, and most subclasses of {@link Panel}. It will also include any
 * classes specified via the {@link WithClassesToStub} annotation on the test class. This makes
 * it much safer to test code that uses or extends these types.
 * <p>
 * This list can be customized via {@link WithClassesToStub} or by defining a new test runner
 * extending {@link GwtMockitoTestRunner} and overriding this method. This allows users to
 * explicitly stub out particular classes that are causing problems in tests. If you override this
 * method, you will probably want to retain the classes that are stubbed here by doing something
 * like this:
 *
 * <pre>
 * &#064;Override
 * protected Collection&lt;Class&lt;?&gt;&gt; getClassesToStub() {
 *   Collection&lt;Class&lt;?&gt;&gt; classes = super.getClassesToStub();
 *   classes.add(MyBaseWidget.class);
 *   return classes;
 * }
 * </pre>
 *
 * @return a collection of classes whose methods should be stubbed with no-ops while running tests
 */
protected Collection<Class<?>> getClassesToStub() {
  Collection<Class<?>> classes = new LinkedList<Class<?>>();
  classes.add(Composite.class);
  classes.add(DOM.class);
  classes.add(UIObject.class);
  classes.add(Widget.class);

  classes.add(DataGrid.class);
  classes.add(HTMLTable.class);
  classes.add(Image.class);

  classes.add(AbsolutePanel.class);
  classes.add(CellList.class);
  classes.add(CellPanel.class);
  classes.add(CellTable.class);
  classes.add(ComplexPanel.class);
  classes.add(DeckLayoutPanel.class);
  classes.add(DeckPanel.class);
  classes.add(DecoratorPanel.class);
  classes.add(DockLayoutPanel.class);
  classes.add(DockPanel.class);
  classes.add(FlowPanel.class);
  classes.add(FocusPanel.class);
  classes.add(HorizontalPanel.class);
  classes.add(HTMLPanel.class);
  classes.add(LayoutPanel.class);
  classes.add(Panel.class);
  classes.add(PopupPanel.class);
  classes.add(RenderablePanel.class);
  classes.add(ResizeLayoutPanel.class);
  classes.add(SimpleLayoutPanel.class);
  classes.add(SimplePanel.class);
  classes.add(SplitLayoutPanel.class);
  classes.add(StackPanel.class);
  classes.add(VerticalPanel.class);
  classes.add(ValueListBox.class);

  WithClassesToStub annotation = unitTestClass.getAnnotation(WithClassesToStub.class);
  if (annotation != null) {
    classes.addAll(Arrays.asList(annotation.value()));
  }

  return classes;
}
 
Example #5
Source File: GwtMockitoWidgetBaseClassesTest.java    From gwtmockito with Apache License 2.0 4 votes vote down vote up
@Test
public void testUiObjects() throws Exception {
  invokeAllAccessibleMethods(new Widget() {});
  invokeAllAccessibleMethods(new UIObject() {});
  invokeAllAccessibleMethods(new Composite() {});
}
 
Example #6
Source File: ChoiceStrategy.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
NavigationHandler(InteractionUnit interactionUnit, Map<Integer, QName> childUnits, Composite widget) {
    this.interactionUnit = interactionUnit;
    this.childUnits = childUnits;
    this.widget = widget;
}