1 | |
package org.jtheque.films.view.impl.frames; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.error.JThequeError; |
20 | |
import org.jtheque.core.managers.view.impl.components.panel.FileChooserPanel; |
21 | |
import org.jtheque.core.managers.view.impl.frame.abstraction.SwingDialogView; |
22 | |
import org.jtheque.core.utils.ui.PanelBuilder; |
23 | |
import org.jtheque.films.view.able.IImportView; |
24 | |
import org.jtheque.films.view.impl.actions.CloseViewAction; |
25 | |
import org.jtheque.films.view.impl.actions.file.AcValidateImportView; |
26 | |
import org.jtheque.utils.io.SimpleFilter; |
27 | |
|
28 | |
import java.awt.Color; |
29 | |
import java.awt.Container; |
30 | |
import java.awt.Frame; |
31 | |
import java.util.Collection; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
public final class ImportView extends SwingDialogView implements IImportView { |
39 | |
private static final long serialVersionUID = 4572891526592518739L; |
40 | |
|
41 | |
private FileChooserPanel chooser; |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
public ImportView(Frame parent) { |
49 | 0 | super(parent); |
50 | |
|
51 | 0 | setResizable(false); |
52 | 0 | setTitleKey("import.view.title"); |
53 | 0 | setContentPane(buildContentPane()); |
54 | |
|
55 | 0 | pack(); |
56 | 0 | setLocationRelativeTo(getOwner()); |
57 | 0 | } |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
private Container buildContentPane() { |
65 | 0 | PanelBuilder builder = new PanelBuilder(); |
66 | |
|
67 | 0 | chooser = new FileChooserPanel(); |
68 | 0 | chooser.setTextKey("import.view.filePath"); |
69 | 0 | chooser.setBackground(Color.white); |
70 | 0 | builder.add(chooser, builder.gbcSet(0, 0)); |
71 | |
|
72 | 0 | builder.addButtonBar(builder.gbcSet(0, 1), new AcValidateImportView(), new CloseViewAction("generic.view.actions.cancel", this)); |
73 | |
|
74 | 0 | return builder.getPanel(); |
75 | |
} |
76 | |
|
77 | |
@Override |
78 | |
public String getFilePath() { |
79 | 0 | return chooser.getFilePath(); |
80 | |
} |
81 | |
|
82 | |
@Override |
83 | |
public void sendMessage(String message, Object value) { |
84 | 0 | if ("filter".equals(message)) { |
85 | 0 | chooser.setFileFilter((SimpleFilter) value); |
86 | |
} |
87 | 0 | } |
88 | |
|
89 | |
@Override |
90 | |
protected void validate(Collection<JThequeError> errors) { |
91 | 0 | } |
92 | |
} |