コード例 #1
0
 private void handleException(Exception e) {
   Alert a = new Alert("Exception", e.toString(), null, null);
   a.setTimeout(Alert.FOREVER);
   // Throw with a proper JR alert. Crash for now until someone fixes this.
   // mDisplay.setCurrent(a, mMainForm);
   throw new RuntimeException(
       "Snapper MIDLlet exception needs to be displayed as an alert, but fixed to use j2me properly");
 }
コード例 #2
0
 int getLineLength(int y) {
   try {
     return ((StringBuffer) vectorLines.elementAt(y)).length();
   } catch (Exception ex) {
     System.out.println(ex.toString() + " in getLineLength()");
     return 0;
   }
 }
コード例 #3
0
 StringBuffer getLine(int y) {
   try {
     return (StringBuffer) vectorLines.elementAt(y);
   } catch (Exception ex) {
     System.out.println(ex.toString() + " in getLine()");
     return new StringBuffer("");
   }
 }
コード例 #4
0
 boolean addNewLine(int y) {
   try {
     vectorLines.insertElementAt(new StringBuffer(""), y);
     return true;
   } catch (Exception ex) {
     System.out.println(ex.toString());
     return false;
   }
 }
コード例 #5
0
 boolean removeLine(int y) {
   try {
     vectorLines.removeElementAt(y);
     return true;
   } catch (Exception ex) {
     System.out.println(ex.toString() + " in removeLine()");
     return false;
   }
 }
コード例 #6
0
 boolean setLine(int y, StringBuffer stringBuffer) {
   try {
     vectorLines.setElementAt(stringBuffer, y);
     return true;
   } catch (Exception ex) {
     System.out.println(ex.toString() + " in setLine()");
     return false;
   }
 }
コード例 #7
0
  boolean copyLine(int sourceY, int destinationY) {
    try {
      // getLine
      StringBuffer currentLine = (StringBuffer) vectorLines.elementAt(sourceY);
      // setLine
      vectorLines.setElementAt(currentLine, destinationY);

      return true;
    } catch (Exception ex) {
      System.out.println(ex.toString() + " in copyLine()");
      return false;
    }
  }
コード例 #8
0
  boolean removeFromLine(int xFrom, int xTo, int y) {
    try {
      // getLine
      StringBuffer currentLine = (StringBuffer) vectorLines.elementAt(y);

      currentLine.delete(xFrom, xTo);
      // setLine
      vectorLines.setElementAt(currentLine, y);
      return true;
    } catch (Exception ex) {
      System.out.println(ex.toString() + " in removeFromLine()");
      return false;
    }
  }
コード例 #9
0
  boolean updateToLine(int x, int y, char ch) {
    try {
      // getLine
      StringBuffer currentLine = (StringBuffer) vectorLines.elementAt(y);

      currentLine.setCharAt(x - 1, ch);
      // setLine
      vectorLines.setElementAt(currentLine, y);

      return true;
    } catch (Exception ex) {
      System.out.println(ex.toString() + " in updateToLine()");
      return false;
    }
  }
コード例 #10
0
ファイル: DiscoveryApp.java プロジェクト: schoeberl/yari
  /** Save the URL setting the user entered in to the urlTextBox. */
  private void saveURLSetting() {
    String temp;
    Exception ex;

    temp = urlTextBox.getString();

    ex = GraphicalInstaller.saveSettings(temp, MIDletSuite.INTERNAL_SUITE_ID);
    if (ex != null) {
      displayException(Resource.getString(ResourceConstants.EXCEPTION), ex.toString());
      return;
    }

    defaultInstallListUrl = temp;

    displaySuccessMessage(Resource.getString(ResourceConstants.AMS_MGR_SAVED));
  }
コード例 #11
0
  boolean shiftDown(int y) {
    try {
      addNewLine(getLinesCount() + 1 - 1);

      // tricky! -1 because of beginning from 0, -1 because next line, -1 because getLinesCount() is
      // already updated (+1)
      for (int sourceY = getLinesCount() - 2; sourceY >= y; sourceY--) // -1
      {
        copyLine(sourceY, sourceY + 1);
      }

      return true;
    } catch (Exception ex) {
      System.out.println(ex.toString() + " in shiftDown()");
      return false;
    }
  }
コード例 #12
0
ファイル: DiscoveryApp.java プロジェクト: schoeberl/yari
  /** Ask the user for the URL. */
  private void getUrl() {
    try {
      if (urlTextBox == null) {
        urlTextBox =
            new TextBox(
                Resource.getString(ResourceConstants.AMS_DISC_APP_WEBSITE_INSTALL),
                defaultInstallListUrl,
                1024,
                TextField.ANY);
        urlTextBox.addCommand(endCmd);
        urlTextBox.addCommand(saveCmd);
        urlTextBox.addCommand(discoverCmd);
        urlTextBox.setCommandListener(this);
      }

      display.setCurrent(urlTextBox);
    } catch (Exception ex) {
      displayException(Resource.getString(ResourceConstants.EXCEPTION), ex.toString());
    }
  }
コード例 #13
0
  boolean addToLine(int x, int y, char ch) {
    try {
      // getLine
      StringBuffer currentLine = (StringBuffer) vectorLines.elementAt(y);

      currentLine.insert(x, ch);

      if (vectorLines.size() < y) {
        vectorLines.addElement(currentLine);
      } else {
        // setLine
        vectorLines.setElementAt(currentLine, y);
      }

      return true;
    } catch (Exception ex) {
      System.out.println(ex.toString() + " in addToLine()");
      return false;
    }
  }
コード例 #14
0
ファイル: DiscoveryApp.java プロジェクト: schoeberl/yari
  /**
   * Install a suite.
   *
   * @param selectedSuite index into the installList
   */
  private void installSuite(int selectedSuite) {
    MIDletStateHandler midletStateHandler = MIDletStateHandler.getMidletStateHandler();
    MIDletSuite midletSuite = midletStateHandler.getMIDletSuite();
    SuiteDownloadInfo suite;
    String displayName;

    suite = (SuiteDownloadInfo) installList.elementAt(selectedSuite);

    midletSuite.setTempProperty(null, "arg-0", "I");
    midletSuite.setTempProperty(null, "arg-1", suite.url);
    midletSuite.setTempProperty(null, "arg-2", suite.label);

    displayName = Resource.getString(ResourceConstants.INSTALL_APPLICATION);
    try {
      midletStateHandler.startMIDlet("com.sun.midp.installer.GraphicalInstaller", displayName);
      /*
       * Give the create MIDlet notification 1 second to get to
       * AMS.
       */
      Thread.sleep(1000);
      notifyDestroyed();
    } catch (Exception ex) {
      StringBuffer sb = new StringBuffer();

      sb.append(displayName);
      sb.append("\n");
      sb.append(Resource.getString(ResourceConstants.ERROR));
      sb.append(": ");
      sb.append(ex.toString());

      Alert a =
          new Alert(
              Resource.getString(ResourceConstants.AMS_CANNOT_START),
              sb.toString(),
              null,
              AlertType.ERROR);
      a.setTimeout(Alert.FOREVER);
      display.setCurrent(a, urlTextBox);
    }
  }
コード例 #15
0
  boolean divideLine(int x, int y) // fire <=> enter + insert when # pressed
      {
    try {
      // getLine
      StringBuffer currentLine = (StringBuffer) vectorLines.elementAt(y);

      String newLine = currentLine.toString().substring(x, currentLine.toString().length());

      currentLine.delete(x, currentLine.length());
      // setLine
      vectorLines.setElementAt(currentLine, y);

      if (shiftDown(y)) {
        vectorLines.setElementAt(new StringBuffer(newLine), y + 1);
      }

      return true;
    } catch (Exception ex) {
      System.out.println(ex.toString() + " in divideLine()");
      return false;
    }
  }