private void initMainMenuList() { mainMenuList = new List(content.title, List.IMPLICIT); mainMenuList.append(tr.t(Translator.CATEGORIES), null); mainMenuList.append(tr.t(Translator.OPTIONS), null); mainMenuList.append(tr.t(Translator.HELP), null); mainMenuList.append(tr.t(Translator.ABOUT), null); mainMenuList.append(tr.t(Translator.EXIT), null); mainMenuList.setCommandListener(this); }
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(); } }
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); }
private void createAboutForm() { form = new Form(tr.t(Translator.ABOUT)); form.setCommandListener(this); form.addCommand(backCommand); StringBuffer sb = new StringBuffer(); sb.append(content.title).append(" by ").append(content.vendor).append('\n'); sb.append("Version: ").append(content.version); sb.append("\nContent copyrights:").append(content.copyrights); sb.append("\n\nCreated using Creomobile Framework"); form.append(sb.toString()); }
public Catalog() { tr = new Translator(); content = new Content(); serializator = new Serializator(1); initMainMenuList(); content.initCategories(); backCommand = new Command(tr.t(Translator.BACK), Command.BACK, 0); backCommandCanvas = new Command(tr.t(Translator.BACK), Command.BACK, 0); canvas = new CatalogCanvas(); // canvas.addCommand(exitCommand); canvas.addCommand(backCommandCanvas); canvas.setCommandListener(this); optionForm = new OptionsForm(this, canvas, tr); display = Display.getDisplay(this); display.setCurrent(mainMenuList); }
private void createHelpForm() { form = new Form(tr.t(Translator.HELP)); form.setCommandListener(this); form.addCommand(backCommand); form.append(tr.t(Translator.HELP_CONTENT)); }