Пример #1
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();
      }
    }
  }
Пример #2
0
  public List showList(String title, String[] sArray) {
    if (list == null) {
      list = new List(title, Choice.IMPLICIT, sArray, null);
      list.addCommand(backCommand);
      list.setCommandListener(this);
    } else {
      list.setTitle(title);
      int listSize = list.size();
      for (int i = 0; i < listSize; i++) {
        list.delete(0);
      }
      for (int i = 0; i < sArray.length; i++) {
        list.append(sArray[i], null);
      }
    }

    return list;
  }
Пример #3
0
  /**
   * Shows the available images names.
   *
   * @returns false if no images names were found actually
   */
  boolean showImagesNames(Hashtable base) {
    Enumeration keys = base.keys();

    // no images actually
    if (!keys.hasMoreElements()) {
      informSearchError("No images names in found services");

      return false;
    }

    // prepare the list to be shown
    while (listScreen.size() != 0) {
      listScreen.delete(0);
    }

    while (keys.hasMoreElements()) {
      listScreen.append((String) keys.nextElement(), null);
    }

    Display.getDisplay(parent).setCurrent(listScreen);

    return true;
  }