import java.util.List;
import be.nikiroo.jvcard.launcher.Main;
-import be.nikiroo.jvcard.resources.StringUtils;
-import be.nikiroo.jvcard.resources.Trans.StringId;
+import be.nikiroo.jvcard.resources.ColorOption;
+import be.nikiroo.jvcard.resources.StringId;
import be.nikiroo.jvcard.tui.KeyAction.Mode;
-import be.nikiroo.jvcard.tui.UiColors.Element;
import be.nikiroo.jvcard.tui.panes.ContactDetails;
import be.nikiroo.jvcard.tui.panes.ContactDetailsRaw;
import be.nikiroo.jvcard.tui.panes.ContactList;
import be.nikiroo.jvcard.tui.panes.MainContent;
+import be.nikiroo.utils.StringUtils;
+import be.nikiroo.utils.Version;
import com.googlecode.lanterna.TerminalSize;
import com.googlecode.lanterna.gui2.BasicWindow;
* Information about a question to ask the user and its answer.
*
* @author niki
- *
+ *
*/
private class UserQuestion {
private boolean oneKeyAnswer;
if (mess != null || messagePanel.getChildCount() > 0) {
messagePanel.removeAllComponents();
if (mess != null) {
- Element element = (error ? UiColors.Element.LINE_MESSAGE_ERR
- : UiColors.Element.LINE_MESSAGE);
- Label lbl = element.createLabel(" " + mess + " ");
+ ColorOption element = (error ? ColorOption.LINE_MESSAGE_ERR
+ : ColorOption.LINE_MESSAGE);
+ Label lbl = UiColors.createLabel(element, " " + mess + " ");
messagePanel.addComponent(lbl, LinearLayout
.createLayoutData(LinearLayout.Alignment.Center));
}
llayout.setSpacing(0);
hpanel.setLayoutManager(llayout);
- Label lbl = UiColors.Element.LINE_MESSAGE_QUESTION.createLabel(" "
+ Label lbl = UiColors.createLabel(ColorOption.LINE_MESSAGE_QUESTION, " "
+ question + " ");
text = new TextBox(new TerminalSize(getSize().getColumns()
- lbl.getSize().getColumns(), 1));
*/
private void setTitle() {
String prefix = " " + Main.APPLICATION_TITLE + " (version "
- + Main.APPLICATION_VERSION + ")";
+ + Version.getCurrentVersion() + ")";
String title = null;
int count = -1;
super.setTitle(prefix);
Label lblPrefix = new Label(prefix);
- UiColors.Element.TITLE_MAIN.themeLabel(lblPrefix);
+ UiColors.themeLabel(ColorOption.TITLE_MAIN, lblPrefix);
Label lblTitle = null;
if (title.length() > 0) {
lblTitle = new Label(title);
- UiColors.Element.TITLE_VARIABLE.themeLabel(lblTitle);
+ UiColors.themeLabel(ColorOption.TITLE_VARIABLE, lblTitle);
}
- Label lblCount = null;
- if (countStr != null) {
- lblCount = new Label(countStr);
- UiColors.Element.TITLE_COUNT.themeLabel(lblCount);
- }
+ Label lblCount = new Label(countStr);
+ UiColors.themeLabel(ColorOption.TITLE_COUNT, lblCount);
titlePanel.removeAllComponents();
titlePanel.addComponent(lblPrefix, BorderLayout.Location.LEFT);
- if (lblTitle != null)
+ if (lblTitle != null) {
titlePanel.addComponent(lblTitle, BorderLayout.Location.CENTER);
- if (lblCount != null)
- titlePanel.addComponent(lblCount, BorderLayout.Location.RIGHT);
+ }
+ titlePanel.addComponent(lblCount, BorderLayout.Location.RIGHT);
}
}
layout.setSpacing(0);
kPane.setLayoutManager(layout);
- kPane.addComponent(UiColors.Element.ACTION_KEY
- .createLabel(keyTrans));
- kPane.addComponent(UiColors.Element.ACTION_DESC.createLabel(trans));
+ kPane.addComponent(UiColors.createLabel(ColorOption.ACTION_KEY,
+ keyTrans));
+ kPane.addComponent(UiColors.createLabel(ColorOption.ACTION_DESC,
+ trans));
actionPanel.addComponent(kPane);
}
}
if (width > 0) {
- actionPanel.addComponent(UiColors.Element.ACTION_DESC
- .createLabel(StringUtils.padString("", width)));
+ actionPanel.addComponent(UiColors.createLabel(
+ ColorOption.ACTION_DESC, StringUtils.padString("", width)));
}
}
*
* @param key
* the key that was pressed
- * @param answer
- * the answer given for this key
*
* @return if the window handled the input
*/
setMessage(mess, action.isError());
}
- if (action.onAction()) {
+ if (!action.isError() && action.onAction()) {
handleAction(action, null);
}
/**
* Handle the input in case of "normal" (not "ask for answer") mode.
*
- * @param key
- * the key that was pressed
+ * @param action
+ * the key that was pressed and the action to take
* @param answer
* the answer given for this key
*
- * @return if the window handled the input
*/
private void handleAction(KeyAction action, String answer) {
MainContent content = getContent();