Change build scripts
[jvcard.git] / src / com / googlecode / lanterna / gui2 / dialogs / DialogWindow.java
CommitLineData
a3b510ab
NR
1package com.googlecode.lanterna.gui2.dialogs;
2
3import com.googlecode.lanterna.gui2.*;
4
5import java.util.Collections;
6import java.util.HashSet;
7import java.util.Set;
8
9/**
10 * Thin layer on top of the {@code AbstractWindow} class that automatically sets properties and hints to the window to
11 * make it act more like a modal dialog window
12 */
13public abstract class DialogWindow extends AbstractWindow {
14
15 private static final Set<Hint> GLOBAL_DIALOG_HINTS =
16 Collections.unmodifiableSet(new HashSet<Hint>(Collections.singletonList(Hint.MODAL)));
17
18 /**
19 * Default constructor, takes a title for the dialog and runs code shared for dialogs
20 * @param title
21 */
22 protected DialogWindow(String title) {
23 super(title);
24 setHints(GLOBAL_DIALOG_HINTS);
25 }
26
27 /**
28 * Opens the dialog by showing it on the GUI and doesn't return until the dialog has been closed
29 * @param textGUI Text GUI to add the dialog to
30 * @return Depending on the {@code DialogWindow} implementation, by default {@code null}
31 */
32 public Object showDialog(WindowBasedTextGUI textGUI) {
33 textGUI.addWindow(this);
34
35 //Wait for the window to close, in case the window manager doesn't honor the MODAL hint
36 waitUntilClosed();
37 return null;
38 }
39}