Example usage for com.google.gwt.json.client JSONValue isObject

List of usage examples for com.google.gwt.json.client JSONValue isObject

Introduction

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

Prototype

public JSONObject isObject() 

Source Link

Document

Returns non-null if this JSONValue is really a JSONObject.

Usage

From source file:org.celstec.arlearn2.portal.client.htmlDisplay.CrsDisplay.java

License:Open Source License

private void loadResponses(Long runId) {
    ResponseClient.getInstance().getResponses(runId, generalItemId, new JsonCallback() {
        public void onJsonReceived(JSONValue jsonValue) {
            if (jsonValue.isObject().containsKey("responses")) {
                JSONArray array = jsonValue.isObject().get("responses").isArray();
                for (int i = 0; i < array.size(); i++) {
                    Response response = new Response(array.get(i).isObject());

                    generalItemDisplay.handleResponse(response);

                }//w  w  w  .  j  a va2  s  .  c  o m
            }

        };
    });
}

From source file:org.celstec.arlearn2.portal.client.htmlDisplay.CrsDisplay.java

License:Open Source License

private void loadUsers(final long runId) {
    UserClient.getInstance().getUsers(runId, new JsonCallback() {
        public void onJsonReceived(JSONValue jsonValue) {

            if (jsonValue.isObject().containsKey("users")) {
                JSONArray array = jsonValue.isObject().get("users").isArray();
                for (int i = 0; i < array.size(); i++) {
                    JSONObject userObject = array.get(i).isObject();
                    Account account = new Account(userObject);
                    generalItemDisplay.putAccount(account);

                }/*from  ww w  .  j a v a 2  s .  co  m*/
            }
            loadResponses(runId);
            loadActions(runId);

        }
    });

}

From source file:org.celstec.arlearn2.portal.client.htmlDisplay.HtmlDisplayPage.java

License:Open Source License

public void loadPage() {
    loadParameters();/*  w  ww.  j  av  a2s.  com*/
    final HTMLPane htmlPane = new HTMLPane();
    htmlPane.setEvalScriptBlocks(true);
    GeneralItemsClient.getInstance().getGeneralItem(gameId, generalItemId, new JsonCallback() {
        public void onJsonReceived(JSONValue jsonValue) {
            System.out.println(jsonValue);
            String richText = jsonValue.isObject().get("richText").isString().stringValue();
            System.out.println("string " + richText);
            contents = richText;
            htmlPane.setContents(contents);
            //                RootPanel.get("htmlDisplay").getElement().setInnerHTML(contents);
        }
    });

    htmlPane.setWidth100();
    htmlPane.setHeight100();
    htmlPane.setShowEdges(true);

    NotificationSubscriber.getInstance().addNotificationHandler("org.celstec.arlearn2.beans.run.Message",
            new NotificationHandler() {

                @Override
                public void onNotification(JSONObject bean) {
                    hideElement(bean.get("title").isString().stringValue());
                    //                htmlPane.setContents(contents);
                }
            });

    RootPanel.get("htmlDisplay").add(htmlPane);
    loadUsers(runId);
}

From source file:org.celstec.arlearn2.portal.client.htmlDisplay.HtmlDisplayPage.java

License:Open Source License

private void loadUsers(long runId) {
    UserClient.getInstance().getUsers(runId, new JsonCallback() {
        public void onJsonReceived(JSONValue jsonValue) {
            System.out.println("users " + jsonValue);
            if (jsonValue.isObject().containsKey("users")) {
                JSONArray array = jsonValue.isObject().get("users").isArray();
                for (int i = 0; i < array.size(); i++) {
                    JSONObject userObject = array.get(i).isObject();
                    registerUser(userObject.get("localId").isString().stringValue(),
                            userObject.get("name").isString().stringValue(),
                            userObject.get("picture").isString().stringValue());
                }/*from   w  ww.  j ava  2s .  c  o m*/
                updateUsers();
            }

        }
    });

}

From source file:org.celstec.arlearn2.portal.client.RegisterForGame.java

License:Open Source License

public void loadPage() {
    String gameIdAsString = Window.Location.getParameter("gameId");
    gameId = Long.parseLong(gameIdAsString);
    AccountClient.getInstance().accountDetails(new JsonCallback() {
        @Override/*from  w  w w  .j  ava  2s . co  m*/
        public void onJsonReceived(JSONValue jsonValue) {
            myAccount = new Account(jsonValue.isObject());
            fullIdentifier = myAccount.getAccountType() + ":" + myAccount.getLocalId();
            System.out.println(myAccount.getJsonRep());
            proceedToRetrievingGame();
        }
    });

}

From source file:org.celstec.arlearn2.portal.client.RegisterForGame.java

License:Open Source License

private void proceedToRetrievingGame() {
    GameClient.getInstance().getGame(gameId, new JsonCallback() {
        @Override/*www  .  ja  va2s  . c  om*/
        public void onJsonReceived(JSONValue jsonValue) {
            game = new Game(jsonValue.isObject());
            System.out.println(game.getJsonRep());
            if (game.getRoles() != null && game.getRoles().length != 0) {
                RoleWindow rw = new RoleWindow(game.getRoles());
                rw.show();

            } else {
                System.out.println("bef creation");
                proceedToRunCreation();
            }
        }
    });
}

From source file:org.celstec.arlearn2.portal.client.RegisterForGame.java

License:Open Source License

private void proceedToRunCreation() {
    System.out.println("in run creation");
    RunClient.getInstance().createRun(game.getGameId(), game.getString(GameModel.GAME_TITLE_FIELD),
            new JsonCallback() {
                @Override//from  www. j ava2s . c  om
                public void onJsonReceived(JSONValue jsonValue) {
                    System.out.println("after creation");
                    run = new Run(jsonValue.isObject());
                    //                System.out.println(run.getJsonRep());
                    proceedToAddUser();
                }

            });
}

From source file:org.celstec.arlearn2.portal.client.RegisterForRun.java

License:Open Source License

public void loadPage() {
    String gameIdAsString = Window.Location.getParameter("runId");
    runId = Long.parseLong(gameIdAsString);
    AccountClient.getInstance().accountDetails(new JsonCallback() {
        @Override/* ww w . j  av a2  s  .  c  o m*/
        public void onJsonReceived(JSONValue jsonValue) {
            myAccount = new Account(jsonValue.isObject());
            fullIdentifier = myAccount.getAccountType() + ":" + myAccount.getLocalId();
            System.out.println(myAccount.getJsonRep());
            proceedToRetrievingRun();
        }
    });

}

From source file:org.celstec.arlearn2.portal.client.RegisterForRun.java

License:Open Source License

private void proceedToRetrievingRun() {
    RunClient.getInstance().getRun(runId, new JsonCallback() {
        @Override/* w ww .j a  v  a2 s .c  o  m*/
        public void onJsonReceived(JSONValue jsonValue) {
            run = new Run(jsonValue.isObject());
            System.out.println(run.getJSON());
            proceedToAddUser();

            //                if (game.getRoles()!= null && game.getRoles().length != 0) {
            //                    RoleWindow rw = new RoleWindow(game.getRoles());
            //                    rw.show();
            //
            //                } else {
            //
            //                    proceedToRunCreation();
            //                }
        }
    });
}

From source file:org.codehaus.sonar.plugins.testability.client.model.MethodTestabilityCostDataDecoderImpl.java

License:Open Source License

public MethodTestabilityCostData decode(String data) {
    JSONValue jsonValue = JSONParser.parse(data);
    JSONObject rootObject = jsonValue.isObject();
    MethodTestabilityCostData methodTestabilityCostData = new MethodTestabilityCostData();
    parseMethodCosts(rootObject.get("methodCosts").isObject(), methodTestabilityCostData);
    parseViolationCosts(rootObject.get("violationCosts").isObject(), methodTestabilityCostData);
    return methodTestabilityCostData;
}