Пример #1
1
  public void commandAction(Command command, Displayable displayable) {

    if (command == back) {
      controller.MainMenu();
    }
    if (command == viewStages) {
      busNos = busNo.getString().toUpperCase();
      fetchStagesData(busNos);
    }
    if (command == backToNo) {

      controller.getDisp().setCurrent(this);
    }
    if (command == MapStages) {
      controller.pointresultCanvas.busStagesPoints.removeAllElements();
      for (int mapStages = 0; mapStages < PostionAddress.length - 1; mapStages++) {
        String pos = PostionAddress[mapStages];
        String[] point = StringUtil.split(pos, "||");
        System.out.println(point[0] + "== " + point[1]);
        controller.pointBusStages(point[0], point[1]);
      }

      String pos = PostionAddress[Stages.getSelectedIndex()];
      String[] point = StringUtil.split(pos, "||");
      controller.gotoSpot(point[0], point[1]);
      controller.ShowPointingCanvas();
    }
    if (command == backToPlaces) {

      controller.getDisp().setCurrent(Stages);
    }
    if (command == showBuses) {
      controller.showProgressBar();
      fetchBusNoData();
    }
    if (command == showStages) {
      busNos = busesNearMe.getString(busesNearMe.getSelectedIndex()).toUpperCase();
      fetchStagesData(busNos);
    }
    if (command == viewBusPosition) {

      String[] data = GetBusPosition("Tt");
      String Message = "" + data[0] + "\n" + data[1] + "\n" + data[2];
      controller.showBusPosition(Message, data[3], data[4]);
    }
  }
 public void commandAction(Command command, Displayable displayable) {
   display.setCurrent(parentView);
   if (command == cmdSelect) {
     setString(list.getString(list.getSelectedIndex()));
   }
   if (command == cmdClear) {
     recentList.removeAllElements();
     saveRecentList();
   }
 }
Пример #3
1
  public void commandAction(Command c, Displayable d) {

    if (c == List.SELECT_COMMAND) {
      List down = (List) dsp.getCurrent();
      String title = down.getTitle();

      if (title.equals("Menu:")) {
        switch (down.getSelectedIndex()) {
          case 0:
            {
              System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex()));
              addRecordForm();
              break;
            }
          case 1:
            {
              System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex()));
              showAllRecordForm();
              break;
            }
          case 2:
            {
              System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex()));
              showFirstRecord();
              break;
            }
          case 3:
            {
              System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex()));
              getNumberRecord();
              break;
            }
          case 4:
            {
              System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex()));
              editRecord(1);
              break;
            }
        }
      }
    }

    if (c == cmdExit) {
      // rs.closeRecordStore();
      notifyDestroyed();
    }
    if (c == cmdMenu) {
      dsp.setCurrent(listMenu);
    }
    if (c == cmdEdit) {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      // filtr; filtr dostane pri vytvoreni stream jako parametr;
      // format dat nezavisly na platforme
      // definuje metodu write() pro vsechny primitivni typy
      DataOutputStream dout = new DataOutputStream(buffer);
      // byte [] data = txf.getString().getBytes();
      try {
        dout.writeUTF(txfName.getString());
        dout.writeInt(Integer.valueOf(txfNumber.getString()).intValue());
        txfName.delete(0, txfName.size());
        txfNumber.delete(0, txfNumber.size());
        // zapise buffer do streamu
        dout.flush();
        // prevod ByteArrayOutputStream na pole bytu;
        byte[] b = buffer.toByteArray();
        rs.setRecord(1, b, 0, b.length);
      } catch (Exception e) {
      } finally {
        try {
          dout.close();
        } catch (Exception e2) {
        }
      }
    }
    if (c == cmdAdd) {
      // vystupni stream; zapisuje do buferu v pamžti
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      // filtr; filtr dostane pri vytvoreni stream jako parametr;
      // format dat nezavisly na platforme
      // definuje metodu write() pro vsechny primitivni typy
      DataOutputStream dout = new DataOutputStream(buffer);
      // byte [] data = txf.getString().getBytes();
      try {
        dout.writeUTF(txfName.getString());
        dout.writeInt(Integer.valueOf(txfNumber.getString()).intValue());
        txfName.delete(0, txfName.size());
        txfNumber.delete(0, txfNumber.size());
        // zapise buffer do streamu
        dout.flush();
        // prevod ByteArrayOutputStream na pole bytu;
        byte[] b = buffer.toByteArray();
        rs.addRecord(b, 0, b.length);
      } catch (Exception e) {
      } finally {
        try {
          dout.close();
        } catch (Exception e2) {
        }
      }
    }
  }
Пример #4
1
  public String fetchBusNoData() {

    busesNearMe.deleteAll();

    busesNearMe.setTitle("Buses for  " + Stages.getString(Stages.getSelectedIndex()));
    new Thread() {
      public void run() {

        String toF = "";
        try {

          String[] tt = StringUtil.split(Stages.getString(Stages.getSelectedIndex()), " ");
          System.out.println("From field" + tt[0]);
          for (int y = 0; y < tt.length; y++) {
            if (y != tt.length - 1) {
              toF = toF + "" + tt[y] + "%20";
              System.out.println("From field" + toF);
            } else {
              toF = toF + tt[y];
              System.out.print("in else ");
            }
            System.out.print("Out of loop");
          }
          System.out.print(BusNowebsite + toF);
        } catch (Exception e) {
          controller.showAlert("Network Error", 3, AlertType.ERROR);
          displayList();
        }

        String addloc = "";

        StreamConnection c = null;
        InputStream s = null;
        StringBuffer b = new StringBuffer();
        System.out.print(BusNowebsite + toF);
        try {
          c = (StreamConnection) Connector.open(BusNowebsite + toF);
          s = c.openDataInputStream();
          int ch;
          int k = 0;
          while ((ch = s.read()) != -1) {
            // System.out.print((char) ch);
            b.append((char) ch);
          }

          result = b.toString();
          System.out.print(result);
          // String stagesString = fetchStagesData();
          JSONObject ff1 = new JSONObject(result);
          String data1 = ff1.getString("routes");
          JSONArray jsonArray1 = new JSONArray(data1);

          for (int i = 0; i < jsonArray1.length(); i++) {
            //   JSONObject jsonUser = jsonArray1.getJSONObject(i);
            //    String lat = jsonUser.getString ("lat");
            busesNearMe.append(jsonArray1.optString(i), null);
            System.out.println(jsonArray1.optString(i));
          }

          controller.getDisp().setCurrent(busesNearMe);
        } catch (Exception e) {
          System.out.print("Error " + e);
          //   controller.getDisp().setCurrent(Stages);
          // controller.showAlert("Network Error", 3, AlertType.ERROR);
          //
          //  controller.getDisp().setCurrent(controller.showAlert("Network Error", 3,
          // AlertType.ERROR), Stages);

        }
      }
    }.start();
    controller.getDisp().setCurrent(Stages);
    return result;
  }
Пример #5
1
  public void commandAction(Command c, Displayable d) {
    if (c == mExitCommand) {
      destroyApp(true);
      notifyDestroyed();
    } else if ((c == List.SELECT_COMMAND) && (d == mMenu)) {
      int selection = mMenu.getSelectedIndex();
      String item = "[none]";

      if ((selection >= 0) && (selection < mMenu.size())) {
        item = mMenu.getString(selection);
      }

      if (item == kQuerySlots) {
        Form slotList = new Form("Slots");
        String slots = System.getProperty("microedition.smartcardslots");
        int index = 0;

        while (index < slots.length()) {
          String slot;
          int comma = slots.indexOf(',', index);

          if (comma == -1) {
            slot = slots.substring(index).trim();
            index = slots.length();
          } else {
            slot = slots.substring(index, comma).trim();
            index = comma + 1;
          }

          StringItem slotItem = new StringItem(null, slot);
          slotItem.setLayout(Item.LAYOUT_2 | Item.LAYOUT_NEWLINE_AFTER);
          slotList.append(slotItem);
        }

        slotList.addCommand(mBackCommand);
        slotList.setCommandListener(this);
        mDisplay.setCurrent(slotList);
      } else if (item == kSignTest) {
        System.out.println("Starting sign test...");

        /*
        try {
          CMSMessageSignatureService.sign(
            "This is the message to sign",
            CMSMessageSignatureService.SIG_INCLUDE_CONTENT |
                CMSMessageSignatureService.SIG_INCLUDE_CERTIFICATE,
            null,
            "This is the prompt");
        }
        catch (Exception e) {
          System.out.println("sign() barfed: " + e);
        }*/
        new Thread() {
          public void run() {
            fromSpecification();
            System.out.println("Sign test finished.");
          }
        }.start();
      }
    } else if (c == mBackCommand) {
      mDisplay.setCurrent(mMenu);
    }
  }
Пример #6
1
  public void commandAction(Command command, Displayable displayable) {
    if ((displayable == D_MAIN) && D_MAIN.Responds()) {
      if (command == c_exit) {
        exitMIDlet();
      }
      if (command == c_history) {
        switchDisplayable(null, getL_history());
        Stack st = D_MAIN.getEqHS();
        Enumeration en = st.elements();
        l_history.deleteAll();
        while (en.hasMoreElements()) {
          l_history.append((String) en.nextElement(), null);
        }
      }
      if (command == c_tovars) {
        getL_vars().deleteAll();
        StringBuffer sb;
        Enumeration values = D_MAIN.getEqVars().elements();
        Enumeration names = D_MAIN.getEqVars().keys();
        String name;
        Real value;
        while ((values.hasMoreElements()) && (names.hasMoreElements())) {
          name = String.valueOf(names.nextElement());
          value = new Real(String.valueOf((values.nextElement())));
          Real.NumberFormat n = new Real.NumberFormat();
          n.maxwidth = 17;
          n.fse = Real.NumberFormat.FSE_NONE;
          sb = new StringBuffer(value.toString(n));
          if (chartools.contains(sb, 'e')) {
            StringBuffer ev = new StringBuffer();
            for (int i = sb.length() - 1; i > -1; --i) {
              if (sb.charAt(i) == 'e') {
                sb.deleteCharAt(i);
                break;
              }
              ev.append(sb.charAt(i));
              sb.deleteCharAt(i);
            }
            ev.reverse();
            sb.append(" * 10^(" + ev + ")");
            if ((!(sb.equals(new StringBuffer(""))))
                && (!(name.equals("")))
                && (!(sb.equals(new StringBuffer("null"))))
                && (!(name.equals("null")))) {
              l_vars.append(name + " = " + sb.toString(), null);
            }
          } else {
            if ((!(sb.equals(new StringBuffer(""))))
                && (!(name.equals("")))
                && (!(sb.equals(new StringBuffer("null"))))
                && (!(name.equals("null")))) {
              getL_vars().append(name + " = " + sb.toString(), null);
            }
          }
        }
        switchDisplayable(null, getL_vars());
      }
    }
    if (displayable == f_welcome) {
      if (command == c_canvas) {
        switchDisplayable(null, D_MAIN);
      }
    } else if (displayable == form) {
      if (command == c_history) {

      } else if (command == c_tovars) {

      }
    } else if (displayable == l_history) {
      if (command == List.SELECT_COMMAND) {

        l_historyAction();

      } else if (command == c_canvas) {
        switchDisplayable(null, D_MAIN);

      } else if (command == c_insert) {

        if (l_history.size() != 0) {
          StringBuffer sb = new StringBuffer();
          String his = l_history.getString(l_history.getSelectedIndex());
          boolean p_end = false;
          for (int i = 0; i < his.length(); i++) {
            if (his.charAt(i) == '=') {
              break;
            }
            if (p_end) {
              sb.append(his.charAt(i));
            }
            if (his.charAt(i) == ':') {
              p_end = true;
            }
          }
          sb.deleteCharAt(sb.length() - 1);
          D_MAIN.appendDispCont(" " + sb.toString());
        }
        switchDisplayable(null, D_MAIN);
        D_MAIN.repaint();
      }
    } else if (displayable == l_vars) {
      if (command == List.SELECT_COMMAND) {

        l_varsAction();

      } else if (command == c_canvas) {
        switchDisplayable(null, D_MAIN);

      } else if (command == c_delvar) {
        try {
          StringBuffer sb = new StringBuffer();
          String his = l_vars.getString(l_vars.getSelectedIndex());
          for (int i = 0; i < his.length(); i++) {
            if (his.charAt(i) == '=') {
              break;
            }
            sb.append(his.charAt(i));
          }
          D_MAIN.deletevar(sb.toString().trim());
          l_vars.delete(l_vars.getSelectedIndex());
        } catch (error er) {
          switchDisplayable(null, getA_error());
          a_error.setString(er.getMessage());
        }

      } else if (command == c_insert) {
        StringBuffer sb = new StringBuffer();
        String his = l_vars.getString(l_vars.getSelectedIndex());
        for (int i = 0; i < his.length(); i++) {
          if (his.charAt(i) == '=') {
            break;
          }
          sb.append(his.charAt(i));
        }
        D_MAIN.appendDispCont(sb.toString());
        switchDisplayable(null, D_MAIN);

        D_MAIN.repaint();
      }
    }
  }
Пример #7
0
 public void commandAction(Command c, Displayable d) {
   if (processorThread.isAlive()) {
     logger.error(Locale.get("fsdiscover.StillBusyTryAgain") /*Still busy, try again later*/);
     return;
   }
   if (c == BACK_CMD) {
     /**
      * Need to call sl.selectedFile() before calling parent.show(), as we need to keep track of
      * state for e.g. GuiDiscover
      */
     sl.selectionCanceled();
     parent.show();
     return;
   }
   if (c == ROOT_CMD) {
     url = "file:///";
     processorThread = new Thread(this);
     processorThread.start();
     return;
   }
   if (list.getSelectedIndex() < 0) {
     logger.error(Locale.get("fsdiscover.NoElementSelected") /*No element selected*/);
     return;
   }
   if (c == OK_CMD) {
     selectEntry();
     return;
   }
   if (c == DOWN_CMD) {
     if (list.getString(list.getSelectedIndex()).equalsIgnoreCase("..")) {
       c = UP_CMD;
     } else {
       url = (String) urlList.elementAt(list.getSelectedIndex());
       processorThread = new Thread(this);
       processorThread.start();
       return;
     }
   }
   if (c == UP_CMD) {
     url = url.substring(0, url.substring(0, url.length() - 1).lastIndexOf('/') + 1);
     // #debug debug
     logger.debug("Moving up directory to :" + url);
     if (url.length() < 9) { // file:///
       url = "file:///";
     }
     processorThread = new Thread(this);
     processorThread.start();
     return;
   }
 }
Пример #8
0
  public void commandAction(Command command, Displayable screen) {
    try {
      if (screen.equals(mainMenuList)) {

        int position = mainMenuList.getSelectedIndex();
        String selected = mainMenuList.getString(position);

        if (selected.equals(tr.t(Translator.CATEGORIES))) {
          level = ROOT_FILE;
          showCategory(0);
        } else if (selected.equals(tr.t(Translator.OPTIONS))) {
          optionForm.fillOptions();
          display.setCurrent(optionForm);
        } else if (selected.equals(tr.t(Translator.HELP))) {
          createHelpForm();
          display.setCurrent(form);
        } else if (selected.equals(tr.t(Translator.ABOUT))) {
          createAboutForm();
          display.setCurrent(form);
        } else if (selected.equals(tr.t(Translator.EXIT))) {
          exitMIDlet();
        }

      } else if (screen.equals(list) && command.equals(List.SELECT_COMMAND)) {
        int position = list.getSelectedIndex();
        displayedCategory.lastSelectedPosition = position;

        if (position < subCategories.size()) {
          showCategory(
              ((Integer) displayedCategory.subcategories.elementAt(position)).intValue()); // level
        } else {
          int itemPosition = position - subCategories.size();
          int itemIndex = ((Integer) displayedCategory.items.elementAt(itemPosition)).intValue();
          showItem((Item) itemsIndex.elementAt(itemIndex));
        }
      } else if (command.equals(backCommand) && screen.equals(list)) {
        if (displayedCategory.parentId != PARENT_CATEGORY_MAIN_SCREEN) {
          showCategory(displayedCategory.parentId);
        } else {
          displayMain();
        }
      } else if (command.equals(backCommand) && screen.equals(form)) {
        displayMain();
      } else if (command.equals(backCommandCanvas) && screen.equals(canvas)) {
        showCategory(lastSelectedCategoryIndex);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Пример #9
0
 public void listTweets() {
   com.twapime.app.ui.Timeline ui =
       new com.twapime.app.ui.Timeline("Tweets of List", listUI, midlet);
   ui.show();
   //
   ListManager t = ListManager.getInstance(userManager);
   t.startGetListTweets(lists[listUI.getSelectedIndex()], null, ui);
 }
Пример #10
0
 private void handleGoto(Command c) {
   if (c != cancelCmd) {
     int i = gotoList.getSelectedIndex();
     curLine = tocSection[i];
     repaint();
   }
   gotoList = null;
   display.setCurrent(this);
 }
Пример #11
0
 private void handleBooks(Command c) {
   if (c != cancelCmd) {
     curBook = booksList.getSelectedIndex();
     state = LOADING;
     repaint();
     enqueMsg(MSG_BOOK);
   }
   booksList = null;
   display.setCurrent(this);
 }
Пример #12
0
 private void doAction() {
   int index = contacts.getSelectedIndex();
   ContactsBean bean = (ContactsBean) Engine.getEngine().getBean(getId());
   Vector contacts = Engine.getEngine().getContacts();
   Contact contact = (Contact) contacts.elementAt(index);
   bean.setContacts(contact);
   //		Debug.println("Index=" + index + " " + contact.toString());
   // TODO: show SMS
   UIManager.getInstance().show(UIManager.SCREEN_SMS);
 }
Пример #13
0
 private void selectEntry() {
   url = (String) urlList.elementAt(list.getSelectedIndex());
   /**
    * Need to call sl.selectedFile() before calling parent.show(), as we need to keep track of
    * state for e.g. GuiDiscover
    */
   if (chooseType == CHOOSE_FILEONLY && url.endsWith("/")) {
     logger.info("Requested a file but got a dir: " + url);
   } else {
     sl.selectedFile(url);
     parent.show();
   }
 }
Пример #14
0
 /**
  * Respond to a command issued on any Screen.
  *
  * @param c command activated by the user
  * @param s the Displayable the command was on.
  */
 public void commandAction(Command c, Displayable s) {
   if (c == discoverCmd) {
     // user wants to discover the suites that can be installed
     discoverSuitesToInstall(urlTextBox.getString());
   } else if (s == installListBox && (c == List.SELECT_COMMAND || c == installCmd)) {
     installSuite(installListBox.getSelectedIndex());
   } else if (c == backCmd) {
     display.setCurrent(urlTextBox);
   } else if (c == saveCmd) {
     saveURLSetting();
   } else if (c == endCmd || c == Alert.DISMISS_COMMAND) {
     // goto back to the manager midlet
     notifyDestroyed();
   }
 }
Пример #15
0
  public void commandAction(Command c, Displayable d) {
    if (c == EXIT_CMD) {
      if (d == this) {
        parent.show();
      } else {
        show();
      }
    }
    if (c == ADD_CMD) {
      this.addTag = true;
      TextField tf = new TextField("key", "", 100, TextField.ANY);
      tf.addCommand(OK_CMD);
      tf.setItemCommandListener(this);
      this.append(tf);
      Display.getDisplay(GpsMid.getInstance()).setCurrentItem(tf);
      tf = new TextField("value", "", 100, TextField.ANY);
      tf.addCommand(OK_CMD);
      tf.setItemCommandListener(this);
      this.append(tf);
    }
    if (c == UPLOAD_CMD) {
      parent.show();
      eway.uploadXML(this);
    }

    if (c == REVERSE_CMD) {
      osmway.reverseWay();
    }

    if (c == PRESET_CMD) {
      presets = new List("Tagging Presets", List.IMPLICIT);
      presets.append("maxspeed=20 mph", null);
      presets.append("maxspeed=30 mph", null);
      presets.append("oneway=yes", null);
      presets.append("name=", null);
      presets.append("ref=", null);
      presets.append("lcn_ref=", null);
      presets.append("foot=yes", null);
      presets.append("bicycle=yes", null);
      presets.append("motorcar=yes", null);
      presets.append("access=private", null);
      presets.append("maxweight=7.5", null);
      presets.append("maxlength=18", null);
      presets.append("maxwidth=3", null);
      presets.append("maxheigt=4", null);
      presets.addCommand(OK_CMD);
      presets.addCommand(EXIT_CMD);
      presets.setCommandListener(this);
      presets.setSelectCommand(OK_CMD);
      GpsMid.getInstance().show(presets);
    }

    if (c == OK_CMD) {
      String addPreset = presets.getString(presets.getSelectedIndex());
      int split = addPreset.indexOf("=");
      osmway
          .getTags()
          .put(addPreset.substring(0, split), addPreset.substring(split + 1, addPreset.length()));
      presets = null;
      setupScreen();
      show();
    }
  }
Пример #16
0
  /**
   * Process the command events.
   *
   * @param c - the issued command.
   * @param d - the screen object the command was issued for.
   */
  public void commandAction(Command c, Displayable d) {
    // back to demo main screen
    if (c == SCR_MAIN_BACK_CMD) {
      destroy();
      parent.show();

      return;
    }

    // starts images (device/services) search
    if (c == SCR_MAIN_SEARCH_CMD) {
      Form f = new Form("Searching...");
      f.addCommand(SCR_SEARCH_CANCEL_CMD);
      f.setCommandListener(this);
      f.append(new Gauge("Searching images...", false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING));
      Display.getDisplay(parent).setCurrent(f);
      bt_client.requestSearch();

      return;
    }

    // cancels device/services search
    if (c == SCR_SEARCH_CANCEL_CMD) {
      bt_client.cancelSearch();
      Display.getDisplay(parent).setCurrent(mainScreen);

      return;
    }

    // back to client main screen
    if (c == SCR_IMAGES_BACK_CMD) {
      bt_client.requestLoad(null);
      Display.getDisplay(parent).setCurrent(mainScreen);

      return;
    }

    // starts image download
    if (c == SCR_IMAGES_LOAD_CMD) {
      Form f = new Form("Loading...");
      f.addCommand(SCR_LOAD_CANCEL_CMD);
      f.setCommandListener(this);
      f.append(new Gauge("Loading image...", false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING));
      Display.getDisplay(parent).setCurrent(f);

      List l = (List) d;
      bt_client.requestLoad(l.getString(l.getSelectedIndex()));

      return;
    }

    // cancels image load
    if (c == SCR_LOAD_CANCEL_CMD) {
      bt_client.cancelLoad();
      Display.getDisplay(parent).setCurrent(listScreen);

      return;
    }

    // back to client main screen
    if (c == SCR_SHOW_BACK_CMD) {
      Display.getDisplay(parent).setCurrent(listScreen);

      return;
    }
  }
Пример #17
0
 /**
  * Get the last selected image from the Photo List screen. TODO: This really only gets the
  * selected List item. So it is only an image name if you are on the PhotoList screen... Need to
  * fix this
  */
 public String getSelectedMediaName() {
   List selected = (List) Display.getDisplay(midlet).getCurrent();
   if (selected == null) System.out.println("Current List from display is NULL!");
   String name = selected.getString(selected.getSelectedIndex());
   return name;
 }