2 * This file is part of lanterna (http://code.google.com/p/lanterna/).
4 * lanterna is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Copyright (C) 2010-2015 Martin
19 package com
.googlecode
.lanterna
.gui2
.dialogs
;
21 import com
.googlecode
.lanterna
.gui2
.*;
24 * Dialog that displays a text message, an optional spinning indicator and an optional progress bar. There is no buttons
25 * in this dialog so it has to be explicitly closed through code.
28 public class WaitingDialog
extends DialogWindow
{
29 private WaitingDialog(String title
, String text
) {
32 Panel mainPanel
= Panels
.horizontal(
34 AnimatedLabel
.createClassicSpinningLine());
35 setComponent(mainPanel
);
39 public Object
showDialog(WindowBasedTextGUI textGUI
) {
40 showDialog(textGUI
, true);
45 * Displays the waiting dialog and optionally blocks until another thread closes it
46 * @param textGUI GUI to add the dialog to
47 * @param blockUntilClosed If {@code true}, the method call will block until another thread calls {@code close()} on
48 * the dialog, otherwise the method call returns immediately
50 public void showDialog(WindowBasedTextGUI textGUI
, boolean blockUntilClosed
) {
51 textGUI
.addWindow(this);
53 if(blockUntilClosed
) {
54 //Wait for the window to close, in case the window manager doesn't honor the MODAL hint
60 * Creates a new waiting dialog
61 * @param title Title of the waiting dialog
62 * @param text Text to display on the waiting dialog
63 * @return Created waiting dialog
65 public static WaitingDialog
createDialog(String title
, String text
) {
66 return new WaitingDialog(title
, text
);
70 * Creates and displays a waiting dialog without blocking for it to finish
71 * @param textGUI GUI to add the dialog to
72 * @param title Title of the waiting dialog
73 * @param text Text to display on the waiting dialog
74 * @return Created waiting dialog
76 public static WaitingDialog
showDialog(WindowBasedTextGUI textGUI
, String title
, String text
) {
77 WaitingDialog waitingDialog
= createDialog(title
, text
);
78 waitingDialog
.showDialog(textGUI
, false);