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:de.eckhartarnold.client.ImageCollectionReader.java

License:Apache License

private HashMap<String, String> interpretStringDictionary(JSONValue json) throws JSONException {
    JSONObject dict = json.isObject();
    HashMap<String, String> stringDict = new HashMap<String, String>();
    for (String key : dict.keySet()) {
        stringDict.put(key, dict.get(key).isString().stringValue());
    }/*from  ww w  . j a  v a2 s .  c o  m*/
    return stringDict;
}

From source file:de.kp.ames.search.client.action.ActionImpl.java

License:Open Source License

/**
 * @param jValue
 */
public void registerResponse(JSONValue jValue) {
    this.jResponse = jValue.isObject();
}

From source file:de.kp.ames.web.client.core.apps.AppsManager.java

License:Open Source License

/**
 * A helper method to specify the action that is
 * invoked after a control label has been clicked
 * /*from ww w .ja va 2 s . c  o  m*/
 * @param id
 * @param control
 */
public void afterCommControlSelected(final String id, final ControlLabel control) {

    new AppsService().doGetCredentials("comm", new ActivityImpl() {
        public void execute(JSONValue jValue) {

            JSONObject jCreds = jValue.isObject();

            final String alias;
            final String keypass;

            /*
             * Data guard
             */
            if (!jCreds.containsKey("alias"))
                return;
            if (!jCreds.containsKey("keypass"))
                return;

            alias = jCreds.get("alias").isString().stringValue();
            keypass = jCreds.get("keypass").isString().stringValue();

            if (id.equals(ApplicationConstants.FNC_APP_ID_Chat)) {
                doStartComm(id, "chat", alias, keypass);

            } else if (id.equals(ApplicationConstants.FNC_APP_ID_Mail)) {
                doStartComm(id, "mail", alias, keypass);

            }

        }
    });

}

From source file:de.kp.ames.web.client.core.apps.AppsManager.java

License:Open Source License

private void doStartComm(final String id, String service, final String alias, final String keypass) {

    ActivityImpl activity = new ActivityImpl() {

        public void execute(JSONValue jValue) {

            JSONObject jCreds = jValue.isObject();

            String username = null;
            String password = null;

            if (jCreds.containsKey("user"))
                username = jCreds.get("user").isString().stringValue();
            if (jCreds.containsKey("password"))
                password = jCreds.get("password").isString().stringValue();

            CustomAppsManager.getInstance().createCommApp(id, alias, keypass, username, password);

        }/*from   w  w w .java  2s  .co  m*/

    };

    new AppsService().doGetCredentials(service, activity);

}

From source file:de.kp.ames.web.client.core.apps.CustomAppsManager.java

License:Open Source License

/**
 * Create showcase viewport/*from  w  w  w.  jav a  2s .  com*/
 */
public void createShowCase(JSONValue jValue) {

    JSONObject jObject = jValue.isObject();

    /*
     * Retrieve User
     */
    JSONObject jUser = jObject.get("user").isObject();
    UserManager.getInstance().setUser(jUser);

    /*
     * Register callers apps
     */
    this.jRegisteredApps = jObject.get("apps").isArray();

    /* 
     * Remove the initial splash screen
     */
    removeSplash();

    /*
     * Create viewport
     */
    createViewport();

    /*
     * Create ShowCase
     */
    createApp(ApplicationConstants.FNC_APP_ID_ShowCase);

}

From source file:de.kp.ames.web.client.core.apps.CustomAppsManager.java

License:Open Source License

/**
 * Create operational viewport//from  ww w  .  j a v a  2  s  .c o  m
 */
public void createOpsCase(JSONValue jValue) {

    JSONObject jObject = jValue.isObject();

    /*
     * Retrieve User
     */
    JSONObject jUser = jObject.get("user").isObject();
    UserManager.getInstance().setUser(jUser);

    /*
     * Register callers apps
     */
    this.jRegisteredApps = jObject.get("apps").isArray();

    /* 
     * Remove the initial splash screen
     */
    removeSplash();

    /*
     * Create viewport
     */
    createViewport();

    /* 
     * Add the user to main topline
     */
    viewport.setUser(UserManager.getInstance().getUserName());

    /*
     * Create desktop application as initial
     * viewport to enable the user to select
     * specific apps
     */
    createDesktop();

    /*
     * Show disclaimer dialog
     */
    createDisclaimer();

}

From source file:de.kp.ames.web.client.fnc.ns.action.NsEditImpl.java

License:Open Source License

@Override
public void doAfterEdit(JSONValue jValue) {

    String[] keys = {/* w w  w.  ja v  a2 s  .  com*/

            JaxrConstants.RIM_NAME, JaxrConstants.RIM_DESC, JaxrConstants.RIM_SLOT };

    JSONObject jNode = jValue.isObject();
    for (String key : keys) {
        node.setAttribute(key, jNode.get(key).isString().stringValue());
    }

    ((NsTreeImpl) tree).updateData(node);

}

From source file:de.kp.ames.web.client.fnc.service.LoginService.java

License:Open Source License

/**
 * Register method//from ww  w  . j a  v  a2 s . c  o m
 * 
 * @param alias
 * @param keypass
 * @param activityCallback
 */
public void register(final String alias, final String keypass, final ActivityImpl activityCallback) {

    RequestMethodImpl requestMethod = new RequestMethodImpl();
    requestMethod.setName(MethodConstants.METH_REGISTER);

    requestMethod.addAttribute(CoreAttrs.ALIAS, alias);
    requestMethod.addAttribute(CoreAttrs.KEYPASS, keypass);

    sendPostRequest(requestMethod, null, new ConnectionCallback() {

        public void onSuccess(String response) {

            try {

                JSONValue jValue = JSONParser.parseStrict(response);
                JSONObject jObject = jValue.isObject();

                boolean result = jObject.get("result").isBoolean().booleanValue();

                if (result == true) {
                    activityCallback.execute(jObject);

                } else {
                    String message = jObject.get("message").isString().stringValue();
                    doRequestError(message);
                }

            } catch (NullPointerException e) {
                doLoginFailed();

            }

        }

        public void onError(Throwable throwable) {
            doLoginFailed();
        }

        public void onTimeout(String message) {
            doLoginFailed();
        }

        public void onFailure(String message) {
            doLoginFailed();
        }

    });

}

From source file:de.kp.ames.web.client.test.ShowCaseImpl.java

License:Open Source License

protected void showTestCase(TreeNode node) {

    ScNode scNode = (ScNode) node;//from  w w w  .j a v a 2s. c o m

    /*
     * Retrieve node identifier
     */
    final String nid = scNode.getNodeID();

    /*
     * Tab
     */
    String tid = nid + ":tab";
    Tab tab = mainTabs.getTab(tid);

    if (tab == null) {
        /*
         * Create new tab
         */

        if (nid.equals(ScFactory.PREFIX + "access:data:DatabaseGridImpl:leaf")) {
            /*
             * Initialize Database Grid Example with
             * a predefined Accessor
             */
            final ShowCaseImpl self = this;
            ActivityImpl activity = new ActivityImpl() {
                public void execute(JSONValue jValue) {
                    JSONObject jDatabase = jValue.isObject();
                    Tab tab = ScFactory.createDatabaseGridImpl(nid, jDatabase);
                    tab.setWidth(80);
                    self.mainTabs.addTab(tab);
                    self.mainTabs.selectTab(tab);
                }
            };

            String format = FormatConstants.FNC_FORMAT_ID_Json;
            String type = ClassificationConstants.FNC_ID_Database;

            String item = ScData.TEST_DATABASE_ACCESSOR;

            new AccessService().doGet(format, type, item, activity);

        } else {
            tab = ScFactory.getTab(nid);
            tab.setWidth(80);
            mainTabs.addTab(tab);
            mainTabs.selectTab(tab);
        }

    } else {
        mainTabs.selectTab(tab);

    }

}

From source file:edu.ucsb.eucalyptus.admin.client.extensions.store.JSONImageInfo.java

License:Open Source License

public String getProviderTitle() {
    JSONValue providerValue = object.get("provider");
    if (providerValue != null) {
        JSONObject providerObject = providerValue.isObject();
        if (providerObject != null) {
            return JSONUtil.asString(providerObject.get("title"));
        }/* w  w w. j av  a  2  s .  c  o m*/
    }
    return null;
}