X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Ftui%2FMainWindow.java;h=a87b7ba9b7b09c393cd2d950810ae0e277fea87b;hb=59597d59aa262e31c2e1b7f66b4cb299f88ebd1b;hp=c3277e3c0f7dc5c11a6b9f3519b3bbdeb1734870;hpb=668268fc236425a7be575417cd0d3810c29127a1;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/tui/MainWindow.java b/src/be/nikiroo/jvcard/tui/MainWindow.java index c3277e3..a87b7ba 100644 --- a/src/be/nikiroo/jvcard/tui/MainWindow.java +++ b/src/be/nikiroo/jvcard/tui/MainWindow.java @@ -1,13 +1,16 @@ package be.nikiroo.jvcard.tui; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import be.nikiroo.jvcard.i18n.Trans.StringId; +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.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; @@ -219,6 +222,16 @@ public class MainWindow extends BasicWindow { if (contentStack.size() > 0) prev = contentStack.remove(contentStack.size() - 1); + if (prev != null) { + try { + String mess = prev.wakeup(); + if (mess != null) + setMessage(mess, false); + } catch (IOException e) { + setMessage(e.getMessage(), true); + } + } + pushContent(prev); return removed; @@ -238,9 +251,9 @@ public class MainWindow extends BasicWindow { 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)); } @@ -305,7 +318,7 @@ public class MainWindow extends BasicWindow { 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)); @@ -407,8 +420,7 @@ public class MainWindow extends BasicWindow { if (title.length() > 0) { prefix = prefix + ": "; - title = StringUtils.sanitize(title, UiColors.getInstance() - .isUnicode()); + title = StringUtils.sanitize(title, Main.isUnicode()); } String countStr = ""; @@ -439,18 +451,18 @@ public class MainWindow extends BasicWindow { 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); + UiColors.themeLabel(ColorOption.TITLE_COUNT, lblCount); } titlePanel.removeAllComponents(); @@ -501,16 +513,17 @@ public class MainWindow extends BasicWindow { if (" ".equals(trans)) continue; - String keyTrans = Main.trans(action.getKey()); + String keyTrans = KeyAction.trans(action.getKey()); Panel kPane = new Panel(); LinearLayout layout = new LinearLayout(Direction.HORIZONTAL); 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); } @@ -522,8 +535,8 @@ public class MainWindow extends BasicWindow { } if (width > 0) { - actionPanel.addComponent(UiColors.Element.ACTION_DESC - .createLabel(StringUtils.padString("", width))); + actionPanel.addComponent(UiColors.createLabel( + ColorOption.ACTION_DESC, StringUtils.padString("", width))); } } @@ -609,7 +622,13 @@ public class MainWindow extends BasicWindow { handled = true; - if (action.onAction()) { + action.getObject(); // see {@link KeyAction#getMessage()} + String mess = action.getMessage(); + if (mess != null) { + setMessage(mess, action.isError()); + } + + if (!action.isError() && action.onAction()) { handleAction(action, null); } @@ -657,6 +676,10 @@ public class MainWindow extends BasicWindow { case CONTACT_LIST: if (action.getCard() != null) { pushContent(new ContactList(action.getCard())); + } else if (action.getObject() != null + && action.getObject() instanceof MainContent) { + MainContent mergeContent = (MainContent) action.getObject(); + pushContent(mergeContent); } break; case CONTACT_DETAILS: