1 | |
package org.jtheque.films.view.impl.frames; |
2 | |
|
3 | |
import org.jtheque.core.managers.Managers; |
4 | |
import org.jtheque.core.managers.beans.IBeansManager; |
5 | |
import org.jtheque.core.managers.error.JThequeError; |
6 | |
import org.jtheque.core.managers.view.impl.components.panel.FileChooserPanel; |
7 | |
import org.jtheque.core.managers.view.impl.frame.abstraction.SwingDialogView; |
8 | |
import org.jtheque.core.utils.ui.PanelBuilder; |
9 | |
import org.jtheque.films.persistence.od.able.Film; |
10 | |
import org.jtheque.films.services.able.IFilmsService; |
11 | |
import org.jtheque.films.view.able.IVideoFileView; |
12 | |
import org.jtheque.films.view.impl.actions.CloseViewAction; |
13 | |
import org.jtheque.films.view.impl.actions.video.file.AcValidateVideoFileView; |
14 | |
import org.jtheque.primary.view.impl.models.DataContainerCachedComboBoxModel; |
15 | |
import org.jtheque.utils.ui.GridBagUtils; |
16 | |
import org.jtheque.utils.ui.SwingUtils; |
17 | |
|
18 | |
import javax.swing.Action; |
19 | |
import javax.swing.JComponent; |
20 | |
import java.awt.Container; |
21 | |
import java.awt.Frame; |
22 | |
import java.util.Collection; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
public final class VideoFileView extends SwingDialogView implements IVideoFileView { |
44 | |
private DataContainerCachedComboBoxModel<Film> model; |
45 | |
private FileChooserPanel fieldFile; |
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
public VideoFileView(Frame parent) { |
53 | 0 | super(parent); |
54 | |
|
55 | 0 | setContentPane(buildContentPane()); |
56 | 0 | pack(); |
57 | |
|
58 | 0 | setLocationRelativeTo(getOwner()); |
59 | 0 | } |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
private Container buildContentPane() { |
67 | 0 | PanelBuilder builder = new PanelBuilder(); |
68 | |
|
69 | 0 | Action validateAction = new AcValidateVideoFileView(); |
70 | |
|
71 | 0 | fieldFile = new FileChooserPanel(); |
72 | 0 | fieldFile.setTextKey("video.file.view.file"); |
73 | 0 | SwingUtils.addFieldValidateAction(fieldFile, validateAction); |
74 | |
|
75 | 0 | builder.add(fieldFile, builder.gbcSet(0, 0, GridBagUtils.HORIZONTAL, 2, 1)); |
76 | |
|
77 | 0 | builder.addI18nLabel("video.file.view.film", builder.gbcSet(0, 1)); |
78 | |
|
79 | 0 | model = new DataContainerCachedComboBoxModel<Film>(Managers.getManager(IBeansManager.class).<IFilmsService>getBean("filmsService")); |
80 | |
|
81 | 0 | JComponent combo = builder.addComboBox(model, builder.gbcSet(1, 1)); |
82 | 0 | SwingUtils.addFieldValidateAction(combo, validateAction); |
83 | |
|
84 | 0 | builder.addButtonBar(builder.gbcSet(0, 2, GridBagUtils.HORIZONTAL, 2, 1), |
85 | |
validateAction, new CloseViewAction("generic.view.actions.cancel", this)); |
86 | |
|
87 | 0 | return builder.getPanel(); |
88 | |
} |
89 | |
|
90 | |
@Override |
91 | |
protected void validate(Collection<JThequeError> errors) { |
92 | 0 | } |
93 | |
|
94 | |
@Override |
95 | |
public String getFilePath() { |
96 | 0 | return fieldFile.getFilePath(); |
97 | |
} |
98 | |
|
99 | |
@Override |
100 | |
public Film getFilm() { |
101 | 0 | return model.getSelectedData(); |
102 | |
} |
103 | |
} |