1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
package org.argouml.uml.reveng; |
40 | |
|
41 | |
import java.awt.GridBagConstraints; |
42 | |
import java.awt.GridBagLayout; |
43 | |
import java.awt.Insets; |
44 | |
|
45 | |
import javax.swing.ButtonGroup; |
46 | |
import javax.swing.JCheckBox; |
47 | |
import javax.swing.JLabel; |
48 | |
import javax.swing.JPanel; |
49 | |
import javax.swing.JRadioButton; |
50 | |
import javax.swing.JTextField; |
51 | |
|
52 | |
import org.argouml.configuration.Configuration; |
53 | |
import org.argouml.configuration.ConfigurationKey; |
54 | |
import org.argouml.i18n.Translator; |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
public class ConfigPanelExtension extends JPanel { |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | 0 | public static final ConfigurationKey KEY_IMPORT_EXTENDED_MODEL_ATTR = |
67 | |
Configuration |
68 | |
.makeKey("import", "extended", "java", "model", "attributes"); |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | 0 | public static final ConfigurationKey KEY_IMPORT_EXTENDED_MODEL_ARRAYS = |
76 | |
Configuration.makeKey("import", "extended", "java", "model", "arrays"); |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | 0 | public static final ConfigurationKey KEY_IMPORT_EXTENDED_COLLECTIONS_FLAG = |
83 | |
Configuration |
84 | |
.makeKey("import", "extended", "java", "collections", "flag"); |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | 0 | public static final ConfigurationKey KEY_IMPORT_EXTENDED_COLLECTIONS_LIST = |
91 | |
Configuration |
92 | |
.makeKey("import", "extended", "java", "collections", "list"); |
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | 0 | public static final ConfigurationKey KEY_IMPORT_EXTENDED_ORDEREDCOLLS_FLAG = |
99 | |
Configuration |
100 | |
.makeKey("import", "extended", "java", "orderedcolls", "flag"); |
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | 0 | public static final ConfigurationKey KEY_IMPORT_EXTENDED_ORDEREDCOLLS_LIST = |
107 | |
Configuration |
108 | |
.makeKey("import", "extended", "java", "orderedcolls", "list"); |
109 | |
|
110 | |
private JPanel configPanel; |
111 | |
|
112 | |
private JRadioButton attribute; |
113 | |
|
114 | |
private JRadioButton datatype; |
115 | |
|
116 | |
private JCheckBox modelcollections, modelorderedcollections; |
117 | |
|
118 | |
private JTextField collectionlist, orderedcollectionlist; |
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | 0 | public ConfigPanelExtension() { |
124 | |
|
125 | 0 | configPanel = this; |
126 | 0 | configPanel.setLayout(new GridBagLayout()); |
127 | |
|
128 | 0 | JLabel attributeLabel1 = |
129 | |
new JLabel( |
130 | |
Translator.localize("action.import-java-attr-model")); |
131 | 0 | configPanel.add(attributeLabel1, |
132 | |
createGridBagConstraints(true, false, false)); |
133 | 0 | ButtonGroup group1 = new ButtonGroup(); |
134 | 0 | attribute = |
135 | |
new JRadioButton( |
136 | |
Translator.localize("action.import-java-UML-attr")); |
137 | 0 | group1.add(attribute); |
138 | 0 | configPanel.add(attribute, |
139 | |
createGridBagConstraints(false, false, false)); |
140 | 0 | JRadioButton association = |
141 | |
new JRadioButton( |
142 | |
Translator.localize("action.import-java-UML-assoc")); |
143 | 0 | group1.add(association); |
144 | 0 | configPanel.add(association, |
145 | |
createGridBagConstraints(false, true, false)); |
146 | 0 | String modelattr = |
147 | |
Configuration.getString(KEY_IMPORT_EXTENDED_MODEL_ATTR); |
148 | 0 | if ("1".equals(modelattr)) { |
149 | 0 | association.setSelected(true); |
150 | |
} else { |
151 | 0 | attribute.setSelected(true); |
152 | |
} |
153 | |
|
154 | 0 | JLabel attributeLabel2 = |
155 | |
new JLabel( |
156 | |
Translator.localize("action.import-java-array-model")); |
157 | 0 | configPanel.add(attributeLabel2, |
158 | |
createGridBagConstraints(true, false, false)); |
159 | 0 | ButtonGroup group2 = new ButtonGroup(); |
160 | 0 | datatype = |
161 | |
new JRadioButton( |
162 | |
Translator.localize( |
163 | |
"action.import-java-array-model-datatype")); |
164 | 0 | group2.add(datatype); |
165 | 0 | configPanel.add(datatype, |
166 | |
createGridBagConstraints(false, false, false)); |
167 | 0 | JRadioButton multi = |
168 | |
new JRadioButton( |
169 | |
Translator.localize( |
170 | |
"action.import-java-array-model-multi")); |
171 | 0 | group2.add(multi); |
172 | 0 | configPanel.add(multi, |
173 | |
createGridBagConstraints(false, true, false)); |
174 | 0 | String modelarrays = |
175 | |
Configuration.getString(KEY_IMPORT_EXTENDED_MODEL_ARRAYS); |
176 | 0 | if ("1".equals(modelarrays)) { |
177 | 0 | multi.setSelected(true); |
178 | |
} else { |
179 | 0 | datatype.setSelected(true); |
180 | |
} |
181 | |
|
182 | 0 | String s = Configuration |
183 | |
.getString(KEY_IMPORT_EXTENDED_COLLECTIONS_FLAG); |
184 | 0 | boolean flag = ("true".equals(s)); |
185 | 0 | modelcollections = |
186 | |
new JCheckBox(Translator.localize( |
187 | |
"action.import-option-model-collections"), flag); |
188 | 0 | configPanel.add(modelcollections, |
189 | |
createGridBagConstraints(true, false, false)); |
190 | |
|
191 | 0 | s = Configuration.getString(KEY_IMPORT_EXTENDED_COLLECTIONS_LIST); |
192 | 0 | collectionlist = new JTextField(s); |
193 | 0 | configPanel.add(collectionlist, |
194 | |
createGridBagConstraints(false, false, true)); |
195 | 0 | JLabel listLabel = |
196 | |
new JLabel( |
197 | |
Translator.localize("action.import-comma-separated-names")); |
198 | 0 | configPanel.add(listLabel, |
199 | |
createGridBagConstraints(false, true, false)); |
200 | |
|
201 | 0 | s = Configuration.getString(KEY_IMPORT_EXTENDED_ORDEREDCOLLS_FLAG); |
202 | 0 | flag = ("true".equals(s)); |
203 | 0 | modelorderedcollections = |
204 | |
new JCheckBox(Translator.localize( |
205 | |
"action.import-option-model-ordered-collections"), flag); |
206 | 0 | configPanel.add(modelorderedcollections, |
207 | |
createGridBagConstraints(true, false, false)); |
208 | |
|
209 | 0 | s = Configuration.getString(KEY_IMPORT_EXTENDED_ORDEREDCOLLS_LIST); |
210 | 0 | orderedcollectionlist = new JTextField(s); |
211 | 0 | configPanel.add(orderedcollectionlist, |
212 | |
createGridBagConstraints(false, false, true)); |
213 | 0 | listLabel = |
214 | |
new JLabel( |
215 | |
Translator.localize("action.import-comma-separated-names")); |
216 | 0 | configPanel.add(listLabel, |
217 | |
createGridBagConstraintsFinal()); |
218 | |
|
219 | |
|
220 | |
|
221 | 0 | } |
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
private GridBagConstraints createGridBagConstraints(boolean topInset, |
233 | |
boolean bottomInset, boolean fill) { |
234 | 0 | GridBagConstraints gbc = new GridBagConstraints(); |
235 | 0 | gbc.gridx = GridBagConstraints.RELATIVE; |
236 | 0 | gbc.gridy = GridBagConstraints.RELATIVE; |
237 | 0 | gbc.gridwidth = GridBagConstraints.REMAINDER; |
238 | 0 | gbc.gridheight = 1; |
239 | 0 | gbc.weightx = 1.0; |
240 | 0 | gbc.weighty = 0.0; |
241 | 0 | gbc.anchor = GridBagConstraints.NORTHWEST; |
242 | 0 | gbc.fill = fill ? GridBagConstraints.HORIZONTAL |
243 | |
: GridBagConstraints.NONE; |
244 | 0 | gbc.insets = |
245 | |
new Insets( |
246 | |
topInset ? 5 : 0, |
247 | |
5, |
248 | |
bottomInset ? 5 : 0, |
249 | |
5); |
250 | 0 | gbc.ipadx = 0; |
251 | 0 | gbc.ipady = 0; |
252 | 0 | return gbc; |
253 | |
} |
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
private GridBagConstraints createGridBagConstraintsFinal() { |
260 | 0 | GridBagConstraints gbc = createGridBagConstraints(false, true, false); |
261 | 0 | gbc.gridheight = GridBagConstraints.REMAINDER; |
262 | 0 | gbc.weighty = 1.0; |
263 | 0 | return gbc; |
264 | |
} |
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
public JRadioButton getAttribute() { |
270 | 0 | return attribute; |
271 | |
} |
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
public JRadioButton getDatatype() { |
277 | 0 | return datatype; |
278 | |
} |
279 | |
|
280 | |
public void disposeDialog() { |
281 | 0 | Configuration.setString(KEY_IMPORT_EXTENDED_MODEL_ATTR, |
282 | |
String.valueOf(getAttribute().isSelected() ? "0" : "1")); |
283 | 0 | Configuration.setString(KEY_IMPORT_EXTENDED_MODEL_ARRAYS, |
284 | |
String.valueOf(getDatatype().isSelected() ? "0" : "1")); |
285 | 0 | Configuration.setString(KEY_IMPORT_EXTENDED_COLLECTIONS_FLAG, |
286 | |
String.valueOf(modelcollections.isSelected())); |
287 | 0 | Configuration.setString(KEY_IMPORT_EXTENDED_COLLECTIONS_LIST, |
288 | |
String.valueOf(collectionlist.getText())); |
289 | 0 | Configuration.setString(KEY_IMPORT_EXTENDED_ORDEREDCOLLS_FLAG, |
290 | |
String.valueOf(modelorderedcollections.isSelected())); |
291 | 0 | Configuration.setString(KEY_IMPORT_EXTENDED_ORDEREDCOLLS_LIST, |
292 | |
String.valueOf(orderedcollectionlist.getText())); |
293 | 0 | } |
294 | |
} |