List of usage examples for com.google.gwt.core.client JavaScriptObject createObject
public static native JavaScriptObject createObject() ;
From source file:com.googlecode.gwtphonegap.client.util.JSNIHelper.java
License:Apache License
/** * Convinient method to map from a map to a javascript object * <p/>/*ww w . j a v a 2 s .com*/ * <br> * <code> * Example:<br> * map.put("id", "1234");<br> * map.put("name", "Ronny Bubke");<br> * becomes:<br> * { id : "1234", name : "Ronny Bubke" }<br> * </code> * * @param map * @return */ public static JavaScriptObject createObject(Map<String, ?> map) { JavaScriptObject object = JavaScriptObject.createObject(); for (Entry<String, ?> entry : map.entrySet()) { enhanceObject(object, entry.getKey(), entry.getValue()); } return object; }
From source file:com.googlecode.gwtphonegap.collection.client.JsLightMap.java
License:Apache License
public JsLightMap() { this(JavaScriptObject.createObject()); }
From source file:com.gwtext.client.core.Margins.java
License:Open Source License
/** * Create a new Margins instance./* w w w.j a va 2s. c o m*/ * * @param top the top margin * @param left the left margin * @param right the right margin * @param bottom the bottom margin */ public Margins(int top, int left, int right, int bottom) { this.top = top; this.left = left; this.right = right; this.bottom = bottom; jsObj = JavaScriptObject.createObject(); JavaScriptObjectHelper.setAttribute(jsObj, "top", top); JavaScriptObjectHelper.setAttribute(jsObj, "left", left); JavaScriptObjectHelper.setAttribute(jsObj, "right", right); JavaScriptObjectHelper.setAttribute(jsObj, "bottom", bottom); }
From source file:com.gwtmobile.persistence.client.Persistence.java
License:Apache License
private static JavaScriptObject Map2AssociativeArray(Map<String, String> fields) { JavaScriptObject assoArray = JavaScriptObject.createObject(); for (Map.Entry<String, String> field : fields.entrySet()) { setAssoArray(assoArray, field.getKey(), field.getValue()); }/* w w w . j a v a 2 s . c om*/ return assoArray; }
From source file:com.imaginedreal.mgwt.trafficflow.client.AppEntryPoint.java
License:Apache License
private void start() { SuperDevModeUtil.showDevMode();//from w w w . j ava 2 s.com final ClientFactory clientFactory = new ClientFactoryImpl(); // Initialize and configure Google Analytics plugin final Analytics analytics = GWT.create(Analytics.class); analytics.initialize(); ((ClientFactoryImpl) clientFactory).setAnalytics(analytics); analytics.startTrackerWithId(Consts.ANALYTICS_TRACKING_ID); final PhoneGap phoneGap = GWT.create(PhoneGap.class); phoneGap.addHandler(new PhoneGapAvailableHandler() { @Override public void onPhoneGapAvailable(PhoneGapAvailableEvent event) { ((ClientFactoryImpl) clientFactory).setPhoneGap(phoneGap); buildDisplay(clientFactory, phoneGap); } }); phoneGap.addHandler(new PhoneGapTimeoutHandler() { @Override public void onPhoneGapTimeout(PhoneGapTimeoutEvent event) { Window.alert("Cannot load PhoneGap"); } }); phoneGap.initializePhoneGap(); if (Consts.ADS_ENABLED) { // Initialize and configure AdMob plugin final AdMob adMob = GWT.create(AdMob.class); adMob.initialize(); AdMobOptions options = (AdMobOptions) JavaScriptObject.createObject().cast(); options.setAdId(Consts.AD_UNIT_ID); options.setOffsetTopBar(true); options.setAutoShow(true); options.setPosition(AdPosition.BOTTOM_CENTER.getPosition()); adMob.createBanner(options); } }
From source file:com.kk_electronic.kkportal.core.rpc.SimpleEncoder.java
License:Open Source License
public String encode(List<Request> requests) { JsArray<JavaScriptObject> array = JsArray.createArray().cast(); for (Request request : requests) { JsonRpcRequest o = JavaScriptObject.createObject().cast(); o.setId(request.getId());/*from ww w .j av a2 s . co m*/ o.setMethod(request.getFeatureName() + "." + request.getMethod()); JsArrayMixed jsParams = JsonValueHelper.makeJSONArray(request.getParams()).isArray() .getJavaScriptObject().cast(); o.setParams(jsParams); array.push(o); } return new JSONArray(array).toString(); }
From source file:com.kk_electronic.kkportal.core.security.UserProvider.java
License:Open Source License
@Override public User get() { User user = JavaScriptObject.createObject().cast(); user.setUsername("Jes"); return user; }
From source file:com.objetdirect.tatami.client.grid.Cell.java
License:Open Source License
public JavaScriptObject toJSObject() { JavaScriptObject jsRepresentation = JavaScriptObject.createObject(); Set<String> cellAttributesKey = attributes.keySet(); for (Iterator<String> iterator = cellAttributesKey.iterator(); iterator.hasNext();) { String cellAttributeKey = iterator.next(); Object cellAttributeValue = attributes.get(cellAttributeKey); if (cellAttributeValue instanceof String) { addAttribute(jsRepresentation, cellAttributeKey, (String) cellAttributeValue); } else if (cellAttributeValue instanceof Number) { addAttribute(jsRepresentation, cellAttributeKey, ((Number) cellAttributeValue).floatValue()); } else if (cellAttributeValue instanceof Boolean) { addAttribute(jsRepresentation, cellAttributeKey, ((Boolean) cellAttributeValue).booleanValue()); } else {/* w w w .j a v a2 s . c o m*/ addAttribute(jsRepresentation, cellAttributeKey, JSHelper.convertObjectToJSObject(cellAttributeValue)); } } if (editor != null) { jsRepresentation = setCellEditor(jsRepresentation, editor.getDojoGridEditorName(), Boolean.TRUE); Map<String, ? extends Object> editorAttrs = editor.getAttributes(); if (editorAttrs != null) { Set<String> editorProperties = editorAttrs.keySet(); for (String attr : editorProperties) { addAttribute(jsRepresentation, attr, JSHelper.convertObjectToJSObject(editor.getAttributes().get(attr))); } } } return jsRepresentation; }
From source file:com.qtitools.player.client.Player.java
License:Open Source License
/** * Return interface to get assessment session time *//*from ww w .j a v a 2 s .com*/ public JavaScriptObject getAssessmentSessionReport() { IAssessmentReport report = deliveryEngine.report(); int assessmentSessionTime = report.getAssessmentSessionTime(); int score = (int) (report.getAssessmentResult().getScore() - report.getAssessmentResult().getMinPoints()); int max = (int) (report.getAssessmentResult().getMaxPoints() - report.getAssessmentResult().getMinPoints()); int itemIndex = report.getCurrentItemIndex(); int itemsCount = report.getItemsCount(); int itemsVisited = report.getItemsVisitedCount(); boolean passed = report.getAssessmentMasteryPassed(); String lessonStatus = "INCOMPLETE"; if (itemsVisited == itemsCount) { if (max == 0) lessonStatus = "COMPLETED"; else if (passed) lessonStatus = "PASSED"; else lessonStatus = "FAILED"; } JavaScriptObject jsItemScores = JSArrayUtils.createArray(report.getItemsResults().length); JavaScriptObject jsItemScoreMaxs = JSArrayUtils.createArray(report.getItemsResults().length); for (int i = 0; i < report.getItemsResults().length; i++) { jsItemScores = JSArrayUtils.fillArray(jsItemScores, i, (int) (report.getItemsResults()[i].getScore() - report.getItemsResults()[i].getMinPoints())); jsItemScoreMaxs = JSArrayUtils.fillArray(jsItemScoreMaxs, i, (int) (report.getItemsResults()[i].getMaxPoints() - report.getItemsResults()[i].getMinPoints())); } JavaScriptObject jsMistakes = JSArrayUtils.createArray(itemsCount); for (int i = 0; i < itemsCount; i++) jsMistakes = JSArrayUtils.fillArray(jsMistakes, i, report.getItemsMistakes()[i]); JavaScriptObject jsChecks = JSArrayUtils.createArray(itemsCount); for (int i = 0; i < itemsCount; i++) jsChecks = JSArrayUtils.fillArray(jsChecks, i, report.getItemsChecks()[i]); JavaScriptObject jsTimes = JSArrayUtils.createArray(itemsCount); for (int i = 0; i < itemsCount; i++) jsTimes = JSArrayUtils.fillArray(jsTimes, i, report.getItemsTimes()[i]); JavaScriptObject obj = JavaScriptObject.createObject(); initAssessmentSessionReportJS(obj, assessmentSessionTime, score, max, lessonStatus, itemIndex + 1, itemsCount, jsItemScores, jsItemScoreMaxs, jsMistakes, jsChecks, jsTimes, report.getTotalMistakes(), report.getTotalChecks()); return obj; }
From source file:com.qtitools.player.client.Player.java
License:Open Source License
public JavaScriptObject getEngineMode() { JavaScriptObject obj = JavaScriptObject.createObject(); String es = deliveryEngine.getEngineMode(); initEngineModeJS(obj, es); return obj; }