source: josm/trunk/src/org/openstreetmap/josm/gui/IExtendedDialog.java@ 12749

Last change on this file since 12749 was 12678, checked in by Don-vip, 7 years ago

see #15182 - move WindowGeometry from tools to gui.util

  • Property svn:eol-style set to native
File size: 6.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui;
3
4import java.awt.Component;
5
6import javax.swing.Icon;
7import javax.swing.JOptionPane;
8
9import org.openstreetmap.josm.gui.util.WindowGeometry;
10
11/**
12 * Extracted interface of {@link ExtendedDialog} class.
13 * @since 11945
14 */
15public interface IExtendedDialog {
16
17 /**
18 * Allows decorating the buttons with icons.
19 * @param buttonIcons The button icons
20 * @return {@code this}
21 */
22 ExtendedDialog setButtonIcons(Icon... buttonIcons);
23
24 /**
25 * Convenience method to provide image names instead of images.
26 * @param buttonIcons The button icon names
27 * @return {@code this}
28 */
29 ExtendedDialog setButtonIcons(String... buttonIcons);
30
31 /**
32 * Allows decorating the buttons with tooltips. Expects a String array with
33 * translated tooltip texts.
34 *
35 * @param toolTipTexts the tool tip texts. Ignored, if null.
36 * @return {@code this}
37 */
38 ExtendedDialog setToolTipTexts(String... toolTipTexts);
39
40 /**
41 * Sets the content that will be displayed in the message dialog.
42 *
43 * Note that depending on your other settings more UI elements may appear.
44 * The content is played on top of the other elements though.
45 *
46 * @param content Any element that can be displayed in the message dialog
47 * @return {@code this}
48 */
49 ExtendedDialog setContent(Component content);
50
51 /**
52 * Sets the content that will be displayed in the message dialog.
53 *
54 * Note that depending on your other settings more UI elements may appear.
55 * The content is played on top of the other elements though.
56 *
57 * @param content Any element that can be displayed in the message dialog
58 * @param placeContentInScrollPane if true, places the content in a JScrollPane
59 * @return {@code this}
60 */
61 ExtendedDialog setContent(Component content, boolean placeContentInScrollPane);
62
63 /**
64 * Sets the message that will be displayed. The String will be automatically
65 * wrapped if it is too long.
66 *
67 * Note that depending on your other settings more UI elements may appear.
68 * The content is played on top of the other elements though.
69 *
70 * @param message The text that should be shown to the user
71 * @return {@code this}
72 */
73 ExtendedDialog setContent(String message);
74
75 /**
76 * Decorate the dialog with an icon that is shown on the left part of
77 * the window area. (Similar to how it is done in {@link JOptionPane})
78 * @param icon The icon to display
79 * @return {@code this}
80 */
81 ExtendedDialog setIcon(Icon icon);
82
83 /**
84 * Convenience method to allow values that would be accepted by {@link JOptionPane} as messageType.
85 * @param messageType The {@link JOptionPane} messageType
86 * @return {@code this}
87 */
88 ExtendedDialog setIcon(int messageType);
89
90 /**
91 * Show the dialog to the user. Call this after you have set all options
92 * for the dialog. You can retrieve the result using {@link #getValue()}.
93 * @return {@code this}
94 */
95 ExtendedDialog showDialog();
96
97 /**
98 * Retrieve the user choice after the dialog has been closed.
99 *
100 * @return <ul> <li>The selected button. The count starts with 1.</li>
101 * <li>A return value of {@link ExtendedDialog#DialogClosedOtherwise} means the dialog has been closed otherwise.</li>
102 * </ul>
103 */
104 int getValue();
105
106 /**
107 * This is called by {@link #showDialog()}.
108 * Only invoke from outside if you need to modify the contentPane
109 */
110 void setupDialog();
111
112 /**
113 * Call this if you want the dialog to remember the geometry (size and position) set by the user.
114 * Set the pref to <code>null</code> or to an empty string to disable again.
115 * By default, it's disabled.
116 *
117 * Note: If you want to set the width of this dialog directly use the usual
118 * setSize, setPreferredSize, setMaxSize, setMinSize
119 *
120 * @param pref The preference to save the dimension to
121 * @param wg The default window geometry that should be used if no
122 * existing preference is found (only takes effect if
123 * <code>pref</code> is not null or empty
124 * @return {@code this}
125 */
126 ExtendedDialog setRememberWindowGeometry(String pref, WindowGeometry wg);
127
128 /**
129 * Calling this will offer the user a "Do not show again" checkbox for the
130 * dialog. Default is to not offer the choice; the dialog will be shown
131 * every time.
132 * Currently, this is not supported for non-modal dialogs.
133 * @param togglePref The preference to save the checkbox state to
134 * @return {@code this}
135 */
136 ExtendedDialog toggleEnable(String togglePref);
137
138 /**
139 * Sets the button that will react to ENTER.
140 * @param defaultButtonIdx The button index (starts to 1)
141 * @return {@code this}
142 */
143 ExtendedDialog setDefaultButton(int defaultButtonIdx);
144
145 /**
146 * Used in combination with toggle:
147 * If the user presses 'cancel' the toggle settings are ignored and not saved to the pref
148 * @param cancelButtonIdx index of the button that stands for cancel, accepts multiple values
149 * @return {@code this}
150 */
151 ExtendedDialog setCancelButton(Integer... cancelButtonIdx);
152
153 /**
154 * Makes default button request initial focus or not.
155 * @param focus {@code true} to make default button request initial focus
156 * @since 7407
157 */
158 void setFocusOnDefaultButton(boolean focus);
159
160 /**
161 * This function returns true if the dialog has been set to "do not show again"
162 * @return true if dialog should not be shown again
163 */
164 boolean toggleCheckState();
165
166 /**
167 * Configures how this dialog support for context sensitive help.
168 * <ul>
169 * <li>if helpTopic is null, the dialog doesn't provide context sensitive help</li>
170 * <li>if helpTopic != null, the dialog redirect user to the help page for this helpTopic when
171 * the user clicks F1 in the dialog</li>
172 * <li>if showHelpButton is true, the dialog displays "Help" button (rightmost button in
173 * the button row)</li>
174 * </ul>
175 *
176 * @param helpTopic the help topic
177 * @param showHelpButton true, if the dialog displays a help button
178 * @return {@code this}
179 */
180 ExtendedDialog configureContextsensitiveHelp(String helpTopic, boolean showHelpButton);
181}
Note: See TracBrowser for help on using the repository browser.