List of usage examples for com.google.gwt.json.client JSONNumber JSONNumber
public JSONNumber(double value)
From source file:com.audata.client.search.SearchPanel.java
License:Open Source License
public void onClick(Widget sender) { /*/*from ww w . j a v a2s . c om*/ * When the add button is pressed */ if (sender == this.add) { if (this.field1 != null && this.field1.isValid()) { String disName = this.fieldName.getText(); String fieldName = (String) this.currentField.get("FieldName"); Boolean isUDF = (Boolean) this.currentField.get("isUDF"); String operator = ""; if (this.and.isChecked()) { operator = "and"; } else { operator = "or"; } String value1 = ""; String disValue1 = ""; if (this.field1.type == FieldTypes.TYPE_KEYWORD) { disValue1 = this.field1.getValue(); value1 = this.field1.getText(); } else { if (this.field1.type == FieldTypes.TYPE_STRING) { disValue1 = this.field1.getText(); value1 = this.field1.getText(); //value1.replaceAll("\\*", "%"); if ((value1.indexOf("%") < 0) && (value1.indexOf("*") < 0)) { value1 = "%" + value1 + "%"; } } else { disValue1 = this.field1.getText(); value1 = this.field1.getText(); } } if (this.field2 != null && this.field2.getText().length() != 0 && this.field2.isValid()) { String value2 = this.field2.getText(); String disValue2 = this.field2.getText(); Criteria crit = new Criteria(fieldName, disName, isUDF.booleanValue(), value1, disValue1, value2, disValue2, operator); this.searchTerms.add(crit); } else { Criteria crit = new Criteria(fieldName, disName, isUDF.booleanValue(), value1, disValue1, operator); this.searchTerms.add(crit); } } this.paintCriteria(); } /* * When the clear button is pressed */ if (sender == this.clear) { this.criteria.clear(); this.searchTerms.clear(); return; } /* * When the search button is pressed */ if (sender == this.search) { if (this.searchTerms.size() > 0) { JSONArray criteria = new JSONArray(); for (int i = 0; i < this.searchTerms.size(); i++) { Criteria c = (Criteria) this.searchTerms.get(i); String sterms = c.getSearchString(); if (i == 0) { int pos = sterms.indexOf(" "); sterms = sterms.substring(pos + 1); } criteria.set(i, new JSONString(sterms)); } JSONArray params = new JSONArray(); params.set(0, criteria); params.set(1, new JSONNumber(0)); params.set(2, JSONBoolean.getInstance(false)); AuDoc.jsonCall.asyncPost2("search.complexsearch", params, new SearchResponseHandler(this.audoc, SearchResponseHandler.TYPE_FULL, params)); AuDoc.state.setItem("Search", this.searchTerms); } } /* * When the save button is pressed */ if (sender == this.save) { //open a save search dialog if (this.searchTerms.size() > 0) { SavedSearchDialog s = new SavedSearchDialog(this.searchTerms); s.show(); } return; } }
From source file:com.audata.client.trays.TrayClickListener.java
License:Open Source License
public void onClick(Widget sender) { JSONArray params = new JSONArray(); params.set(0, new JSONString(this.uuid)); params.set(1, new JSONNumber(0)); params.set(2, JSONBoolean.getInstance(false)); AuDoc.jsonCall.asyncPost2("trays.getItems", params, new ItemResponseListener(this.audoc, this.uuid, this.name)); }
From source file:com.blockwithme.util.client.webworkers.impl.AbstractWebWorkerImpl.java
License:Apache License
@Override public final void postMessage(final String channel, final double value) { final JSONObject message = new JSONObject(); message.put("value", new JSONNumber(value)); postMessage(channel, message);// w w w . j ava2 s . c om }
From source file:com.blockwithme.util.client.webworkers.impl.AbstractWebWorkerImpl.java
License:Apache License
@Override public final void postMessage(final String channel, final long value) { final JSONObject message = new JSONObject(); if ((value <= SystemUtils.MAX_DOUBLE_INT_VALUE) && (value >= SystemUtils.MIN_DOUBLE_INT_VALUE)) { message.put("value", new JSONNumber(value)); } else {//from ww w . jav a 2s . com message.put("value", new JSONString("0x" + Long.toHexString(value))); } postMessage(channel, message); }
From source file:com.blockwithme.util.client.webworkers.thread.impl.WebWorkerLogHandler.java
License:Apache License
@Override public void publish(final LogRecord record) { if (!isLoggable(record)) { return;/*from ww w . j a v a 2 s . c om*/ } final Level level = record.getLevel(); final String loggerName = record.getLoggerName(); final String message = record.getMessage(); final long millis = record.getMillis(); final Throwable thrown = record.getThrown(); final JSONObject msg = new JSONObject(); if (level != null) { msg.put("level", new JSONString(level.toString())); } if (loggerName != null) { msg.put("loggerName", new JSONString(loggerName)); } if (message != null) { msg.put("message", new JSONString(message)); } if (millis != 0) { msg.put("millis", new JSONNumber(millis)); } if (thrown != null) { msg.put("thrown_type", new JSONString(thrown.getClass().getName())); final String thrownMessage = thrown.getMessage(); if (thrownMessage != null) { msg.put("thrown_msg", new JSONString(thrownMessage)); } // Forget about the Stack trace ... } worker.postMessage("java.util.logging", msg); }
From source file:com.brazoft.foundation.gwt.client.json.JSON.java
License:Apache License
public static JSONCollection<Number> asNumberCollection() { return new JSONCollection<Number>() { @Override//ww w .j av a2s. co m JSONValue toJSONValue(Number value) { return new JSONNumber(value.doubleValue()); } @Override Number toValue(JSONValue value) { return value.isNumber().doubleValue(); } }; }
From source file:com.brazoft.foundation.gwt.client.json.JSONObject.java
License:Apache License
public JSONObject put(String key, Number value) { this.wrapped.put(key, new JSONNumber(value.doubleValue())); return this; }
From source file:com.chap.links.client.GraphDemo3_offline.java
License:Apache License
/** * This is the entry point method.// w w w . j a v a 2 s . c o m */ public void onModuleLoad() { DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy-MM-dd"); JSONArray dataA = new JSONArray(); JSONArray dataB = new JSONArray(); // create data Date d = dtf.parse("2012-08-23"); int n = 200; // number of datapoints for (int i = 0; i < n; i++) { JSONObject pointA = new JSONObject(); pointA.put("date", new JSONNumber(d.getTime())); pointA.put("value", new JSONNumber(customFunctionA(i))); dataA.set(i, pointA); JSONObject pointB = new JSONObject(); pointB.put("date", new JSONNumber(d.getTime())); pointB.put("value", new JSONNumber(customFunctionB(i))); dataB.set(i, pointB); d.setTime(d.getTime() + 1000 * 60); // steps of one minute } JSONObject dataSetA = new JSONObject(); dataSetA.put("label", new JSONString("Function A")); dataSetA.put("data", dataA); JSONObject dataSetB = new JSONObject(); dataSetB.put("label", new JSONString("Function B")); dataSetB.put("data", dataB); Graph.Options options = Graph.Options.create(); options.setHeight("400px"); options.setLineStyle(Graph.Options.LINESTYLE.DOT, 1); options.setLineColor("blue", 1); options.setLineLegend(false, 0); JSONArray data = new JSONArray(); data.set(0, dataSetA); data.set(1, dataSetB); // create the graph, with data and options chart = new Graph(data.getJavaScriptObject(), options); RootPanel.get("mygraph").add(chart); }
From source file:com.data2semantics.yasgui.client.settings.Settings.java
License:Open Source License
public void setSelectedTabNumber(int selectedTabNumber) { put(SettingKeys.SELECTED_TAB_NUMBER, new JSONNumber(selectedTabNumber)); }
From source file:com.dawg6.web.dhcalc.client.JsonUtil.java
License:Open Source License
public static JSONObject toJSONObject(Hero hero) { JSONObject obj = new JSONObject(); obj.put("name", new JSONString(hero.name)); obj.put("id", new JSONNumber(hero.id)); obj.put("level", new JSONNumber(hero.level)); obj.put("paragonLevel", new JSONNumber(hero.paragonLevel)); obj.put("lastUpdated", new JSONNumber(hero.lastUpdated)); obj.put("hardcore", JSONBoolean.getInstance(hero.hardcore)); obj.put("seasonal", JSONBoolean.getInstance(hero.seasonal)); obj.put("dead", JSONBoolean.getInstance(hero.dead)); obj.put("clazz", new JSONString(hero.clazz)); return obj;/*from w w w . j a va2 s. c o m*/ }