X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Ftui%2FMainWindow.java;h=617d8a521eb692e17f103f56ddb9bf9f6ba0ab4f;hb=d5260eeb873fcf2ef9855dedcd9e2a3a3a990582;hp=1cbc01412a77f9e7163862e85b007f07e6d3a5b5;hpb=e119a1c1a924998b9315e46c96b1c750aab1deb9;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/tui/MainWindow.java b/src/be/nikiroo/jvcard/tui/MainWindow.java index 1cbc014..617d8a5 100644 --- a/src/be/nikiroo/jvcard/tui/MainWindow.java +++ b/src/be/nikiroo/jvcard/tui/MainWindow.java @@ -7,14 +7,15 @@ import java.util.LinkedList; import java.util.List; import be.nikiroo.jvcard.launcher.Main; -import be.nikiroo.jvcard.resources.StringUtils; -import be.nikiroo.jvcard.resources.enums.ColorOption; -import be.nikiroo.jvcard.resources.enums.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.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; @@ -54,7 +55,7 @@ public class MainWindow extends BasicWindow { * Information about a question to ask the user and its answer. * * @author niki - * + * */ private class UserQuestion { private boolean oneKeyAnswer; @@ -404,7 +405,7 @@ public class MainWindow extends BasicWindow { */ private void setTitle() { String prefix = " " + Main.APPLICATION_TITLE + " (version " - + Main.APPLICATION_VERSION + ")"; + + Version.getCurrentVersion() + ")"; String title = null; int count = -1; @@ -459,19 +460,16 @@ public class MainWindow extends BasicWindow { UiColors.themeLabel(ColorOption.TITLE_VARIABLE, lblTitle); } - Label lblCount = null; - if (countStr != null) { - lblCount = new Label(countStr); - UiColors.themeLabel(ColorOption.TITLE_COUNT, 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); } } @@ -522,7 +520,8 @@ public class MainWindow extends BasicWindow { kPane.addComponent(UiColors.createLabel(ColorOption.ACTION_KEY, keyTrans)); - kPane.addComponent(UiColors.createLabel(ColorOption.ACTION_DESC, trans)); + kPane.addComponent(UiColors.createLabel(ColorOption.ACTION_DESC, + trans)); actionPanel.addComponent(kPane); } @@ -534,8 +533,8 @@ public class MainWindow extends BasicWindow { } if (width > 0) { - actionPanel.addComponent(UiColors.createLabel(ColorOption.ACTION_DESC, - StringUtils.padString("", width))); + actionPanel.addComponent(UiColors.createLabel( + ColorOption.ACTION_DESC, StringUtils.padString("", width))); } } @@ -604,8 +603,6 @@ public class MainWindow extends BasicWindow { * * @param key * the key that was pressed - * @param answer - * the answer given for this key * * @return if the window handled the input */ @@ -627,7 +624,7 @@ public class MainWindow extends BasicWindow { setMessage(mess, action.isError()); } - if (action.onAction()) { + if (!action.isError() && action.onAction()) { handleAction(action, null); } @@ -640,12 +637,11 @@ public class MainWindow extends BasicWindow { /** * 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();