1 | |
package org.jtheque.core.managers.view.impl.frame.abstraction; |
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.error.JThequeError; |
21 | |
import org.jtheque.core.managers.language.ILanguageManager; |
22 | |
import org.jtheque.core.managers.view.able.IViewManager; |
23 | |
import org.jtheque.core.managers.view.able.components.IModel; |
24 | |
import org.jtheque.core.utils.ui.FilthyPanelBuilder; |
25 | |
import org.jtheque.core.utils.ui.PanelBuilder; |
26 | |
|
27 | |
import javax.swing.JFrame; |
28 | |
import java.awt.Container; |
29 | |
import java.awt.Frame; |
30 | |
import java.util.Collection; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public abstract class SwingBuildedDialogView<T extends IModel> extends SwingDialogView { |
38 | |
private boolean filthy; |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
protected SwingBuildedDialogView(){ |
44 | 0 | this((Frame) Managers.getManager(IViewManager.class).getViews().getMainView().getImpl(), false); |
45 | 0 | } |
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
protected SwingBuildedDialogView(boolean filthy){ |
53 | 0 | this((Frame) Managers.getManager(IViewManager.class).getViews().getMainView().getImpl(), filthy); |
54 | 0 | } |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
protected SwingBuildedDialogView(Frame frame) { |
62 | 0 | this(frame, false); |
63 | 0 | } |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
protected SwingBuildedDialogView(Frame frame, boolean filthy) { |
72 | 0 | super(frame); |
73 | |
|
74 | 0 | setModal(true); |
75 | 0 | setResizable(true); |
76 | |
|
77 | 0 | Managers.getManager(ILanguageManager.class).addInternationalizable(this); |
78 | |
|
79 | 0 | setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); |
80 | 0 | setIconImage(getDefaultWindowIcon()); |
81 | |
|
82 | 0 | this.filthy = filthy; |
83 | 0 | } |
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
protected final void build(){ |
89 | 0 | initView(); |
90 | |
|
91 | 0 | setContentPane(buildContentPane()); |
92 | |
|
93 | 0 | pack(); |
94 | |
|
95 | 0 | setLocationRelativeTo(getOwner()); |
96 | 0 | } |
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
private Container buildContentPane(){ |
104 | 0 | PanelBuilder builder = filthy ? new FilthyPanelBuilder() : new PanelBuilder(); |
105 | |
|
106 | 0 | buildView(builder); |
107 | |
|
108 | 0 | return builder.getPanel(); |
109 | |
} |
110 | |
|
111 | |
@Override |
112 | |
protected void validate(Collection<JThequeError> errors){ |
113 | |
|
114 | 0 | } |
115 | |
|
116 | |
@Override |
117 | |
public T getModel(){ |
118 | 0 | return (T) super.getModel(); |
119 | |
} |
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
protected abstract void initView(); |
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
protected abstract void buildView(PanelBuilder builder); |
132 | |
} |