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