Java Code Examples for com.google.gwt.core.shared.GWT#create()

The following examples show how to use com.google.gwt.core.shared.GWT#create() . 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: EventBinderTest.java    From gwteventbinder with Apache License 2.0 6 votes vote down vote up
public void testEventBinder() {
  EventBus eventBus = new SimpleEventBus();
  TestPresenter presenter = new TestPresenter();
  TestPresenter.MyEventBinder binder = GWT.create(TestPresenter.MyEventBinder.class);
  binder.bindEventHandlers(presenter, eventBus);

  // Test one event
  assertEquals(0, presenter.firstEventsHandled);
  eventBus.fireEvent(new FirstEvent());
  assertEquals(1, presenter.firstEventsHandled);
  assertEquals(1, presenter.firstEventsWithoutParameterHandled);
  assertEquals(1, presenter.firstAndSecondEventsHandled);

  // Test another event twice
  assertEquals(0, presenter.secondEventsHandled);
  eventBus.fireEvent(new SecondEvent());
  eventBus.fireEvent(new SecondEvent());
  assertEquals(2, presenter.secondEventsHandled);
  assertEquals(3, presenter.firstAndSecondEventsHandled);
}
 
Example 2
Source File: GwtMockitoTest.java    From gwtmockito with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldCreateFakeMessages() {
  SampleMessages messages = GWT.create(SampleMessages.class);

  assertEquals("noArgs", messages.noArgs());
  assertEquals("oneArg(somearg)", messages.oneArg("somearg"));
  assertEquals("twoArgs(onearg, twoarg)", messages.twoArgs("onearg", "twoarg"));
  assertEquals("safeHtml(arg)",
      messages.safeHtml(SafeHtmlUtils.fromTrustedString("arg")).asString());
  assertEquals("safeHtmlWithUri(argX, http://uriY)",
      messages.safeHtmlWithUri(SafeHtmlUtils.fromTrustedString("argX"),
          UriUtils.fromSafeConstant("http://uriY")).asString());
}
 
Example 3
Source File: GoogleAnalytics.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static GoogleAnalytics get(String account) {
	GoogleAnalytics ga = GoogleAnalytics.cache.get(account);
	if (ga == null) {
		ga = GWT.create(GoogleAnalytics.class);
		ga.initialize(account);
	}
	return ga;
}
 
Example 4
Source File: UriBuilderImpl.java    From requestor with Apache License 2.0 5 votes vote down vote up
@Override
public UriBuilder queryParam(String name, Object... values) throws IllegalArgumentException {
    assertNotNull(name, "Parameter name cannot be null.");
    assertNotNull(values, "Parameter values cannot be null.");

    if (queryParams == null) queryParams = GWT.create(Buckets.class);
    for (Object value : values) {
        queryParams.add(name, value != null ? value.toString() : null);
    }
    return this;
}
 
Example 5
Source File: GoogleAnalytics.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static GoogleAnalytics init(String account, String domain) {
	GoogleAnalytics ga = GoogleAnalytics.cache.get(account);
	if (ga == null) {
		ga = GWT.create(GoogleAnalytics.class);
		ga.initialize(account, domain);
	}
	return ga;
}
 
Example 6
Source File: VButtonValueRenderer.java    From vaadin-grid-util with MIT License 5 votes vote down vote up
/**
 * dirty hack - before we fire onClick we keep last clicked button because of the lost of RelativeElement during converting and the
 * issue of different layouts
 */
@Override
public FlowPanel createWidget() {
	FlowPanel buttonBar = GWT.create(FlowPanel.class);
	buttonBar.setStylePrimaryName("v-button-bar");

	int buttonsAdded = 0;
	if ((this.buttonBITM & VIEW_BITM) != 0) {
		buttonBar.add(genButton(VIEW_BITM));
		buttonsAdded++;
	}
	if ((this.buttonBITM & EDIT_BITM) != 0) {
		buttonBar.add(genButton(EDIT_BITM));
		buttonsAdded++;
	}
	if ((this.buttonBITM & DELETE_BITM) != 0) {
		buttonBar.add(genButton(DELETE_BITM));
		buttonsAdded++;
	}

	FlowPanel panel = GWT.create(FlowPanel.class);
	panel.setStylePrimaryName(STYLE_NAME);
	if (buttonsAdded == 3) {
		panel.addStyleName("three-buttons");
	} else if (buttonsAdded == 2) {
		panel.addStyleName("two-buttons");
	} else {
		panel.addStyleName("one-button");
	}
	panel.add(buttonBar);

	HTML valueLabel = GWT.create(HTML.class);
	valueLabel.setStylePrimaryName("v-cell-value");
	panel.add(valueLabel);
	return panel;
}
 
Example 7
Source File: GwtMockitoTest.java    From gwtmockito with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("unused")
public void testShouldAllowLayoutPanelSubclasses() {
  class MyPanel extends SimpleLayoutPanel {
    public MyPanel() {
      Label label = GWT.create(Label.class);
      add(label);
    }
  }
  new MyPanel();
}
 
Example 8
Source File: GwtMockitoTest.java    From gwtmockito with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldMockUiBinders() {
  class Owner {
    @UiField Element uiField;
  }
  Owner owner = new Owner();
  SomeUiBinder uiBinder = GWT.create(SomeUiBinder.class);
  uiBinder.createAndBindUi(owner);

  when(owner.uiField.getClassName()).thenReturn("class");
  Assert.assertEquals("class", owner.uiField.getClassName());
}
 
Example 9
Source File: GanttWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
protected BgGridElement createBackgroundGrid() {
    // implementation may be overridden via deferred binding. There is
    // BgGridSvgElement alternative available and also used by Chrome.
    BgGridElement grid = GWT.create(BgGridCssElement.class);
    grid.init(container, content);
    return grid;
}
 
Example 10
Source File: GanttWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
public GanttWidget() {

        setElement(DivElement.as(DOM.createDiv()));
        setStyleName(STYLE_GANTT);

        nowElement.setClassName(STYLE_NOW_ELEMENT);

        moveElement.setClassName(STYLE_MOVE_ELEMENT);
        // not visible by default
        moveElement.getStyle().setDisplay(Display.NONE);

        timeline = GWT.create(TimelineWidget.class);

        container = DivElement.as(DOM.createDiv());
        container.setClassName(STYLE_GANTT_CONTAINER);

        content = DivElement.as(DOM.createDiv());
        content.setClassName(STYLE_GANTT_CONTENT);
        container.appendChild(content);

        content.appendChild(moveElement);
        content.appendChild(nowElement);

        scrollbarSpacer = DivElement.as(DOM.createDiv());
        scrollbarSpacer.getStyle().setHeight(AbstractNativeScrollbar.getNativeScrollbarHeight(), Unit.PX);
        scrollbarSpacer.getStyle().setDisplay(Display.NONE);

        getElement().appendChild(timeline.getElement());
        getElement().appendChild(container);
        getElement().appendChild(scrollbarSpacer);
    }
 
Example 11
Source File: ImportBatchItemDataSource.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public DeleteTask(DataSource ds, String batchId, String[] pids,
        Callback<Record[], String> callback) {

    this.ds = ds;
    this.pids = pids;
    this.callback = callback;
    this.i18n = GWT.create(ClientMessages.class);
    this.batchId = batchId;
    this.deleted = new ArrayList<Record>(pids.length);
}
 
Example 12
Source File: RenamingClassNameTest.java    From gss.gwt with Apache License 2.0 5 votes vote down vote up
public void testObfuscationScope() {
  ScopeResource res = GWT.create(ScopeResource.class);

  assertEquals(res.scopeA().foo(), res.scopeA2().foo());
  assertNotSame(res.scopeA().foo(), res.scopeB().foo());
  assertNotSame(res.scopeB().foo(), res.scopeC().foo());
  assertNotSame(res.scopeA().foo(), res.scopeC().foo());
}
 
Example 13
Source File: CubaProgressBarRenderer.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public CubaProgressBarWidget createWidget() {
    CubaProgressBarWidget progressBar = GWT.create(CubaProgressBarWidget.class);
    progressBar.addStyleDependentName("static");
    progressBar.setClickThroughEnabled(true);
    return progressBar;
}
 
Example 14
Source File: ServiceProvider.java    From lumongo with Apache License 2.0 4 votes vote down vote up
private ServiceProvider() {
	uiQueryServiceAsync = GWT.create(UIQueryService.class);
}
 
Example 15
Source File: MyWidget.java    From pitest with Apache License 2.0 4 votes vote down vote up
public MyWidget() {
  dataProvider = GWT.create(DataProvider.class);
  doStuffInJavaScript();
  initWidget(UI_BINDER.createAndBindUi(this));
}
 
Example 16
Source File: RenamingClassNameTest.java    From gss.gwt with Apache License 2.0 4 votes vote down vote up
protected TestResources res() {
  return GWT.create(TestResources.class);
}
 
Example 17
Source File: ServerErrorHandler.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ServerErrorHandler() {
	super((ServerErrorConstants) GWT.create(ServerErrorConstants.class), ServerErrorHandler.SERVER_ERROR_PREFIX);
}
 
Example 18
Source File: ClientErrorHandler.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ClientErrorHandler() {
	super((ClientErrorConstants) GWT.create(ClientErrorConstants.class), ClientErrorHandler.CLIENT_ERROR_PREFIX);
}
 
Example 19
Source File: GwtMockitoRunnerlessTest.java    From gwtmockito with Apache License 2.0 4 votes vote down vote up
@Test(expected = UnsupportedOperationException.class)
public void shouldRestoreGwtCreateAfterTearDown() {
  GwtMockito.tearDown();
  GWT.create(SampleInterface.class);
}
 
Example 20
Source File: GwtMockitoTest.java    From gwtmockito with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
  GWT.create(SomeUiBinder.class); // Make sure GWT.create in setUp works
}