1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
/* */ package NET.worlds.console;
/* */
/* */ import java.awt.Frame;
/* */ import java.io.File;
/* */ import javax.swing.JFileChooser;
/* */ import javax.swing.SwingUtilities;
/* */ import javax.swing.UIManager;
/* */ import javax.swing.UnsupportedLookAndFeelException;
/* */ import javax.swing.filechooser.FileNameExtensionFilter;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class FileSysDialog
/* */ implements Runnable
/* */ {
/* */ public static final int OPEN = 0;
/* */ public static final int SAVE = 1;
/* */ private String title;
/* */ private String typesAndExts;
/* */ private String fileName;
/* */ private static File lastFile;
/* */ private int mode;
/* */ private DialogReceiver receiver;
/* 40 */ private boolean parentDisabled = false;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private Frame parent;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* 69 */ JFileChooser fc = null;
/* */
/* 71 */ private static String OpenFileText = "Open File";
/* 72 */ private static String SaveFileText = "Save File";
/* */
/* */ private boolean disableParent;
/* */
/* */ public FileSysDialog(Frame parent, DialogReceiver receiver, String title, int mode, String typesAndExts, String fileName, boolean disableParent)
/* */ {
/* 78 */ this.receiver = receiver;
/* 79 */ this.title = title;
/* 80 */ this.typesAndExts = typesAndExts;
/* 81 */ this.mode = mode;
/* 82 */ this.fileName = fileName;
/* 83 */ this.parent = parent;
/* 84 */ this.disableParent = disableParent;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* 93 */ SwingUtilities.invokeLater(this);
/* */ }
/* */
/* */ public void run()
/* */ {
/* 98 */ if ((this.disableParent) &&
/* 99 */ (this.parent.isEnabled())) {
/* 100 */ this.parent.setEnabled(false);
/* 101 */ this.parentDisabled = true;
/* */ }
/* */
/* */ try
/* */ {
/* 106 */ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
/* */ }
/* */ catch (ClassNotFoundException e1) {
/* 109 */ e1.printStackTrace();
/* 110 */ return;
/* */ }
/* */ catch (InstantiationException e1) {
/* 113 */ e1.printStackTrace();
/* 114 */ return;
/* */ }
/* */ catch (IllegalAccessException e1) {
/* 117 */ e1.printStackTrace();
/* 118 */ return;
/* */ }
/* */ catch (UnsupportedLookAndFeelException e1) {
/* 121 */ e1.printStackTrace();
/* 122 */ return;
/* */ }
/* */
/* 125 */ File file = null;
/* */ try {
/* 127 */ if ((this.fileName != null) && (this.fileName != "")) {
/* 128 */ file = new File(this.fileName);
/* 129 */ if ((file != null) && (file.getParent() != null)) {
/* 130 */ this.fc = new JFileChooser(file.getParent());
/* */ }
/* */ }
/* 133 */ if (this.fc == null)
/* */ {
/* 135 */ if ((lastFile != null) && (lastFile.getParent() != null)) {
/* 136 */ this.fc = new JFileChooser(lastFile.getParent());
/* */ }
/* */ }
/* 139 */ if (this.fc == null) {
/* 140 */ this.fc = new JFileChooser(".");
/* */ }
/* */ } catch (Exception e) {
/* 143 */ e.printStackTrace();
/* 144 */ return;
/* */ }
/* */
/* 147 */ this.fc.setFileSelectionMode(0);
/* 148 */ this.fc.setDialogType(this.mode == 0 ? 0 :
/* 149 */ 1);
/* */
/* 151 */ if (this.title != null)
/* 152 */ this.fc.setDialogTitle(this.title);
/* 153 */ if (this.typesAndExts != null) {
/* 154 */ buildFileChooser(this.fc, this.typesAndExts);
/* */ }
/* */
/* 157 */ if (file != null) {
/* 158 */ this.fc.setSelectedFile(file);
/* */ }
/* 160 */ int retval = this.fc.showDialog(null, this.mode == 0 ? OpenFileText :
/* 161 */ SaveFileText);
/* 162 */ if (retval == 0) {
/* 163 */ approveSelection();
/* */ } else {
/* 165 */ cancelSelection();
/* */ }
/* 167 */ if ((this.disableParent) && (this.parentDisabled)) {
/* 168 */ this.parent.setEnabled(true);
/* 169 */ this.parentDisabled = false;
/* */ }
/* */ }
/* */
/* */ private static void buildFileChooser(JFileChooser fc2, String specString)
/* */ {
/* 175 */ String[] entries = specString.split("\\|");
/* */
/* */
/* 178 */ boolean even = false;
/* 179 */ String desc = "";
/* */
/* 181 */ FileNameExtensionFilter first = null;
/* 182 */ String[] arrayOfString1; int j = (arrayOfString1 = entries).length; for (int i = 0; i < j; i++) { String entry = arrayOfString1[i];
/* 183 */ if (even)
/* */ {
/* 185 */ String[] fields = entry.split(";");
/* */
/* 187 */ for (int i = 0; i < fields.length; i++) {
/* 188 */ String[] ext = fields[i].split("\\.");
/* 189 */ if (ext.length > 0) {
/* 190 */ fields[i] = ext[(ext.length - 1)];
/* */ }
/* */ }
/* 193 */ FileNameExtensionFilter ff = null;
/* 194 */ switch (fields.length) {
/* */ case 1:
/* 196 */ ff = new FileNameExtensionFilter(desc, new String[] { fields[0] });
/* 197 */ break;
/* */ case 2:
/* 199 */ ff = new FileNameExtensionFilter(desc, new String[] { fields[0], fields[1] });
/* 200 */ break;
/* */ case 3:
/* 202 */ ff = new FileNameExtensionFilter(desc, new String[] { fields[0],
/* 203 */ fields[1], fields[2] });
/* 204 */ break;
/* */ case 4:
/* 206 */ ff = new FileNameExtensionFilter(desc, new String[] { fields[0],
/* 207 */ fields[1], fields[2], fields[3] });
/* */ }
/* */
/* 210 */ if (ff != null) {
/* 211 */ fc2.addChoosableFileFilter(ff);
/* 212 */ if (first == null) {
/* 213 */ first = ff;
/* */ }
/* */ }
/* 216 */ even = false;
/* */ } else {
/* 218 */ desc = entry;
/* 219 */ even = true;
/* */ }
/* */ }
/* 222 */ if (first != null)
/* 223 */ fc2.setFileFilter(first);
/* */ }
/* */
/* */ public int getMode() {
/* 227 */ return this.mode;
/* */ }
/* */
/* */ public void approveSelection() {
/* 231 */ File file = this.fc.getSelectedFile();
/* 232 */ lastFile = file;
/* 233 */ this.fileName = file.getAbsolutePath();
/* 234 */ this.receiver.dialogDone(this, this.fileName != null);
/* */ }
/* */
/* */ public void cancelSelection() {
/* 238 */ this.receiver.dialogDone(this, false);
/* */ }
/* */
/* */ public String fileName() {
/* 242 */ return this.fileName;
/* */ }
/* */ }
/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\FileSysDialog.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|