- public void setMessage(String mess, boolean error) {
- messagePanel.removeAllComponents();
- if (mess != null) {
- Element element = (error ? UiColors.Element.LINE_MESSAGE_ERR
- : UiColors.Element.LINE_MESSAGE);
- Label lbl = element.createLabel(" " + mess + " ");
- messagePanel.addComponent(lbl, LinearLayout
- .createLayoutData(LinearLayout.Alignment.Center));
+ public boolean setMessage(String mess, boolean error) {
+ 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 + " ");
+ messagePanel.addComponent(lbl, LinearLayout
+ .createLayoutData(LinearLayout.Alignment.Center));
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Show a question to the user and switch to "ask for answer" mode see
+ * {@link MainWindow#handleQuestion}. The user will be asked to enter some
+ * answer and confirm with ENTER.
+ *
+ * @param question
+ * the question to ask
+ * @param initial
+ * the initial answer if any (to be edited by the user)
+ */
+ public void setQuestion(KeyStroke key, String question, String initial) {
+ setQuestion(key, question, initial, false);
+ }
+
+ /**
+ * Show a question to the user and switch to "ask for answer" mode see
+ * {@link MainWindow#handleQuestion}. The user will be asked to hit one key
+ * as an answer.
+ *
+ * @param question
+ * the question to ask
+ */
+ public void setQuestion(KeyStroke key, String question) {
+ setQuestion(key, question, null, true);
+ }
+
+ @Override
+ public void draw(TextGUIGraphics graphics) {
+ int width = graphics.getSize().getColumns();
+
+ if (width != this.width) {
+ this.width = width;
+
+ setTitle();
+
+ if (actions != null)
+ setActions(new ArrayList<KeyAction>(actions), false);
+ }
+
+ super.draw(graphics);
+ }
+
+ @Override
+ public void invalidate() {
+ super.invalidate();
+ for (MainContent content : contentStack) {
+ content.invalidate();