Example usage for com.google.gwt.json.client JSONNumber JSONNumber

List of usage examples for com.google.gwt.json.client JSONNumber JSONNumber

Introduction

In this page you can find the example usage for com.google.gwt.json.client JSONNumber JSONNumber.

Prototype

public JSONNumber(double value) 

Source Link

Document

Creates a new JSONNumber from the double value.

Usage

From source file:org.kaaproject.kaa.server.admin.client.mvp.activity.LogAppendersActivity.java

License:Apache License

@Override
protected void onCustomRowAction(final RowActionEvent<String> event) {
    Integer appenderId = Integer.valueOf(event.getClickedId());
    final int action = event.getAction();
    AsyncCallback<LogAppenderDto> callback = new AsyncCallback<LogAppenderDto>() {
        @Override// w  w  w .  j  a  v a  2  s .  c o m
        public void onFailure(Throwable caught) {
            Utils.handleException(caught, listView);
        }

        @Override
        public void onSuccess(LogAppenderDto key) {
            JSONObject json = (JSONObject) JSONParser.parseLenient(key.getJsonConfiguration());
            json.put("minLogSchemaVersion", new JSONNumber(key.getMinLogSchemaVersion()));
            json.put("maxLogSchemaVersion", new JSONNumber(key.getMaxLogSchemaVersion()));
            json.put("pluginTypeName", new JSONString(key.getPluginTypeName()));
            json.put("pluginClassName", new JSONString(key.getPluginClassName()));
            JSONArray headersStructure = new JSONArray();
            for (LogHeaderStructureDto header : key.getHeaderStructure()) {
                headersStructure.set(headersStructure.size(), new JSONString(header.getValue()));
            }
            json.put("headerStructure", headersStructure);

            ServletHelper.downloadJsonFile(json.toString(), key.getPluginTypeName() + ".json");
        }
    };

    switch (action) {
    case KaaRowAction.DOWNLOAD_SCHEMA:
        KaaAdmin.getDataSource().getLogAppender(String.valueOf(appenderId), callback);
        break;
    default:
        break;
    }
}

From source file:org.kie.workbench.common.dmn.client.editors.types.common.ScrollHelper.java

License:Apache License

JavaScriptObject property(final String key, final double value) {
    final JSONObject jsonObject = new JSONObject();
    jsonObject.put(key, new JSONNumber(value));
    return jsonObject.getJavaScriptObject();
}

From source file:org.kie.workbench.common.dmn.client.editors.types.listview.common.KebabMenuInitializer.java

License:Apache License

JSONObject bodyDropdownProperties(final JQueryEvent e) {
    final JSONObject jsonObject = makeJsonObject();
    jsonObject.put("position", new JSONString("absolute"));
    jsonObject.put("zIndex", new JSONNumber(1051)); // Bootstrap modal z-index value is 1050
    jsonObject.put("left", new JSONNumber(offsetLeft(e.target)));
    jsonObject.put("top", new JSONNumber(offsetTop(e.target)));
    return jsonObject;
}

From source file:org.kie.workbench.common.dmn.client.editors.types.listview.common.MenuInitializer.java

License:Apache License

JSONObject bodyDropdownProperties(final JQueryEvent e) {
    final JSONObject jsonObject = makeJsonObject();
    jsonObject.put("position", new JSONString("absolute"));
    jsonObject.put("left", new JSONNumber(offsetLeft(e.target)));
    jsonObject.put("top", new JSONNumber(offsetTop(e.target)));
    jsonObject.put("z-index", new JSONNumber(1051)); // The '.modal.in' CSS has a z-index of '1050', so the dropdown element needs a higher value.
    return jsonObject;
}

From source file:org.kie.workbench.common.dmn.client.editors.types.listview.constraint.common.typed.day.time.DayTimeValueConverter.java

License:Apache License

JSONValue number(final Integer value) {
    return Objects.isNull(value) ? JSONNull.getInstance() : new JSONNumber(value);
}

From source file:org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListView.java

License:Apache License

private JavaScriptObject property(final String key, final double value) {
    final JSONObject jsonObject = new JSONObject();
    jsonObject.put(key, new JSONNumber(value));
    return jsonObject.getJavaScriptObject();
}

From source file:org.lirazs.gbackbone.client.core.data.Options.java

License:Apache License

@Override
public JSONValue toJsonValue() {
    JSONObject j = new JSONObject();

    for (String key : this.keySet()) {
        JSONValue value = null;/*from  w  w w.j  av a  2 s. com*/
        Object o = this.get(key);

        if (o == null)
            value = JSONNull.getInstance();
        else if (o instanceof Integer)
            value = new JSONNumber((Integer) o);
        else if (o instanceof Float)
            value = new JSONNumber((Float) o);
        else if (o instanceof Double)
            value = new JSONNumber((Double) o);
        else if (o instanceof Long)
            value = new JSONNumber((Long) o);
        else if (o instanceof Short)
            value = new JSONNumber((Short) o);
        else if (o instanceof Byte)
            value = new JSONNumber((Byte) o);
        else if (o instanceof Boolean) {
            value = JSONBoolean.getInstance((Boolean) o);
        } else if (o instanceof String) {
            value = new JSONString((String) o);
        } else if (o instanceof Options) {
            value = ((Options) o).toJsonObject();
        }
        j.put(key, value);
    }
    return j;
}

From source file:org.moxieapps.gwt.highcharts.client.ColorAxis.java

License:Apache License

/**
 * Convenience method for adding stops along the 'colorAxis' of a chart.  Note that this method is intended for
 * use in conjunction with the {@link ColorAxis#setStops(com.google.gwt.json.client.JSONArray...)} method.
 * @param stopNumber The relative position in the gradient.
 * @param stopColor The color/*  www  .  jav a  2  s  .  c  o m*/
 * @return A tuple containing the stop number and stop color.
 * @see ColorAxis#setStops(com.google.gwt.json.client.JSONArray...)
 */
public static JSONArray addStop(Number stopNumber, String stopColor) {
    JSONArray stop = new JSONArray();
    stop.set(0, new JSONNumber(stopNumber.doubleValue()));
    stop.set(1, new JSONString(stopColor));
    return stop;
}

From source file:org.moxieapps.gwt.highcharts.client.plotOptions.BaseProportionalPlotOptions.java

License:Apache License

/**
 * Convenience method for setting the 'center' option of the pie plot options
 * to pixel values.  Equivalent to:/*from   w  ww .jav a  2s.c om*/
 * <pre><code>
 *     piePlotOptions.setOption("center", new Number[] { 100, 120 });
 * </code></pre>
 * The center of the pie chart relative to the plot area (in pixels).  See the
 * {@link #setCenter(double, double)} method to set the center using percentages instead.
 * Defaults to 50%, 50%.
 *
 * @param x The horizontal center of the pie chart relative to the plot area (in pixels)
 * @param y The vertical center of the pie chart relative to the plot area (in pixels)
 * @return A reference to this {@link BaseProportionalPlotOptions} instance for convenient method chaining.
 */
public T setCenter(int x, int y) {
    JSONArray center = new JSONArray();
    center.set(0, new JSONNumber(x));
    center.set(1, new JSONNumber(y));
    return this.setOption("center", center);
}

From source file:org.nightcode.gwt.selectio.client.requestfactory.ItemRequestJson.java

License:Apache License

@Override
public Request<ItemPageProxy> getItems(final String query, final int start, final int length) {
    final JSONObject requestObject = new JSONObject();

    if (query != null) {
        requestObject.put("query", new JSONString(query));
    }//  w w  w  . ja va 2  s.c  o  m
    requestObject.put("start", new JSONNumber(start));
    requestObject.put("length", new JSONNumber(length));

    return new Request<ItemPageProxy>() {
        @Override
        public void fire(final Receiver<? super ItemPageProxy> receiver) {
            selectorRequestFactory.getRequestTransport().send(requestObject.toString(),
                    new RequestTransport.TransportReceiver() {
                        @Override
                        public void onTransportSuccess(String payload) {
                            ItemPageProxy itemPage = ItemPageJso.itemPageFromJson(payload);
                            itemPage.setQuery(query);
                            itemPage.setStart(start);
                            itemPage.setLength(length);
                            receiver.onSuccess(itemPage);
                        }

                        @Override
                        public void onTransportFailure(ServerFailure failure) {
                            receiver.onFailure(failure);
                        }
                    });
        }
    };
}