Package com.gloopics.g3viewer.client

Source Code of com.gloopics.g3viewer.client.Utils

package com.gloopics.g3viewer.client;

import com.allen_sauer.gwt.dnd.client.DragContext;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONNumber;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.ui.Widget;

public class Utils {
  public static int extractId(JSONValue a_Value){
    JSONNumber jn = a_Value.isNumber();
    if (jn != null){
      return (int) jn.doubleValue();
    }
    else{
      String val = a_Value.isString().stringValue();
      return Integer.parseInt(val);
    }
  }
 
  public static JSONArray extractIds(DragContext context) {
    JSONArray jsa = new JSONArray();
   
    int i = 0;
    for (Widget widget : context.selectedWidgets){
      if (widget instanceof Item){
        jsa.set(i, new JSONNumber(((Item)widget).getID()));
        i++;
      }
    }
    return jsa;
  }

}
TOP

Related Classes of com.gloopics.g3viewer.client.Utils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.