1 | |
package org.jtheque.core.managers.view.impl.frame; |
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.able.IConfigView; |
21 | |
import org.jtheque.core.managers.view.able.components.IModel; |
22 | |
import org.jtheque.core.managers.view.impl.actions.config.ApplyChangesAction; |
23 | |
import org.jtheque.core.managers.view.impl.actions.config.ApplyChangesAndCloseAction; |
24 | |
import org.jtheque.core.managers.view.impl.actions.config.CancelChangesAction; |
25 | |
import org.jtheque.core.managers.view.impl.components.LayerTabbedPane; |
26 | |
import org.jtheque.core.managers.view.impl.components.config.ConfigTabComponent; |
27 | |
import org.jtheque.core.managers.view.impl.frame.abstraction.SwingBuildedDialogView; |
28 | |
import org.jtheque.core.managers.view.listeners.ConfigTabEvent; |
29 | |
import org.jtheque.core.managers.view.listeners.ConfigTabListener; |
30 | |
import org.jtheque.core.utils.ui.PanelBuilder; |
31 | |
import org.jtheque.utils.ui.GridBagUtils; |
32 | |
|
33 | |
import java.util.Collection; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
public final class ConfigView extends SwingBuildedDialogView<IModel> implements ConfigTabListener, IConfigView { |
41 | |
private LayerTabbedPane tab; |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
public ConfigView(){ |
47 | 0 | super(); |
48 | |
|
49 | 0 | build(); |
50 | 0 | } |
51 | |
|
52 | |
@Override |
53 | |
protected void initView(){ |
54 | 0 | setTitleKey("config.view.title"); |
55 | 0 | } |
56 | |
|
57 | |
@Override |
58 | |
protected void buildView(PanelBuilder builder){ |
59 | 0 | tab = new LayerTabbedPane(); |
60 | |
|
61 | 0 | for (ConfigTabComponent component : getManager().getConfigTabComponents()) { |
62 | 0 | tab.addLayeredTab(component.getTitle(), component.getComponent()); |
63 | |
} |
64 | |
|
65 | 0 | getManager().addConfigTabListener(this); |
66 | |
|
67 | 0 | builder.add(tab, builder.gbcSet(0, 0, GridBagUtils.BOTH)); |
68 | |
|
69 | 0 | builder.addButtonBar(builder.gbcSet(0, 1, GridBagUtils.HORIZONTAL), |
70 | |
new ApplyChangesAndCloseAction(), new ApplyChangesAction(), new CancelChangesAction()); |
71 | 0 | } |
72 | |
|
73 | |
@Override |
74 | |
public ConfigTabComponent getSelectedPanelConfig() { |
75 | 0 | return (ConfigTabComponent) tab.getSelectedComponent(); |
76 | |
} |
77 | |
|
78 | |
@Override |
79 | |
public void tabAdded(ConfigTabEvent event) { |
80 | 0 | tab.addLayeredTab(event.getComponent().getTitle(), event.getComponent().getComponent()); |
81 | 0 | } |
82 | |
|
83 | |
@Override |
84 | |
public void tabRemoved(ConfigTabEvent event) { |
85 | 0 | tab.removeTabAt(tab.indexOfTab(event.getComponent().getTitle())); |
86 | 0 | } |
87 | |
|
88 | |
@Override |
89 | |
protected void validate(Collection<JThequeError> errors){ |
90 | 0 | getSelectedPanelConfig().validate(errors); |
91 | 0 | } |
92 | |
} |