예제 #1
0
  public KeyBindingsScreen(final Display display) {

    super("Key Bindings", IMPLICIT);

    this.display = display;

    keyBindings = KeyBindings.getInstance();

    screenKeyBinder = new KeyBinderScreen(this);

    addCommand(CMD_RESET);
    setCommandListener(this);

    for (int i = 0; i < KeyBindings.actionNames.length; i++) append("", null);
    updateList();

    alertKeyConflict = new Alert("Key already in use!");
    alertKeyConflict.setType(AlertType.WARNING);
    alertKeyConflict.setTimeout(Alert.FOREVER);
    alertKeyConflict.addCommand(CMD.NO);
    alertKeyConflict.addCommand(CMD.YES);
    alertKeyConflict.setCommandListener(this);

    alertReset = new Alert("Please confirm:");
    alertReset.setString("Reset to default key bindings?");
    alertReset.setType(AlertType.WARNING);
    alertReset.addCommand(CMD.NO);
    alertReset.addCommand(CMD.YES);
    alertReset.setCommandListener(this);
  }
예제 #2
0
 // #ifdef includeSorting
 // [EF] Added in the scenario 02
 private void incrementCountViews(String selectedImageName) {
   try {
     MediaData image = getAlbumData().getMediaInfo(selectedImageName);
     image.increaseNumberOfViews();
     updateMedia(image);
     System.out.println(
         "<* BaseController.handleCommand() *> Image = "
             + selectedImageName
             + "; # views = "
             + image.getNumberOfViews());
   } catch (ImageNotFoundException e) {
     Alert alert =
         new Alert(
             "Error",
             "The selected photo was not found in the mobile device",
             null,
             AlertType.ERROR);
     Display.getDisplay(midlet).setCurrent(alert, Display.getDisplay(midlet).getCurrent());
   } catch (InvalidImageDataException e) {
     Alert alert = new Alert("Error", "The image data is not valid", null, AlertType.ERROR);
     alert.setTimeout(5000);
   } catch (PersistenceMechanismException e) {
     Alert alert =
         new Alert(
             "Error", "It was not possible to recovery the selected image", null, AlertType.ERROR);
     alert.setTimeout(5000);
   }
 }
    /** Shows current tweet dialog and downloads user image */
    private void showTweet() {
      String text = current_tweet.getText();

      if (text != null) {
        String from = current_tweet.getFromUser();
        Alert a = new Alert("" + from, text, null, AlertType.INFO);

        a.setTimeout(Alert.FOREVER);
        display.setCurrent(a, this);
        String url = current_tweet.getProfileImageUrl();

        if (url != null) {
          // download and set user image to visible alert
          Image img;
          InputStream is = null;

          try {
            is = Connector.openInputStream(url);
            img = Image.createImage(is);
            a.setImage(img);
          } catch (Throwable t) { // do not show errors if image
            // download fails
          } finally {
            try {
              if (is != null) {
                is.close();
              }
            } catch (Throwable e) {
            }
          }
        }
      }
    }
예제 #4
0
 /**
  * Muestra un mensaje de aviso del tipo que se le especifique
  *
  * @param tipo Es el tipo de mensaje a mostrar.<br>
  *     0 representa una excepción genérica<br>
  *     1 representa un intento de conexión fallido debido a que el servidor no ha aceptado nuestra
  *     petición<br>
  *     2 representa un error al escoger el dispositivo con el que conectarnos.
  * @param d Display sobre el que mostrar el mensaje
  * @param ex Es la excepción que ha provocado el mensaje de error (en caso de que se muestre un
  *     mensaje debido a una excepción)
  */
 public void mostrarAlarma(int tipo, Display d, Exception ex) {
   Alert alerta = null;
   if (tipo == 0) {
     alerta =
         new Alert(
             "ERROR EN LA APLICACION",
             "Se ha producido el siguiente error en la aplicación:\n" + ex.getMessage(),
             null,
             AlertType.ERROR);
   } else if (tipo == 1) {
     alerta =
         new Alert(
             "PETICIÓN RECHAZADA",
             "El usuario el que queria recibir cartas ha rechazado su conexión",
             null,
             AlertType.INFO);
   } else if (tipo == 2) {
     alerta =
         new Alert(
             "IMPLOSIBLE CONEXIÓN",
             "Este dispositivo no ofrece la posibilidad de intercambiar cartas con usted",
             null,
             AlertType.INFO);
   }
   alerta.setTimeout(Alert.FOREVER);
   display.setCurrent(alerta, this);
 }
예제 #5
0
  /** @see CommandListener#commandAction(Command, Displayable) */
  public void commandAction(Command cmd, Displayable disp) {
    if (cmd.getCommandType() == Command.EXIT) {
      sim.destroyApp(false);
      sim.notifyDestroyed();
    } else {
      Display d = Sim.getDisplay();

      switch (getSelectedIndex()) {
        case 0: // Neues Spiel
          gamemode = new GameModeForm();
          d.setCurrent(gamemode);
          break;

        case 1: // Einstellungen
          d.setCurrent(new PrefForm());
          break;

        case 2: // Info
          Info.showInfo(d);
          break;

        case 3: // About
          Alert alert2 =
              new Alert(
                  "About",
                  "SimME\n by SPIESSEIN\n based on HEXI\n by Prof. Slany\n",
                  null,
                  AlertType.INFO);
          alert2.setTimeout(Alert.FOREVER);
          d.setCurrent(alert2, this);
          break;
      }
    }
  }
예제 #6
0
 public void showMsg() {
   Alert success =
       new Alert("Login Successfully", "Your Login Process is completed!", img2, AlertType.INFO);
   success.setImage(img2);
   userName.setString("");
   password.setString("");
   display.setCurrent(success, form);
 }
예제 #7
0
파일: TestMidlet.java 프로젝트: maks/ooksi
  public void showException(Exception e) {
    Alert alert = new Alert("Error");
    alert.setString(e.getMessage());
    alert.setType(AlertType.ERROR);
    alert.setTimeout(Alert.FOREVER);

    display.setCurrent(alert);
  }
예제 #8
0
  /**
   * Display an exception to the user, with a done command.
   *
   * @param title exception form's title
   * @param message exception message
   */
  private void displayException(String title, String message) {
    Alert a = new Alert(title, message, null, AlertType.ERROR);

    a.setTimeout(Alert.FOREVER);
    a.setCommandListener(this);

    display.setCurrent(a);
  }
예제 #9
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");
 }
예제 #10
0
 public void tryAgain() {
   Alert error = new Alert("Login Incorrect", "Please try again", imge, AlertType.ERROR);
   error.setTimeout(900);
   error.setImage(imge);
   userName.setString("");
   password.setString("");
   display.setCurrent(error, form);
 }
예제 #11
0
  public void startApp() {
    // Don't request the foreground on the first startApp call.
    if (!firstStart) {
      Alert a = new Alert("MIDlet 1");
      a.setTimeout(Alert.FOREVER);
      Display.getDisplay(this).setCurrent(a);
    }

    firstStart = false;
  }
예제 #12
0
파일: HelpForm.java 프로젝트: ppires/CIDE
  /**
   * Create about alert.
   *
   * @author Irving Bunton
   * @version 1.0
   */
  public static final Alert getAbout(MIDlet midlet) {
    final Alert about =
        new Alert(
            ResourceProviderME.get("alert.about.title"),
            ResourceProviderME.get(
                "alert.about",
                midlet.getAppProperty("MIDlet-Version")
                    + "-"
                    + midlet.getAppProperty("Program-Version")),
            null,
            AlertType.INFO);
    about.setTimeout(Alert.FOREVER);

    return about;
  }
예제 #13
0
  /**
   * We have to provide this method due to "do not do network operation in command listener method"
   * restriction, which is caused by crooked midp design.
   *
   * <p>This method is called by BTImageClient after it is done with bluetooth initialization and
   * next screen is ready to appear.
   */
  void completeInitialization(boolean isBTReady) {
    // bluetooth was initialized successfully.
    if (isBTReady) {
      StringItem si = new StringItem("Ready for images search!", null);
      si.setLayout(StringItem.LAYOUT_CENTER | StringItem.LAYOUT_VCENTER);
      mainScreen.append(si);
      Display.getDisplay(parent).setCurrent(mainScreen);

      return;
    }

    // something wrong
    Alert al = new Alert("Error", "Can't initialize bluetooth", null, AlertType.ERROR);
    al.setTimeout(DemoMIDlet.ALERT_TIMEOUT);
    Display.getDisplay(parent).setCurrent(al, parent.getDisplayable());
  }
예제 #14
0
  /**
   * Alert the user that an action was successful.
   *
   * @param successMessage message to display to user
   */
  private void displaySuccessMessage(String successMessage) {
    Image icon;
    Alert successAlert;

    icon = GraphicalInstaller.getImageFromInternalStorage("_dukeok8");

    successAlert = new Alert(null, successMessage, icon, null);

    successAlert.setTimeout(GraphicalInstaller.ALERT_TIMEOUT);

    // We need to prevent "flashing" on fast development platforms.
    while (System.currentTimeMillis() - lastDisplayChange < GraphicalInstaller.ALERT_TIMEOUT) ;

    lastDisplayChange = System.currentTimeMillis();
    display.setCurrent(successAlert);
  }
예제 #15
0
파일: NGCalc.java 프로젝트: revzin/ngcalc
  public Alert getA_error() {
    if (a_error == null) {

      a_error = new Alert("\u041E\u0448\u0438\u0431\u043A\u0430!");
      a_error.setTimeout(Alert.FOREVER);
    }
    return a_error;
  }
예제 #16
0
 /**
  * Constructor
  *
  * @param mod
  * @param name
  */
 public PhotoViewScreen(AlbumData mod, String name) {
   imageName = name;
   model = mod;
   try {
     loadImage();
   } catch (ImageNotFoundException e) {
     Alert alert =
         new Alert("Error", "The selected image can not be found", null, AlertType.ERROR);
     alert.setTimeout(5000);
   } catch (PersistenceMechanismException e) {
     Alert alert =
         new Alert(
             "Error", "It was not possible to recovery the selected image", null, AlertType.ERROR);
     alert.setTimeout(5000);
   }
   this.addCommand(backCommand);
 }
예제 #17
0
  private void showAlert(
      String alertTitleResourceString,
      String alertTextResourceString,
      String alternateAlertTitle,
      String alternateAlertText) {
    Resources resources = getResoursable();

    String alertTitle = null;
    String alertText = null;

    alertTitle = resources.get(alertTitleResourceString);
    alertText = resources.get(alertTextResourceString);

    Alert alert = new Alert(alertTitle, alertText, null, AlertType.ERROR);
    alert.setTimeout(Alert.FOREVER);
    App.getDisplay().setCurrent(alert);
  }
 public void commandAction(Command c, Displayable d) {
   if (c == help1Command) {
     midlet.getFavoriteList().removeAllFavorites();
     Alert alert = new Alert("Info", "Ihre Favoriten wurden entfernt!", null, AlertType.INFO);
     alert.setTimeout(Alert.FOREVER);
     midlet.getDisplay().setCurrent(alert);
   } else if (c == help2Command) {
     midlet.setView(Main.INFO_VIEW);
   } else if (c == itemCommand) {
     pressedField = true;
     repaint();
     serviceRepaints();
     midlet.setView(selected);
   } else if (c == exitCommand) {
     midlet.destroyApp(false);
     midlet.notifyDestroyed();
   }
 }
    public void run() {
      try {
        //				byte [] snap = videoControl.getSnapshot("encoding=jpeg&width=160&height=120");
        byte[] snap = videoControl.getSnapshot("encoding=jpeg");
        if (snap != null) {
          Image im = Image.createImage(snap, 0, snap.length);
          int a = im.getHeight();
          int b = im.getWidth();

          System.out.println("my height is " + a);
          System.out.println("My width is " + b);
          Alert al = new Alert("MyImage", "My dimensions are:" + b + "," + a, im, AlertType.INFO);
          al.setTimeout(2000);
          parentMidlet.getDisplay().setCurrent(al, aVideoCanvas);
        }
      } catch (MediaException me) {
        System.err.println(me);
      }
    }
예제 #20
0
 /** Notify a success event */
 public void notifySuccess(String message) {
   if (mActiveAlert != null) {
     if (mProgressActive) {
       System.out.println("Final progress message");
       mActiveAlert.setTitle("Info");
       mActiveAlert.setString(message);
       mActiveAlert.setIndicator(null);
       mProgressActive = false;
     } else {
       waitForNoAlert();
       mActiveAlert = null;
     }
   }
   if (mActiveAlert == null) {
     mActiveAlert = mController.showInfo(message);
     mActiveAlert.setCommandListener(this);
     mAlertDisplayed = true;
   }
 }
예제 #21
0
 /** Notify a long running process is beginning */
 public void notifyProgressStart(String message) {
   if (mActiveAlert != null) {
     waitForNoAlert();
     mActiveAlert = null;
   }
   if (mActiveAlert == null) {
     mActiveAlert = mController.createProgressAlert(message);
     mProgressActive = true;
     mActiveAlert.setCommandListener(this);
     mAlertDisplayed = true;
   }
 }
예제 #22
0
  /**
   * 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);
    }
  }
예제 #23
0
 public void commandAction(Command command, Displayable displayable) {
   if (command == cmdSave) {
     State.user = textUser.getString();
     State.password = textPass.getString();
     int period = Integer.parseInt(textPeriod.getString());
     if (period < 1) period = 1;
     State.connectionPeriod = period * 1000;
     try {
       Tools.updateRecord(RecordTypes.USER, State.user);
       Tools.updateRecord(RecordTypes.PASSWORD, State.password);
       Tools.updateRecord(RecordTypes.CONNECTIONPERIOD, Integer.toString(State.connectionPeriod));
     } catch (RecordStoreException rse) {
       Alert alertScreen = new Alert("Error");
       alertScreen.setString("There was an error storing the data");
       alertScreen.setTimeout(Alert.FOREVER);
     }
     State.display.setCurrent(mainForm);
   }
   if (command == cmdCancel) {
     State.display.setCurrent(mainForm);
   }
 }
예제 #24
0
 /** Notify an error event inluding a possible message and exception object */
 public void notifyError(String message, Throwable th) {
   String lErrorMsg = (th != null ? th.toString() : "");
   if (mActiveAlert != null) {
     if (mProgressActive) {
       mActiveAlert.setTitle("Error");
       mActiveAlert.setString(message + "\n" + lErrorMsg);
       mActiveAlert.setIndicator(null);
       mProgressActive = false;
     } else {
       waitForNoAlert();
       mActiveAlert = null;
     }
   }
   if (mActiveAlert == null) {
     mActiveAlert = mController.showError(message + "\n" + lErrorMsg);
     mActiveAlert.setCommandListener(this);
     mAlertDisplayed = true;
     if (mListener != null) {
       mListener.notifyError();
     }
   }
 }
    /** Sets Twitter map as current displayable and starts feed update. */
    private void showTwitterMap() {
      try {
        moveToPlaceInSettings();
      } catch (Throwable t) {
        Alert a =
            new Alert(
                "Failed",
                "Cannot find location: " + config.getLocationString(),
                null,
                AlertType.ERROR);

        a.setTimeout(Alert.FOREVER);
        display.setCurrent(a, config);
        return;
      }
      display.setCurrent(this);
      if (config.getUpdateInterval() <= 0) {
        startTweetUpdate();
      } else { // scheduled mode
        tweets_updater = new Timer();
        tweets_updater.scheduleAtFixedRate(
            new TweetsUpdater(), 50, config.getUpdateInterval() * 1000);
      }
    }
예제 #26
0
  public void keyPressed(int key) {

    int actionOld;
    String keyName;

    if (key == 0 || key == keyBindings.getKeyForAction(actionToBind)) {

      display.setCurrent(this);

    } else if (keyBindings.isBound(key)) {

      selectedKey = key;

      actionOld = keyBindings.getActionForKey(key);
      keyName = screenKeyBinder.getKeyName(key);

      msgKeyConflict.delete(0, msgKeyConflict.length());
      msgKeyConflict.append("Key ").append(keyName);
      msgKeyConflict.append(" is already in use for '");
      msgKeyConflict.append(KeyBindings.actionNames[actionOld]).append("'.");
      msgKeyConflict.append("\nDo you want to unset it from '");
      msgKeyConflict.append(KeyBindings.actionNames[actionOld]);
      msgKeyConflict.append("' and use it for '");
      msgKeyConflict.append(KeyBindings.actionNames[actionToBind]).append("' ?");
      alertKeyConflict.setString(msgKeyConflict.toString());

      display.setCurrent(alertKeyConflict);

    } else { // key is valid and free

      keyBindings.bindKeyToAction(actionToBind, key);

      updateList(actionToBind);

      display.setCurrent(this);
    }
  }
예제 #27
0
 /**
  * @param message
  * @param type
  * @param backScreen
  */
 public void showAlert(String message, AlertType type, Displayable backScreen) {
   Alert alert = new Alert("TwAPIme", message, null, type);
   alert.setTimeout(Alert.FOREVER);
   //
   Display.getDisplay(midlet).setCurrent(alert, backScreen);
 }
예제 #28
0
 /** Notify progress through a long running process */
 public void notifyProgress(int percent) {
   if (mActiveAlert != null) {
     System.out.println("Setting value : " + percent);
     mActiveAlert.getIndicator().setValue(percent);
   }
 }
예제 #29
0
 public void showAlert(String title, String msg, Displayable next) {
   Alert alert = new Alert(title);
   alert.setString(msg);
   _manager.next(alert, next);
 }
예제 #30
0
 /** Informs the error during the selected image load. */
 void informLoadError(String resMsg) {
   Alert al = new Alert("Error", resMsg, null, AlertType.ERROR);
   al.setTimeout(DemoMIDlet.ALERT_TIMEOUT);
   Display.getDisplay(parent).setCurrent(al, listScreen);
 }