Java Code Examples for com.google.gwt.core.client.JsArrayString#push()

The following examples show how to use com.google.gwt.core.client.JsArrayString#push() . 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: MultipleSelect.java    From gwtbootstrap3-extras with Apache License 2.0 6 votes vote down vote up
@Override
protected void setSelectedValue(List<String> value) {
    if (isAttached()) {
        final JsArrayString arr = JavaScriptObject.createArray().cast();
        for (final String val : value) {
            arr.push(val);
        }
        setValue(getElement(), arr);
    } else {
        for (Entry<OptionElement, Option> entry : itemMap.entrySet()) {
            Option opt = entry.getValue();
            boolean selected = value.contains(opt.getValue());
            opt.setSelected(selected);
        }
    }
}
 
Example 2
Source File: AssetManager.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
public static JsArrayString getExtensionsToLoad() {
  JsArrayString result = JsArrayString.createArray().cast();
  if (INSTANCE != null) {
    for (String s : INSTANCE.extensions) {
      result.push(s);
    }
  }
  return result;
}
 
Example 3
Source File: ToolBarManager.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected JsArrayString extractOptions(ToolbarButton[] options) {
    JsArrayString jsOptions = JsArrayString.createArray().cast();
    for (ToolbarButton option : options) {
        jsOptions.push(option.getId());
    }
    return jsOptions;
}
 
Example 4
Source File: StringUtils.java    From bitcoin-transaction-explorer with MIT License 5 votes vote down vote up
public static String join(final String delimiter, final String... text) {
  final JsArrayString jsa = JavaScriptObject.createArray().cast();

  for (int i = 0; i < text.length; i++) {
    jsa.push(text[i]);
  }

  return jsa.join(delimiter);
}
 
Example 5
Source File: JSHelper.java    From lumongo with Apache License 2.0 5 votes vote down vote up
public static JsArrayString toJsArray(Iterable<String> values) {
	JsArrayString array = JsArrayString.createArray().cast();
	for (String value : values) {
		array.push(value);
	}
	return array;
}
 
Example 6
Source File: JavaScriptObjectGwtTest.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
public void testRootJsArrayString() {
    JsArrayString array = JavaScriptObject.createArray().cast();
    array.push( "Hello" );
    array.push( "World" );
    array.push( "!" );

    String json = JsArrayStringMapper.INSTANCE.write( array );
    assertEquals( "[\"Hello\",\"World\",\"!\"]", json );

    array = JsArrayStringMapper.INSTANCE.read( json );
    assertEquals( 3, array.length() );
    assertEquals( "Hello", array.get( 0 ) );
    assertEquals( "World", array.get( 1 ) );
    assertEquals( "!", array.get( 2 ) );
}
 
Example 7
Source File: SliderBase.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
private void updateSliderForStringArray(SliderOption option, List<String> value) {
    JsArrayString array = JavaScriptObject.createArray().cast();
    for (String val : value) {
        array.push(val);
    }
    if (isAttached()) {
        setAttribute(getElement(), option.getName(), array);
        refresh();
    } else {
        String arrayStr = JsonUtils.stringify(array);
        attributeMixin.setAttribute(option.getDataAttribute(), arrayStr);
    }
}
 
Example 8
Source File: SummernoteBase.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
/**
 * Set customized font names.
 *
 * @param fontNames customized font names
 * @see SummernoteFontName
 */
public void setFontNames(final SummernoteFontName... fontNames) {
    JsArrayString array = JavaScriptObject.createArray().cast();
    for (SummernoteFontName fontName : fontNames) {
        array.push(fontName.getName());
    }
    options.setFontNames(array);
}
 
Example 9
Source File: SummernoteOptions.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new toolbar group.
 *
 * @param name
 * @param buttons
 * @return
 */
static final JsArrayMixed newToolbarGroup(String name, ToolbarButton... buttons) {
    JsArrayString arr = JavaScriptObject.createArray().cast();
    for (ToolbarButton button : buttons) {
        arr.push(button.getId());
    }
    return getToolbarGroup(name, arr);
}
 
Example 10
Source File: AreaChartData.java    From dashbuilder with Apache License 2.0 4 votes vote down vote up
public final void setLabels(String[] labels){
	JsArrayString array = JsArrayString.createArray().cast();
	for(String str : labels)
		array.push(str);
	setLabels(array);
}
 
Example 11
Source File: SListProxyHandler.java    From swellrt with Apache License 2.0 3 votes vote down vote up
@SuppressWarnings("rawtypes")
public Object ownKeys(SList target) throws SException {

  JsArrayString keys = JavaScriptObject.createArray().<JsArrayString>cast();

  for (int i = 0; i < target.size(); i++)
    keys.push(""+i);

  keys.push("length");

  return keys;
}
 
Example 12
Source File: SummernoteBase.java    From gwtbootstrap3-extras with Apache License 2.0 3 votes vote down vote up
/**
 * Set a list for Web fonts to be ignored. <br>
 * <br>
 * Summernote tests font in fontNames before adding them to drop-down.
 * This is problem while using Web fonts. It’s not easy picking up
 * nice time to check availabilities of Web fonts.
 *
 * @param fontNames
 */
public void setFontNamesIgnoreCheck(final SummernoteFontName... fontNames) {
    JsArrayString array = JavaScriptObject.createArray().cast();
    for (SummernoteFontName fontName : fontNames) {
        array.push(fontName.getName());
    }
    options.setFontNamesIgnoreCheck(array);
}