| 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.bin.Cache; |
| 24 |
|
import jalview.io.DataSourceType; |
| 25 |
|
import jalview.io.FileLoader; |
| 26 |
|
import jalview.io.JalviewFileChooser; |
| 27 |
|
import jalview.io.JalviewFileView; |
| 28 |
|
import jalview.util.MessageManager; |
| 29 |
|
import jalview.ws.jws2.dm.JabaOption; |
| 30 |
|
import jalview.ws.params.ArgumentI; |
| 31 |
|
import jalview.ws.params.OptionI; |
| 32 |
|
import jalview.ws.params.ParameterI; |
| 33 |
|
import jalview.ws.params.ValueConstrainI; |
| 34 |
|
import jalview.ws.params.ValueConstrainI.ValueType; |
| 35 |
|
import jalview.ws.params.simple.FileParameter; |
| 36 |
|
import jalview.ws.params.simple.LogarithmicParameter; |
| 37 |
|
import jalview.ws.params.simple.RadioChoiceParameter; |
| 38 |
|
import jalview.ws.params.simple.StringParameter; |
| 39 |
|
import java.awt.BorderLayout; |
| 40 |
|
import java.awt.Color; |
| 41 |
|
import java.awt.Component; |
| 42 |
|
import java.awt.Container; |
| 43 |
|
import java.awt.Dimension; |
| 44 |
|
import java.awt.FlowLayout; |
| 45 |
|
import java.awt.Font; |
| 46 |
|
import java.awt.Rectangle; |
| 47 |
|
import java.awt.event.ActionEvent; |
| 48 |
|
import java.awt.event.ActionListener; |
| 49 |
|
import java.awt.event.FocusAdapter; |
| 50 |
|
import java.awt.event.FocusEvent; |
| 51 |
|
import java.awt.event.KeyAdapter; |
| 52 |
|
import java.awt.event.KeyEvent; |
| 53 |
|
import java.awt.event.MouseAdapter; |
| 54 |
|
import java.awt.event.MouseEvent; |
| 55 |
|
import java.awt.event.MouseListener; |
| 56 |
|
import java.io.File; |
| 57 |
|
import java.net.URL; |
| 58 |
|
import java.util.ArrayList; |
| 59 |
|
import java.util.LinkedHashMap; |
| 60 |
|
import java.util.List; |
| 61 |
|
import java.util.Map; |
| 62 |
|
|
| 63 |
|
import javax.swing.ButtonGroup; |
| 64 |
|
import javax.swing.JButton; |
| 65 |
|
import javax.swing.JCheckBox; |
| 66 |
|
import javax.swing.JComboBox; |
| 67 |
|
import javax.swing.JComponent; |
| 68 |
|
import javax.swing.JLabel; |
| 69 |
|
import javax.swing.JMenuItem; |
| 70 |
|
import javax.swing.JPanel; |
| 71 |
|
import javax.swing.JPopupMenu; |
| 72 |
|
import javax.swing.JRadioButton; |
| 73 |
|
import javax.swing.JScrollPane; |
| 74 |
|
import javax.swing.JSlider; |
| 75 |
|
import javax.swing.JTextArea; |
| 76 |
|
import javax.swing.JTextField; |
| 77 |
|
import javax.swing.border.TitledBorder; |
| 78 |
|
import javax.swing.event.ChangeEvent; |
| 79 |
|
import javax.swing.event.ChangeListener; |
| 80 |
|
|
| 81 |
|
import net.miginfocom.swing.MigLayout; |
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
@author |
| 88 |
|
|
| 89 |
|
|
| |
|
| 0% |
Uncovered Elements: 103 (103) |
Complexity: 29 |
Complexity Density: 0.45 |
|
| 90 |
|
public class OptsAndParamsPage |
| 91 |
|
{ |
| 92 |
|
public static final int PARAM_WIDTH = 340; |
| 93 |
|
|
| 94 |
|
public static final int PARAM_HEIGHT = 150; |
| 95 |
|
|
| 96 |
|
public static final int PARAM_CLOSEDHEIGHT = 80; |
| 97 |
|
|
| 98 |
|
URL linkImageURL = getClass().getResource("/images/link.gif"); |
| 99 |
|
|
| 100 |
|
Map<String, OptionBox> optSet = new LinkedHashMap<>(); |
| 101 |
|
|
| 102 |
|
Map<String, ParamBox> paramSet = new LinkedHashMap<>(); |
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
boolean compact = false; |
| 108 |
|
|
| 109 |
|
OptsParametersContainerI poparent; |
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| |
|
| 0% |
Uncovered Elements: 103 (103) |
Complexity: 36 |
Complexity Density: 0.62 |
|
| 115 |
|
public class OptionBox extends JPanel |
| 116 |
|
implements MouseListener, ActionListener |
| 117 |
|
{ |
| 118 |
|
JCheckBox enabled; |
| 119 |
|
|
| 120 |
|
final URL finfo; |
| 121 |
|
|
| 122 |
|
boolean hasLink = false; |
| 123 |
|
|
| 124 |
|
boolean initEnabled = false; |
| 125 |
|
|
| 126 |
|
String initVal = null; |
| 127 |
|
|
| 128 |
|
OptionI option; |
| 129 |
|
|
| 130 |
|
JComboBox<Object> val; |
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
@param |
| 136 |
|
|
| 137 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 138 |
0 |
public OptionBox(OptionI opt)... |
| 139 |
|
{ |
| 140 |
0 |
option = opt; |
| 141 |
0 |
setLayout(new FlowLayout(FlowLayout.LEFT)); |
| 142 |
0 |
enabled = new JCheckBox(opt.getLabel()); |
| 143 |
0 |
enabled.setSelected(opt.isRequired()); |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
0 |
if (opt.isRequired() && !(opt instanceof JabaOption)) |
| 150 |
|
{ |
| 151 |
0 |
finfo = null; |
| 152 |
0 |
add(new JLabel(opt.getLabel())); |
| 153 |
|
} |
| 154 |
|
else |
| 155 |
|
{ |
| 156 |
0 |
finfo = option.getFurtherDetails(); |
| 157 |
0 |
configureCheckbox(opt); |
| 158 |
0 |
add(enabled); |
| 159 |
|
} |
| 160 |
|
|
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
0 |
val = buildComboBox(opt); |
| 166 |
0 |
val.setSelectedItem(opt.getValue()); |
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
0 |
if (opt.getPossibleValues().size() > 1 || opt.isRequired()) |
| 173 |
|
{ |
| 174 |
0 |
val.addActionListener(this); |
| 175 |
0 |
add(val); |
| 176 |
|
} |
| 177 |
|
|
| 178 |
0 |
setInitialValue(); |
| 179 |
|
} |
| 180 |
|
|
| 181 |
|
|
| 182 |
|
|
| 183 |
|
|
| 184 |
|
|
| 185 |
|
@param |
| 186 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 6 |
Complexity Density: 0.43 |
|
| 187 |
0 |
protected void configureCheckbox(OptionI opt)... |
| 188 |
|
{ |
| 189 |
0 |
enabled.setFont(new Font("Verdana", Font.PLAIN, 11)); |
| 190 |
0 |
enabled.addActionListener(this); |
| 191 |
0 |
final String desc = opt.getDescription(); |
| 192 |
0 |
if (finfo != null) |
| 193 |
|
{ |
| 194 |
0 |
hasLink = true; |
| 195 |
|
|
| 196 |
0 |
String description = desc; |
| 197 |
0 |
if (desc == null || desc.trim().isEmpty()) |
| 198 |
|
{ |
| 199 |
0 |
description = MessageManager |
| 200 |
|
.getString("label.opt_and_params_further_details"); |
| 201 |
|
} |
| 202 |
0 |
description = description + "<br><img src=\"" + linkImageURL |
| 203 |
|
+ "\"/>"; |
| 204 |
0 |
String text = JvSwingUtils.wrapTooltip(true, description); |
| 205 |
0 |
enabled.setToolTipText(text); |
| 206 |
0 |
enabled.addMouseListener(this); |
| 207 |
|
} |
| 208 |
|
else |
| 209 |
|
{ |
| 210 |
0 |
if (desc != null && desc.trim().length() > 0) |
| 211 |
|
{ |
| 212 |
0 |
enabled.setToolTipText(JvSwingUtils.wrapTooltip(true, desc)); |
| 213 |
|
} |
| 214 |
|
} |
| 215 |
|
} |
| 216 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 217 |
0 |
@Override... |
| 218 |
|
public void actionPerformed(ActionEvent e) |
| 219 |
|
{ |
| 220 |
0 |
if (e.getSource() != enabled) |
| 221 |
|
{ |
| 222 |
0 |
enabled.setSelected(true); |
| 223 |
|
} |
| 224 |
0 |
checkIfModified(); |
| 225 |
|
} |
| 226 |
|
|
| |
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 227 |
0 |
private void checkIfModified()... |
| 228 |
|
{ |
| 229 |
0 |
boolean notmod = (initEnabled == enabled.isSelected()); |
| 230 |
0 |
if (enabled.isSelected()) |
| 231 |
|
{ |
| 232 |
0 |
if (initVal != null) |
| 233 |
|
{ |
| 234 |
0 |
notmod &= initVal.equals(val.getSelectedItem()); |
| 235 |
|
} |
| 236 |
|
else |
| 237 |
|
{ |
| 238 |
|
|
| 239 |
0 |
notmod &= option.getValue() == null |
| 240 |
|
|| option.getValue().equals(val.getSelectedItem()); |
| 241 |
|
} |
| 242 |
|
} |
| 243 |
|
else |
| 244 |
|
{ |
| 245 |
0 |
notmod &= (initVal != null) ? initVal.equals(val.getSelectedItem()) |
| 246 |
|
: val.getSelectedItem() != initVal; |
| 247 |
|
} |
| 248 |
0 |
poparent.argSetModified(this, !notmod); |
| 249 |
|
} |
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
|
|
| 254 |
|
|
| 255 |
|
@return |
| 256 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 257 |
0 |
public ArgumentI getSelectedOption()... |
| 258 |
|
{ |
| 259 |
0 |
if (!enabled.isSelected()) |
| 260 |
|
{ |
| 261 |
0 |
return null; |
| 262 |
|
} |
| 263 |
0 |
String value = getSelectedValue(option, val.getSelectedIndex()); |
| 264 |
0 |
OptionI opt = option.copy(); |
| 265 |
0 |
opt.setValue(value); |
| 266 |
0 |
return opt; |
| 267 |
|
} |
| 268 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 269 |
0 |
@Override... |
| 270 |
|
public void mouseClicked(MouseEvent e) |
| 271 |
|
{ |
| 272 |
0 |
if (e.isPopupTrigger()) |
| 273 |
|
{ |
| 274 |
0 |
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY()); |
| 275 |
|
} |
| 276 |
|
} |
| 277 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 278 |
0 |
@Override... |
| 279 |
|
public void mouseEntered(MouseEvent e) |
| 280 |
|
{ |
| 281 |
|
|
| 282 |
|
} |
| 283 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 284 |
0 |
@Override... |
| 285 |
|
public void mouseExited(MouseEvent e) |
| 286 |
|
{ |
| 287 |
|
|
| 288 |
|
} |
| 289 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 290 |
0 |
@Override... |
| 291 |
|
public void mousePressed(MouseEvent e) |
| 292 |
|
{ |
| 293 |
0 |
if (e.isPopupTrigger()) |
| 294 |
|
{ |
| 295 |
0 |
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY()); |
| 296 |
|
} |
| 297 |
|
} |
| 298 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 299 |
0 |
@Override... |
| 300 |
|
public void mouseReleased(MouseEvent e) |
| 301 |
|
{ |
| 302 |
|
} |
| 303 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 4 |
Complexity Density: 1.33 |
|
| 304 |
0 |
public void resetToDefault(boolean setDefaultParams)... |
| 305 |
|
{ |
| 306 |
0 |
enabled.setSelected(false); |
| 307 |
0 |
if (option.isRequired() |
| 308 |
|
|| (setDefaultParams && option.getValue() != null)) |
| 309 |
|
{ |
| 310 |
|
|
| 311 |
0 |
selectOption(option, option.getValue()); |
| 312 |
|
} |
| 313 |
|
} |
| 314 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 4 |
Complexity Density: 1 |
|
| 315 |
0 |
public void setInitialValue()... |
| 316 |
|
{ |
| 317 |
0 |
initEnabled = enabled.isSelected(); |
| 318 |
0 |
if (option.getPossibleValues() != null |
| 319 |
|
&& option.getPossibleValues().size() > 1) |
| 320 |
|
{ |
| 321 |
0 |
initVal = (String) val.getSelectedItem(); |
| 322 |
|
} |
| 323 |
|
else |
| 324 |
|
{ |
| 325 |
0 |
initVal = (initEnabled) ? (String) val.getSelectedItem() : null; |
| 326 |
|
} |
| 327 |
|
} |
| 328 |
|
|
| 329 |
|
|
| 330 |
|
|
| 331 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 332 |
0 |
@Override... |
| 333 |
|
public String toString() |
| 334 |
|
{ |
| 335 |
0 |
return option == null ? super.toString() : option.toString(); |
| 336 |
|
} |
| 337 |
|
} |
| 338 |
|
|
| 339 |
|
|
| 340 |
|
|
| 341 |
|
|
| |
|
| 0% |
Uncovered Elements: 347 (347) |
Complexity: 89 |
Complexity Density: 0.39 |
|
| 342 |
|
public class ParamBox extends JPanel |
| 343 |
|
implements ChangeListener, ActionListener, MouseListener |
| 344 |
|
{ |
| 345 |
|
|
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
|
private int sliderScaleFactor = 1; |
| 350 |
|
|
| 351 |
|
boolean isLogarithmicParameter; |
| 352 |
|
|
| 353 |
|
boolean isChoiceParameter; |
| 354 |
|
|
| 355 |
|
boolean isIntegerParameter; |
| 356 |
|
|
| 357 |
|
boolean isStringParameter; |
| 358 |
|
|
| 359 |
|
boolean adjusting; |
| 360 |
|
|
| 361 |
|
|
| 362 |
|
|
| 363 |
|
|
| 364 |
|
JComboBox<Object> choicebox; |
| 365 |
|
|
| 366 |
|
|
| 367 |
|
|
| 368 |
|
|
| 369 |
|
ButtonGroup buttonGroup; |
| 370 |
|
|
| 371 |
|
JPanel controlsPanel = new JPanel(); |
| 372 |
|
|
| 373 |
|
boolean descriptionIsVisible = false; |
| 374 |
|
|
| 375 |
|
JScrollPane descPanel = new JScrollPane(); |
| 376 |
|
|
| 377 |
|
final URL finfo; |
| 378 |
|
|
| 379 |
|
Object lastVal; |
| 380 |
|
|
| 381 |
|
ParameterI parameter; |
| 382 |
|
|
| 383 |
|
final OptsParametersContainerI pmdialogbox; |
| 384 |
|
|
| 385 |
|
JPanel settingPanel = new JPanel(); |
| 386 |
|
|
| 387 |
|
JSlider slider; |
| 388 |
|
|
| 389 |
|
JTextArea descriptionText = new JTextArea(); |
| 390 |
|
|
| 391 |
|
ValueConstrainI validator; |
| 392 |
|
|
| 393 |
|
JTextField valueField; |
| 394 |
|
|
| 395 |
|
private String descTooltip; |
| 396 |
|
|
| |
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 7 |
Complexity Density: 0.33 |
|
| 397 |
0 |
public ParamBox(final OptsParametersContainerI paramContainer,... |
| 398 |
|
ParameterI parm) |
| 399 |
|
{ |
| 400 |
0 |
pmdialogbox = paramContainer; |
| 401 |
0 |
finfo = parm.getFurtherDetails(); |
| 402 |
0 |
validator = parm.getValidValue(); |
| 403 |
0 |
parameter = parm; |
| 404 |
0 |
isLogarithmicParameter = parm instanceof LogarithmicParameter; |
| 405 |
0 |
if (validator != null) |
| 406 |
|
{ |
| 407 |
0 |
ValueType type = validator.getType(); |
| 408 |
0 |
isIntegerParameter = type == ValueType.Integer; |
| 409 |
0 |
isStringParameter = type == ValueType.String |
| 410 |
|
|| type == ValueType.File; |
| 411 |
|
|
| 412 |
|
|
| 413 |
|
|
| 414 |
|
|
| 415 |
|
|
| 416 |
0 |
if (validator.getMin() != null && validator.getMax() != null |
| 417 |
|
|
| 418 |
|
&& !isStringParameter) |
| 419 |
|
{ |
| 420 |
0 |
double min = validator.getMin().doubleValue(); |
| 421 |
0 |
double max = validator.getMax().doubleValue(); |
| 422 |
0 |
if (isLogarithmicParameter) |
| 423 |
|
{ |
| 424 |
0 |
min = Math.log(min); |
| 425 |
0 |
max = Math.log(max); |
| 426 |
|
} |
| 427 |
0 |
sliderScaleFactor = (int) (1000000 / (max - min)); |
| 428 |
|
|
| 429 |
|
} |
| 430 |
|
} |
| 431 |
|
|
| 432 |
0 |
List<String> possibleValues = parameter.getPossibleValues(); |
| 433 |
0 |
isChoiceParameter = possibleValues != null |
| 434 |
|
&& !possibleValues.isEmpty(); |
| 435 |
|
|
| 436 |
0 |
if (compact) |
| 437 |
|
{ |
| 438 |
0 |
addCompactParameter(parm); |
| 439 |
|
} |
| 440 |
|
else |
| 441 |
|
{ |
| 442 |
0 |
addExpandableParam(parm); |
| 443 |
|
|
| 444 |
|
} |
| 445 |
|
} |
| 446 |
|
|
| 447 |
|
|
| 448 |
|
|
| 449 |
|
|
| 450 |
|
@param |
| 451 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 452 |
0 |
private void addCompactParameter(ParameterI parm)... |
| 453 |
|
{ |
| 454 |
0 |
setLayout(new MigLayout("", "[][grow]")); |
| 455 |
|
|
| 456 |
0 |
String ttipText = null; |
| 457 |
|
|
| 458 |
0 |
controlsPanel.setLayout(new BorderLayout()); |
| 459 |
|
|
| 460 |
0 |
if (parm.getDescription() != null |
| 461 |
|
&& parm.getDescription().trim().length() > 0) |
| 462 |
|
{ |
| 463 |
0 |
ttipText = (JvSwingUtils.wrapTooltip(true, |
| 464 |
0 |
parm.getDescription() + (finfo != null ? "<br><img src=\"" |
| 465 |
|
+ linkImageURL + "\"/>" |
| 466 |
|
+ MessageManager.getString( |
| 467 |
|
"label.opt_and_params_further_details") |
| 468 |
|
: ""))); |
| 469 |
|
} |
| 470 |
|
|
| 471 |
0 |
JvSwingUtils.addtoLayout(this, ttipText, new JLabel(parm.getName()), |
| 472 |
|
controlsPanel, ""); |
| 473 |
0 |
updateControls(parm); |
| 474 |
0 |
validate(); |
| 475 |
|
} |
| 476 |
|
|
| 477 |
|
|
| 478 |
|
|
| 479 |
|
|
| 480 |
|
|
| 481 |
|
@param |
| 482 |
|
|
| |
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 5 |
Complexity Density: 0.19 |
|
| 483 |
0 |
private void addExpandableParam(ParameterI parm)... |
| 484 |
|
{ |
| 485 |
0 |
setPreferredSize(new Dimension(PARAM_WIDTH, PARAM_CLOSEDHEIGHT)); |
| 486 |
0 |
setBorder(new TitledBorder(parm.getName())); |
| 487 |
0 |
setLayout(null); |
| 488 |
0 |
descriptionText.setFont(new Font("Verdana", Font.PLAIN, 11)); |
| 489 |
0 |
descriptionText.setBackground(getBackground()); |
| 490 |
|
|
| 491 |
0 |
descriptionText.setEditable(false); |
| 492 |
0 |
descPanel.getViewport().setView(descriptionText); |
| 493 |
|
|
| 494 |
0 |
descPanel.setVisible(false); |
| 495 |
|
|
| 496 |
0 |
JPanel firstrow = new JPanel(); |
| 497 |
0 |
firstrow.setLayout(null); |
| 498 |
0 |
controlsPanel.setLayout(new BorderLayout()); |
| 499 |
0 |
controlsPanel.setBounds(new Rectangle(39, 10, PARAM_WIDTH - 70, |
| 500 |
|
PARAM_CLOSEDHEIGHT - 50)); |
| 501 |
0 |
firstrow.add(controlsPanel); |
| 502 |
0 |
firstrow.setBounds(new Rectangle(10, 20, PARAM_WIDTH - 30, |
| 503 |
|
PARAM_CLOSEDHEIGHT - 30)); |
| 504 |
|
|
| 505 |
|
|
| 506 |
0 |
if (parm.getDescription() != null |
| 507 |
|
&& parm.getDescription().trim().length() > 0) |
| 508 |
|
{ |
| 509 |
0 |
addExpandableHelp(firstrow, parm); |
| 510 |
|
} |
| 511 |
0 |
add(firstrow); |
| 512 |
0 |
validator = parm.getValidValue(); |
| 513 |
0 |
parameter = parm; |
| 514 |
0 |
if (validator != null) |
| 515 |
|
{ |
| 516 |
0 |
isIntegerParameter = validator.getType() == ValueType.Integer; |
| 517 |
|
} |
| 518 |
|
else |
| 519 |
|
{ |
| 520 |
0 |
if (parameter.getPossibleValues() != null) |
| 521 |
|
{ |
| 522 |
0 |
isChoiceParameter = true; |
| 523 |
|
} |
| 524 |
|
} |
| 525 |
0 |
updateControls(parm); |
| 526 |
0 |
descPanel.setBounds(new Rectangle(10, PARAM_CLOSEDHEIGHT, |
| 527 |
|
PARAM_WIDTH - 20, PARAM_HEIGHT - PARAM_CLOSEDHEIGHT - 5)); |
| 528 |
0 |
add(descPanel); |
| 529 |
0 |
validate(); |
| 530 |
|
} |
| 531 |
|
|
| 532 |
|
|
| 533 |
|
|
| 534 |
|
|
| 535 |
|
@param |
| 536 |
|
@param |
| 537 |
|
|
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 2 |
Complexity Density: 0.14 |
|
| 538 |
0 |
protected void addExpandableHelp(JPanel container, ParameterI param)... |
| 539 |
|
{ |
| 540 |
0 |
JButton showDescBtn = new JButton("+"); |
| 541 |
0 |
showDescBtn.setFont(new Font("Verdana", Font.PLAIN, 8)); |
| 542 |
0 |
if (finfo != null) |
| 543 |
|
{ |
| 544 |
0 |
descTooltip = JvSwingUtils.wrapTooltip(true, |
| 545 |
|
MessageManager.formatMessage( |
| 546 |
|
"label.opt_and_params_show_brief_desc_image_link", |
| 547 |
|
new String[] |
| 548 |
|
{ linkImageURL.toExternalForm() })); |
| 549 |
0 |
showDescBtn.addMouseListener(this); |
| 550 |
|
} |
| 551 |
|
else |
| 552 |
|
{ |
| 553 |
0 |
descTooltip = JvSwingUtils.wrapTooltip(true, MessageManager |
| 554 |
|
.getString("label.opt_and_params_show_brief_desc")); |
| 555 |
|
} |
| 556 |
0 |
showDescBtn.setToolTipText(descTooltip); |
| 557 |
0 |
showDescBtn.addActionListener(new ActionListener() |
| 558 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 559 |
0 |
@Override... |
| 560 |
|
public void actionPerformed(ActionEvent e) |
| 561 |
|
{ |
| 562 |
0 |
descriptionIsVisible = !descriptionIsVisible; |
| 563 |
0 |
showDescBtn.setText(descriptionIsVisible ? "-" : "+"); |
| 564 |
0 |
showDescBtn.setToolTipText( |
| 565 |
0 |
descriptionIsVisible ? null : descTooltip); |
| 566 |
0 |
descPanel.setVisible(descriptionIsVisible); |
| 567 |
0 |
descPanel.getVerticalScrollBar().setValue(0); |
| 568 |
0 |
ParamBox.this.setPreferredSize(new Dimension(PARAM_WIDTH, |
| 569 |
0 |
(descriptionIsVisible) ? PARAM_HEIGHT |
| 570 |
|
: PARAM_CLOSEDHEIGHT)); |
| 571 |
0 |
ParamBox.this.validate(); |
| 572 |
0 |
pmdialogbox.refreshParamLayout(); |
| 573 |
|
} |
| 574 |
|
}); |
| 575 |
0 |
descriptionText.setWrapStyleWord(true); |
| 576 |
0 |
descriptionText.setLineWrap(true); |
| 577 |
0 |
descriptionText.setColumns(32); |
| 578 |
0 |
descriptionText.setText(param.getDescription()); |
| 579 |
0 |
showDescBtn.setBounds(new Rectangle(10, 10, 16, 16)); |
| 580 |
0 |
container.add(showDescBtn); |
| 581 |
|
} |
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 582 |
0 |
@Override... |
| 583 |
|
public void actionPerformed(ActionEvent e) |
| 584 |
|
{ |
| 585 |
0 |
if (adjusting) |
| 586 |
|
{ |
| 587 |
0 |
return; |
| 588 |
|
} |
| 589 |
0 |
checkIfModified(); |
| 590 |
|
} |
| 591 |
|
|
| 592 |
|
|
| 593 |
|
|
| 594 |
|
|
| 595 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 596 |
0 |
private void checkIfModified()... |
| 597 |
|
{ |
| 598 |
0 |
Object newValue = updateSliderFromValueField(); |
| 599 |
0 |
boolean modified = true; |
| 600 |
0 |
if (newValue.getClass() == lastVal.getClass()) |
| 601 |
|
{ |
| 602 |
0 |
modified = !newValue.equals(lastVal); |
| 603 |
|
} |
| 604 |
0 |
pmdialogbox.argSetModified(this, modified); |
| 605 |
|
} |
| 606 |
|
|
| 607 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 608 |
0 |
@Override... |
| 609 |
|
public int getBaseline(int width, int height) |
| 610 |
|
{ |
| 611 |
0 |
return 0; |
| 612 |
|
} |
| 613 |
|
|
| 614 |
|
|
| 615 |
|
|
| 616 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 617 |
0 |
@Override... |
| 618 |
|
public Component.BaselineResizeBehavior getBaselineResizeBehavior() |
| 619 |
|
{ |
| 620 |
0 |
return Component.BaselineResizeBehavior.CONSTANT_ASCENT; |
| 621 |
|
} |
| 622 |
|
|
| 623 |
|
|
| 624 |
|
|
| 625 |
|
|
| 626 |
|
@return |
| 627 |
|
|
| |
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 628 |
0 |
public ArgumentI getParameter()... |
| 629 |
|
{ |
| 630 |
0 |
ParameterI prm = parameter.copy(); |
| 631 |
0 |
String value = null; |
| 632 |
0 |
if (parameter instanceof RadioChoiceParameter) |
| 633 |
|
{ |
| 634 |
0 |
value = buttonGroup.getSelection().getActionCommand(); |
| 635 |
|
} |
| 636 |
0 |
else if (isChoiceParameter) |
| 637 |
|
{ |
| 638 |
0 |
value = getSelectedValue(this.parameter, |
| 639 |
|
choicebox.getSelectedIndex()); |
| 640 |
|
} |
| 641 |
|
else |
| 642 |
|
{ |
| 643 |
0 |
value = valueField.getText(); |
| 644 |
|
} |
| 645 |
0 |
prm.setValue(value); |
| 646 |
0 |
return prm; |
| 647 |
|
} |
| 648 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 649 |
0 |
public void init()... |
| 650 |
|
{ |
| 651 |
|
|
| 652 |
0 |
lastVal = null; |
| 653 |
|
} |
| 654 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 655 |
0 |
@Override... |
| 656 |
|
public void mouseClicked(MouseEvent e) |
| 657 |
|
{ |
| 658 |
0 |
if (e.isPopupTrigger()) |
| 659 |
|
{ |
| 660 |
0 |
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY()); |
| 661 |
|
} |
| 662 |
|
} |
| 663 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 664 |
0 |
@Override... |
| 665 |
|
public void mouseEntered(MouseEvent e) |
| 666 |
|
{ |
| 667 |
|
|
| 668 |
|
} |
| 669 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 670 |
0 |
@Override... |
| 671 |
|
public void mouseExited(MouseEvent e) |
| 672 |
|
{ |
| 673 |
|
|
| 674 |
|
} |
| 675 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 676 |
0 |
@Override... |
| 677 |
|
public void mousePressed(MouseEvent e) |
| 678 |
|
{ |
| 679 |
0 |
if (e.isPopupTrigger()) |
| 680 |
|
{ |
| 681 |
0 |
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY()); |
| 682 |
|
} |
| 683 |
|
} |
| 684 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 685 |
0 |
@Override... |
| 686 |
|
public void mouseReleased(MouseEvent e) |
| 687 |
|
{ |
| 688 |
|
|
| 689 |
|
} |
| 690 |
|
|
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
| 691 |
0 |
@Override... |
| 692 |
|
public void stateChanged(ChangeEvent e) |
| 693 |
|
{ |
| 694 |
0 |
if (adjusting) |
| 695 |
|
{ |
| 696 |
0 |
return; |
| 697 |
|
} |
| 698 |
0 |
try |
| 699 |
|
{ |
| 700 |
0 |
adjusting = true; |
| 701 |
0 |
if (!isLogarithmicParameter) |
| 702 |
|
{ |
| 703 |
|
|
| 704 |
|
|
| 705 |
|
|
| 706 |
0 |
valueField.setText(isIntegerParameter |
| 707 |
|
? String.valueOf(slider.getValue()) |
| 708 |
|
: formatDouble( |
| 709 |
|
slider.getValue() / (float) sliderScaleFactor)); |
| 710 |
|
} |
| 711 |
|
else |
| 712 |
|
{ |
| 713 |
0 |
double value = Math.pow(Math.E, |
| 714 |
|
slider.getValue() / (double) sliderScaleFactor); |
| 715 |
0 |
valueField.setText(formatDouble(value)); |
| 716 |
|
} |
| 717 |
0 |
checkIfModified(); |
| 718 |
|
} finally |
| 719 |
|
{ |
| 720 |
0 |
adjusting = false; |
| 721 |
|
} |
| 722 |
|
} |
| 723 |
|
|
| 724 |
|
|
| 725 |
|
|
| 726 |
|
|
| 727 |
|
|
| 728 |
|
@param |
| 729 |
|
@return |
| 730 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 731 |
0 |
String formatDouble(double value)... |
| 732 |
|
{ |
| 733 |
0 |
String format = value < 0.001 ? "%3.1E" : "%3.3f"; |
| 734 |
0 |
return String.format(format, value); |
| 735 |
|
} |
| 736 |
|
|
| 737 |
|
|
| 738 |
|
|
| 739 |
|
|
| 740 |
|
@param |
| 741 |
|
@return |
| 742 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 743 |
0 |
String formatNumber(Number n)... |
| 744 |
|
{ |
| 745 |
0 |
return n instanceof Integer ? String.valueOf(n.intValue()) |
| 746 |
|
: formatDouble(n.doubleValue()); |
| 747 |
|
} |
| 748 |
|
|
| |
|
| 0% |
Uncovered Elements: 46 (46) |
Complexity: 9 |
Complexity Density: 0.3 |
|
| 749 |
0 |
void updateControls(ParameterI parm)... |
| 750 |
|
{ |
| 751 |
0 |
adjusting = true; |
| 752 |
0 |
boolean init = (choicebox == null && valueField == null |
| 753 |
|
&& buttonGroup == null); |
| 754 |
0 |
if (init) |
| 755 |
|
{ |
| 756 |
0 |
if (parm instanceof RadioChoiceParameter) |
| 757 |
|
{ |
| 758 |
0 |
buttonGroup = addRadioButtons(parameter, controlsPanel); |
| 759 |
|
} |
| 760 |
0 |
else if (isChoiceParameter) |
| 761 |
|
{ |
| 762 |
0 |
choicebox = buildComboBox(parm); |
| 763 |
0 |
choicebox.addActionListener(this); |
| 764 |
0 |
controlsPanel.add(choicebox, BorderLayout.CENTER); |
| 765 |
|
} |
| 766 |
|
else |
| 767 |
|
{ |
| 768 |
0 |
slider = new JSlider(); |
| 769 |
0 |
slider.addChangeListener(this); |
| 770 |
0 |
int cols = parm instanceof StringParameter ? 20 : 0; |
| 771 |
0 |
valueField = new JTextField(cols); |
| 772 |
0 |
valueField.addActionListener(this); |
| 773 |
0 |
valueField.addKeyListener(new KeyAdapter() |
| 774 |
|
{ |
| 775 |
|
|
| 776 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 5 |
Complexity Density: 1.25 |
|
| 777 |
0 |
@Override... |
| 778 |
|
public void keyReleased(KeyEvent e) |
| 779 |
|
{ |
| 780 |
0 |
int keyCode = e.getKeyCode(); |
| 781 |
0 |
if (e.isActionKey() && keyCode != KeyEvent.VK_LEFT |
| 782 |
|
&& keyCode != KeyEvent.VK_RIGHT) |
| 783 |
|
{ |
| 784 |
0 |
if (valueField.getText().trim().length() > 0) |
| 785 |
|
{ |
| 786 |
0 |
actionPerformed(null); |
| 787 |
|
} |
| 788 |
|
} |
| 789 |
|
} |
| 790 |
|
|
| 791 |
|
}); |
| 792 |
0 |
valueField.addFocusListener(new FocusAdapter() { |
| 793 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 794 |
0 |
@Override... |
| 795 |
|
public void focusLost(FocusEvent e) |
| 796 |
|
{ |
| 797 |
0 |
actionPerformed(null); |
| 798 |
|
} |
| 799 |
|
|
| 800 |
|
}); |
| 801 |
0 |
valueField.setPreferredSize(new Dimension(65, 25)); |
| 802 |
0 |
if (parm instanceof FileParameter) |
| 803 |
|
{ |
| 804 |
0 |
valueField.setToolTipText(MessageManager |
| 805 |
|
.getString("label.double_click_to_browse")); |
| 806 |
0 |
valueField.addMouseListener(new MouseAdapter() |
| 807 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 3 |
Complexity Density: 0.25 |
|
| 808 |
0 |
@Override... |
| 809 |
|
public void mouseClicked(MouseEvent e) |
| 810 |
|
{ |
| 811 |
0 |
if (e.getClickCount() == 2) |
| 812 |
|
{ |
| 813 |
0 |
String dir = Cache.getProperty("LAST_DIRECTORY"); |
| 814 |
0 |
JalviewFileChooser chooser = new JalviewFileChooser(dir); |
| 815 |
0 |
chooser.setFileView(new JalviewFileView()); |
| 816 |
0 |
chooser.setDialogTitle( |
| 817 |
|
MessageManager.getString("action.select_ddbb")); |
| 818 |
|
|
| 819 |
0 |
int val = chooser.showOpenDialog(ParamBox.this); |
| 820 |
0 |
if (val == JalviewFileChooser.APPROVE_OPTION) |
| 821 |
|
{ |
| 822 |
0 |
File choice = chooser.getSelectedFile(); |
| 823 |
0 |
String path = choice.getPath(); |
| 824 |
0 |
valueField.setText(path); |
| 825 |
0 |
Cache.setProperty("LAST_DIRECTORY", choice.getParent()); |
| 826 |
0 |
FileLoader.updateRecentlyOpened(path, |
| 827 |
|
DataSourceType.FILE); |
| 828 |
|
} |
| 829 |
|
} |
| 830 |
|
} |
| 831 |
|
}); |
| 832 |
|
} |
| 833 |
|
|
| 834 |
0 |
controlsPanel.add(slider, BorderLayout.WEST); |
| 835 |
0 |
controlsPanel.add(valueField, BorderLayout.EAST); |
| 836 |
|
} |
| 837 |
|
} |
| 838 |
|
|
| 839 |
0 |
String value = parm.getValue(); |
| 840 |
0 |
if (value != null) |
| 841 |
|
{ |
| 842 |
0 |
if (isChoiceParameter) |
| 843 |
|
{ |
| 844 |
0 |
if (!(parm instanceof RadioChoiceParameter)) |
| 845 |
|
{ |
| 846 |
0 |
choicebox.setSelectedItem(value); |
| 847 |
|
} |
| 848 |
|
} |
| 849 |
|
else |
| 850 |
|
{ |
| 851 |
0 |
valueField.setText(value); |
| 852 |
|
} |
| 853 |
|
} |
| 854 |
0 |
lastVal = updateSliderFromValueField(); |
| 855 |
0 |
adjusting = false; |
| 856 |
|
} |
| 857 |
|
|
| 858 |
|
|
| 859 |
|
|
| 860 |
|
|
| 861 |
|
|
| 862 |
|
|
| 863 |
|
@param |
| 864 |
|
@param |
| 865 |
|
|
| 866 |
|
@return |
| 867 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
|
| 868 |
0 |
protected ButtonGroup addRadioButtons(OptionI option, Container comp)... |
| 869 |
|
{ |
| 870 |
0 |
ButtonGroup bg = new ButtonGroup(); |
| 871 |
0 |
JPanel radioPanel = new JPanel(); |
| 872 |
0 |
radioPanel.add(new JLabel(option.getDescription())); |
| 873 |
|
|
| 874 |
0 |
String value = option.getValue(); |
| 875 |
|
|
| 876 |
0 |
for (String opt : option.getPossibleValues()) |
| 877 |
|
{ |
| 878 |
0 |
JRadioButton btn = new JRadioButton(opt); |
| 879 |
0 |
btn.setActionCommand(opt); |
| 880 |
0 |
boolean selected = opt.equals(value); |
| 881 |
0 |
btn.setSelected(selected); |
| 882 |
0 |
btn.addActionListener(this); |
| 883 |
0 |
bg.add(btn); |
| 884 |
0 |
radioPanel.add(btn); |
| 885 |
|
} |
| 886 |
0 |
comp.add(radioPanel); |
| 887 |
|
|
| 888 |
0 |
return bg; |
| 889 |
|
} |
| 890 |
|
|
| 891 |
|
|
| 892 |
|
|
| 893 |
|
|
| 894 |
|
|
| 895 |
|
|
| 896 |
|
|
| 897 |
|
|
| 898 |
|
|
| 899 |
|
|
| 900 |
|
|
| 901 |
|
|
| 902 |
|
|
| 903 |
|
@return |
| 904 |
|
|
| |
|
| 0% |
Uncovered Elements: 74 (74) |
Complexity: 23 |
Complexity Density: 0.44 |
|
| 905 |
0 |
Object updateSliderFromValueField()... |
| 906 |
|
{ |
| 907 |
0 |
if (validator == null || isStringParameter) |
| 908 |
|
{ |
| 909 |
0 |
if (isChoiceParameter) |
| 910 |
|
{ |
| 911 |
0 |
if (parameter instanceof RadioChoiceParameter) |
| 912 |
|
{ |
| 913 |
0 |
return buttonGroup.getSelection().getActionCommand(); |
| 914 |
|
} |
| 915 |
|
else |
| 916 |
|
{ |
| 917 |
0 |
return getSelectedValue(this.parameter, |
| 918 |
|
choicebox.getSelectedIndex()); |
| 919 |
|
} |
| 920 |
|
} |
| 921 |
0 |
slider.setVisible(false); |
| 922 |
0 |
return valueField.getText().trim(); |
| 923 |
|
} |
| 924 |
|
|
| 925 |
0 |
if (validator.getMin() == null || validator.getMax() == null) |
| 926 |
|
{ |
| 927 |
0 |
slider.setVisible(false); |
| 928 |
|
} |
| 929 |
|
|
| 930 |
0 |
valueField.setText(valueField.getText().trim()); |
| 931 |
|
|
| 932 |
|
|
| 933 |
|
|
| 934 |
|
|
| 935 |
|
|
| 936 |
0 |
try |
| 937 |
|
{ |
| 938 |
0 |
valueField.setBackground(Color.WHITE); |
| 939 |
0 |
double d = Double.parseDouble(valueField.getText()); |
| 940 |
0 |
if (validator.getMin() != null |
| 941 |
|
&& validator.getMin().doubleValue() > d) |
| 942 |
|
{ |
| 943 |
0 |
valueField.setText(formatNumber(validator.getMin())); |
| 944 |
|
} |
| 945 |
0 |
if (validator.getMax() != null |
| 946 |
|
&& validator.getMax().doubleValue() < d) |
| 947 |
|
{ |
| 948 |
0 |
valueField.setText(formatNumber(validator.getMax())); |
| 949 |
|
} |
| 950 |
|
} catch (NumberFormatException e) |
| 951 |
|
{ |
| 952 |
0 |
valueField.setBackground(Color.yellow); |
| 953 |
0 |
return Float.NaN; |
| 954 |
|
} |
| 955 |
0 |
if (isIntegerParameter) |
| 956 |
|
{ |
| 957 |
0 |
int iVal = 0; |
| 958 |
0 |
try |
| 959 |
|
{ |
| 960 |
0 |
iVal = Integer.valueOf(valueField.getText()); |
| 961 |
|
} catch (Exception e) |
| 962 |
|
{ |
| 963 |
0 |
valueField.setBackground(Color.yellow); |
| 964 |
0 |
return Integer.valueOf(0); |
| 965 |
|
} |
| 966 |
|
|
| 967 |
0 |
if (validator.getMin() != null && validator.getMax() != null) |
| 968 |
|
{ |
| 969 |
0 |
slider.getModel().setRangeProperties(iVal, 1, |
| 970 |
|
validator.getMin().intValue(), |
| 971 |
|
validator.getMax().intValue() + 1, true); |
| 972 |
|
} |
| 973 |
|
else |
| 974 |
|
{ |
| 975 |
0 |
slider.setVisible(false); |
| 976 |
|
} |
| 977 |
0 |
return Integer.valueOf(iVal); |
| 978 |
|
} |
| 979 |
0 |
if (isLogarithmicParameter) |
| 980 |
|
{ |
| 981 |
0 |
double dVal = 0d; |
| 982 |
0 |
try |
| 983 |
|
{ |
| 984 |
0 |
double eValue = Double.valueOf(valueField.getText()); |
| 985 |
0 |
dVal = Math.log(eValue); |
| 986 |
|
} catch (Exception e) |
| 987 |
|
{ |
| 988 |
|
|
| 989 |
0 |
valueField.setBackground(Color.yellow); |
| 990 |
0 |
return Double.NaN; |
| 991 |
|
} |
| 992 |
0 |
if (validator.getMin() != null && validator.getMax() != null) |
| 993 |
|
{ |
| 994 |
0 |
double scaleMin = Math.log(validator.getMin().doubleValue()) |
| 995 |
|
* sliderScaleFactor; |
| 996 |
0 |
double scaleMax = Math.log(validator.getMax().doubleValue()) |
| 997 |
|
* sliderScaleFactor; |
| 998 |
0 |
slider.getModel().setRangeProperties( |
| 999 |
|
(int) (sliderScaleFactor * dVal), 1, |
| 1000 |
|
(int) scaleMin, 1 + (int) scaleMax, true); |
| 1001 |
|
} |
| 1002 |
|
else |
| 1003 |
|
{ |
| 1004 |
0 |
slider.setVisible(false); |
| 1005 |
|
} |
| 1006 |
0 |
return Double.valueOf(dVal); |
| 1007 |
|
} |
| 1008 |
0 |
float fVal = 0f; |
| 1009 |
0 |
try |
| 1010 |
|
{ |
| 1011 |
0 |
fVal = Float.valueOf(valueField.getText()); |
| 1012 |
|
} catch (Exception e) |
| 1013 |
|
{ |
| 1014 |
0 |
return Float.valueOf(0f); |
| 1015 |
|
} |
| 1016 |
0 |
if (validator.getMin() != null && validator.getMax() != null) |
| 1017 |
|
{ |
| 1018 |
0 |
float scaleMin = validator.getMin().floatValue() |
| 1019 |
|
* sliderScaleFactor; |
| 1020 |
0 |
float scaleMax = validator.getMax().floatValue() |
| 1021 |
|
* sliderScaleFactor; |
| 1022 |
0 |
slider.getModel().setRangeProperties( |
| 1023 |
|
(int) (fVal * sliderScaleFactor), 1, (int) scaleMin, |
| 1024 |
|
1 + (int) scaleMax, true); |
| 1025 |
|
} |
| 1026 |
|
else |
| 1027 |
|
{ |
| 1028 |
0 |
slider.setVisible(false); |
| 1029 |
|
} |
| 1030 |
0 |
return Float.valueOf(fVal); |
| 1031 |
|
} |
| 1032 |
|
} |
| 1033 |
|
|
| 1034 |
|
|
| 1035 |
|
|
| 1036 |
|
|
| 1037 |
|
|
| 1038 |
|
|
| 1039 |
|
|
| 1040 |
|
@param |
| 1041 |
|
|
| 1042 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1043 |
0 |
public OptsAndParamsPage(OptsParametersContainerI paramContainer,... |
| 1044 |
|
boolean compact) |
| 1045 |
|
{ |
| 1046 |
0 |
poparent = paramContainer; |
| 1047 |
0 |
this.compact = compact; |
| 1048 |
|
} |
| 1049 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 1050 |
0 |
public static void showUrlPopUp(JComponent invoker, final String finfo,... |
| 1051 |
|
int x, int y) |
| 1052 |
|
{ |
| 1053 |
|
|
| 1054 |
0 |
JPopupMenu mnu = new JPopupMenu(); |
| 1055 |
0 |
JMenuItem mitem = new JMenuItem( |
| 1056 |
|
MessageManager.formatMessage("label.view_params", new String[] |
| 1057 |
|
{ finfo })); |
| 1058 |
0 |
mitem.addActionListener(new ActionListener() |
| 1059 |
|
{ |
| 1060 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1061 |
0 |
@Override... |
| 1062 |
|
public void actionPerformed(ActionEvent e) |
| 1063 |
|
{ |
| 1064 |
0 |
Desktop.showUrl(finfo); |
| 1065 |
|
|
| 1066 |
|
} |
| 1067 |
|
}); |
| 1068 |
0 |
mnu.add(mitem); |
| 1069 |
0 |
mnu.show(invoker, x, y); |
| 1070 |
|
} |
| 1071 |
|
|
| 1072 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1073 |
0 |
public Map<String, OptionBox> getOptSet()... |
| 1074 |
|
{ |
| 1075 |
0 |
return optSet; |
| 1076 |
|
} |
| 1077 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1078 |
0 |
public void setOptSet(Map<String, OptionBox> optSet)... |
| 1079 |
|
{ |
| 1080 |
0 |
this.optSet = optSet; |
| 1081 |
|
} |
| 1082 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1083 |
0 |
public Map<String, ParamBox> getParamSet()... |
| 1084 |
|
{ |
| 1085 |
0 |
return paramSet; |
| 1086 |
|
} |
| 1087 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1088 |
0 |
public void setParamSet(Map<String, ParamBox> paramSet)... |
| 1089 |
|
{ |
| 1090 |
0 |
this.paramSet = paramSet; |
| 1091 |
|
} |
| 1092 |
|
|
| 1093 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 1094 |
0 |
OptionBox addOption(OptionI opt)... |
| 1095 |
|
{ |
| 1096 |
0 |
OptionBox cb = optSet.get(opt.getName()); |
| 1097 |
0 |
if (cb == null) |
| 1098 |
|
{ |
| 1099 |
0 |
cb = new OptionBox(opt); |
| 1100 |
0 |
optSet.put(opt.getName(), cb); |
| 1101 |
|
|
| 1102 |
|
} |
| 1103 |
0 |
return cb; |
| 1104 |
|
} |
| 1105 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 1106 |
0 |
ParamBox addParameter(ParameterI arg)... |
| 1107 |
|
{ |
| 1108 |
0 |
ParamBox pb = paramSet.get(arg.getName()); |
| 1109 |
0 |
if (pb == null) |
| 1110 |
|
{ |
| 1111 |
0 |
pb = new ParamBox(poparent, arg); |
| 1112 |
0 |
paramSet.put(arg.getName(), pb); |
| 1113 |
|
|
| 1114 |
|
} |
| 1115 |
0 |
pb.init(); |
| 1116 |
|
|
| 1117 |
0 |
pb.updateControls(arg); |
| 1118 |
0 |
return pb; |
| 1119 |
|
} |
| 1120 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.6 |
|
| 1121 |
0 |
void selectOption(OptionI option, String string)... |
| 1122 |
|
{ |
| 1123 |
0 |
OptionBox cb = optSet.get(option.getName()); |
| 1124 |
0 |
if (cb == null) |
| 1125 |
|
{ |
| 1126 |
0 |
cb = addOption(option); |
| 1127 |
|
} |
| 1128 |
0 |
cb.enabled.setSelected(string != null); |
| 1129 |
0 |
if (string != null) |
| 1130 |
|
{ |
| 1131 |
0 |
if (option.getPossibleValues().contains(string)) |
| 1132 |
|
{ |
| 1133 |
0 |
cb.val.setSelectedItem(string); |
| 1134 |
|
} |
| 1135 |
|
else |
| 1136 |
|
{ |
| 1137 |
0 |
throw new Error(MessageManager.formatMessage( |
| 1138 |
|
"error.invalid_value_for_option", new String[] |
| 1139 |
|
{ string, option.getName() })); |
| 1140 |
|
} |
| 1141 |
|
|
| 1142 |
|
} |
| 1143 |
0 |
if (option.isRequired() && !cb.enabled.isSelected()) |
| 1144 |
|
{ |
| 1145 |
|
|
| 1146 |
|
} |
| 1147 |
0 |
cb.setInitialValue(); |
| 1148 |
|
} |
| 1149 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 1150 |
0 |
void setParameter(ParameterI arg)... |
| 1151 |
|
{ |
| 1152 |
0 |
ParamBox pb = paramSet.get(arg.getName()); |
| 1153 |
0 |
if (pb == null) |
| 1154 |
|
{ |
| 1155 |
0 |
addParameter(arg); |
| 1156 |
|
} |
| 1157 |
|
else |
| 1158 |
|
{ |
| 1159 |
0 |
pb.updateControls(arg); |
| 1160 |
|
} |
| 1161 |
|
|
| 1162 |
|
} |
| 1163 |
|
|
| 1164 |
|
|
| 1165 |
|
|
| 1166 |
|
|
| 1167 |
|
|
| 1168 |
|
|
| 1169 |
|
@return |
| 1170 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 1171 |
0 |
public List<ArgumentI> getCurrentSettings()... |
| 1172 |
|
{ |
| 1173 |
0 |
List<ArgumentI> argSet = new ArrayList<>(); |
| 1174 |
0 |
for (OptionBox opts : getOptSet().values()) |
| 1175 |
|
{ |
| 1176 |
0 |
ArgumentI opt = opts.getSelectedOption(); |
| 1177 |
0 |
if (opt != null) |
| 1178 |
|
{ |
| 1179 |
0 |
argSet.add(opt); |
| 1180 |
|
} |
| 1181 |
|
} |
| 1182 |
0 |
for (ParamBox parambox : getParamSet().values()) |
| 1183 |
|
{ |
| 1184 |
0 |
ArgumentI parm = parambox.getParameter(); |
| 1185 |
0 |
if (parm != null) |
| 1186 |
|
{ |
| 1187 |
0 |
argSet.add(parm); |
| 1188 |
|
} |
| 1189 |
|
} |
| 1190 |
|
|
| 1191 |
0 |
return argSet; |
| 1192 |
|
} |
| 1193 |
|
|
| 1194 |
|
|
| 1195 |
|
|
| 1196 |
|
|
| 1197 |
|
|
| 1198 |
|
|
| 1199 |
|
@param |
| 1200 |
|
@return |
| 1201 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
| 1202 |
0 |
protected static JComboBox<Object> buildComboBox(OptionI opt)... |
| 1203 |
|
{ |
| 1204 |
0 |
JComboBox<Object> cb = null; |
| 1205 |
0 |
List<String> displayNames = opt.getDisplayNames(); |
| 1206 |
0 |
if (displayNames != null) |
| 1207 |
|
{ |
| 1208 |
0 |
List<Object> displayNamesObjects = new ArrayList<>(); |
| 1209 |
0 |
displayNamesObjects.addAll(displayNames); |
| 1210 |
0 |
cb = JvSwingUtils.buildComboWithTooltips(displayNamesObjects, |
| 1211 |
|
opt.getPossibleValues()); |
| 1212 |
|
} |
| 1213 |
|
else |
| 1214 |
|
{ |
| 1215 |
0 |
cb = new JComboBox<>(); |
| 1216 |
0 |
for (String v : opt.getPossibleValues()) |
| 1217 |
|
{ |
| 1218 |
0 |
cb.addItem(v); |
| 1219 |
|
} |
| 1220 |
|
} |
| 1221 |
0 |
return cb; |
| 1222 |
|
} |
| 1223 |
|
|
| 1224 |
|
|
| 1225 |
|
|
| 1226 |
|
|
| 1227 |
|
|
| 1228 |
|
|
| 1229 |
|
@return |
| 1230 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 5 |
Complexity Density: 0.71 |
|
| 1231 |
0 |
protected static String getSelectedValue(OptionI opt, int sel)... |
| 1232 |
|
{ |
| 1233 |
0 |
List<String> possibleValues = opt.getPossibleValues(); |
| 1234 |
0 |
String value = null; |
| 1235 |
0 |
if (possibleValues != null && possibleValues.size() == 1) |
| 1236 |
|
{ |
| 1237 |
|
|
| 1238 |
|
|
| 1239 |
0 |
value = possibleValues.get(0); |
| 1240 |
|
} |
| 1241 |
0 |
else if (sel >= 0 && sel < possibleValues.size()) |
| 1242 |
|
{ |
| 1243 |
0 |
value = possibleValues.get(sel); |
| 1244 |
|
} |
| 1245 |
0 |
return value; |
| 1246 |
|
} |
| 1247 |
|
} |