Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.swing / org.gvsig.tools.swing.api / src / main / java / org / gvsig / tools / swing / api / threadsafedialogs / ThreadSafeDialogsManager.java @ 1741

History | View | Annotate | Download (8.24 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.swing.api.threadsafedialogs;
25

    
26
import java.awt.Component;
27
import java.io.File;
28
import javax.swing.filechooser.FileFilter;
29

    
30
public interface ThreadSafeDialogsManager {
31
        
32
        /**
33
         * Create a message dialog with an ok button.
34
         * 
35
         * If message or title start whit a "_" then try to translate.
36
         *
37
         * This method is thread safe to use.
38
         * 
39
         * @param message to present in the dialog
40
         * @param title title of the dialog
41
         * @param messageType type of icon to use.
42
         * 
43
         * @see javax.swing.JOptionPane#showMessageDialog(Component, Object, String, int)
44
         */
45
        public void messageDialog(String message, String title, int messageType);
46
        
47
        /**
48
         * Create a message dialog with ok button.
49
         * 
50
         * If message or title start whit a "_" then try to translate.
51
         * if messageArgs not is null the message can be formated whit MessageFormat.
52
         * 
53
         * This method is thread safe to use.
54
         * 
55
         * @param message to present in the dialog
56
         * @param messageArgs string array of arguments used to format the message 
57
         * @param title title of the dialog
58
         * @param messageType type of icon to use.
59
         * 
60
         * @see javax.swing.JOptionPane#showMessageDialog(Component, Object, String, int)
61
         */
62
        public void messageDialog(String message, String messageArgs[], String title, int messageType);
63

    
64
    public void messageDialog(String message, String messageArgs[], String title, int messageType, String msgid);
65
        
66
        /**
67
         * Show a JOptionPane confirm dialog.
68
         * 
69
         * if this method is invoked out of the event dispatch thread of swing, 
70
         * the dialog is presented in the thread of swing and the calling thread
71
         * wait to close to continue.
72
         * 
73
         * @param message
74
         * @param title
75
         * @param optionType
76
         * @param messageType
77
         * @return
78
         * 
79
         * @see javax.swing.JOptionPane#showConfirmDialog(Component, Object, String, int, int)
80
         * 
81
         */
82
        public int confirmDialog(String message, String title, int optionType, int messageType) ;
83
    
84
    public int confirmDialog(String message, String title, int optionType, int messageType, String msgid) ;
85

    
86
        /**
87
         * Show a JOptionPane input dialog.
88
         * 
89
         * if this method is invoked out of the event dispatch thread of swing, 
90
         * the dialog is presented in the thread of swing and the calling thread
91
         * wait to close to continue.
92
         * 
93
         * @param message
94
         * @param title
95
         * @param optionType 
96
         *           an integer designating the options available on the dialog: 
97
         *           YES_NO_OPTION, YES_NO_CANCEL_OPTION, or OK_CANCEL_OPTION
98
         * @param messageType
99
         *           an integer designating the kind of message this is; 
100
         *           primarily used to determine the icon from the pluggable 
101
         *           Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, 
102
         *           WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
103
         * @return
104
         * 
105
         * @see javax.swing.JOptionPane#showInputDialog(Component, Object, String, int)
106
         * 
107
         */
108
        public String inputDialog(String message, String title, int messageType, String initialValue) ;
109
        
110
        /**
111
         * Show a JOptionPane input dialog.
112
         * 
113
         * if this method is invoked out of the event dispatch thread of swing, 
114
         * the dialog is presented in the thread of swing and the calling thread
115
         * wait to close to continue.
116
         * 
117
         * @param message
118
         * @param title
119
         * @param optionType
120
         * @param messageType
121
         * @return
122
         * 
123
         * @see javax.swing.JOptionPane#showInputDialog(Component, Object, String, int)
124
         * 
125
         */
126
        public String inputDialog(String message, String title);
127
                
128
        /**
129
         * Creates an return a new instance of the component specified 
130
         * 
131
         * This method ensure that the component is created in the event dispatch thread of swing. 
132
         * 
133
         * @param theClass of component to be created
134
         * @param parameters passed to the constructor of the component
135
         * 
136
         * @return the instance of the component created
137
         */
138
        public Component createComponent(final Class<? extends Component> theClass,  final Object ... parameters);
139

    
140
        /**
141
         * Creates an return a new instance of the component specified 
142
         * 
143
         * This method ensure that the component is created in the event dispatch thread of swing. 
144
         * 
145
         * @param theClass of component to be created
146
         * @param parameters passed to the constructor of the component
147
         * 
148
         * @return the instance of the component created
149
         */
150
        public Component createComponentWithParams(final Class<? extends Component> theClass,  final Object[] parameters);
151
        
152
        /**
153
         * Creates and show a JFileChooser dialog.
154
         * 
155
         * This method return an array whit the selected files. If multiselection is
156
         * not allowed, an array with one element is returned. 
157
         * 
158
         * If the user select the cancel button, null is returned.
159
         * 
160
         * if this method is invoked out of the event dispatch thread of swing, 
161
         * the dialog is presented in the thread of swing and the calling thread
162
         * wait to close to continue.
163
         * 
164
         * @param title, title of dialog
165
         * @param type of the dialog, JFileChooser.SAVE_DIALOG or JFileChooser.OPEN_DIALOG
166
         * @param selectionMode of the dialog, values are: JFileChooser.FILES_ONLY, JFileChooser.DIRECTORIES_ONLY, JFileChooser.FILES_AND_DIRECTORIES
167
         * @param multiselection, true if multiselection is allowed
168
         * @param inihelpertialPath, to show in the dialog
169
         * @param filter used to filter the files show in the dialog.
170
         * @param fileHidingEnabled, if true hidden files are show
171
         * @return an array whit the files selecteds or null.
172
         */
173
        public File[] showChooserDialog(
174
                        final String title,
175
                        final int type,
176
                        final int selectionMode,
177
                        final boolean multiselection, 
178
                        final File inihelpertialPath,
179
                        final FileFilter filter,
180
                        final boolean fileHidingEnabled
181
                        ) ;
182

    
183
        /**
184
         * Creates and show a JFileChooser dialog for folder selection.
185
         *
186
         * This is an utility method that wrap a showChooserDialog call.
187
         *  
188
          * @param title, title of dialog
189
         * @param initialPath, to show in the dialog
190
         * @return an array whit the files selecteds or null.
191
         * 
192
         * @see #showChooserDialog(String, int, int, boolean, File, FileFilter, boolean)
193
         */
194
        public File[] showOpenDirectoryDialog(String title, File initialPath) ;
195
        
196
        /**
197
         * Creates and show a JFileChooser dialog for selection a file for open.
198
         *
199
         * This is an utility method that wrap a {@link #showChooserDialog(String, int, int, boolean, File, FileFilter, boolean)}  call.
200
         *  
201
          * @param title, title of dialog
202
         * @param initialPath, to show in the dialog
203
         * @return an array whit the files selecteds or null.
204
         * 
205
         * @see #showChooserDialog(String, int, int, boolean, File, FileFilter, boolean)
206
         */
207
        public File[] showOpenFileDialog(String title, File initialPath) ;
208
        
209
        /**
210
         * Creates and show a JFileChooser dialog for selection a file for save.
211
         *
212
         * This is an utility method that wrap a {@link #showChooserDialog(String, int, int, boolean, File, FileFilter, boolean)}  call.
213
         *  
214
          * @param title, title of dialog
215
         * @param initialPath, to show in the dialog
216
         * @return an array whit the files selecteds or null.
217
         * 
218
         * @see #showChooserDialog(String, int, int, boolean, File, FileFilter, boolean)
219
         */
220
        public File[] showSaveFileDialog(String title, File initialPath) ;
221

    
222
    /**
223
     * Show a non intrusibe message to the user.
224
     * 
225
     * This method is thread safe.
226
     * 
227
     * @param message
228
     * @param message_type One of: JOptionPane.ERROR_MESSAGE,
229
     * JOptionPane.WARNING_MESSAGE, JOptionPane.INFORMATION_MESSAGE 
230
     */
231
    public void message(String message, int message_type);
232
}