Exemple #1
1
  public void startApp() {
    // Create Record Store
    try {
      rs = RecordStore.openRecordStore("myrs", true);
    } catch (RecordStoreException e) {
    }

    dsp = Display.getDisplay(this);
    listMenu.setCommandListener(this);
    listMenu.addCommand(cmdExit);
    dsp.setCurrent(listMenu);
  }
  /** @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;
      }
    }
  }
 public void setOnScreen(View view) {
   if (view instanceof LcduiView) {
     Displayable displayable = ((LcduiView) view).getDisplayable();
     boolean isAlert = displayable instanceof Alert;
     if (!isAlert) {
       lastNonAlert = displayable;
     }
     // trick to avoid the error "Alert cannot be displayed on Alert"
     if (!isAlert) {
       display.setCurrent(displayable);
     } else {
       if (lastNonAlert != null) {
         display.setCurrent((Alert) displayable, lastNonAlert);
       } else {
         App.getLogger()
             .log(
                 "DisplayManagerLcdui handling alert on alert. New alert text : "
                     + ((Alert) displayable).getString(),
                 Logger.LEVEL_DEBUG);
         display.setCurrent((Alert) displayable, new Form(null));
       }
     }
     currentView = view;
   } else {
     App.getLogger()
         .log(
             "DisplayManagerLcdui cannot accept any view other than LcduiView",
             Logger.LEVEL_WARNING);
   }
 }
 // #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);
   }
 }
Exemple #5
0
 protected void startApp() throws MIDletStateChangeException {
   if (soletrandoCanvas == null) {
     soletrandoCanvas = new SoletrandoCanvas(this);
     display = Display.getDisplay(this);
     display.setCurrent(soletrandoCanvas);
   }
 }
Exemple #6
0
  public void inquiryCompleted(int discType) {
    if (remote == null) {
      mDisplay.setCurrent(vorForm);
      // Wait until the canvas appears...
      // For Nokia it is not the same?
      while (mDisplay.getCurrent() != vorForm) ;
      messages.insert("No NXT Brick found", messages.size());
    } else {
      try {
        remoteName = remote.getFriendlyName(false);
        messages.insert("Connecting to " + remoteName + "\n", messages.size());
      } catch (IOException ioe) {
        System.out.println("error retrieving friendly name");
      }

      try {
        // int[] attrs = {0x100}; // default attribute set plus service name
        UUID[] uuids = new UUID[] {new UUID(SERIALID)}; // Serial port service
        // agent.searchServices(attrs, uuids, remote, this);
        agent.searchServices(null, uuids, remote, this);
      } catch (BluetoothStateException bse) {
        System.out.println("service search failed");
      }
    }
  }
Exemple #7
0
 public void startApp() {
   this.gameCanvas = new MobileBoard();
   this.t = new Thread(gameCanvas);
   t.start();
   d = Display.getDisplay(this);
   d.setCurrent(gameCanvas);
 }
  /** Creates a new instance of PrivacyForm */
  public PrivacyForm(Display display, PrivacyItem item, PrivacyList plist) {
    this.display = display;
    parentView = display.getCurrent();
    this.item = item;
    targetList = plist;

    textValue = new TextField(null, item.value, 64, ConstMIDP.TEXTFIELD_URL);
    TextFieldCombo.setLowerCaseLatin(textValue);

    form.append(choiceAction);
    choiceAction.setSelectedIndex(item.action, true);

    form.append(choiseType);

    form.append(textValue);
    choiseType.setSelectedIndex(item.type, true);
    switchType();

    form.append(choiseStanzas);
    choiseStanzas.setSelectedFlags(item.stanzasSet);

    // form.append("Order: "+item.order);

    form.setItemStateListener(this);
    form.setCommandListener(this);
    form.addCommand(cmdOk);
    form.addCommand(cmdCancel);
    display.setCurrent(form);
  }
 public void startApp() {
   display = Display.getDisplay(this);
   Form form = new Form("Date Field");
   form.append(datein);
   form.append(dateout);
   display.setCurrent(form);
 }
  private void createForm(
      final Display display, String room, String server, String nick, final String password) {
    this.display = display;
    parentView = display.getCurrent();

    Form formJoin = new Form(SR.MS_JOIN_CONFERENCE);

    roomField = new TextField(SR.MS_ROOM, room, 64, ConstMIDP.TEXTFIELD_URL);
    TextFieldCombo.setLowerCaseLatin(roomField);
    formJoin.append(roomField);

    hostField = new TextField(SR.MS_AT_HOST, server, 64, ConstMIDP.TEXTFIELD_URL);
    TextFieldCombo.setLowerCaseLatin(hostField);
    formJoin.append(hostField);

    if (nick == null) nick = sd.account.getNickName();
    nickField = new TextFieldCombo(SR.MS_NICKNAME, nick, 32, TextField.ANY, "roomnick", display);
    formJoin.append(nickField);

    passField =
        new TextField(SR.MS_PASSWORD, password, 32, TextField.ANY | ConstMIDP.TEXTFIELD_SENSITIVE);
    formJoin.append(passField);

    msgLimitField = new NumberField(SR.MS_MSG_LIMIT, 20, 0, 20);
    formJoin.append(msgLimitField);

    formJoin.addCommand(cmdJoin);
    // formJoin.addCommand(cmdBookmarks);
    formJoin.addCommand(cmdAdd);

    formJoin.addCommand(cmdCancel);
    formJoin.setCommandListener(this);
    display.setCurrent(formJoin);
  }
  public void startNotify() {
    release();
    if (enableLights) display.flashBacklight(1000);

    if (lenVibra > 0) display.vibrate(lenVibra);
    new Thread(this).start();
  }
Exemple #12
0
  public void switchDisplayable(Alert alert, Displayable nextDisplayable) {

    Display display = getDisplay();
    if (alert == null) {
      display.setCurrent(nextDisplayable);
    } else {
      display.setCurrent(alert, nextDisplayable);
    }
  }
 public void commandAction(Command c, Displayable d) {
   if (c == backCmd) {
     display = Display.getDisplay(midlet);
     display.setCurrent(query);
   } else if (c == saveCmd) {
     display = Display.getDisplay(midlet);
     display.setCurrent(query);
     // save();
   }
 }
Exemple #14
0
  public WMouseXP() {
    curInstance = this;

    if (checBTAPISupport()) {
      maincanvas = new MainCanvas(false);
      Display.getDisplay(this).setCurrent(maincanvas);
    } else {
      Display.getDisplay(this).setCurrent(get_NoBTAPIForm());
    }
  }
 /**
  * Switches a current displayable in a display. The <code>display</code> instance is taken from
  * <code>getDisplay</code> method. This method is used by all actions in the design for switching
  * displayable.
  *
  * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then
  *     <code>nextDisplayable</code> is set immediately
  * @param nextDisplayable the Displayable to be set
  */
 public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
   // GEN-END:|5-switchDisplayable|0|5-preSwitch
   // write pre-switch user code here
   Display display = getDisplay(); // GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
   if (alert == null) {
     display.setCurrent(nextDisplayable);
   } else {
     display.setCurrent(alert, nextDisplayable);
   } // GEN-END:|5-switchDisplayable|1|5-postSwitch
   // write post-switch user code here
 } // GEN-BEGIN:|5-switchDisplayable|2|
  // #ifdef includePhoto
  // [NC] Added in the scenario 07
  public void showImage(String name) {
    // [EF] Instead of replicating this code, I change to use the method "getSelectedImageName()".
    Image storedImage = null;
    try {
      storedImage =
          ((ImageAlbumData) getAlbumData()).getImageFromRecordStore(getCurrentStoreName(), name);
    } 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());
      return;
    } catch (PersistenceMechanismException e) {
      Alert alert =
          new Alert("Error", "The mobile database can open this photo", null, AlertType.ERROR);
      Display.getDisplay(midlet).setCurrent(alert, Display.getDisplay(midlet).getCurrent());
      return;
    }

    // We can pass in the image directly here, or just the name/model pair and have it loaded
    PhotoViewScreen canv = new PhotoViewScreen(storedImage);
    canv.setCommandListener(this);
    AbstractController nextcontroller = this;
    // #if includeCopyMedia || includeSmsFeature
    // [NC] Changed in the scenario 07: just the first line below to support generic
    // AbstractController
    PhotoViewController controller =
        new PhotoViewController(
            midlet, getAlbumData(), (AlbumListScreen) getAlbumListScreen(), name);
    controller.setNextController(nextcontroller);
    canv.setCommandListener(controller);
    nextcontroller = controller;
    // #endif

    // #ifdef includeSmsFeature
    /* [NC] Added in scenario 06 */
    // [NC] Changed in the scenario 07: just the first line below to support generic
    // AbstractController
    SmsSenderController smscontroller =
        new SmsSenderController(
            midlet, getAlbumData(), (AlbumListScreen) getAlbumListScreen(), name);
    // this.setNextController(smscontroller);
    smscontroller.setNextController(nextcontroller);
    canv.setCommandListener(smscontroller);
    nextcontroller = smscontroller;
    // #endif

    setCurrentScreen(canv);
  }
  private void showMessage(String msg) {
    Logger.debug(PanicConstants.TAG, "msg: " + msg);

    if (_display.getCurrent() == _tbMain) {
      try {
        _tbMain.setString(msg);
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else if (_display.getCurrent() == _lsCanvas) {
      _lsCanvas.setLargeString(msg);
    }
  }
 public void startApp() {
   display = Display.getDisplay(this);
   try {
     form.append(img);
   } catch (Exception e) {
   }
   form.append(userName);
   form.append(password);
   form.addCommand(cancel);
   form.addCommand(login);
   form.setCommandListener(this);
   display.setCurrent(form);
 }
Exemple #19
0
 /**
  * Creates an alert message on the phone.
  *
  * @param message The message to display.
  */
 public void alertError(String message) {
   Alert alert = new Alert("Alert", message, null, AlertType.CONFIRMATION);
   Display display = Display.getDisplay(this.midlet);
   Displayable current = display.getCurrent();
   if (!(current instanceof Alert)) {
     // This next call can't be done when current is an Alert
     display.setCurrent(alert, current);
   }
   try {
     Thread.sleep(2000);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
 }
Exemple #20
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();
    }
  }
  /**
   * Starts application and shows the list of samples. The user can select a sample for execution
   * and return to the selection screen.
   */
  public void startApp() {

    M3GCanvas mCanvas = new M3GCanvas();
    mCanvas.addCommand(exitCommand);
    mCanvas.setCommandListener(this);
    Display.getDisplay(this).setCurrent(mCanvas);
  }
Exemple #22
0
 public void startApp() {
   if (mForm == null) {
     mForm = new Form(mAppID);
     mNumberEntry = new TextField("Connect To:", null, 256, TextField.PHONENUMBER);
     try {
       mInitialImage = Image.createImage(DEFAULT_IMAGE);
     } catch (Exception e) {
       System.out.println("start app err");
       e.printStackTrace();
     }
     mColorSquare =
         new ImageItem(null, mInitialImage, ImageItem.LAYOUT_DEFAULT, "waiting for image");
     mForm.append(mNumberEntry);
     mForm.append(mColorSquare);
     mForm.addCommand(mRedCommand);
     mForm.addCommand(mExitCommand);
     mForm.addCommand(mBlueCommand);
     mForm.setCommandListener(this);
   }
   Display.getDisplay(this).setCurrent(mForm);
   try {
     conn = (MessageConnection) Connector.open("mms://:" + mAppID);
     conn.setMessageListener(this);
   } catch (Exception e) {
     System.out.println("" + e);
   }
   if (conn != null) {
     startReceive();
   }
 }
Exemple #23
0
  public void showCategory(int selectedCategory) {
    if (selectedCategory == PARENT_CATEGORY_ROOT_FILE) {
      level = ROOT_FILE;
      selectedCategory = PARENT_CATEGORY_TOP;
    }
    if (level == ROOT_FILE) {
      setRootContent();
      displayedCategory = (Category) categoriesIndex.elementAt(0);
      level = NON_ROOT_FILE;
      lastSelectedCategoryIndex = PARENT_CATEGORY_TOP;
    } else if (level == NON_ROOT_FILE) {
      createContentObjectAndInitCategory(selectedCategory);
      level = IN_NON_ROOT_FILE;
      lastSelectedCategoryIndex = PARENT_CATEGORY_TOP;
    } else if (level == IN_NON_ROOT_FILE) {
      displayedCategory = (Category) categoriesIndex.elementAt(selectedCategory);
      lastSelectedCategoryIndex = selectedCategory;
    }
    subCategories = displayedCategory.subcategories;
    items = displayedCategory.items;

    String[] sArray = new String[subCategories.size() + items.size()];
    fillCategories(sArray);
    fillItems(sArray);
    List tmpList = showList(tr.t("CATEGORIES"), sArray);
    tmpList.setSelectedIndex(displayedCategory.lastSelectedPosition, true);

    display.setCurrent(tmpList);
  }
Exemple #24
0
 /**
  * @see javax.microedition.lcdui.CommandListener#commandAction(javax.microedition.lcdui.Command,
  *     javax.microedition.lcdui.Displayable)
  */
 public void commandAction(Command c, Displayable d) {
   if (c == back) {
     Display.getDisplay(midlet).setCurrent(backScreen);
   } else if (c == select) {
     listTweets();
   }
 }
Exemple #25
0
  /**
   * Display the connecting form to the user, let call set actions.
   *
   * @param action action to put in the form's title
   * @param name name to in the form's title
   * @param url URL of a JAD
   * @param size 0 if unknown, else size of object to download in K bytes
   * @param gaugeLabel label for progress gauge
   * @return displayed form
   */
  private Form displayProgressForm(
      String action, String name, String url, int size, String gaugeLabel) {
    Gauge progressGauge;
    StringItem urlItem;

    progressForm = new Form(null);

    progressForm.setTitle(action + " " + name);

    if (size <= 0) {
      progressGauge = new Gauge(gaugeLabel, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);
    } else {
      progressGauge = new Gauge(gaugeLabel, false, size, 0);
    }

    progressGaugeIndex = progressForm.append(progressGauge);

    if (url == null) {
      urlItem = new StringItem("", "");
    } else {
      urlItem = new StringItem(Resource.getString(ResourceConstants.AMS_WEBSITE) + ": ", url);
    }

    progressUrlIndex = progressForm.append(urlItem);

    display.setCurrent(progressForm);
    lastDisplayChange = System.currentTimeMillis();

    return progressForm;
  }
 /**
  * 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);
 }
  /**
   * 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());
  }
Exemple #28
0
 public boolean onPrepareOptionsMenu(Menu menu) {
   Displayable d = Display.getDisplay(midlet).getCurrent();
   if (d != null) {
     return d.onPrepareOptionsMenu(menu);
   }
   return false;
 }
Exemple #29
0
 public boolean onOptionsItemSelected(MenuItem item) {
   Displayable d = Display.getDisplay(midlet).getCurrent();
   if (d != null) {
     return d.onOptionsItemSelected(item);
   }
   return super.onOptionsItemSelected(item);
 }
  public void commandAction(Command c, Displayable d) {
    if (c == cmdCancel) {
      destroyView();
    }
    // if (c==cmdBookmarks) { new Bookmarks(display, null); }
    if (c == cmdJoin || c == cmdAdd) {
      String nick = nickField.getString().trim();
      String host = hostField.getString().trim();
      String room = roomField.getString().trim();
      String pass = passField.getString();
      int msgLimit = msgLimitField.getValue();

      if (nick.length() == 0) return;
      if (room.length() == 0) return;
      if (host.length() == 0) return;
      StringBuffer gchat = new StringBuffer(room.trim());
      gchat.append('@');
      gchat.append(host.trim());
      // sd.roster.mucContact(gchat.toString(), Contact.ORIGIN_GROUPCHAT);
      if (c == cmdAdd) new Bookmarks(display, new BookmarkItem(gchat.toString(), nick, pass));
      else {
        try {
          gchat.append('/');
          gchat.append(nick);
          join(gchat.toString(), pass, msgLimit);

          display.setCurrent(sd.roster);
        } catch (Exception e) {
          e.printStackTrace();
          // display.setCurrent(new Alert("Exception", e.toString(), null, AlertType.ERROR),
          // sd.roster);
        }
      }
    }
  }