List of usage examples for com.google.gwt.json.client JSONNumber JSONNumber
public JSONNumber(double value)
From source file:com.openkm.frontend.client.util.JSONUtil.java
License:Open Source License
/** * toJson//from w ww.j a v a 2 s . c o m * */ public static JSONObject toJson(Object obj) { JSONObject json = new JSONObject(); if (obj instanceof GWTQueryParams) { GWTQueryParams params = (GWTQueryParams) obj; json.put("author", new JSONString(params.getAuthor())); json.put("keywords", new JSONString(params.getKeywords())); json.put("content", new JSONString(params.getContent())); json.put("name", new JSONString(params.getName())); json.put("path", new JSONString(URL.encodeQueryString(params.getPath()))); json.put("mimeType", new JSONString(params.getMimeType())); json.put("domain", new JSONNumber(params.getDomain())); json.put("mailFrom", new JSONString(params.getMailFrom())); json.put("mailTo", new JSONString(params.getMailTo())); json.put("mailSubject", new JSONString(params.getMailSubject())); json.put("categoryUuid", new JSONString(params.getCategoryUuid())); json.put("categoryPath", new JSONString(URL.encodeQueryString(params.getCategoryPath()))); json.put("operator", new JSONString(params.getOperator())); if (params.getLastModifiedFrom() != null) { json.put("lastModifiedFrom", new JSONString(ISO8601.formatBasic(params.getLastModifiedFrom()))); } if (params.getLastModifiedTo() != null) { json.put("lastModifiedTo", new JSONString(ISO8601.formatBasic(params.getLastModifiedTo()))); } if (!params.getProperties().isEmpty()) { JSONObject properties = new JSONObject(); for (String key : params.getProperties().keySet()) { GWTPropertyParams propertyParam = params.getProperties().get(key); JSONObject property = new JSONObject(); // Only is necessary groupName and value property.put("grpName", new JSONString(propertyParam.getGrpName())); property.put("value", new JSONString(propertyParam.getValue())); properties.put(key, property); } json.put("properties", properties); } } return json; }
From source file:com.ponysdk.core.terminal.instruction.PTInstruction.java
License:Apache License
public void put(final ClientToServerModel key, final int value) { put(key.toStringValue(), new JSONNumber(value)); }
From source file:com.ponysdk.core.terminal.instruction.PTInstruction.java
License:Apache License
public void put(final ClientToServerModel key, final double value) { put(key.toStringValue(), new JSONNumber(value)); }
From source file:com.ponysdk.core.terminal.ui.PTAddOn.java
License:Apache License
protected void doCreate(final ReaderBuffer buffer, final int objectId, final UIBuilder uiBuilder) { // ServerToClientModel.FACTORY final String signature = buffer.readBinaryModel().getStringValue(); final JavascriptAddOnFactory factory = getFactory(uiBuilder, signature); final JSONObject params = new JSONObject(); params.put("id", new JSONNumber(objectId)); final BinaryModel binaryModel = buffer.readBinaryModel(); if (ServerToClientModel.PADDON_CREATION == binaryModel.getModel()) params.put("args", binaryModel.getJsonObject()); else/*from w w w . ja v a 2s . co m*/ buffer.rewind(binaryModel); try { addOn = factory.newAddOn(params.getJavaScriptObject()); addOn.onInit(); } catch (final JavaScriptException e) { log.log(Level.SEVERE, "PTAddOn #" + getObjectID() + " (" + signature + ") " + e.getMessage(), e); } }
From source file:com.ponysdk.core.terminal.ui.PTAddOnComposite.java
License:Apache License
@Override protected void doCreate(final ReaderBuffer buffer, final int objectId, final UIBuilder uiBuilder) { // ServerToClientModel.FACTORY final String signature = buffer.readBinaryModel().getStringValue(); final JavascriptAddOnFactory factory = getFactory(uiBuilder, signature); final JSONObject params = new JSONObject(); params.put("id", new JSONNumber(objectId)); BinaryModel binaryModel = buffer.readBinaryModel(); if (ServerToClientModel.PADDON_CREATION == binaryModel.getModel()) { params.put("args", binaryModel.getJsonObject()); binaryModel = buffer.readBinaryModel(); }//from w w w . ja va 2 s . c o m final int widgetID = binaryModel.getIntValue(); final PTWidget<?> object = (PTWidget<?>) uiBuilder.getPTObject(widgetID); widget = object.uiObject; final Element element = widget.getElement(); params.put("widgetID", new JSONString(String.valueOf(widgetID))); params.put("widgetElement", new JSONObject(element)); widget.addAttachHandler(event -> { try { if (event.isAttached()) { addOn.onAttached(); flushPendingUpdates(); } else { addOn.onDetached(); } } catch (final JavaScriptException e) { log.log(Level.SEVERE, "PTAddOnComposite #" + getObjectID() + " (" + signature + ") " + e.getMessage(), e); } }); try { addOn = factory.newAddOn(params.getJavaScriptObject()); addOn.onInit(); if (widget.isAttached()) addOn.onAttached(); initialized = true; } catch (final JavaScriptException e) { log.log(Level.SEVERE, "PTAddOnComposite #" + getObjectID() + " (" + signature + ") " + e.getMessage(), e); } }
From source file:com.ponysdk.core.terminal.ui.PTPopupPanel.java
License:Apache License
@Override public void addHandler(final ReaderBuffer buffer, final HandlerModel handlerModel) { if (HandlerModel.HANDLER_POPUP_POSITION == handlerModel) { uiObject.setVisible(true);/*from ww w .j a v a 2s .com*/ uiObject.show(); Scheduler.get().scheduleDeferred(() -> { final PTInstruction eventInstruction = new PTInstruction(getObjectID()); final JSONArray widgetInfo = new JSONArray(); int i = 0; widgetInfo.set(i++, new JSONNumber(uiObject.getOffsetWidth())); widgetInfo.set(i++, new JSONNumber(uiObject.getOffsetHeight())); widgetInfo.set(i++, new JSONNumber(Window.getClientWidth())); widgetInfo.set(i++, new JSONNumber(Window.getClientHeight())); eventInstruction.put(ClientToServerModel.POPUP_POSITION, widgetInfo); uiBuilder.sendDataToServer(uiObject, eventInstruction); }); } else { super.addHandler(buffer, handlerModel); } }
From source file:com.ponysdk.core.terminal.ui.PTWidget.java
License:Apache License
protected void triggerMouseEvent(final DomHandlerType domHandlerType, final MouseEvent<?> event) { final PTInstruction eventInstruction = buildEventInstruction(domHandlerType); final JSONArray eventInfo = new JSONArray(); eventInfo.set(0, new JSONNumber(event.getClientX())); eventInfo.set(1, new JSONNumber(event.getClientY())); eventInfo.set(2, new JSONNumber(event.getX())); eventInfo.set(3, new JSONNumber(event.getY())); eventInfo.set(4, new JSONNumber(event.getNativeButton())); eventInfo.set(5, JSONBoolean.getInstance(event.isControlKeyDown())); eventInfo.set(6, JSONBoolean.getInstance(event.isAltKeyDown())); eventInfo.set(7, JSONBoolean.getInstance(event.isShiftKeyDown())); eventInfo.set(8, JSONBoolean.getInstance(event.isMetaKeyDown())); eventInstruction.put(ClientToServerModel.EVENT_INFO, eventInfo); final JSONArray widgetInfo = new JSONArray(); widgetInfo.set(0, new JSONNumber(uiObject.getAbsoluteLeft())); widgetInfo.set(1, new JSONNumber(uiObject.getAbsoluteTop())); widgetInfo.set(2, new JSONNumber(uiObject.getOffsetHeight())); widgetInfo.set(3, new JSONNumber(uiObject.getOffsetWidth())); eventInstruction.put(ClientToServerModel.WIDGET_POSITION, widgetInfo); uiBuilder.sendDataToServer(uiObject, eventInstruction); preventOrStopEvent(event);//from w ww . j a v a2s . com }
From source file:com.ponysdk.core.terminal.ui.PTWidget.java
License:Apache License
private void triggerMouseWhellEvent(final DomHandlerType domHandlerType, final MouseWheelEvent event) { final PTInstruction eventInstruction = buildEventInstruction(domHandlerType); final JSONArray eventInfo = new JSONArray(); eventInfo.set(0, new JSONNumber(event.getClientX())); eventInfo.set(1, new JSONNumber(event.getClientY())); eventInfo.set(2, new JSONNumber(event.getX())); eventInfo.set(3, new JSONNumber(event.getY())); eventInfo.set(4, new JSONNumber(event.getNativeButton())); eventInfo.set(5, new JSONNumber(event.getDeltaY())); eventInstruction.put(ClientToServerModel.EVENT_INFO, eventInfo); final JSONArray widgetInfo = new JSONArray(); widgetInfo.set(0, new JSONNumber(uiObject.getAbsoluteLeft())); widgetInfo.set(1, new JSONNumber(uiObject.getAbsoluteTop())); widgetInfo.set(2, new JSONNumber(uiObject.getOffsetHeight())); widgetInfo.set(3, new JSONNumber(uiObject.getOffsetWidth())); eventInstruction.put(ClientToServerModel.WIDGET_POSITION, widgetInfo); uiBuilder.sendDataToServer(uiObject, eventInstruction); preventOrStopEvent(event);/*from w w w . j a v a 2 s . co m*/ }
From source file:com.rcharts.client.category.Axis.java
License:Apache License
/** * Make grid lines over axis and hides them. Must be called * 1)for invert axis: before axis line drawn * 2)for regular axis: after axis line drawn *//*from ww w . j a v a 2 s . c om*/ public void makeGridLines() { Style gridStyle = null; /* if(!isValueAxis() || gridLineLength == 0){ return; } */ //Iterator over label for line charts Iterator<String> labelIt = tickLabels.iterator(); double gridHoverWidth = (axisLength - 20) / tickLabels.size(); Style hoverStyle = new Style(); if (!isValueAxis && (chart instanceof LineChart || chart instanceof ComboChart) && chart.getTheme() == Theme.HIGHCHARTS) { hoverStyle.put("stroke-width", new JSONNumber(gridHoverWidth)); hoverStyle.put("stroke", new JSONString("#ffffff")); hoverStyle.put("opacity", new JSONNumber(0)); } Iterator<Point> it = tickPoints.iterator(); while (it.hasNext()) { Point p = it.next(); PathBuilder pb = new PathBuilder(); if (!isInvert) { pb.M(p.getX(), p.getY()); } if (orient == Orientation.HORIZONTAL) { //do vertical line i.e increment y if (isInvert) { pb.M(p.getX(), p.getY() - gridLineLength); } pb.l(0, gridLineLength); gridStyle = RaphaelFactory.get().getVGridLineStyle(); } else { if (isInvert) { pb.M(p.getX() - gridLineLength, p.getY()); } pb.l(gridLineLength, 0); gridStyle = RaphaelFactory.get().getHGridLineStyle(); } Path tickPath = chart.new Path(pb); tickPath.attr(gridStyle); gridLinesSet.push(tickPath); axisList.add(tickPath); set.push(tickPath); if (!isValueAxis && (chart instanceof LineChart || chart instanceof ComboChart) && chart.getTheme() == Theme.HIGHCHARTS) { if (labelIt.hasNext()) { String cat = labelIt.next(); Path hoverPath = chart.new Path(pb); hoverPath.attr(hoverStyle); hoverPath.toBack(); gridMap.put(cat, hoverPath); set.push(hoverPath); axisList.add(hoverPath); } } } if (!showGridLine || !isValueAxis) { gridLinesSet.attr("opacity", 0); } if (isValueAxis) { gridLinesSet.attr("opacity", 1); } if (!isInvert) { updateTickPoints(gridLineLength); } }
From source file:com.rcharts.client.styles.Style.java
License:Apache License
public void setStrokeWidth(double strokeWidth) { style.put(Keys.STROKE_WIDTH, new JSONNumber(strokeWidth)); }