1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import jalview.util.MessageManager; |
24 |
|
import jalview.ws.params.ArgumentI; |
25 |
|
import jalview.ws.params.OptionI; |
26 |
|
import jalview.ws.params.ParameterI; |
27 |
|
import jalview.ws.params.ValueConstrainI; |
28 |
|
import jalview.ws.params.ValueConstrainI.ValueType; |
29 |
|
|
30 |
|
import java.awt.BorderLayout; |
31 |
|
import java.awt.Component; |
32 |
|
import java.awt.Dimension; |
33 |
|
import java.awt.Font; |
34 |
|
import java.awt.GridLayout; |
35 |
|
import java.awt.Rectangle; |
36 |
|
import java.awt.event.ActionEvent; |
37 |
|
import java.awt.event.ActionListener; |
38 |
|
import java.awt.event.KeyEvent; |
39 |
|
import java.awt.event.KeyListener; |
40 |
|
import java.awt.event.MouseEvent; |
41 |
|
import java.awt.event.MouseListener; |
42 |
|
import java.net.URL; |
43 |
|
import java.util.ArrayList; |
44 |
|
import java.util.List; |
45 |
|
import java.util.Map; |
46 |
|
|
47 |
|
import javax.swing.JButton; |
48 |
|
import javax.swing.JCheckBox; |
49 |
|
import javax.swing.JComboBox; |
50 |
|
import javax.swing.JComponent; |
51 |
|
import javax.swing.JLabel; |
52 |
|
import javax.swing.JMenuItem; |
53 |
|
import javax.swing.JPanel; |
54 |
|
import javax.swing.JPopupMenu; |
55 |
|
import javax.swing.JScrollPane; |
56 |
|
import javax.swing.JSlider; |
57 |
|
import javax.swing.JTextArea; |
58 |
|
import javax.swing.JTextField; |
59 |
|
import javax.swing.border.TitledBorder; |
60 |
|
import javax.swing.event.ChangeEvent; |
61 |
|
import javax.swing.event.ChangeListener; |
62 |
|
|
63 |
|
import net.miginfocom.swing.MigLayout; |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
@author |
70 |
|
|
71 |
|
|
|
|
| 0% |
Uncovered Elements: 80 (80) |
Complexity: 23 |
Complexity Density: 0.47 |
|
72 |
|
public class OptsAndParamsPage |
73 |
|
{ |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
boolean compact = false; |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 100 (100) |
Complexity: 34 |
Complexity Density: 0.62 |
|
79 |
|
public class OptionBox extends JPanel |
80 |
|
implements MouseListener, ActionListener |
81 |
|
{ |
82 |
|
JCheckBox enabled = new JCheckBox(); |
83 |
|
|
84 |
|
final URL finfo; |
85 |
|
|
86 |
|
boolean hasLink = false; |
87 |
|
|
88 |
|
boolean initEnabled = false; |
89 |
|
|
90 |
|
String initVal = null; |
91 |
|
|
92 |
|
OptionI option; |
93 |
|
|
94 |
|
JLabel optlabel = new JLabel(); |
95 |
|
|
96 |
|
JComboBox val = new JComboBox(); |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 7 |
Complexity Density: 0.29 |
|
98 |
0 |
public OptionBox(OptionI opt)... |
99 |
|
{ |
100 |
0 |
option = opt; |
101 |
0 |
setLayout(new BorderLayout()); |
102 |
0 |
enabled.setSelected(opt.isRequired()); |
103 |
0 |
enabled.setFont(new Font("Verdana", Font.PLAIN, 11)); |
104 |
0 |
enabled.setText(""); |
105 |
0 |
enabled.setText(opt.getName()); |
106 |
0 |
enabled.addActionListener(this); |
107 |
0 |
finfo = option.getFurtherDetails(); |
108 |
0 |
String desc = opt.getDescription(); |
109 |
0 |
if (finfo != null) |
110 |
|
{ |
111 |
0 |
hasLink = true; |
112 |
|
|
113 |
0 |
enabled.setToolTipText(JvSwingUtils.wrapTooltip(true, |
114 |
0 |
((desc == null || desc.trim().length() == 0) |
115 |
|
? MessageManager.getString( |
116 |
|
"label.opt_and_params_further_details") |
117 |
|
: desc) + "<br><img src=\"" + linkImageURL |
118 |
|
+ "\"/>")); |
119 |
0 |
enabled.addMouseListener(this); |
120 |
|
} |
121 |
|
else |
122 |
|
{ |
123 |
0 |
if (desc != null && desc.trim().length() > 0) |
124 |
|
{ |
125 |
0 |
enabled.setToolTipText( |
126 |
|
JvSwingUtils.wrapTooltip(true, opt.getDescription())); |
127 |
|
} |
128 |
|
} |
129 |
0 |
add(enabled, BorderLayout.NORTH); |
130 |
0 |
for (Object str : opt.getPossibleValues()) |
131 |
|
{ |
132 |
0 |
val.addItem(str); |
133 |
|
} |
134 |
0 |
val.setSelectedItem(opt.getValue()); |
135 |
0 |
if (opt.getPossibleValues().size() > 1) |
136 |
|
{ |
137 |
0 |
setLayout(new GridLayout(1, 2)); |
138 |
0 |
val.addActionListener(this); |
139 |
0 |
add(val, BorderLayout.SOUTH); |
140 |
|
} |
141 |
|
|
142 |
|
|
143 |
|
|
144 |
0 |
setInitialValue(); |
145 |
|
} |
146 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
147 |
0 |
@Override... |
148 |
|
public void actionPerformed(ActionEvent e) |
149 |
|
{ |
150 |
0 |
if (e.getSource() != enabled) |
151 |
|
{ |
152 |
0 |
enabled.setSelected(true); |
153 |
|
} |
154 |
0 |
checkIfModified(); |
155 |
|
} |
156 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
157 |
0 |
private void checkIfModified()... |
158 |
|
{ |
159 |
0 |
boolean notmod = (initEnabled == enabled.isSelected()); |
160 |
0 |
if (enabled.isSelected()) |
161 |
|
{ |
162 |
0 |
if (initVal != null) |
163 |
|
{ |
164 |
0 |
notmod &= initVal.equals(val.getSelectedItem()); |
165 |
|
} |
166 |
|
else |
167 |
|
{ |
168 |
|
|
169 |
0 |
notmod &= option.getValue() == null |
170 |
|
|| option.getValue().equals(val.getSelectedItem()); |
171 |
|
} |
172 |
|
} |
173 |
|
else |
174 |
|
{ |
175 |
0 |
notmod &= (initVal != null) ? initVal.equals(val.getSelectedItem()) |
176 |
|
: val.getSelectedItem() != initVal; |
177 |
|
} |
178 |
0 |
poparent.argSetModified(this, !notmod); |
179 |
|
} |
180 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.6 |
|
181 |
0 |
public OptionI getOptionIfEnabled()... |
182 |
|
{ |
183 |
0 |
if (!enabled.isSelected()) |
184 |
|
{ |
185 |
0 |
return null; |
186 |
|
} |
187 |
0 |
OptionI opt = option.copy(); |
188 |
0 |
if (opt.getPossibleValues() != null |
189 |
|
&& opt.getPossibleValues().size() == 1) |
190 |
|
{ |
191 |
|
|
192 |
|
|
193 |
0 |
opt.setValue(opt.getPossibleValues().get(0)); |
194 |
|
} |
195 |
0 |
if (val.getSelectedItem() != null) |
196 |
|
{ |
197 |
0 |
opt.setValue((String) val.getSelectedItem()); |
198 |
|
} |
199 |
|
else |
200 |
|
{ |
201 |
0 |
if (option.getValue() != null) |
202 |
|
{ |
203 |
0 |
opt.setValue(option.getValue()); |
204 |
|
} |
205 |
|
} |
206 |
0 |
return opt; |
207 |
|
} |
208 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
209 |
0 |
@Override... |
210 |
|
public void mouseClicked(MouseEvent e) |
211 |
|
{ |
212 |
0 |
if (e.isPopupTrigger()) |
213 |
|
{ |
214 |
0 |
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY()); |
215 |
|
} |
216 |
|
} |
217 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
218 |
0 |
@Override... |
219 |
|
public void mouseEntered(MouseEvent e) |
220 |
|
{ |
221 |
|
|
222 |
|
|
223 |
|
} |
224 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
225 |
0 |
@Override... |
226 |
|
public void mouseExited(MouseEvent e) |
227 |
|
{ |
228 |
|
|
229 |
|
|
230 |
|
} |
231 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
232 |
0 |
@Override... |
233 |
|
public void mousePressed(MouseEvent e) |
234 |
|
{ |
235 |
0 |
if (e.isPopupTrigger()) |
236 |
|
{ |
237 |
0 |
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY()); |
238 |
|
} |
239 |
|
} |
240 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
241 |
0 |
@Override... |
242 |
|
public void mouseReleased(MouseEvent e) |
243 |
|
{ |
244 |
|
} |
245 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 4 |
Complexity Density: 1.33 |
|
246 |
0 |
public void resetToDefault(boolean setDefaultParams)... |
247 |
|
{ |
248 |
0 |
enabled.setSelected(false); |
249 |
0 |
if (option.isRequired() |
250 |
|
|| (setDefaultParams && option.getValue() != null)) |
251 |
|
{ |
252 |
|
|
253 |
0 |
selectOption(option, option.getValue()); |
254 |
|
} |
255 |
|
} |
256 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 4 |
Complexity Density: 1 |
|
257 |
0 |
public void setInitialValue()... |
258 |
|
{ |
259 |
0 |
initEnabled = enabled.isSelected(); |
260 |
0 |
if (option.getPossibleValues() != null |
261 |
|
&& option.getPossibleValues().size() > 1) |
262 |
|
{ |
263 |
0 |
initVal = (String) val.getSelectedItem(); |
264 |
|
} |
265 |
|
else |
266 |
|
{ |
267 |
0 |
initVal = (initEnabled) ? (String) val.getSelectedItem() : null; |
268 |
|
} |
269 |
|
} |
270 |
|
|
271 |
|
} |
272 |
|
|
|
|
| 0% |
Uncovered Elements: 262 (262) |
Complexity: 71 |
Complexity Density: 0.44 |
|
273 |
|
public class ParamBox extends JPanel |
274 |
|
implements ChangeListener, ActionListener, MouseListener |
275 |
|
{ |
276 |
|
boolean adjusting = false; |
277 |
|
|
278 |
|
boolean choice = false; |
279 |
|
|
280 |
|
JComboBox choicebox; |
281 |
|
|
282 |
|
JPanel controlPanel = new JPanel(); |
283 |
|
|
284 |
|
boolean descisvisible = false; |
285 |
|
|
286 |
|
JScrollPane descPanel = new JScrollPane(); |
287 |
|
|
288 |
|
final URL finfo; |
289 |
|
|
290 |
|
boolean integ = false; |
291 |
|
|
292 |
|
Object lastVal; |
293 |
|
|
294 |
|
ParameterI parameter; |
295 |
|
|
296 |
|
final OptsParametersContainerI pmdialogbox; |
297 |
|
|
298 |
|
JPanel settingPanel = new JPanel(); |
299 |
|
|
300 |
|
JButton showDesc = new JButton(); |
301 |
|
|
302 |
|
JSlider slider = null; |
303 |
|
|
304 |
|
JTextArea string = new JTextArea(); |
305 |
|
|
306 |
|
ValueConstrainI validator = null; |
307 |
|
|
308 |
|
JTextField valueField = null; |
309 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
310 |
0 |
public ParamBox(final OptsParametersContainerI pmlayout,... |
311 |
|
ParameterI parm) |
312 |
|
{ |
313 |
0 |
pmdialogbox = pmlayout; |
314 |
0 |
finfo = parm.getFurtherDetails(); |
315 |
0 |
validator = parm.getValidValue(); |
316 |
0 |
parameter = parm; |
317 |
0 |
if (validator != null) |
318 |
|
{ |
319 |
0 |
integ = validator.getType() == ValueType.Integer; |
320 |
|
} |
321 |
|
else |
322 |
|
{ |
323 |
0 |
if (parameter.getPossibleValues() != null) |
324 |
|
{ |
325 |
0 |
choice = true; |
326 |
|
} |
327 |
|
} |
328 |
|
|
329 |
0 |
if (!compact) |
330 |
|
{ |
331 |
0 |
makeExpanderParam(parm); |
332 |
|
} |
333 |
|
else |
334 |
|
{ |
335 |
0 |
makeCompactParam(parm); |
336 |
|
|
337 |
|
} |
338 |
|
} |
339 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
340 |
0 |
private void makeCompactParam(ParameterI parm)... |
341 |
|
{ |
342 |
0 |
setLayout(new MigLayout("", "[][grow]")); |
343 |
|
|
344 |
0 |
String ttipText = null; |
345 |
|
|
346 |
0 |
controlPanel.setLayout(new BorderLayout()); |
347 |
|
|
348 |
0 |
if (parm.getDescription() != null |
349 |
|
&& parm.getDescription().trim().length() > 0) |
350 |
|
{ |
351 |
|
|
352 |
0 |
ttipText = (JvSwingUtils.wrapTooltip(true, |
353 |
0 |
parm.getDescription() + (finfo != null ? "<br><img src=\"" |
354 |
|
+ linkImageURL + "\"/>" |
355 |
|
+ MessageManager.getString( |
356 |
|
"label.opt_and_params_further_details") |
357 |
|
: ""))); |
358 |
|
} |
359 |
|
|
360 |
0 |
JvSwingUtils.mgAddtoLayout(this, ttipText, new JLabel(parm.getName()), |
361 |
|
controlPanel, ""); |
362 |
0 |
updateControls(parm); |
363 |
0 |
validate(); |
364 |
|
} |
365 |
|
|
|
|
| 0% |
Uncovered Elements: 48 (48) |
Complexity: 6 |
Complexity Density: 0.15 |
|
366 |
0 |
private void makeExpanderParam(ParameterI parm)... |
367 |
|
{ |
368 |
0 |
setPreferredSize(new Dimension(PARAM_WIDTH, PARAM_CLOSEDHEIGHT)); |
369 |
0 |
setBorder(new TitledBorder(parm.getName())); |
370 |
0 |
setLayout(null); |
371 |
0 |
showDesc.setFont(new Font("Verdana", Font.PLAIN, 6)); |
372 |
0 |
showDesc.setText("+"); |
373 |
0 |
string.setFont(new Font("Verdana", Font.PLAIN, 11)); |
374 |
0 |
string.setBackground(getBackground()); |
375 |
|
|
376 |
0 |
string.setEditable(false); |
377 |
0 |
descPanel.getViewport().setView(string); |
378 |
|
|
379 |
0 |
descPanel.setVisible(false); |
380 |
|
|
381 |
0 |
JPanel firstrow = new JPanel(); |
382 |
0 |
firstrow.setLayout(null); |
383 |
0 |
controlPanel.setLayout(new BorderLayout()); |
384 |
0 |
controlPanel.setBounds(new Rectangle(39, 10, PARAM_WIDTH - 70, |
385 |
|
PARAM_CLOSEDHEIGHT - 50)); |
386 |
0 |
firstrow.add(controlPanel); |
387 |
0 |
firstrow.setBounds(new Rectangle(10, 20, PARAM_WIDTH - 30, |
388 |
|
PARAM_CLOSEDHEIGHT - 30)); |
389 |
|
|
390 |
0 |
final ParamBox me = this; |
391 |
|
|
392 |
0 |
if (parm.getDescription() != null |
393 |
|
&& parm.getDescription().trim().length() > 0) |
394 |
|
{ |
395 |
|
|
396 |
0 |
if (finfo != null) |
397 |
|
{ |
398 |
0 |
showDesc.setToolTipText(JvSwingUtils.wrapTooltip(true, |
399 |
|
MessageManager.formatMessage( |
400 |
|
"label.opt_and_params_show_brief_desc_image_link", |
401 |
|
new String[] |
402 |
|
{ linkImageURL.toExternalForm() }))); |
403 |
0 |
showDesc.addMouseListener(this); |
404 |
|
} |
405 |
|
else |
406 |
|
{ |
407 |
0 |
showDesc.setToolTipText( |
408 |
|
JvSwingUtils.wrapTooltip(true, MessageManager.getString( |
409 |
|
"label.opt_and_params_show_brief_desc"))); |
410 |
|
} |
411 |
0 |
showDesc.addActionListener(new ActionListener() |
412 |
|
{ |
413 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
414 |
0 |
@Override... |
415 |
|
public void actionPerformed(ActionEvent e) |
416 |
|
{ |
417 |
0 |
descisvisible = !descisvisible; |
418 |
0 |
descPanel.setVisible(descisvisible); |
419 |
0 |
descPanel.getVerticalScrollBar().setValue(0); |
420 |
0 |
me.setPreferredSize(new Dimension(PARAM_WIDTH, |
421 |
0 |
(descisvisible) ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT)); |
422 |
0 |
me.validate(); |
423 |
0 |
pmdialogbox.refreshParamLayout(); |
424 |
|
} |
425 |
|
}); |
426 |
0 |
string.setWrapStyleWord(true); |
427 |
0 |
string.setLineWrap(true); |
428 |
0 |
string.setColumns(32); |
429 |
0 |
string.setText(parm.getDescription()); |
430 |
0 |
showDesc.setBounds(new Rectangle(10, 10, 16, 16)); |
431 |
0 |
firstrow.add(showDesc); |
432 |
|
} |
433 |
0 |
add(firstrow); |
434 |
0 |
validator = parm.getValidValue(); |
435 |
0 |
parameter = parm; |
436 |
0 |
if (validator != null) |
437 |
|
{ |
438 |
0 |
integ = validator.getType() == ValueType.Integer; |
439 |
|
} |
440 |
|
else |
441 |
|
{ |
442 |
0 |
if (parameter.getPossibleValues() != null) |
443 |
|
{ |
444 |
0 |
choice = true; |
445 |
|
} |
446 |
|
} |
447 |
0 |
updateControls(parm); |
448 |
0 |
descPanel.setBounds(new Rectangle(10, PARAM_CLOSEDHEIGHT, |
449 |
|
PARAM_WIDTH - 20, PARAM_HEIGHT - PARAM_CLOSEDHEIGHT - 5)); |
450 |
0 |
add(descPanel); |
451 |
0 |
validate(); |
452 |
|
} |
453 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
454 |
0 |
@Override... |
455 |
|
public void actionPerformed(ActionEvent e) |
456 |
|
{ |
457 |
0 |
if (adjusting) |
458 |
|
{ |
459 |
0 |
return; |
460 |
|
} |
461 |
0 |
if (!choice) |
462 |
|
{ |
463 |
0 |
updateSliderFromValueField(); |
464 |
|
} |
465 |
0 |
checkIfModified(); |
466 |
|
} |
467 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.5 |
|
468 |
0 |
private void checkIfModified()... |
469 |
|
{ |
470 |
0 |
Object cstate = updateSliderFromValueField(); |
471 |
0 |
boolean notmod = false; |
472 |
0 |
if (cstate.getClass() == lastVal.getClass()) |
473 |
|
{ |
474 |
0 |
if (cstate instanceof int[]) |
475 |
|
{ |
476 |
0 |
notmod = (((int[]) cstate)[0] == ((int[]) lastVal)[0]); |
477 |
|
} |
478 |
0 |
else if (cstate instanceof float[]) |
479 |
|
{ |
480 |
0 |
notmod = (((float[]) cstate)[0] == ((float[]) lastVal)[0]); |
481 |
|
} |
482 |
0 |
else if (cstate instanceof String[]) |
483 |
|
{ |
484 |
0 |
notmod = (((String[]) cstate)[0].equals(((String[]) lastVal)[0])); |
485 |
|
} |
486 |
|
} |
487 |
0 |
pmdialogbox.argSetModified(this, !notmod); |
488 |
|
} |
489 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
490 |
0 |
@Override... |
491 |
|
public int getBaseline(int width, int height) |
492 |
|
{ |
493 |
0 |
return 0; |
494 |
|
} |
495 |
|
|
496 |
|
|
497 |
|
|
498 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
499 |
0 |
@Override... |
500 |
|
public Component.BaselineResizeBehavior getBaselineResizeBehavior() |
501 |
|
{ |
502 |
0 |
return Component.BaselineResizeBehavior.CONSTANT_ASCENT; |
503 |
|
} |
504 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
505 |
0 |
public int getBoxHeight()... |
506 |
|
{ |
507 |
0 |
return (descisvisible ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT); |
508 |
|
} |
509 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
510 |
0 |
public ParameterI getParameter()... |
511 |
|
{ |
512 |
0 |
ParameterI prm = parameter.copy(); |
513 |
0 |
if (choice) |
514 |
|
{ |
515 |
0 |
prm.setValue((String) choicebox.getSelectedItem()); |
516 |
|
} |
517 |
|
else |
518 |
|
{ |
519 |
0 |
prm.setValue(valueField.getText()); |
520 |
|
} |
521 |
0 |
return prm; |
522 |
|
} |
523 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
524 |
0 |
public void init()... |
525 |
|
{ |
526 |
|
|
527 |
0 |
lastVal = null; |
528 |
|
} |
529 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
530 |
0 |
@Override... |
531 |
|
public void mouseClicked(MouseEvent e) |
532 |
|
{ |
533 |
0 |
if (e.isPopupTrigger()) |
534 |
|
{ |
535 |
0 |
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY()); |
536 |
|
} |
537 |
|
} |
538 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
539 |
0 |
@Override... |
540 |
|
public void mouseEntered(MouseEvent e) |
541 |
|
{ |
542 |
|
|
543 |
|
|
544 |
|
} |
545 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
546 |
0 |
@Override... |
547 |
|
public void mouseExited(MouseEvent e) |
548 |
|
{ |
549 |
|
|
550 |
|
|
551 |
|
} |
552 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
553 |
0 |
@Override... |
554 |
|
public void mousePressed(MouseEvent e) |
555 |
|
{ |
556 |
0 |
if (e.isPopupTrigger()) |
557 |
|
{ |
558 |
0 |
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY()); |
559 |
|
} |
560 |
|
} |
561 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
562 |
0 |
@Override... |
563 |
|
public void mouseReleased(MouseEvent e) |
564 |
|
{ |
565 |
|
|
566 |
|
|
567 |
|
} |
568 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 1 |
|
569 |
0 |
@Override... |
570 |
|
public void stateChanged(ChangeEvent e) |
571 |
|
{ |
572 |
0 |
if (!adjusting) |
573 |
|
{ |
574 |
0 |
valueField.setText("" + ((integ) ? ("" + slider.getValue()) |
575 |
|
: ("" + slider.getValue() / 1000f))); |
576 |
0 |
checkIfModified(); |
577 |
|
} |
578 |
|
|
579 |
|
} |
580 |
|
|
|
|
| 0% |
Uncovered Elements: 38 (38) |
Complexity: 7 |
Complexity Density: 0.27 |
|
581 |
0 |
public void updateControls(ParameterI parm)... |
582 |
|
{ |
583 |
0 |
adjusting = true; |
584 |
0 |
boolean init = (choicebox == null && valueField == null); |
585 |
0 |
if (init) |
586 |
|
{ |
587 |
0 |
if (choice) |
588 |
|
{ |
589 |
0 |
choicebox = new JComboBox(); |
590 |
0 |
choicebox.addActionListener(this); |
591 |
0 |
controlPanel.add(choicebox, BorderLayout.CENTER); |
592 |
|
} |
593 |
|
else |
594 |
|
{ |
595 |
0 |
slider = new JSlider(); |
596 |
0 |
slider.addChangeListener(this); |
597 |
0 |
valueField = new JTextField(); |
598 |
0 |
valueField.addActionListener(this); |
599 |
0 |
valueField.addKeyListener(new KeyListener() |
600 |
|
{ |
601 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
602 |
0 |
@Override... |
603 |
|
public void keyTyped(KeyEvent e) |
604 |
|
{ |
605 |
|
} |
606 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 1 |
|
607 |
0 |
@Override... |
608 |
|
public void keyReleased(KeyEvent e) |
609 |
|
{ |
610 |
0 |
if (e.isActionKey()) |
611 |
|
{ |
612 |
0 |
if (valueField.getText().trim().length() > 0) |
613 |
|
{ |
614 |
0 |
actionPerformed(null); |
615 |
|
} |
616 |
|
} |
617 |
|
} |
618 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
619 |
0 |
@Override... |
620 |
|
public void keyPressed(KeyEvent e) |
621 |
|
{ |
622 |
|
} |
623 |
|
}); |
624 |
0 |
valueField.setPreferredSize(new Dimension(60, 25)); |
625 |
0 |
controlPanel.add(slider, BorderLayout.WEST); |
626 |
0 |
controlPanel.add(valueField, BorderLayout.EAST); |
627 |
|
|
628 |
|
} |
629 |
|
} |
630 |
|
|
631 |
0 |
if (parm != null) |
632 |
|
{ |
633 |
0 |
if (choice) |
634 |
|
{ |
635 |
0 |
if (init) |
636 |
|
{ |
637 |
0 |
List vals = parm.getPossibleValues(); |
638 |
0 |
for (Object val : vals) |
639 |
|
{ |
640 |
0 |
choicebox.addItem(val); |
641 |
|
} |
642 |
|
} |
643 |
|
|
644 |
0 |
if (parm.getValue() != null) |
645 |
|
{ |
646 |
0 |
choicebox.setSelectedItem(parm.getValue()); |
647 |
|
} |
648 |
|
} |
649 |
|
else |
650 |
|
{ |
651 |
0 |
valueField.setText(parm.getValue()); |
652 |
|
} |
653 |
|
} |
654 |
0 |
lastVal = updateSliderFromValueField(); |
655 |
0 |
adjusting = false; |
656 |
|
} |
657 |
|
|
|
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 18 |
Complexity Density: 0.49 |
|
658 |
0 |
public Object updateSliderFromValueField()... |
659 |
|
{ |
660 |
0 |
int iVal; |
661 |
0 |
float fVal; |
662 |
0 |
if (validator != null) |
663 |
|
{ |
664 |
0 |
if (integ) |
665 |
|
{ |
666 |
0 |
iVal = 0; |
667 |
0 |
try |
668 |
|
{ |
669 |
0 |
valueField.setText(valueField.getText().trim()); |
670 |
0 |
iVal = Integer.valueOf(valueField.getText()); |
671 |
0 |
if (validator.getMin() != null |
672 |
|
&& validator.getMin().intValue() > iVal) |
673 |
|
{ |
674 |
0 |
iVal = validator.getMin().intValue(); |
675 |
|
|
676 |
|
|
677 |
|
} |
678 |
0 |
if (validator.getMax() != null |
679 |
|
&& validator.getMax().intValue() < iVal) |
680 |
|
{ |
681 |
0 |
iVal = validator.getMax().intValue(); |
682 |
|
|
683 |
|
|
684 |
|
} |
685 |
|
} catch (Exception e) |
686 |
|
{ |
687 |
|
} |
688 |
0 |
; |
689 |
|
|
690 |
0 |
valueField.setText("" + iVal); |
691 |
0 |
if (validator.getMin() != null && validator.getMax() != null) |
692 |
|
{ |
693 |
0 |
slider.getModel().setRangeProperties(iVal, 1, |
694 |
|
validator.getMin().intValue(), |
695 |
|
validator.getMax().intValue() + 1, true); |
696 |
|
} |
697 |
|
else |
698 |
|
{ |
699 |
0 |
slider.setVisible(false); |
700 |
|
} |
701 |
0 |
return new int[] { iVal }; |
702 |
|
} |
703 |
|
else |
704 |
|
{ |
705 |
0 |
fVal = 0f; |
706 |
0 |
try |
707 |
|
{ |
708 |
0 |
valueField.setText(valueField.getText().trim()); |
709 |
0 |
fVal = Float.valueOf(valueField.getText()); |
710 |
0 |
if (validator.getMin() != null |
711 |
|
&& validator.getMin().floatValue() > fVal) |
712 |
|
{ |
713 |
0 |
fVal = validator.getMin().floatValue(); |
714 |
|
|
715 |
|
|
716 |
|
|
717 |
0 |
valueField.setText("" + fVal); |
718 |
|
} |
719 |
0 |
if (validator.getMax() != null |
720 |
|
&& validator.getMax().floatValue() < fVal) |
721 |
|
{ |
722 |
0 |
fVal = validator.getMax().floatValue(); |
723 |
|
|
724 |
|
|
725 |
|
|
726 |
0 |
valueField.setText("" + fVal); |
727 |
|
} |
728 |
|
} catch (Exception e) |
729 |
|
{ |
730 |
|
} |
731 |
0 |
; |
732 |
0 |
if (validator.getMin() != null && validator.getMax() != null) |
733 |
|
{ |
734 |
0 |
slider.getModel().setRangeProperties((int) (fVal * 1000f), 1, |
735 |
|
(int) (validator.getMin().floatValue() * 1000f), |
736 |
|
1 + (int) (validator.getMax().floatValue() * 1000f), |
737 |
|
true); |
738 |
|
} |
739 |
|
else |
740 |
|
{ |
741 |
0 |
slider.setVisible(false); |
742 |
|
} |
743 |
0 |
return new float[] { fVal }; |
744 |
|
} |
745 |
|
} |
746 |
|
else |
747 |
|
{ |
748 |
0 |
if (!choice) |
749 |
|
{ |
750 |
0 |
slider.setVisible(false); |
751 |
0 |
return new String[] { valueField.getText().trim() }; |
752 |
|
} |
753 |
|
else |
754 |
|
{ |
755 |
0 |
return new String[] { (String) choicebox.getSelectedItem() }; |
756 |
|
} |
757 |
|
} |
758 |
|
|
759 |
|
} |
760 |
|
} |
761 |
|
|
762 |
|
public static final int PARAM_WIDTH = 340; |
763 |
|
|
764 |
|
public static final int PARAM_HEIGHT = 150; |
765 |
|
|
766 |
|
public static final int PARAM_CLOSEDHEIGHT = 80; |
767 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
768 |
0 |
public OptsAndParamsPage(OptsParametersContainerI paramContainer)... |
769 |
|
{ |
770 |
0 |
this(paramContainer, false); |
771 |
|
} |
772 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
773 |
0 |
public OptsAndParamsPage(OptsParametersContainerI paramContainer,... |
774 |
|
boolean compact) |
775 |
|
{ |
776 |
0 |
poparent = paramContainer; |
777 |
0 |
this.compact = compact; |
778 |
|
} |
779 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
780 |
0 |
public static void showUrlPopUp(JComponent invoker, final String finfo,... |
781 |
|
int x, int y) |
782 |
|
{ |
783 |
|
|
784 |
0 |
JPopupMenu mnu = new JPopupMenu(); |
785 |
0 |
JMenuItem mitem = new JMenuItem( |
786 |
|
MessageManager.formatMessage("label.view_params", new String[] |
787 |
|
{ finfo })); |
788 |
0 |
mitem.addActionListener(new ActionListener() |
789 |
|
{ |
790 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
791 |
0 |
@Override... |
792 |
|
public void actionPerformed(ActionEvent e) |
793 |
|
{ |
794 |
0 |
Desktop.showUrl(finfo); |
795 |
|
|
796 |
|
} |
797 |
|
}); |
798 |
0 |
mnu.add(mitem); |
799 |
0 |
mnu.show(invoker, x, y); |
800 |
|
} |
801 |
|
|
802 |
|
URL linkImageURL = getClass().getResource("/images/link.gif"); |
803 |
|
|
804 |
|
Map<String, OptionBox> optSet = new java.util.LinkedHashMap<String, OptionBox>(); |
805 |
|
|
806 |
|
Map<String, ParamBox> paramSet = new java.util.LinkedHashMap<String, ParamBox>(); |
807 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
808 |
0 |
public Map<String, OptionBox> getOptSet()... |
809 |
|
{ |
810 |
0 |
return optSet; |
811 |
|
} |
812 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
813 |
0 |
public void setOptSet(Map<String, OptionBox> optSet)... |
814 |
|
{ |
815 |
0 |
this.optSet = optSet; |
816 |
|
} |
817 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
818 |
0 |
public Map<String, ParamBox> getParamSet()... |
819 |
|
{ |
820 |
0 |
return paramSet; |
821 |
|
} |
822 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
823 |
0 |
public void setParamSet(Map<String, ParamBox> paramSet)... |
824 |
|
{ |
825 |
0 |
this.paramSet = paramSet; |
826 |
|
} |
827 |
|
|
828 |
|
OptsParametersContainerI poparent; |
829 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
830 |
0 |
OptionBox addOption(OptionI opt)... |
831 |
|
{ |
832 |
0 |
OptionBox cb = optSet.get(opt.getName()); |
833 |
0 |
if (cb == null) |
834 |
|
{ |
835 |
0 |
cb = new OptionBox(opt); |
836 |
0 |
optSet.put(opt.getName(), cb); |
837 |
|
|
838 |
|
} |
839 |
0 |
return cb; |
840 |
|
} |
841 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
842 |
0 |
ParamBox addParameter(ParameterI arg)... |
843 |
|
{ |
844 |
0 |
ParamBox pb = paramSet.get(arg.getName()); |
845 |
0 |
if (pb == null) |
846 |
|
{ |
847 |
0 |
pb = new ParamBox(poparent, arg); |
848 |
0 |
paramSet.put(arg.getName(), pb); |
849 |
|
|
850 |
|
} |
851 |
0 |
pb.init(); |
852 |
|
|
853 |
0 |
pb.updateControls(arg); |
854 |
0 |
return pb; |
855 |
|
} |
856 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.6 |
|
857 |
0 |
void selectOption(OptionI option, String string)... |
858 |
|
{ |
859 |
0 |
OptionBox cb = optSet.get(option.getName()); |
860 |
0 |
if (cb == null) |
861 |
|
{ |
862 |
0 |
cb = addOption(option); |
863 |
|
} |
864 |
0 |
cb.enabled.setSelected(string != null); |
865 |
0 |
if (string != null) |
866 |
|
{ |
867 |
0 |
if (option.getPossibleValues().contains(string)) |
868 |
|
{ |
869 |
0 |
cb.val.setSelectedItem(string); |
870 |
|
} |
871 |
|
else |
872 |
|
{ |
873 |
0 |
throw new Error(MessageManager.formatMessage( |
874 |
|
"error.invalid_value_for_option", new String[] |
875 |
|
{ string, option.getName() })); |
876 |
|
} |
877 |
|
|
878 |
|
} |
879 |
0 |
if (option.isRequired() && !cb.enabled.isSelected()) |
880 |
|
{ |
881 |
|
|
882 |
|
} |
883 |
0 |
cb.setInitialValue(); |
884 |
|
} |
885 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
886 |
0 |
void setParameter(ParameterI arg)... |
887 |
|
{ |
888 |
0 |
ParamBox pb = paramSet.get(arg.getName()); |
889 |
0 |
if (pb == null) |
890 |
|
{ |
891 |
0 |
addParameter(arg); |
892 |
|
} |
893 |
|
else |
894 |
|
{ |
895 |
0 |
pb.updateControls(arg); |
896 |
|
} |
897 |
|
|
898 |
|
} |
899 |
|
|
900 |
|
|
901 |
|
|
902 |
|
|
903 |
|
@return |
904 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
905 |
0 |
public List<ArgumentI> getCurrentSettings()... |
906 |
|
{ |
907 |
0 |
List<ArgumentI> argSet = new ArrayList<ArgumentI>(); |
908 |
0 |
for (OptionBox opts : getOptSet().values()) |
909 |
|
{ |
910 |
0 |
OptionI opt = opts.getOptionIfEnabled(); |
911 |
0 |
if (opt != null) |
912 |
|
{ |
913 |
0 |
argSet.add(opt); |
914 |
|
} |
915 |
|
} |
916 |
0 |
for (ParamBox parambox : getParamSet().values()) |
917 |
|
{ |
918 |
0 |
ParameterI parm = parambox.getParameter(); |
919 |
0 |
if (parm != null) |
920 |
|
{ |
921 |
0 |
argSet.add(parm); |
922 |
|
} |
923 |
|
} |
924 |
|
|
925 |
0 |
return argSet; |
926 |
|
} |
927 |
|
|
928 |
|
} |