Optional.runServer(port);
} catch (Exception e) {
if (e instanceof IOException) {
- System.err
- .println("I/O Exception: Cannot start the server");
- } else {
+ ERR(StringId.CLI_ERR, StringId.CLI_ERR_CANNOT_START,
+ ERR_INTERNAL);
+ return;
+ } else if (e instanceof ClassNotFoundException) {
ERR(StringId.CLI_ERR, StringId.CLI_ERR_NO_REMOTING,
ERR_INTERNAL);
return;
+ } else {
+ e.printStackTrace();
+ ERR(StringId.CLI_ERR, StringId.CLI_ERR, ERR_INTERNAL);
+ return;
}
}
break;
try {
transService.updateFile(dir);
} catch (IOException e) {
- System.err.println(trans(StringId.CLI_ERR_CANNOT_CREATE_LANG,
- dir));
- e.printStackTrace();
+ ERR(StringId.CLI_ERR, StringId.CLI_ERR_CANNOT_CREATE_LANG,
+ ERR_INTERNAL);
+ return;
}
break;
}
ERR(StringId.CLI_ERR, StringId.CLI_ERR_CANNOT_START,
ERR_NO_FILE);
return;
- } else {
+ } else if (e instanceof ClassNotFoundException) {
ERR(StringId.CLI_ERR, StringId.CLI_ERR_NO_TUI, ERR_INTERNAL);
return;
+ } else {
+ e.printStackTrace();
+ ERR(StringId.CLI_ERR, StringId.CLI_ERR, ERR_INTERNAL);
+ return;
}
}
break;
import be.nikiroo.jvcard.tui.KeyAction;
import be.nikiroo.jvcard.tui.KeyAction.DataType;
import be.nikiroo.jvcard.tui.KeyAction.Mode;
+import be.nikiroo.jvcard.tui.TuiLauncher;
+import com.googlecode.lanterna.gui2.MultiWindowTextGUI;
+import com.googlecode.lanterna.gui2.dialogs.ActionListDialogBuilder;
import com.googlecode.lanterna.input.KeyType;
public class ContactDetailsRaw extends MainContentList {
return null;
}
});
- // TODO: ui
+ // TODO: ui and i18n
actions.add(new KeyAction(Mode.ASK_USER, 'a', StringId.KEY_ACTION_ADD) {
+ private String name;
+
+ @Override
+ public boolean onAction() {
+ new ActionListDialogBuilder()
+ .setTitle("New data")
+ .setDescription("Choose a data type")
+ .addAction("Email address", new Runnable() {
+ @Override
+ public void run() {
+ name = "EMAIL";
+ }
+ })
+ .addAction("Telephone number", new Runnable() {
+ @Override
+ public void run() {
+ name = "TEL";
+ }
+ })
+ .addAction("Birthday", new Runnable() {
+ @Override
+ public void run() {
+ name = "BDAY";
+ }
+ })
+ .addAction("[other]", new Runnable() {
+ @Override
+ public void run() {
+ name = "";
+ }
+ })
+ .build()
+ .showDialog(
+ new MultiWindowTextGUI(TuiLauncher.getScreen()));
+
+ String name = this.name;
+ this.name = null;
+
+ if (name != null) {
+ if (name.length() > 0) {
+ Data data = new Data(null, name, "", null);
+ getContact().add(data);
+ addItem("x");
+ }
+
+ return (name.length() == 0);
+ }
+
+ return false;
+ }
+
@Override
public Object getObject() {
return contact;
@Override
public String getQuestion() {
// TODO i18n
- return "new data (xx.group = yy): ";
+ if (name == null)
+ return "Data name: ";
+
+ return null;
}
@Override
public String callback(String answer) {
- int indexEq = answer.indexOf('=');
- if (indexEq >= 0) {
- String name = answer.substring(0, indexEq).trim();
- String value = answer.substring(indexEq + 1).trim();
- String group = null;
-
- int indexDt = name.indexOf('.');
- if (indexDt >= 0) {
- group = name.substring(indexDt + 1).trim();
- name = name.substring(0, indexDt).trim();
- }
-
- Data data = new Data(null, name, value, group);
+ if (answer != null & answer.length() > 0) {
+ Data data = new Data(null, answer, "", null);
getContact().add(data);
addItem("x");
}
+
return null;
}
});