Package net.rim.device.api.script

Examples of net.rim.device.api.script.Scriptable


      });
    }else if (args.length == 2){
      final ScriptableFunction _callback = (ScriptableFunction)args[0];
     
      //if they pass the optional parameter. The default location
      final Scriptable ops = (Scriptable) args[1];
     
      UiApplication.getUiApplication().invokeLater(new Runnable()
      {
        public void run()
        {
View Full Code Here


  
    public Object invoke(Object thiz, Object[] args) throws Exception {
    if (args.length == 2) {
      // Get our configuration object
          Scriptable config = (Scriptable)args[0];
     
      // Grab the selected Index to display
      int selectedIndex = ((Integer)config.getField("selectedIndex")).intValue();    
      int rowHeight  = ((Integer)config.getField("rowHeight")).intValue();
      int visibleRows  = ((Integer)config.getField("visibleRows")).intValue();
      String title = (String)config.getField("title");
     
      // Grab the items to display from the config object
      Scriptable stringArray  = (Scriptable)config.getField("items");
          int count = stringArray.getElementCount();
          String[] choices = new String[count];
          for (int i=0; i<count; i++) {
              choices[i] = stringArray.getElement(i).toString();
          }
     
      // Now get the callback method to fire
      _callback = (ScriptableFunction)args[1];
     
View Full Code Here

  public Object invoke(Object obj, Object[] args) throws Exception
    {
    if (args.length == 1)
    {
      Scriptable config = (Scriptable) args[0];

      if (config != null)
      {
        if (config.getField("title") instanceof String) {title = config.getField("title").toString();}
        if (config.getField("version") instanceof String) {version = config.getField("version").toString();}
        if (config.getField("intro") instanceof String) {intro = config.getField("intro").toString();}
        if (config.getField("author") instanceof String) {author = config.getField("author").toString();}
        if (config.getField("email") instanceof String) {email = config.getField("email").toString();}
        if (config.getField("weibo") instanceof String) {weibo = config.getField("weibo").toString();}
        if (config.getField("facebook") instanceof String) {facebook = config.getField("facebook").toString();}
        if (config.getField("twitter") instanceof String) {twitter = config.getField("twitter").toString();}
        if (config.getField("alipay") instanceof String) {alipay = config.getField("alipay").toString();}

        UiApplication.getUiApplication().invokeLater(new Runnable()
        {
          public void run()
          {
View Full Code Here

        // Set defaults
        String imageNew = null;
        String imageRead = null;
      
        // Grab the options object and its details
        Scriptable item = (Scriptable)args[0];
        String id = (String)item.getField(MessageListItem.FIELD_ID);
        String title = (String)item.getField(MessageListItem.FIELD_TITLE);
        String description = (String)item.getField(MessageListItem.FIELD_DESCRIPTION);
        //Optional Parameter
        Object imageNewArg = item.getField(MessageListItem.FIELD_IMAGENEW);
        if(imageNewArg != UNDEFINED){
          imageNew = (String)imageNewArg;
        }
        Object imageReadArg = item.getField(MessageListItem.FIELD_IMAGEREAD);
        if(imageReadArg != UNDEFINED){
          imageRead = (String)imageReadArg;
        }
       
               
View Full Code Here

      Hashtable params = null;
      String method = null;
     
      Logger.info("Getting options...");
     
      Scriptable config = (Scriptable) args[0];
     
      Logger.info("Setting core options...");
     
      String url = (String) config.getField("url");
      String filePath = (String) config.getField("file");

      Object cMethod = config.getField("method");
      Object cTimeout = config.getField("timeout");
     
      Logger.info("Getting headers and params...");
     
      Object sHeaders = config.getField("headers");
      Object sParams = config.getField("params");
     
      if (!cTimeout.equals(UNDEFINED)) {
        timeout = ((Integer) cTimeout).intValue();
      }
     
      if (!cMethod.equals(UNDEFINED)) {
        method = (String) cMethod;
      }
     
      Logger.info("Setting headers and extra params...");
     
      try {
        headers = objectToHashtable(sHeaders);
        params = objectToHashtable(sParams);
      } catch(Throwable e) {
        Logger.error("Error setting custom params and headers..." + e.getMessage());
      }
     
      _successCallback = (ScriptableFunction) config.getField("success");
      _errorCallback = (ScriptableFunction) config.getField("error");
     
      Logger.info("Beginning download...");

      new DownloadRunnable(url, method, params, filePath, timeout, headers, _transports, _successCallback, _errorCallback);
    }
View Full Code Here

    if (args != null && !_alreadyInit)
    {
       try
       {
        // Grab the options data
        Scriptable optionsSent = (Scriptable)args[0];               
        String guid = (String)optionsSent.getField("guid");
        final long GUID = Long.parseLong(guid);
        String folderName = (String)optionsSent.getField("folderName");
         
        // Set the namespace properties
        MessageListNamespace namespace = MessageListNamespace.getInstance();
        namespace.setDefaultNewImage((String)optionsSent.getField("defaultNewImage"));
        namespace.setDefaultReadImage((String)optionsSent.getField("defaultReadImage"));
       
        // Do all our actual registration stuff
        CustomMessageServices.initializeOnStartup(folderName, "Example App", GUID);
         
        // Set our init flag
View Full Code Here

  private Hashtable objectToHashtable(Object obj) throws Exception
  {
    Hashtable ht = null;
   
    if (!obj.equals(UNDEFINED) && obj != null) {
      Scriptable s = (Scriptable) obj;

      Vector v = new Vector();
      s.enumerateFields(v);
     
      int count = v.size();
      Logger.log("Object Keys: " + String.valueOf(v.size()));
     
      if (count > 0) {
        ht = new Hashtable();
        String fieldName;
       
        for (int i=0; i<count; i++) {
          fieldName = (String) v.elementAt(i);
          ht.put(fieldName, s.getField(fieldName));
        }
      }
    }
    return ht;
  }
View Full Code Here

         // Set defaults
        String imageNew = null;
        String imageRead = null;
      
        // Grab the options object and its details
        Scriptable item = (Scriptable)args[0];
        String id = (String)item.getField(MessageListItem.FIELD_ID);
        String title = (String)item.getField(MessageListItem.FIELD_TITLE);
        String description = (String)item.getField(MessageListItem.FIELD_DESCRIPTION);
        //Optional Parameter
        Object imageNewArg = item.getField(MessageListItem.FIELD_IMAGENEW);
        if(imageNewArg != UNDEFINED){
          imageNew = (String)imageNewArg;
        }
        Object imageReadArg = item.getField(MessageListItem.FIELD_IMAGEREAD);
        if(imageReadArg != UNDEFINED){
          imageRead = (String)imageReadArg;
        }
       
               
View Full Code Here

     
      long timeout = 30000;
     
      Logger.info("Getting options...");
     
      Scriptable config = (Scriptable) args[0];
     
      Logger.info("Setting core options...");
     
      String url = (String) config.getField("url");
      String filePath = (String) config.getField("file");
      String fileKey = (String) config.getField("fileKey");
      String mimeType = (String) config.getField("mimeType");
      Object cTimeout = config.getField("timeout");
     
      Logger.info("Getting headers and params...");
     
      Object sHeaders = config.getField("headers");
      Object sParams = config.getField("params");
     
      if (mimeType.equals(UNDEFINED)) {
        mimeType = null;
      }
     
      if (!cTimeout.equals(UNDEFINED)) {
        timeout = ((Integer) cTimeout).intValue();
      }
     
      Logger.info("Setting headers and extra params...");
     
      try {
        headers = objectToHashtable(sHeaders);
        params = objectToHashtable(sParams);
      } catch(Throwable e) {
        Logger.error("Error setting custom params and headers..." + e.getMessage());
      }
     
      _successCallback = (ScriptableFunction) config.getField("success");
      _errorCallback = (ScriptableFunction) config.getField("error");
     
      Logger.info("Beginning upload...");

      new UploadRunnable(url, fileKey, params, filePath, mimeType, timeout, headers, _transports, _successCallback, _errorCallback);
    }
View Full Code Here

  private Hashtable objectToHashtable(Object obj) throws Exception
  {
    Hashtable ht = null;
   
    if (!obj.equals(UNDEFINED) && obj != null) {
      Scriptable s = (Scriptable) obj;

      Vector v = new Vector();
      s.enumerateFields(v);
     
      int count = v.size();
      Logger.log("Object Keys: " + String.valueOf(v.size()));
     
      if (count > 0) {
        ht = new Hashtable();
        String fieldName;
       
        for (int i=0; i<count; i++) {
          fieldName = (String) v.elementAt(i);
          ht.put(fieldName, s.getField(fieldName));
        }
      }
    }
    return ht;
  }
View Full Code Here

TOP

Related Classes of net.rim.device.api.script.Scriptable

Copyright © 2018 www.massapicom. 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.