Example usage for com.google.gwt.core.client JavaScriptObject createArray

List of usage examples for com.google.gwt.core.client JavaScriptObject createArray

Introduction

In this page you can find the example usage for com.google.gwt.core.client JavaScriptObject createArray.

Prototype

public static native JavaScriptObject createArray() ;

Source Link

Document

Returns a new array.

Usage

From source file:com.cgxlib.xq.client.js.JsObjectArray.java

License:Apache License

public static <T> JsObjectArray<T> create() {
    return JavaScriptObject.createArray().cast();
}

From source file:com.codenvy.ide.ext.web.css.editor.CssPartialParser.java

License:Open Source License

/**
 * Checks whether the passed-in string matches the format of the special value
 * type in question. If it does, it returns a list of proposals that should be
 * shown to the user for this query./*from ww  w. ja  va 2  s .  c om*/
 *
 * @param maybeSpecialValue
 * @param specialValueType
 *         a special value type, e.g., <integer>. This method
 *         can be called with a specialValueType value that is not one of those
 *         special values, in which case the method returns an empty array.
 * @return an array of strings corresponding to the proposals that should be
 *         shown for the special value type
 */
public JsArrayString checkIfSpecialValueAndGetSpecialValueProposals(String maybeSpecialValue,
        String specialValueType) {

    JsArrayString specialValues = getSpecialValues(maybeSpecialValue);
    for (int i = 0; i < specialValues.length(); i++) {
        if (specialValues.get(i).equals(specialValueType)) {
            return specialValueProposals.<Jso>cast().getJsObjectField(specialValueType).cast();
        }
    }
    return JavaScriptObject.createArray().cast();
}

From source file:com.codenvy.ide.ext.web.css.editor.CssPartialParser.java

License:Open Source License

private JsArrayString getValuesAndSpecialValues(JsArrayString existingValues) {
    JsArrayString valuesAndSpecialValuesAfter = JavaScriptObject.createArray().cast();
    for (int i = 0; i < existingValues.length(); i++) {
        String value = existingValues.get(i);
        JsArrayString specialValues = getSpecialValues(value);
        if (specialValues.length() == 0) {
            valuesAndSpecialValuesAfter.push(value);
        }/*from   www.jav  a 2  s  .  c  o  m*/
        for (int j = 0; j < specialValues.length(); j++) {
            valuesAndSpecialValuesAfter.push(specialValues.get(j));
        }
    }
    return valuesAndSpecialValuesAfter;
}

From source file:com.codenvy.ide.ext.web.css.editor.CssPartialParser.java

License:Open Source License

private JsArrayString getSpecialValues(String value) {
    JsArrayString specialValues = JavaScriptObject.createArray().cast();
    if (value.isEmpty()) {
        return specialValues;
    }/* w  w  w.  ja  v  a2 s. c  o m*/
    if (checkIfAngle(value)) {
        specialValues.push(ANGLE);
    }
    if (checkIfInteger(value)) {
        specialValues.push(INTEGER);
    }
    if (checkIfNumber(value)) {
        specialValues.push(NUMBER);
    }
    if (checkIfUri(value)) {
        specialValues.push(URI);
    }
    if (checkIfPercentage(value)) {
        specialValues.push(PERCENTAGE);
    }
    if (checkIfString(value)) {
        specialValues.push(STRING);
    }
    if (checkIfCounter(value)) {
        specialValues.push(COUNTER);
    }
    if (checkIfIdentifier(value)) {
        specialValues.push(IDENTIFIER);
    }
    if (checkIfFrequency(value)) {
        specialValues.push(FREQUENCY);
    }
    if (checkIfColor(value)) {
        specialValues.push(COLOR);
    }
    if (checkIfLength(value)) {
        specialValues.push(LENGTH);
    }
    if (checkIfShape(value)) {
        specialValues.push(SHAPE);
    }
    return specialValues;
}

From source file:com.dawg6.web.dhcalc.client.GearPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
public GearPanel() {

    HorizontalPanel panel = new HorizontalPanel();
    initWidget(panel);//w w  w  . ja  v  a  2s  .c o m

    VerticalPanel verticalPanel_1 = new VerticalPanel();
    panel.add(verticalPanel_1);

    CaptionPanel captionPanel = new CaptionPanel("Current Items");
    verticalPanel_1.add(captionPanel);

    FlexTable table = new FlexTable();
    captionPanel.add(table);

    CaptionPanel cptnpnlNewPanel = new CaptionPanel("Saved Items");
    panel.add(cptnpnlNewPanel);

    VerticalPanel verticalPanel = new VerticalPanel();
    cptnpnlNewPanel.setContentWidget(verticalPanel);
    verticalPanel.setSize("5cm", "3cm");

    savedItems = new ListBox();
    verticalPanel.add(savedItems);
    savedItems.setVisibleItemCount(20);
    savedItems.setWidth("100%");

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSpacing(5);
    verticalPanel.add(horizontalPanel);

    Button btnNewButton = new Button("New button");
    btnNewButton.setText("Rename...");
    horizontalPanel.add(btnNewButton);

    btnNewButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            renameItem();
        }
    });

    Button btnNewButton_1 = new Button("New button");
    btnNewButton_1.setText("Delete");
    horizontalPanel.add(btnNewButton_1);

    btnNewButton_1.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            deleteItem();
        }
    });

    int row = 0;

    for (Slot slot : Slot.values())
        if (!slot.isCube()) {
            final Slot thisSlot = slot;

            Label label = new Label(slot.name());
            label.addStyleName("boldText");
            table.setWidget(row, 0, label);

            Anchor status = new Anchor("unloaded");
            status.setTarget("_blank");
            status.setHref("javascript:void(0);");
            table.setWidget(row, 1, status);
            labels.put(slot, status);
            status.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    event.preventDefault();
                    clickItem(thisSlot);

                }
            });

            Button saveButton = new Button("save");
            table.setWidget(row, 2, saveButton);
            saveButton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    saveSlot(thisSlot);
                }
            });

            Button replaceButton = new Button("replace");
            table.setWidget(row, 3, replaceButton);
            replaceButton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    replaceSlot(thisSlot);
                }
            });

            Button clearButton = new Button("clear");
            table.setWidget(row, 4, clearButton);
            clearButton.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    clearSlot(thisSlot);
                }
            });

            row++;
        }

    Storage storage = getStorage();

    if (storage != null) {
        String data = storage.getItem(SAVED_ITEMS);
        JsoArray<Entry> list = null;

        if (data != null) {
            list = JsonUtils.safeEval(data);
        } else {
            list = (JsoArray<Entry>) JavaScriptObject.createArray();
        }

        for (int i = 0; i < list.length(); i++) {
            Entry e = list.get(i);
            savedItems.addItem(e.getName(), e.getItem());
        }

    }

    setVisible(false);
}

From source file:com.dawg6.web.dhcalc.client.GearPanel.java

License:Open Source License

private JsoArray<Entry> removeItem(JsoArray<Entry> list, String name, String item) {

    @SuppressWarnings("unchecked")
    JsoArray<Entry> copy = (JsoArray<Entry>) JavaScriptObject.createArray();

    for (int n = 0; n < list.length(); n++) {
        Entry e = list.get(n);/*from w w  w .jav a2  s  . c o m*/

        if (!name.equals(e.getName()) || !item.equals(e.getItem()))
            copy.push(e);
    }

    return copy;
}

From source file:com.dawg6.web.dhcalc.client.GearPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
private JsoArray<Entry> getSavedItems() {
    Storage storage = getStorage();/*from w w  w .ja  v  a  2  s .co  m*/

    if (storage != null) {
        String data = storage.getItem(SAVED_ITEMS);
        JsoArray<Entry> list = null;

        if (data != null) {
            list = JsonUtils.safeEval(data);
        } else {
            list = (JsoArray<Entry>) JavaScriptObject.createArray();
        }

        return list;

    } else {
        return (JsoArray<Entry>) JavaScriptObject.createArray();
    }
}

From source file:com.edgenius.wiki.gwt.client.editor.MCEInsertTableDialog.java

License:Open Source License

@Override
protected void okEvent() {
    int row;/*from ww w .  j a v  a2  s. c o  m*/
    int col;
    String borderColor = "", bgColor = "", borderWidth = "", cellpadding = "", cellspacing = "", clz;
    StringBuilder styleBuf = new StringBuilder();
    String hasTitleB = "false";
    if (asGrid.getValue()) {
        row = NumberUtil.toInt(gridRows.getText(), -1);
        col = NumberUtil.toInt(gridCols.getText(), -1);
        if (row <= 0 || col <= 0) {
            Window.alert(Msg.consts.error_input_number_only());
            return;
        }
        styleBuf.append("border-width:0px;width:100%;");
        //!!!please note: this size has same value in MceInsertTableMacro.java, please keep consist.
        cellpadding = "5";
        cellspacing = "5";
        clz = "macroGrid";
    } else {
        clz = "macroTable";
        row = NumberUtil.toInt(rows.getText(), -1);
        col = NumberUtil.toInt(cols.getText(), -1);
        if (row <= 0 || col <= 0) {
            Window.alert(Msg.consts.error_input_number_only());
            return;
        }
        hasTitleB = Boolean.valueOf(hasTitle.getValue()).toString();
        int borderN = NumberUtil.toInt(border.getText(), -1);
        if (borderN == -1) {
            border.setText("0");
            borderN = 0;
        }
        //according to TinyMCE, style string is for creating table, hidden is for update use 
        //although style=border-color is useless as it must put into td/th level,but it is useful to 
        //get back this value when editing table properties
        if (!SharedConstants.TABLE_BORDER_DEFAULT_COLOR.equalsIgnoreCase(borderPicker.getColor())) {
            borderColor = borderPicker.getColor();
            styleBuf.append("border-color:").append(borderColor);
        }
        if (!SharedConstants.TABLE_BG_DEFAULT_COLOR.equalsIgnoreCase(bkPicker.getColor())) {
            //only background color is not white.
            if (styleBuf.length() > 0)
                styleBuf.append(";");

            bgColor = bkPicker.getColor();
            styleBuf.append("background-color:").append(bgColor);
        }
        if (!StringUtil.isBlank(width)) {
            if (styleBuf.length() > 0)
                styleBuf.append(";");
            styleBuf.append("width:").append(width);
        }
        if (!StringUtil.isBlank(height)) {
            if (styleBuf.length() > 0)
                styleBuf.append(";");
            styleBuf.append("height:").append(height);
        }

        //border also pass to client even it is default size, this makes "1px solid #121212" valid 
        borderWidth = borderN + "px";
        if (borderN != DEFAULT_BORDER_SIZE) {
            if (styleBuf.length() > 0)
                styleBuf.append(";");

            styleBuf.append("border-width:").append(borderWidth);
        }
    }
    //Original design is use form.elements['name'].value to retrieve values. But fuck IE, it does work:
    //http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/5144115ec715ce1a/78507fc52fab2429?lnk=gst&q=setName+ie#78507fc52fab2429
    //It means pure javascript can not get value by name. So I collect them into list then pass it to javascript. Fuck IE again.
    JsArrayString input = (JsArrayString) JavaScriptObject.createArray();
    input.set(0, String.valueOf(row));
    input.set(1, String.valueOf(col));
    input.set(2, bgColor);
    input.set(3, borderColor);
    input.set(4, hasTitleB);
    input.set(5, borderWidth);
    input.set(6, styleBuf.toString());
    input.set(7, cellpadding);
    input.set(8, cellspacing);
    input.set(9, clz);

    tiny.restoreEditorBookmark();
    if (update) {
        updateTable(input);
    } else {
        //insert table
        insertTable(input);
    }
    close();

}

From source file:com.edgenius.wiki.gwt.client.editor.MCEMergeCellsDialog.java

License:Open Source License

@Override
protected void okEvent() {
    int row = NumberUtil.toInt(rowBox.getText(), -1);
    int col = NumberUtil.toInt(colBox.getText(), -1);
    if (row <= 0 || col <= 0) {
        Window.alert(Msg.consts.error_input_number_only());
        return;/*from www  .j a  v a  2s .  c o  m*/
    }

    JsArrayString input = (JsArrayString) JavaScriptObject.createArray();
    input.set(0, rowBox.getText());
    input.set(1, colBox.getText());

    mergeCells(input);
    close();

}

From source file:com.emitrom.ti4j.mobile.client.ui.Gradient.java

License:Apache License

/**
 * Set the colors of this gradient using an array of colors with equal amount
 * offsets and colors.//from  w ww  .jav a 2  s .  c  o  m
 * @param colors      The array of color strings
 * @param offsets      The offsets
 */
public final void setColors(String[] colors, double[] offsets) {
    if (colors.length != offsets.length) {
        return; //Misfit between colors and offsets array length
    }
    @SuppressWarnings("unchecked")
    JsArray<JavaScriptObject> c = (JsArray<JavaScriptObject>) JavaScriptObject.createArray();
    c.setLength(colors.length);
    for (int i = 0; i < colors.length; ++i) {
        JavaScriptObject newColor = createColorOffset(colors[i], offsets[i]);
        c.set(i, newColor);
    }
    setColors(c);
}