1 | |
package org.jtheque.films.view.impl.panels.config; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.Managers; |
20 | |
import org.jtheque.core.managers.beans.IBeansManager; |
21 | |
import org.jtheque.core.managers.error.JThequeError; |
22 | |
import org.jtheque.core.managers.language.ILanguageManager; |
23 | |
import org.jtheque.core.managers.view.impl.components.config.ConfigTabComponent; |
24 | |
import org.jtheque.core.utils.ui.PanelBuilder; |
25 | |
import org.jtheque.core.utils.ui.ValidationUtils; |
26 | |
import org.jtheque.films.IFilmsModule; |
27 | |
import org.jtheque.films.services.impl.utils.config.Configuration; |
28 | |
import org.jtheque.utils.ui.GridBagUtils; |
29 | |
|
30 | |
import javax.swing.JComponent; |
31 | |
import javax.swing.JPanel; |
32 | |
import javax.swing.JTextField; |
33 | |
import java.util.Collection; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
public final class JPanelConfigAuto extends JPanel implements ConfigTabComponent { |
41 | |
private JTextField fieldNumberOfActors; |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
public JPanelConfigAuto() { |
47 | 0 | super(); |
48 | |
|
49 | 0 | build(); |
50 | 0 | cancel(); |
51 | 0 | } |
52 | |
|
53 | |
@Override |
54 | |
public String getTitle() { |
55 | 0 | return Managers.getManager(ILanguageManager.class).getMessage("config.view.tab.auto"); |
56 | |
} |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
private void build() { |
62 | 0 | PanelBuilder builder = new PanelBuilder(this); |
63 | |
|
64 | 0 | builder.addI18nLabel("config.auto.actors", |
65 | |
builder.gbcSet(0, 0, GridBagUtils.NONE, GridBagUtils.ABOVE_BASELINE_LEADING)); |
66 | |
|
67 | 0 | fieldNumberOfActors = builder.add(new JTextField(4), |
68 | |
builder.gbcSet(1, 0, GridBagUtils.NONE, GridBagUtils.ABOVE_BASELINE_LEADING, 0, 0, 1.0, 1.0)); |
69 | 0 | } |
70 | |
|
71 | |
@Override |
72 | |
public void apply() { |
73 | 0 | getConfig().setNumberOfActors(Integer.parseInt(fieldNumberOfActors.getText())); |
74 | 0 | } |
75 | |
|
76 | |
@Override |
77 | |
public void cancel() { |
78 | 0 | fieldNumberOfActors.setText(Integer.toString(getConfig().getNumberOfActors())); |
79 | 0 | } |
80 | |
|
81 | |
@Override |
82 | |
public void validate(Collection<JThequeError> errors) { |
83 | 0 | ValidationUtils.rejectIfNotNumerical(fieldNumberOfActors.getText(), "config.auto.actors", errors); |
84 | 0 | } |
85 | |
|
86 | |
@Override |
87 | |
public JComponent getComponent() { |
88 | 0 | return this; |
89 | |
} |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
private static Configuration getConfig() { |
97 | 0 | return Managers.getManager(IBeansManager.class).<IFilmsModule>getBean("filmsModule").getConfiguration(); |
98 | |
} |
99 | |
} |