Java Code Examples for com.google.gwt.core.client.JsonUtils#unsafeEval()
The following examples show how to use
com.google.gwt.core.client.JsonUtils#unsafeEval() .
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: MaterialCandleStick.java From gwt-material-demo with Apache License 2.0 | 6 votes |
private void draw() { JsArrayMixed dataArray = JsonUtils.unsafeEval("[['Mon',20,28,38,45],['Tue',31,38,55,66],['Wed',50,55,77,80],['Thu',77,77,66,50],['Fri',68,66,22,15]]"); // Prepare the data DataTable dataTable = ChartHelper.arrayToDataTable(dataArray, true); // Set options CandlestickChartOptions options = CandlestickChartOptions.create(); BackgroundColor bgColor = BackgroundColor.create(); bgColor.setStroke("#2196f3"); bgColor.setFill("#90caf9"); bgColor.setStrokeWidth(2); options.setLegend(Legend.create(LegendPosition.NONE)); options.setFallingColor(bgColor); options.setRisingColor(bgColor); // Draw the chart chart.draw(dataTable, options); }
Example 2
Source File: MaterialComboCharts.java From gwt-material-demo with Apache License 2.0 | 6 votes |
private void draw() { JsArrayMixed dataArray = JsonUtils .unsafeEval("[['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua Guinea', 'Rwanda', 'Average'],['2004/05', 165, 938, 522, 998, 450, 614.6],['2005/06', 135, 1120, 599, 1268, 288, 682],['2006/07', 157, 1167, 587, 807, 397, 623],['2007/08', 139, 1110, 615, 968, 215, 609.4],['2008/09', 136, 691, 629, 1026, 366, 569.6]]"); // Prepare the data DataTable dataTable = ChartHelper.arrayToDataTable(dataArray); // Set options ComboChartOptions options = ComboChartOptions.create(); options.setFontName("Tahoma"); options.setTitle("Monthly Coffee Production by Country"); options.setHAxis(HAxis.create("Cups")); options.setVAxis(VAxis.create("Month")); options.setSeriesType(SeriesType.BARS); ComboChartSeries series = ComboChartSeries.create(); series.setType(SeriesType.LINE); options.setSeries(5, series); // Draw the chart chart.draw(dataTable, options); }
Example 3
Source File: AnnotationRegistry.java From swellrt with Apache License 2.0 | 6 votes |
/** * Define a new custom annotation. * * @param key annotation's name * @param cssClass a css class for the html container * @param cssStyle css styles for the html container */ public static void define(String key, String cssClass, JavaScriptObject cssStyleObj) throws SEditorException { if (key == null || key.startsWith("paragraph") || key.startsWith(AnnotationConstants.STYLE_PREFIX) || CANONICAL_KEYS.getString(key) != null) { throw new SEditorException("Not valid annotation name"); } JsoView cssStyles = null; if (JsEditorUtils.isString(cssStyleObj)) { JavaScriptObject o = JsonUtils.unsafeEval(cssStyleObj.toString()); if (o != null) { cssStyles = JsoView.as(o); } } else { cssStyles = JsoView.as(cssStyleObj); } AnnotationController annotation = new AnnotationController(key); store.put(key, annotation); UserAnnotationHandler.register(Editor.ROOT_REGISTRIES, key, cssClass, cssStyles, annotation.getTextEventHanlder(), annotation.getTextEventHanlder(), annotation.getTextEventHanlder()); }
Example 4
Source File: OverlaySerdes.java From requestor with Apache License 2.0 | 4 votes |
protected <T extends JavaScriptObject> T eval(String response) { return USE_SAFE_EVAL ? JsonUtils.<T>safeEval(response) : JsonUtils.<T>unsafeEval(response); }
Example 5
Source File: JsonObjectSerdes.java From requestor with Apache License 2.0 | 2 votes |
/** * Performs evaluation of serialized response obeying the #useSafeEval configuration. * <p/> * * If #useSafeEval is {@code true} then the eval is performed using {@link JsonUtils#safeEval}, * otherwise then content will be loosely evaluated by {@link JsonUtils#unsafeEval}. * * @param response The serialized content * * @return The converted JavaScriptObject */ protected JavaScriptObject eval(String response) { return useSafeEval() ? JsonUtils.safeEval(response) : JsonUtils.unsafeEval(response); }