/**
  * Método que trata las acciones a ejecutar al producirse un evento
  *
  * @param c Es el evento que se ha producido (o botón que se ha pulsado)
  * @param d Es la pantalla en la que se ha producido el evento
  */
 public void commandAction(Command c, Displayable d) {
   if (c.equals(this.SELECT_COMMAND)) {
     cliente.conecta(getSelectedIndex());
   } else if (c.equals(volver)) {
     padre.commandAction(volver, this);
   } else if (c.equals(buscar)) {
     cliente.buscaDisp();
   }
 }
Beispiel #2
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();
    }
  }