+
+ @Override
+ protected boolean onMenu(TMenuEvent menu) {
+ // TODO: i18n
+ switch (menu.getId()) {
+ case MENU_EXIT:
+ if (messageBox("Confirmation", "(TODO: i18n) Exit application?",
+ TMessageBox.Type.YESNO).getResult() == TMessageBox.Result.YES) {
+ exit(false);
+ }
+
+ return true;
+ case MENU_IMPORT_URL:
+ String clipboard = "";
+ try {
+ clipboard = ("" + Toolkit.getDefaultToolkit()
+ .getSystemClipboard().getData(DataFlavor.stringFlavor))
+ .trim();
+ } catch (Exception e) {
+ // No data will be handled
+ }
+
+ if (clipboard == null || !clipboard.startsWith("http")) {
+ clipboard = "";
+ }
+
+ String url = inputBox("Import story", "URL to import", clipboard)
+ .getText();
+
+ if (!imprt(url)) {
+ // TODO: bad import
+ }
+
+ return true;
+ case MENU_IMPORT_FILE:
+ try {
+ String filename = fileOpenBox(".");
+ if (!imprt(filename)) {
+ // TODO: bad import
+ }
+ } catch (IOException e) {
+ // TODO: bad file
+ e.printStackTrace();
+ }
+
+ return true;
+ }
+
+ return super.onMenu(menu);
+ }
+
+ private boolean imprt(String url) {
+ try {
+ reader.getLibrary().imprt(BasicReader.getUrl(url), null);
+ main.refreshStories();
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+ }