1
|
package gui;
|
2
|
|
3
|
import java.awt.BorderLayout;
|
4
|
import java.awt.Dimension;
|
5
|
import java.awt.FlowLayout;
|
6
|
import java.awt.GridLayout;
|
7
|
import java.awt.event.*;
|
8
|
|
9
|
import java.io.File;
|
10
|
import java.io.IOException;
|
11
|
import java.text.ParseException;
|
12
|
import java.text.SimpleDateFormat;
|
13
|
import java.time.LocalDate;
|
14
|
import java.time.ZoneId;
|
15
|
import java.util.*;
|
16
|
|
17
|
import javax.swing.*;
|
18
|
import javax.swing.JFormattedTextField.AbstractFormatter;
|
19
|
|
20
|
import org.jdatepicker.impl.JDatePanelImpl;
|
21
|
import org.jdatepicker.impl.JDatePickerImpl;
|
22
|
import org.jdatepicker.impl.UtilDateModel;
|
23
|
|
24
|
import data.BitmapBuilder;
|
25
|
import data.DataLoader;
|
26
|
|
27
|
/**
|
28
|
*
|
29
|
* Zakladni okno aplikace, zprostredkovava vstupy od uzivatele
|
30
|
*
|
31
|
* @author Marek Sobota, Daniel Stus, Lukas Scurko, Jan Jirman
|
32
|
* @version 1.0
|
33
|
*
|
34
|
*/
|
35
|
public class Window extends JFrame{
|
36
|
|
37
|
/**zakladni verze serializace*/
|
38
|
private static final long serialVersionUID = 1L;
|
39
|
|
40
|
/**Minimalni rozmer vypisoveho okna*/
|
41
|
private static final Dimension OUTPUT_WINDOW_MIN_DIM = new Dimension(640, 320);
|
42
|
|
43
|
/**konstanta pro oznaceni souboru se spoji*/
|
44
|
private static final int SEZNAM_LINEK_FILE = 0;
|
45
|
|
46
|
/**konstanta pro oznaceni slozky JDF*/
|
47
|
private static final int JDF_DIR = 1;
|
48
|
|
49
|
/**konstanta pro oznaceni slozky pro vystup*/
|
50
|
private static final int OUTPUT_DIR = 2;
|
51
|
|
52
|
/**konstanta pro oznaceni dialogu pro vyber zacinajiciho data*/
|
53
|
private static final int DATE_PICKER_FROM = 3;
|
54
|
|
55
|
/**konstanta pro oznaceni dialogu pro vyber konciciho data*/
|
56
|
private static final int DATE_PICKER_TO = 4;
|
57
|
|
58
|
/**spolecna delka pro vsechny {@code JTextField}*/
|
59
|
private static final int TEXT_FIELD_LENGTH = 15;
|
60
|
|
61
|
/**konstanta pro nazev souboru caskody*/
|
62
|
private static final String CASKODY = "Caskody.txt";
|
63
|
|
64
|
/**konstanta pro nazev souboru pevnykod*/
|
65
|
private static final String PEVNY_KOD = "Pevnykod.txt";
|
66
|
|
67
|
/**konstanta pro nazev souboru spoje*/
|
68
|
private static final String SPOJE = "Spoje.txt";
|
69
|
|
70
|
/**atribut se souborem se spoji*/
|
71
|
private File linkyFile = null;
|
72
|
|
73
|
/**atribut se slozkou JDF*/
|
74
|
private File jdfDir = null;
|
75
|
|
76
|
/**soubor, do ktereho se zapise vystup programu*/
|
77
|
private File outputFile = null;
|
78
|
|
79
|
/**den zacatku obdobi*/
|
80
|
private LocalDate dateFrom = null;
|
81
|
|
82
|
/**den konce obdobi*/
|
83
|
private LocalDate dateTo = null;
|
84
|
|
85
|
/**panel pro zadani vstupnich dat*/
|
86
|
private JPanel inputP;
|
87
|
|
88
|
/**tlacitko pro odeslani zadanych dat*/
|
89
|
private JButton confirmBT;
|
90
|
|
91
|
/**tlacitko pro vypnuti programu*/
|
92
|
private JButton endBT;
|
93
|
|
94
|
/**Dialog pro vybrani cesty k souborum*/
|
95
|
private JFileChooser fileChooser;
|
96
|
|
97
|
/**Dialog pro vybrani data zacatku*/
|
98
|
private JDatePickerImpl datePickerFrom;
|
99
|
|
100
|
/**Dialog pro vybrani data konce*/
|
101
|
private JDatePickerImpl datePickerTo;
|
102
|
|
103
|
/**TextField pro zobrazeni cesty k souboru s linkami*/
|
104
|
private JTextField linkyPathTF;
|
105
|
|
106
|
/**TextField pro zobrazeni cesty k slozce JDF*/
|
107
|
private JTextField jdfPathTF;
|
108
|
|
109
|
/**TextField pro zobrazeni cesty ke slozce s vystupnim souborem*/
|
110
|
private JTextField outputPathTF;
|
111
|
|
112
|
/**TextField pro zadani nazvu vystupniho souboru*/
|
113
|
private JTextField outputNameTF;
|
114
|
|
115
|
/**TextArea pro výpis informací o běhu programu*/
|
116
|
private JTextArea infoTA;
|
117
|
|
118
|
/**ScrollPane pro obaleni infoTA*/
|
119
|
private JScrollPane scrollPane;
|
120
|
|
121
|
|
122
|
/**
|
123
|
* inicializuje okno, jmenovite jeho panely, komponenty, priradi potrebne listenery a prida je do zobrazeni
|
124
|
*/
|
125
|
public Window(){
|
126
|
super("POVED - Generování Bitových map");
|
127
|
this.setLayout(new BorderLayout());
|
128
|
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
129
|
|
130
|
//nastaveni JPanelu
|
131
|
inputP = new JPanel();
|
132
|
JPanel dateFromP = new JPanel();
|
133
|
JPanel dateToP = new JPanel();
|
134
|
JPanel spojPathP = new JPanel();
|
135
|
JPanel jdfPathP = new JPanel();
|
136
|
JPanel outputP = new JPanel();
|
137
|
inputP.setLayout(new GridLayout(5, 1));
|
138
|
dateFromP.setLayout(new FlowLayout());
|
139
|
dateToP.setLayout(new FlowLayout());
|
140
|
spojPathP.setLayout(new FlowLayout());
|
141
|
jdfPathP.setLayout(new FlowLayout());
|
142
|
outputP.setLayout(new FlowLayout());
|
143
|
|
144
|
//inicializace kompoment
|
145
|
ImageIcon icon = new ImageIcon(Window.class.getResource("/resources/poved.png"));
|
146
|
ImageIcon logo = new ImageIcon(Window.class.getResource("/resources/logo.png"));
|
147
|
JLabel povedLB = new JLabel(logo, JLabel.CENTER);
|
148
|
JLabel dateFromLB = new JLabel("Období od: ");
|
149
|
JLabel dateToLB = new JLabel ("Období do: ");
|
150
|
JLabel seznamLinekPathLB = new JLabel("Seznam linek: ");
|
151
|
JLabel jdfPathLB = new JLabel("JDF: ");
|
152
|
JLabel outputLB = new JLabel("Výstup: ");
|
153
|
confirmBT = new JButton("Potvrdit");
|
154
|
endBT = new JButton("Ukončit");
|
155
|
JButton seznamLinekBT = new JButton("Vybrat seznam linek");
|
156
|
JButton jdfBT = new JButton("Vybrat JDF slozku");
|
157
|
JButton outputBT = new JButton("Vybrat výstupní složku");
|
158
|
linkyPathTF = new JTextField(TEXT_FIELD_LENGTH);
|
159
|
jdfPathTF = new JTextField(TEXT_FIELD_LENGTH);
|
160
|
outputPathTF = new JTextField(TEXT_FIELD_LENGTH);
|
161
|
outputNameTF = new JTextField(TEXT_FIELD_LENGTH);
|
162
|
fileChooser = new JFileChooser();
|
163
|
infoTA = new JTextArea();
|
164
|
scrollPane = new JScrollPane(infoTA);
|
165
|
initDatePicker();
|
166
|
|
167
|
//nastaveni komponent
|
168
|
this.setIconImage(icon.getImage());
|
169
|
linkyPathTF.setEditable(false);
|
170
|
jdfPathTF.setEditable(false);
|
171
|
outputPathTF.setEditable(false);
|
172
|
outputNameTF.setText("Název souboru...");
|
173
|
infoTA.setEditable(false);
|
174
|
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
|
175
|
|
176
|
|
177
|
//pridani listeneru
|
178
|
outputNameTF.addMouseListener(new MouseAdapter() {
|
179
|
|
180
|
/**
|
181
|
* pokud je zapsan vychozi text, po kliknuti se vymaze
|
182
|
*
|
183
|
* @param e kod udalosti
|
184
|
*/
|
185
|
@Override
|
186
|
public void mouseClicked(MouseEvent e) {
|
187
|
if (outputNameTF.getText().trim().equals("Název souboru...") ) outputNameTF.setText("");
|
188
|
}
|
189
|
});
|
190
|
confirmBT.addActionListener(new ConfirmListener());
|
191
|
endBT.addActionListener(new ActionListener(){
|
192
|
@Override
|
193
|
/**
|
194
|
* ukonci program
|
195
|
*
|
196
|
* @param arg0 kod udalosti
|
197
|
*/
|
198
|
public void actionPerformed(ActionEvent arg0) {
|
199
|
printMessage("Ukončuji...");
|
200
|
System.exit(0);
|
201
|
}
|
202
|
});
|
203
|
seznamLinekBT.addActionListener(new FileChooserListener(SEZNAM_LINEK_FILE));
|
204
|
jdfBT.addActionListener(new FileChooserListener(JDF_DIR));
|
205
|
outputBT.addActionListener(new FileChooserListener(OUTPUT_DIR));
|
206
|
|
207
|
//pridani komponent do panelu
|
208
|
inputP.add(dateFromP);
|
209
|
inputP.add(dateToP);
|
210
|
inputP.add(spojPathP);
|
211
|
inputP.add(jdfPathP);
|
212
|
inputP.add(outputP);
|
213
|
dateFromP.add(dateFromLB);
|
214
|
dateFromP.add(datePickerFrom);
|
215
|
dateToP.add(dateToLB);
|
216
|
dateToP.add(datePickerTo);
|
217
|
spojPathP.add(seznamLinekPathLB);
|
218
|
spojPathP.add(linkyPathTF);
|
219
|
spojPathP.add(seznamLinekBT);
|
220
|
jdfPathP.add(jdfPathLB);
|
221
|
jdfPathP.add(jdfPathTF);
|
222
|
jdfPathP.add(jdfBT);
|
223
|
outputP.add(outputLB);
|
224
|
outputP.add(outputNameTF);
|
225
|
outputP.add(outputPathTF);
|
226
|
outputP.add(outputBT);
|
227
|
|
228
|
//pridani panelu do okna
|
229
|
this.add(povedLB, BorderLayout.NORTH);
|
230
|
this.add(inputP, BorderLayout.CENTER);
|
231
|
this.add(confirmBT, BorderLayout.SOUTH);
|
232
|
|
233
|
this.pack();
|
234
|
this.setMinimumSize(this.getSize());
|
235
|
}
|
236
|
|
237
|
/**
|
238
|
*
|
239
|
* inicializuje dve na sobe nezavisle instance {@code DatePickerImpl}
|
240
|
*/
|
241
|
private void initDatePicker(){
|
242
|
UtilDateModel modelFrom = new UtilDateModel();
|
243
|
Properties pFrom = new Properties();
|
244
|
pFrom.put("text.today", "Dnes");
|
245
|
pFrom.put("text.month", "Měsíc");
|
246
|
pFrom.put("text.year", "Rok");
|
247
|
UtilDateModel modelTo = new UtilDateModel();
|
248
|
Properties pTo = new Properties();
|
249
|
pTo.put("text.today", "Dnes");
|
250
|
pTo.put("text.month", "Měsíc");
|
251
|
pTo.put("text.year", "Rok");
|
252
|
JDatePanelImpl datePanelFrom = new JDatePanelImpl(modelFrom, pFrom);
|
253
|
JDatePanelImpl datePanelTo = new JDatePanelImpl(modelTo, pTo);
|
254
|
datePickerFrom = new JDatePickerImpl(datePanelFrom, new DateLabelFormatter());
|
255
|
datePickerTo = new JDatePickerImpl(datePanelTo, new DateLabelFormatter());
|
256
|
datePickerFrom.addActionListener(new DatePickerListener(DATE_PICKER_FROM));
|
257
|
datePickerTo.addActionListener(new DatePickerListener(DATE_PICKER_TO));
|
258
|
|
259
|
}
|
260
|
|
261
|
/**
|
262
|
* zmeni okno ze vstupoveho pohledu, aby od ted zobrazovalo prubezne informace
|
263
|
*/
|
264
|
private void changeToInfo(){
|
265
|
this.remove(inputP);
|
266
|
this.remove(confirmBT);
|
267
|
|
268
|
this.setMinimumSize(OUTPUT_WINDOW_MIN_DIM);
|
269
|
this.add(scrollPane, BorderLayout.CENTER);
|
270
|
this.add(endBT, BorderLayout.SOUTH);
|
271
|
|
272
|
this.revalidate();
|
273
|
}
|
274
|
|
275
|
|
276
|
/**
|
277
|
* metoda pro pridani zpravy do vypisu uzivateli
|
278
|
*
|
279
|
* @param message zprava, kterou chceme uzivateli sdelit
|
280
|
*/
|
281
|
public void printMessage(String message){
|
282
|
infoTA.append(message + "\n");
|
283
|
}
|
284
|
|
285
|
/**
|
286
|
* vytvori instanci {@code BitmapBuilder} a vrati ji
|
287
|
*
|
288
|
* @return nove vytvořena instance
|
289
|
*/
|
290
|
private BitmapBuilder createBitmapBuilder(){
|
291
|
return new BitmapBuilder(this, outputFile);
|
292
|
}
|
293
|
|
294
|
/**
|
295
|
*
|
296
|
* Listener pro potvrzovaci tlacitko, kontroluje, jestli vsechna zadana data jsou platna
|
297
|
*
|
298
|
* @author Marek Sobota, Daniel Stus, Lukas Scurko, Jan Jirman
|
299
|
* @version 1.0
|
300
|
*
|
301
|
*/
|
302
|
class ConfirmListener implements ActionListener{
|
303
|
|
304
|
//@Override
|
305
|
/**
|
306
|
* zkontroluje, zda-li zadana data jsou platna, pote zmeni panely aby okno vypisovalo informace o prubehu generace
|
307
|
* a odesle data na zpracovani
|
308
|
*
|
309
|
* @param arg0 kod udalosti
|
310
|
*/
|
311
|
public void actionPerformed(ActionEvent arg0) {
|
312
|
if(!inputCheck()){
|
313
|
return;
|
314
|
}
|
315
|
changeToInfo();
|
316
|
|
317
|
|
318
|
printMessage("Nastaveno období od: " + dateFrom);
|
319
|
printMessage("Nastaveno období do: " + dateTo);
|
320
|
printMessage("Vybrán soubor s linkami: " + linkyFile.toString());
|
321
|
printMessage("Vybrán adresář s JDF soubory: " + jdfDir.toString());
|
322
|
printMessage("Výstupní soubor nastaven na: " + outputFile.toString());
|
323
|
|
324
|
|
325
|
ArrayList<String[]> loadedData;
|
326
|
BitmapBuilder bitmapBuilder = createBitmapBuilder();
|
327
|
|
328
|
//loader pro načtení dat
|
329
|
DataLoader loader = new DataLoader(jdfDir);
|
330
|
|
331
|
//načítání konkrétních dat
|
332
|
//Načítání linek a pseudo linek pro generaci
|
333
|
List[] lineList = loader.loadLines(linkyFile);
|
334
|
|
335
|
|
336
|
//kontrola, jestli soubor obsahuje data
|
337
|
if(!bitmapBuilder.initLineList(lineList)){
|
338
|
printMessage("Můžete ukončit program");
|
339
|
return;
|
340
|
}
|
341
|
|
342
|
loadedData = loader.loadData(PEVNY_KOD);
|
343
|
bitmapBuilder.getPevnyKod(loadedData);
|
344
|
|
345
|
loadedData.clear();
|
346
|
loadedData = loader.loadData(CASKODY);
|
347
|
bitmapBuilder.getCaskody(loadedData);
|
348
|
|
349
|
loadedData.clear();
|
350
|
loadedData = loader.loadData(SPOJE);
|
351
|
bitmapBuilder.getSpoje(loadedData);
|
352
|
|
353
|
bitmapBuilder.writeBitmaps(dateFrom, dateTo);
|
354
|
|
355
|
|
356
|
// Otevře explorer a zvýrazní výstupní soubor
|
357
|
try {
|
358
|
Runtime.getRuntime().exec("explorer.exe /select," + outputFile);
|
359
|
} catch (IOException e) {
|
360
|
e.printStackTrace();
|
361
|
}
|
362
|
|
363
|
printMessage("Můžete ukončit program");
|
364
|
|
365
|
}
|
366
|
|
367
|
/**
|
368
|
* kontrola jestli jsou obdobi zadana a ve spravnem poradi a jestli jsou cesty vyplněny
|
369
|
*/
|
370
|
private boolean inputCheck(){
|
371
|
if(linkyFile == null || jdfDir == null || outputFile == null){
|
372
|
JOptionPane.showMessageDialog(null, "Nejsou vybrány potřebné soubory/složky",
|
373
|
"Varování", JOptionPane.WARNING_MESSAGE);
|
374
|
return false;
|
375
|
}
|
376
|
if(dateTo == null || dateFrom == null){
|
377
|
JOptionPane.showMessageDialog(null, "Není zadáno datum",
|
378
|
"Varování", JOptionPane.WARNING_MESSAGE);
|
379
|
return false;
|
380
|
}
|
381
|
if(dateTo.compareTo(dateFrom) < 0){
|
382
|
JOptionPane.showMessageDialog(null, "Začátek období je po konci období",
|
383
|
"Varování", JOptionPane.WARNING_MESSAGE);
|
384
|
return false;
|
385
|
}
|
386
|
String outputName = outputNameTF.getText().trim();
|
387
|
if(outputName.length() < 1){
|
388
|
JOptionPane.showMessageDialog(null, "Nebylo zadáno jméno výstupního souboru",
|
389
|
"Varování", JOptionPane.WARNING_MESSAGE);
|
390
|
return false;
|
391
|
}
|
392
|
|
393
|
if(!outputName.endsWith(".txt")){
|
394
|
outputName += ".txt";
|
395
|
}
|
396
|
outputFile = new File(outputFile.getAbsolutePath() + File.separator + outputName);
|
397
|
|
398
|
return true;
|
399
|
}
|
400
|
|
401
|
}
|
402
|
|
403
|
/**
|
404
|
* Listener pro {@code JFileChooser}, zpracovava dialog pro vybrani souboru a kontrolu jeho platnosti
|
405
|
*
|
406
|
* @author Marek Sobota, Daniel Stus, Lukas Scurko, Jan Jirman
|
407
|
* @version 1.0
|
408
|
*
|
409
|
*/
|
410
|
class FileChooserListener implements ActionListener{
|
411
|
|
412
|
/**
|
413
|
* cislo oznacujici, jestli se jedna o soubor se spoji nebo o slozku JDF
|
414
|
*/
|
415
|
private int fileType;
|
416
|
|
417
|
/**
|
418
|
* konstruktor ulozi do atributu typ souboru, ktery ma vybirat
|
419
|
*
|
420
|
* @param fileType ktery soubor se vybral (0 = spoj, 1 = jdf slozka)
|
421
|
*/
|
422
|
public FileChooserListener(int fileType) {
|
423
|
this.fileType = fileType;
|
424
|
}
|
425
|
|
426
|
//@Override
|
427
|
/**
|
428
|
* otevre dialog pro vybrani souboru nebo slozky, overi, zda-li typ souboru vyhovuje
|
429
|
* pokud ano, ulozi ho do prislusne promene, jinak vypise varovani
|
430
|
*
|
431
|
*/
|
432
|
public void actionPerformed(ActionEvent arg0) {
|
433
|
int option = fileChooser.showOpenDialog(null);
|
434
|
if(option == JFileChooser.APPROVE_OPTION){
|
435
|
File selectedFile = fileChooser.getSelectedFile();
|
436
|
|
437
|
if(selectedFile.isFile() && fileType == SEZNAM_LINEK_FILE && selectedFile.getName().endsWith(".txt")){
|
438
|
linkyFile = selectedFile;
|
439
|
linkyPathTF.setText(linkyFile.getAbsolutePath());
|
440
|
}
|
441
|
else if(selectedFile.isDirectory() && fileType == JDF_DIR){
|
442
|
//overi existenci potrebnych souboru ve slozce
|
443
|
File caskody = new File(selectedFile.getAbsolutePath() + File.separator + CASKODY);
|
444
|
File pevnyKod = new File(selectedFile.getAbsolutePath() + File.separator + PEVNY_KOD);
|
445
|
File spoje = new File(selectedFile.getAbsolutePath() + File.separator + SPOJE);
|
446
|
if(!caskody.exists()){
|
447
|
JOptionPane.showMessageDialog(null, "Ve složce se nenachází soubor " + CASKODY,
|
448
|
"Varování", JOptionPane.WARNING_MESSAGE);
|
449
|
return;
|
450
|
}
|
451
|
if(!pevnyKod.exists()){
|
452
|
JOptionPane.showMessageDialog(null, "Ve složce se nenachází soubor " + PEVNY_KOD,
|
453
|
"Varování", JOptionPane.WARNING_MESSAGE);
|
454
|
return;
|
455
|
}
|
456
|
if(!spoje.exists()){
|
457
|
JOptionPane.showMessageDialog(null, "Ve složce se nenachází soubor " + SPOJE,
|
458
|
"Varování", JOptionPane.WARNING_MESSAGE);
|
459
|
return;
|
460
|
}
|
461
|
|
462
|
jdfDir = selectedFile;
|
463
|
jdfPathTF.setText(jdfDir.getAbsolutePath());
|
464
|
}
|
465
|
else if (selectedFile.isDirectory() && fileType == OUTPUT_DIR){
|
466
|
outputFile = new File(selectedFile.getAbsolutePath());
|
467
|
outputPathTF.setText(outputFile.getAbsolutePath());
|
468
|
}
|
469
|
else{
|
470
|
JOptionPane.showMessageDialog(null, "Vybrán nesprávný typ souboru",
|
471
|
"Varování", JOptionPane.WARNING_MESSAGE);
|
472
|
}
|
473
|
}
|
474
|
}
|
475
|
|
476
|
}
|
477
|
|
478
|
/**
|
479
|
*
|
480
|
* Listener pro {@code JDatePicker}, zpracovava dialog pro vybrani data
|
481
|
*
|
482
|
* @author Marek Sobota, Daniel Stus, Lukas Scurko, Jan Jirman
|
483
|
* @version 1.0
|
484
|
*
|
485
|
*/
|
486
|
class DatePickerListener implements ActionListener{
|
487
|
|
488
|
/**cislo oznacujici zda-li se jedna o zacatek nebo konec obdobi*/
|
489
|
private int datePickerType;
|
490
|
|
491
|
/**
|
492
|
* konstruktor ulozi do atributu typ souboru, ktery ma vybirat
|
493
|
*
|
494
|
* @param datePickerType typ data, ktery se vybral (2 = od, 3 = do)
|
495
|
*/
|
496
|
public DatePickerListener(int datePickerType){
|
497
|
this.datePickerType = datePickerType;
|
498
|
}
|
499
|
|
500
|
//@Override
|
501
|
/**
|
502
|
* ulozi vybrane datum z dialogu do odpovidajiciho data
|
503
|
*
|
504
|
* @param arg0 kod udalosti
|
505
|
*/
|
506
|
public void actionPerformed(ActionEvent arg0) {
|
507
|
if(datePickerType == DATE_PICKER_FROM){
|
508
|
dateFrom = ((Date)datePickerFrom.getModel().getValue()).toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
509
|
}
|
510
|
else if (datePickerType == DATE_PICKER_TO){
|
511
|
dateTo = ((Date)datePickerTo.getModel().getValue()).toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
512
|
}
|
513
|
}
|
514
|
|
515
|
|
516
|
}
|
517
|
|
518
|
class DateLabelFormatter extends AbstractFormatter {
|
519
|
|
520
|
private static final long serialVersionUID = 1L;
|
521
|
|
522
|
private String datePattern = "yyyy-MM-dd";
|
523
|
private SimpleDateFormat dateFormatter = new SimpleDateFormat(datePattern);
|
524
|
|
525
|
@Override
|
526
|
public Object stringToValue(String text) throws ParseException {
|
527
|
return dateFormatter.parseObject(text);
|
528
|
}
|
529
|
|
530
|
@Override
|
531
|
public String valueToString(Object value) throws ParseException {
|
532
|
if (value != null) {
|
533
|
Calendar cal = (Calendar) value;
|
534
|
return dateFormatter.format(cal.getTime());
|
535
|
}
|
536
|
|
537
|
return "";
|
538
|
}
|
539
|
|
540
|
}
|
541
|
|
542
|
/**
|
543
|
*
|
544
|
* hlavni metoda a vstupni bod aplikace
|
545
|
*
|
546
|
* @param args parametry programu
|
547
|
*/
|
548
|
public static void main(String[] args){
|
549
|
Window w = new Window();
|
550
|
w.setVisible(true);
|
551
|
}
|
552
|
}
|