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 java.awt.BorderLayout; |
24 |
|
import java.awt.Component; |
25 |
|
import java.awt.Dimension; |
26 |
|
import java.awt.Font; |
27 |
|
import java.awt.GridLayout; |
28 |
|
import java.awt.Rectangle; |
29 |
|
import java.awt.event.ActionEvent; |
30 |
|
import java.awt.event.ActionListener; |
31 |
|
import java.awt.event.FocusAdapter; |
32 |
|
import java.awt.event.FocusEvent; |
33 |
|
import java.awt.event.KeyEvent; |
34 |
|
import java.awt.event.KeyListener; |
35 |
|
import java.awt.event.MouseEvent; |
36 |
|
import java.awt.event.MouseListener; |
37 |
|
import java.net.URL; |
38 |
|
import java.util.ArrayList; |
39 |
|
import java.util.List; |
40 |
|
import java.util.Map; |
41 |
|
|
42 |
|
import javax.swing.JButton; |
43 |
|
import javax.swing.JCheckBox; |
44 |
|
import javax.swing.JComboBox; |
45 |
|
import javax.swing.JComponent; |
46 |
|
import javax.swing.JLabel; |
47 |
|
import javax.swing.JMenuItem; |
48 |
|
import javax.swing.JPanel; |
49 |
|
import javax.swing.JPopupMenu; |
50 |
|
import javax.swing.JScrollPane; |
51 |
|
import javax.swing.JTextArea; |
52 |
|
import javax.swing.JTextField; |
53 |
|
import javax.swing.border.TitledBorder; |
54 |
|
import javax.swing.event.ChangeEvent; |
55 |
|
import javax.swing.event.ChangeListener; |
56 |
|
|
57 |
|
import jalview.util.MessageManager; |
58 |
|
import jalview.ws.params.ArgumentI; |
59 |
|
import jalview.ws.params.OptionI; |
60 |
|
import jalview.ws.params.ParameterI; |
61 |
|
import jalview.ws.params.ValueConstrainI; |
62 |
|
import jalview.ws.params.ValueConstrainI.ValueType; |
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<String> 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 (String 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: 264 (264) |
Complexity: 74 |
Complexity Density: 0.45 |
|
273 |
|
public class ParamBox extends JPanel |
274 |
|
implements ChangeListener, ActionListener, MouseListener |
275 |
|
{ |
276 |
|
boolean adjusting = false; |
277 |
|
|
278 |
|
boolean choice = false; |
279 |
|
|
280 |
|
JComboBox<String> 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 |
|
String lastVal; |
293 |
|
|
294 |
|
ParameterI parameter; |
295 |
|
|
296 |
|
final OptsParametersContainerI pmdialogbox; |
297 |
|
|
298 |
|
JPanel settingPanel = new JPanel(); |
299 |
|
|
300 |
|
JButton showDesc = new JButton(); |
301 |
|
|
302 |
|
Slider 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(final 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 |
|
|
454 |
|
|
455 |
|
|
456 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
457 |
0 |
@Override... |
458 |
|
public void actionPerformed(ActionEvent e) |
459 |
|
{ |
460 |
0 |
if (adjusting) |
461 |
|
{ |
462 |
0 |
return; |
463 |
|
} |
464 |
0 |
if (!choice) |
465 |
|
{ |
466 |
0 |
updateSliderFromValueField(); |
467 |
|
} |
468 |
0 |
checkIfModified(); |
469 |
|
} |
470 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
471 |
0 |
private void checkIfModified()... |
472 |
|
{ |
473 |
0 |
Object cstate = getCurrentValue(); |
474 |
0 |
boolean modified = !cstate.equals(lastVal); |
475 |
0 |
pmdialogbox.argSetModified(this, modified); |
476 |
|
} |
477 |
|
|
478 |
|
|
479 |
|
|
480 |
|
|
481 |
|
@return |
482 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
483 |
0 |
private String getCurrentValue()... |
484 |
|
{ |
485 |
0 |
return choice ? (String) choicebox.getSelectedItem() |
486 |
|
: valueField.getText(); |
487 |
|
} |
488 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
489 |
0 |
@Override... |
490 |
|
public int getBaseline(int width, int height) |
491 |
|
{ |
492 |
0 |
return 0; |
493 |
|
} |
494 |
|
|
495 |
|
|
496 |
|
|
497 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
498 |
0 |
@Override... |
499 |
|
public Component.BaselineResizeBehavior getBaselineResizeBehavior() |
500 |
|
{ |
501 |
0 |
return Component.BaselineResizeBehavior.CONSTANT_ASCENT; |
502 |
|
} |
503 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
504 |
0 |
public int getBoxHeight()... |
505 |
|
{ |
506 |
0 |
return (descisvisible ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT); |
507 |
|
} |
508 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
509 |
0 |
public ParameterI getParameter()... |
510 |
|
{ |
511 |
0 |
ParameterI prm = parameter.copy(); |
512 |
0 |
if (choice) |
513 |
|
{ |
514 |
0 |
prm.setValue((String) choicebox.getSelectedItem()); |
515 |
|
} |
516 |
|
else |
517 |
|
{ |
518 |
0 |
prm.setValue(valueField.getText()); |
519 |
|
} |
520 |
0 |
return prm; |
521 |
|
} |
522 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
523 |
0 |
public void init()... |
524 |
|
{ |
525 |
|
|
526 |
0 |
lastVal = null; |
527 |
|
} |
528 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
529 |
0 |
@Override... |
530 |
|
public void mouseClicked(MouseEvent e) |
531 |
|
{ |
532 |
0 |
if (e.isPopupTrigger()) |
533 |
|
{ |
534 |
0 |
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY()); |
535 |
|
} |
536 |
|
} |
537 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
538 |
0 |
@Override... |
539 |
|
public void mouseEntered(MouseEvent e) |
540 |
|
{ |
541 |
|
|
542 |
|
|
543 |
|
} |
544 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
545 |
0 |
@Override... |
546 |
|
public void mouseExited(MouseEvent e) |
547 |
|
{ |
548 |
|
|
549 |
|
|
550 |
|
} |
551 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
552 |
0 |
@Override... |
553 |
|
public void mousePressed(MouseEvent e) |
554 |
|
{ |
555 |
0 |
if (e.isPopupTrigger()) |
556 |
|
{ |
557 |
0 |
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY()); |
558 |
|
} |
559 |
|
} |
560 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
561 |
0 |
@Override... |
562 |
|
public void mouseReleased(MouseEvent e) |
563 |
|
{ |
564 |
|
|
565 |
|
|
566 |
|
} |
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
571 |
0 |
@Override... |
572 |
|
public void stateChanged(ChangeEvent e) |
573 |
|
{ |
574 |
0 |
if (!adjusting) |
575 |
|
{ |
576 |
0 |
float value = slider.getSliderValue(); |
577 |
0 |
valueField.setText(integ ? Integer.toString((int) value) |
578 |
|
: Float.toString(value)); |
579 |
0 |
checkIfModified(); |
580 |
|
} |
581 |
|
} |
582 |
|
|
|
|
| 0% |
Uncovered Elements: 41 (41) |
Complexity: 7 |
Complexity Density: 0.24 |
|
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.addFocusListener(new FocusAdapter() |
625 |
|
{ |
626 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
627 |
0 |
@Override... |
628 |
|
public void focusLost(FocusEvent e) |
629 |
|
{ |
630 |
0 |
actionPerformed(null); |
631 |
|
} |
632 |
|
|
633 |
|
}); |
634 |
0 |
valueField.setPreferredSize(new Dimension(60, 25)); |
635 |
0 |
valueField.setText(parm.getValue()); |
636 |
0 |
slider = makeSlider(parm.getValidValue()); |
637 |
0 |
updateSliderFromValueField(); |
638 |
0 |
slider.addChangeListener(this); |
639 |
|
|
640 |
0 |
controlPanel.add(slider, BorderLayout.WEST); |
641 |
0 |
controlPanel.add(valueField, BorderLayout.EAST); |
642 |
|
} |
643 |
|
} |
644 |
|
|
645 |
0 |
if (parm != null) |
646 |
|
{ |
647 |
0 |
if (choice) |
648 |
|
{ |
649 |
0 |
if (init) |
650 |
|
{ |
651 |
0 |
List<String> vals = parm.getPossibleValues(); |
652 |
0 |
for (String val : vals) |
653 |
|
{ |
654 |
0 |
choicebox.addItem(val); |
655 |
|
} |
656 |
|
} |
657 |
|
|
658 |
0 |
if (parm.getValue() != null) |
659 |
|
{ |
660 |
0 |
choicebox.setSelectedItem(parm.getValue()); |
661 |
|
} |
662 |
|
} |
663 |
|
else |
664 |
|
{ |
665 |
0 |
valueField.setText(parm.getValue()); |
666 |
|
} |
667 |
|
} |
668 |
0 |
lastVal = getCurrentValue(); |
669 |
0 |
adjusting = false; |
670 |
|
} |
671 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
672 |
0 |
private Slider makeSlider(ValueConstrainI validValue)... |
673 |
|
{ |
674 |
0 |
if (validValue != null) |
675 |
|
{ |
676 |
0 |
final Number minValue = validValue.getMin(); |
677 |
0 |
final Number maxValue = validValue.getMax(); |
678 |
0 |
if (minValue != null && maxValue != null) |
679 |
|
{ |
680 |
0 |
return new Slider(minValue.floatValue(), maxValue.floatValue(), |
681 |
|
minValue.floatValue()); |
682 |
|
} |
683 |
|
} |
684 |
|
|
685 |
|
|
686 |
|
|
687 |
|
|
688 |
0 |
return new Slider(0, 100, 50); |
689 |
|
} |
690 |
|
|
|
|
| 0% |
Uncovered Elements: 51 (51) |
Complexity: 18 |
Complexity Density: 0.55 |
|
691 |
0 |
public void updateSliderFromValueField()... |
692 |
|
{ |
693 |
0 |
if (validator != null) |
694 |
|
{ |
695 |
0 |
final Number minValue = validator.getMin(); |
696 |
0 |
final Number maxValue = validator.getMax(); |
697 |
0 |
if (integ) |
698 |
|
{ |
699 |
0 |
int iVal = 0; |
700 |
0 |
try |
701 |
|
{ |
702 |
0 |
valueField.setText(valueField.getText().trim()); |
703 |
0 |
iVal = Integer.valueOf(valueField.getText()); |
704 |
0 |
if (minValue != null && minValue.intValue() > iVal) |
705 |
|
{ |
706 |
0 |
iVal = minValue.intValue(); |
707 |
|
|
708 |
|
|
709 |
|
} |
710 |
0 |
if (maxValue != null && maxValue.intValue() < iVal) |
711 |
|
{ |
712 |
0 |
iVal = maxValue.intValue(); |
713 |
|
} |
714 |
|
} catch (NumberFormatException e) |
715 |
|
{ |
716 |
0 |
jalview.bin.Console.errPrintln(e.toString()); |
717 |
|
} |
718 |
0 |
if (minValue != null || maxValue != null) |
719 |
|
{ |
720 |
0 |
valueField.setText(String.valueOf(iVal)); |
721 |
0 |
slider.setSliderValue(iVal); |
722 |
|
} |
723 |
|
else |
724 |
|
{ |
725 |
0 |
slider.setVisible(false); |
726 |
|
} |
727 |
|
} |
728 |
|
else |
729 |
|
{ |
730 |
0 |
float fVal = 0f; |
731 |
0 |
try |
732 |
|
{ |
733 |
0 |
valueField.setText(valueField.getText().trim()); |
734 |
0 |
fVal = Float.valueOf(valueField.getText()); |
735 |
0 |
if (minValue != null && minValue.floatValue() > fVal) |
736 |
|
{ |
737 |
0 |
fVal = minValue.floatValue(); |
738 |
|
|
739 |
|
|
740 |
|
|
741 |
0 |
valueField.setText("" + fVal); |
742 |
|
} |
743 |
0 |
if (maxValue != null && maxValue.floatValue() < fVal) |
744 |
|
{ |
745 |
0 |
fVal = maxValue.floatValue(); |
746 |
|
|
747 |
|
|
748 |
|
|
749 |
0 |
valueField.setText("" + fVal); |
750 |
|
} |
751 |
|
} catch (NumberFormatException e) |
752 |
|
{ |
753 |
0 |
jalview.bin.Console.errPrintln(e.toString()); |
754 |
|
} |
755 |
0 |
if (minValue != null && maxValue != null) |
756 |
|
{ |
757 |
0 |
slider.setSliderModel(minValue.floatValue(), |
758 |
|
maxValue.floatValue(), fVal); |
759 |
|
} |
760 |
|
else |
761 |
|
{ |
762 |
0 |
slider.setVisible(false); |
763 |
|
} |
764 |
|
} |
765 |
|
} |
766 |
|
else |
767 |
|
{ |
768 |
0 |
if (!choice) |
769 |
|
{ |
770 |
0 |
slider.setVisible(false); |
771 |
|
} |
772 |
|
} |
773 |
|
} |
774 |
|
} |
775 |
|
|
776 |
|
public static final int PARAM_WIDTH = 340; |
777 |
|
|
778 |
|
public static final int PARAM_HEIGHT = 150; |
779 |
|
|
780 |
|
public static final int PARAM_CLOSEDHEIGHT = 80; |
781 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
782 |
0 |
public OptsAndParamsPage(OptsParametersContainerI paramContainer)... |
783 |
|
{ |
784 |
0 |
this(paramContainer, false); |
785 |
|
} |
786 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
787 |
0 |
public OptsAndParamsPage(OptsParametersContainerI paramContainer,... |
788 |
|
boolean compact) |
789 |
|
{ |
790 |
0 |
poparent = paramContainer; |
791 |
0 |
this.compact = compact; |
792 |
|
} |
793 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
794 |
0 |
public static void showUrlPopUp(JComponent invoker, final String finfo,... |
795 |
|
int x, int y) |
796 |
|
{ |
797 |
|
|
798 |
0 |
JPopupMenu mnu = new JPopupMenu(); |
799 |
0 |
JMenuItem mitem = new JMenuItem( |
800 |
|
MessageManager.formatMessage("label.view_params", new String[] |
801 |
|
{ finfo })); |
802 |
0 |
mitem.addActionListener(new ActionListener() |
803 |
|
{ |
804 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
805 |
0 |
@Override... |
806 |
|
public void actionPerformed(ActionEvent e) |
807 |
|
{ |
808 |
0 |
Desktop.showUrl(finfo); |
809 |
|
|
810 |
|
} |
811 |
|
}); |
812 |
0 |
mnu.add(mitem); |
813 |
0 |
mnu.show(invoker, x, y); |
814 |
|
} |
815 |
|
|
816 |
|
URL linkImageURL = getClass().getResource("/images/link.gif"); |
817 |
|
|
818 |
|
Map<String, OptionBox> optSet = new java.util.LinkedHashMap<>(); |
819 |
|
|
820 |
|
Map<String, ParamBox> paramSet = new java.util.LinkedHashMap<>(); |
821 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
822 |
0 |
public Map<String, OptionBox> getOptSet()... |
823 |
|
{ |
824 |
0 |
return optSet; |
825 |
|
} |
826 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
827 |
0 |
public void setOptSet(Map<String, OptionBox> optSet)... |
828 |
|
{ |
829 |
0 |
this.optSet = optSet; |
830 |
|
} |
831 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
832 |
0 |
public Map<String, ParamBox> getParamSet()... |
833 |
|
{ |
834 |
0 |
return paramSet; |
835 |
|
} |
836 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
837 |
0 |
public void setParamSet(Map<String, ParamBox> paramSet)... |
838 |
|
{ |
839 |
0 |
this.paramSet = paramSet; |
840 |
|
} |
841 |
|
|
842 |
|
OptsParametersContainerI poparent; |
843 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
844 |
0 |
OptionBox addOption(OptionI opt)... |
845 |
|
{ |
846 |
0 |
OptionBox cb = optSet.get(opt.getName()); |
847 |
0 |
if (cb == null) |
848 |
|
{ |
849 |
0 |
cb = new OptionBox(opt); |
850 |
0 |
optSet.put(opt.getName(), cb); |
851 |
|
|
852 |
|
} |
853 |
0 |
return cb; |
854 |
|
} |
855 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
856 |
0 |
ParamBox addParameter(ParameterI arg)... |
857 |
|
{ |
858 |
0 |
ParamBox pb = paramSet.get(arg.getName()); |
859 |
0 |
if (pb == null) |
860 |
|
{ |
861 |
0 |
pb = new ParamBox(poparent, arg); |
862 |
0 |
paramSet.put(arg.getName(), pb); |
863 |
|
|
864 |
|
} |
865 |
0 |
pb.init(); |
866 |
|
|
867 |
0 |
pb.updateControls(arg); |
868 |
0 |
return pb; |
869 |
|
} |
870 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.6 |
|
871 |
0 |
void selectOption(OptionI option, String string)... |
872 |
|
{ |
873 |
0 |
OptionBox cb = optSet.get(option.getName()); |
874 |
0 |
if (cb == null) |
875 |
|
{ |
876 |
0 |
cb = addOption(option); |
877 |
|
} |
878 |
0 |
cb.enabled.setSelected(string != null); |
879 |
0 |
if (string != null) |
880 |
|
{ |
881 |
0 |
if (option.getPossibleValues().contains(string)) |
882 |
|
{ |
883 |
0 |
cb.val.setSelectedItem(string); |
884 |
|
} |
885 |
|
else |
886 |
|
{ |
887 |
0 |
throw new Error(MessageManager.formatMessage( |
888 |
|
"error.invalid_value_for_option", new String[] |
889 |
|
{ string, option.getName() })); |
890 |
|
} |
891 |
|
|
892 |
|
} |
893 |
0 |
if (option.isRequired() && !cb.enabled.isSelected()) |
894 |
|
{ |
895 |
|
|
896 |
|
} |
897 |
0 |
cb.setInitialValue(); |
898 |
|
} |
899 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
900 |
0 |
void setParameter(ParameterI arg)... |
901 |
|
{ |
902 |
0 |
ParamBox pb = paramSet.get(arg.getName()); |
903 |
0 |
if (pb == null) |
904 |
|
{ |
905 |
0 |
addParameter(arg); |
906 |
|
} |
907 |
|
else |
908 |
|
{ |
909 |
0 |
pb.updateControls(arg); |
910 |
|
} |
911 |
|
|
912 |
|
} |
913 |
|
|
914 |
|
|
915 |
|
|
916 |
|
|
917 |
|
@return |
918 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
919 |
0 |
public List<ArgumentI> getCurrentSettings()... |
920 |
|
{ |
921 |
0 |
List<ArgumentI> argSet = new ArrayList<>(); |
922 |
0 |
for (OptionBox opts : getOptSet().values()) |
923 |
|
{ |
924 |
0 |
OptionI opt = opts.getOptionIfEnabled(); |
925 |
0 |
if (opt != null) |
926 |
|
{ |
927 |
0 |
argSet.add(opt); |
928 |
|
} |
929 |
|
} |
930 |
0 |
for (ParamBox parambox : getParamSet().values()) |
931 |
|
{ |
932 |
0 |
ParameterI parm = parambox.getParameter(); |
933 |
0 |
if (parm != null) |
934 |
|
{ |
935 |
0 |
argSet.add(parm); |
936 |
|
} |
937 |
|
} |
938 |
|
|
939 |
0 |
return argSet; |
940 |
|
} |
941 |
|
|
942 |
|
} |