| 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.Console; |
| 24 |
|
import jalview.gui.OptsAndParamsPage.OptionBox; |
| 25 |
|
import jalview.gui.OptsAndParamsPage.ParamBox; |
| 26 |
|
import jalview.util.MessageManager; |
| 27 |
|
import jalview.ws.api.UIinfo; |
| 28 |
|
import jalview.ws.params.ArgumentI; |
| 29 |
|
import jalview.ws.params.OptionI; |
| 30 |
|
import jalview.ws.params.ParamDatastoreI; |
| 31 |
|
import jalview.ws.params.ParameterI; |
| 32 |
|
import jalview.ws.params.WsParamSetI; |
| 33 |
|
import java.awt.BorderLayout; |
| 34 |
|
import java.awt.Component; |
| 35 |
|
import java.awt.Dimension; |
| 36 |
|
import java.awt.FlowLayout; |
| 37 |
|
import java.awt.Font; |
| 38 |
|
import java.awt.GridBagConstraints; |
| 39 |
|
import java.awt.GridBagLayout; |
| 40 |
|
import java.awt.GridLayout; |
| 41 |
|
import java.awt.Rectangle; |
| 42 |
|
import java.awt.event.ActionEvent; |
| 43 |
|
import java.awt.event.ActionListener; |
| 44 |
|
import java.awt.event.HierarchyBoundsListener; |
| 45 |
|
import java.awt.event.HierarchyEvent; |
| 46 |
|
import java.awt.event.ItemEvent; |
| 47 |
|
import java.awt.event.ItemListener; |
| 48 |
|
import java.util.Hashtable; |
| 49 |
|
import java.util.List; |
| 50 |
|
import java.util.Vector; |
| 51 |
|
import java.util.concurrent.CompletableFuture; |
| 52 |
|
import java.util.concurrent.CompletionStage; |
| 53 |
|
|
| 54 |
|
import javax.swing.JButton; |
| 55 |
|
import javax.swing.JComboBox; |
| 56 |
|
import javax.swing.JDialog; |
| 57 |
|
import javax.swing.JFrame; |
| 58 |
|
import javax.swing.JLabel; |
| 59 |
|
import javax.swing.JPanel; |
| 60 |
|
import javax.swing.JScrollPane; |
| 61 |
|
import javax.swing.JTextArea; |
| 62 |
|
import javax.swing.WindowConstants; |
| 63 |
|
import javax.swing.border.TitledBorder; |
| 64 |
|
import javax.swing.event.DocumentEvent; |
| 65 |
|
import javax.swing.event.DocumentListener; |
| 66 |
|
|
| 67 |
|
import net.miginfocom.swing.MigLayout; |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
@author |
| 82 |
|
|
| 83 |
|
|
| |
|
| 0% |
Uncovered Elements: 581 (581) |
Complexity: 123 |
Complexity Density: 0.3 |
|
| 84 |
|
public class WsJobParameters extends JPanel implements ItemListener, |
| 85 |
|
ActionListener, DocumentListener, OptsParametersContainerI |
| 86 |
|
{ |
| 87 |
|
private static final int PREFERRED_WIDTH = 540; |
| 88 |
|
|
| 89 |
|
private static final int DEFAULT_HEIGHT = 640; |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
private static final String SVC_DEF = "Defaults"; |
| 93 |
|
|
| 94 |
|
private int maxOptWidth = 200; |
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
private final CompletableFuture<Boolean> completionStage = new CompletableFuture<>(); |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
OptsAndParamsPage opanp; |
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
JPanel optionsPanel = new JPanel(); |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
JPanel paramsPanel = new JPanel(); |
| 117 |
|
|
| 118 |
|
JPanel setNamePanel = new JPanel(); |
| 119 |
|
|
| 120 |
|
JButton createpref = new JButton(); |
| 121 |
|
|
| 122 |
|
JButton deletepref = new JButton(); |
| 123 |
|
|
| 124 |
|
JButton revertpref = new JButton(); |
| 125 |
|
|
| 126 |
|
JButton updatepref = new JButton(); |
| 127 |
|
|
| 128 |
|
JComboBox<String> setName = new JComboBox<>(); |
| 129 |
|
|
| 130 |
|
JTextArea setDescr = new JTextArea(); |
| 131 |
|
|
| 132 |
|
JScrollPane paramPane = new JScrollPane(); |
| 133 |
|
|
| 134 |
|
JButton startjob = JvSwingUtils.makeButton( |
| 135 |
|
MessageManager.getString("action.start_job"), |
| 136 |
|
MessageManager.getString("label.start_job_current_settings"), |
| 137 |
|
this::startjob_actionPerformed); |
| 138 |
|
JButton canceljob = JvSwingUtils.makeButton( |
| 139 |
|
MessageManager.getString("action.cancel_job"), |
| 140 |
|
MessageManager.getString("label.cancel_job_close_dialog"), |
| 141 |
|
this::canceljob_actionPerformed); |
| 142 |
|
|
| 143 |
|
ParamDatastoreI paramStore; |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
boolean startJob = false; |
| 147 |
|
|
| 148 |
|
JFrame frame = null; |
| 149 |
|
|
| 150 |
|
UIinfo service; |
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
Hashtable<String, String> servicePresets = null; |
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
boolean settingDialog = false; |
| 161 |
|
|
| 162 |
|
private Hashtable<Object, Object> modifiedElements = new Hashtable<>(); |
| 163 |
|
|
| 164 |
|
String lastParmSet = null; |
| 165 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 166 |
0 |
public WsJobParameters(ParamDatastoreI store, WsParamSetI preset,... |
| 167 |
|
List<ArgumentI> args) |
| 168 |
|
{ |
| 169 |
0 |
super(); |
| 170 |
|
|
| 171 |
|
|
| 172 |
0 |
opanp = new OptsAndParamsPage(this, true); |
| 173 |
0 |
jbInit(); |
| 174 |
0 |
this.paramStore = store; |
| 175 |
0 |
this.service = null; |
| 176 |
0 |
initForService(preset, args); |
| 177 |
0 |
validate(); |
| 178 |
|
} |
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
|
|
| 183 |
|
|
| 184 |
|
@param |
| 185 |
|
@param |
| 186 |
|
@param |
| 187 |
|
@param |
| 188 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 189 |
0 |
public WsJobParameters(ParamDatastoreI paramStorei, UIinfo service,... |
| 190 |
|
WsParamSetI preset, List<ArgumentI> jobArgset) |
| 191 |
|
{ |
| 192 |
0 |
super(); |
| 193 |
|
|
| 194 |
0 |
opanp = new OptsAndParamsPage(this, false); |
| 195 |
0 |
jbInit(); |
| 196 |
0 |
this.paramStore = paramStorei; |
| 197 |
0 |
if (paramStore == null && service != null) |
| 198 |
|
{ |
| 199 |
0 |
paramStore = service.getParamStore(); |
| 200 |
|
} |
| 201 |
0 |
this.service = service; |
| 202 |
0 |
initForService(preset, jobArgset); |
| 203 |
0 |
validate(); |
| 204 |
|
} |
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
@return |
| 212 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
|
| 213 |
0 |
public CompletionStage<Boolean> showRunDialog()... |
| 214 |
|
{ |
| 215 |
|
|
| 216 |
|
|
| 217 |
0 |
frame = new JFrame(); |
| 218 |
0 |
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
| 219 |
0 |
if (service != null) |
| 220 |
|
{ |
| 221 |
0 |
frame.setTitle(MessageManager.formatMessage("label.edit_params_for", |
| 222 |
|
new String[] { service.getActionText() })); |
| 223 |
|
} |
| 224 |
0 |
Rectangle deskr = Desktop.getInstance().getBounds(); |
| 225 |
0 |
Dimension pref = this.getPreferredSize(); |
| 226 |
0 |
frame.setBounds( |
| 227 |
|
new Rectangle((int) (deskr.getCenterX() - pref.width / 2), |
| 228 |
|
(int) (deskr.getCenterY() - pref.height / 2), |
| 229 |
|
pref.width, pref.height)); |
| 230 |
0 |
frame.setContentPane(this); |
| 231 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
0 |
frame.validate(); |
| 235 |
0 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
| 236 |
|
{ |
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 237 |
0 |
@Override... |
| 238 |
|
public void run() |
| 239 |
|
{ |
| 240 |
|
|
| 241 |
|
|
| 242 |
|
} |
| 243 |
|
}); |
| 244 |
|
|
| 245 |
0 |
frame.setVisible(true); |
| 246 |
|
|
| 247 |
0 |
return completionStage; |
| 248 |
|
} |
| 249 |
|
|
| |
|
| 0% |
Uncovered Elements: 82 (82) |
Complexity: 2 |
Complexity Density: 0.03 |
|
| 250 |
0 |
private void jbInit()... |
| 251 |
|
{ |
| 252 |
0 |
this.addHierarchyBoundsListener(new HierarchyBoundsListener() |
| 253 |
|
{ |
| 254 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 255 |
0 |
@Override... |
| 256 |
|
public void ancestorResized(HierarchyEvent arg0) |
| 257 |
|
{ |
| 258 |
0 |
refreshParamLayout(); |
| 259 |
|
} |
| 260 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 261 |
0 |
@Override... |
| 262 |
|
public void ancestorMoved(HierarchyEvent arg0) |
| 263 |
|
{ |
| 264 |
|
|
| 265 |
|
|
| 266 |
|
} |
| 267 |
|
}); |
| 268 |
0 |
updatepref = JvSwingUtils.makeButton( |
| 269 |
|
MessageManager.getString("action.update"), |
| 270 |
|
MessageManager.getString("label.update_user_parameter_set"), |
| 271 |
|
this::update_actionPerformed); |
| 272 |
0 |
deletepref = JvSwingUtils.makeButton( |
| 273 |
|
MessageManager.getString("action.delete"), |
| 274 |
|
MessageManager.getString("label.delete_user_parameter_set"), |
| 275 |
|
this::delete_actionPerformed); |
| 276 |
0 |
createpref = JvSwingUtils.makeButton( |
| 277 |
|
MessageManager.getString("action.create"), |
| 278 |
|
MessageManager.getString("label.create_user_parameter_set"), |
| 279 |
|
this::create_actionPerformed); |
| 280 |
0 |
revertpref = JvSwingUtils.makeButton( |
| 281 |
|
MessageManager.getString("action.revert"), |
| 282 |
|
MessageManager |
| 283 |
|
.getString("label.revert_changes_user_parameter_set"), |
| 284 |
|
this::revert_actionPerformed); |
| 285 |
|
|
| 286 |
|
|
| 287 |
0 |
JPanel setDetails = new JPanel(); |
| 288 |
0 |
setDetails.setBorder( |
| 289 |
|
new TitledBorder(MessageManager.getString("label.details"))); |
| 290 |
0 |
setDetails.setLayout(new BorderLayout()); |
| 291 |
0 |
setDescr.setColumns(40); |
| 292 |
0 |
setDescr.setWrapStyleWord(true); |
| 293 |
0 |
setDescr.setLineWrap(true); |
| 294 |
0 |
setDescr.setBackground(getBackground()); |
| 295 |
0 |
setDescr.setEditable(true); |
| 296 |
0 |
setDescr.getDocument().addDocumentListener(this); |
| 297 |
0 |
setDescr.setToolTipText( |
| 298 |
|
MessageManager.getString("label.edit_notes_parameter_set")); |
| 299 |
0 |
JScrollPane setDescrView = new JScrollPane(); |
| 300 |
0 |
setDescrView.getViewport().setView(setDescr); |
| 301 |
0 |
setName.setEditable(true); |
| 302 |
0 |
setName.addItemListener(this); |
| 303 |
0 |
setName.getEditor().addActionListener(this); |
| 304 |
0 |
JPanel setNameInfo = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 305 |
0 |
GridBagLayout gbl = new GridBagLayout(); |
| 306 |
0 |
setNamePanel.setLayout(gbl); |
| 307 |
|
|
| 308 |
0 |
JLabel setNameLabel = new JLabel( |
| 309 |
|
MessageManager.getString("label.current_parameter_set_name")); |
| 310 |
0 |
setNameLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); |
| 311 |
|
|
| 312 |
0 |
setNameInfo.add(setNameLabel); |
| 313 |
0 |
setNameInfo.add(setName); |
| 314 |
|
|
| 315 |
|
|
| 316 |
0 |
updatepref.setVisible(false); |
| 317 |
0 |
deletepref.setVisible(false); |
| 318 |
0 |
revertpref.setVisible(false); |
| 319 |
0 |
createpref.setVisible(false); |
| 320 |
0 |
JPanel setsavebuts = new JPanel(); |
| 321 |
0 |
setsavebuts.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0)); |
| 322 |
0 |
JPanel spacer = new JPanel(); |
| 323 |
0 |
spacer.setPreferredSize(new Dimension(2, 30)); |
| 324 |
0 |
setsavebuts.add(spacer); |
| 325 |
0 |
setsavebuts.add(deletepref); |
| 326 |
0 |
setsavebuts.add(revertpref); |
| 327 |
0 |
setsavebuts.add(createpref); |
| 328 |
0 |
setsavebuts.add(updatepref); |
| 329 |
|
|
| 330 |
0 |
JPanel buttonArea = new JPanel(new GridLayout(1, 1)); |
| 331 |
0 |
buttonArea.add(setsavebuts); |
| 332 |
0 |
setNamePanel.add(setNameInfo); |
| 333 |
0 |
GridBagConstraints gbc = new GridBagConstraints(); |
| 334 |
0 |
gbc.gridheight = 2; |
| 335 |
0 |
gbl.setConstraints(setNameInfo, gbc); |
| 336 |
0 |
setNamePanel.add(buttonArea); |
| 337 |
0 |
gbc = new GridBagConstraints(); |
| 338 |
0 |
gbc.gridx = 0; |
| 339 |
0 |
gbc.gridy = 2; |
| 340 |
0 |
gbc.gridheight = 1; |
| 341 |
0 |
gbl.setConstraints(buttonArea, gbc); |
| 342 |
0 |
setDetails.add(setDescrView, BorderLayout.CENTER); |
| 343 |
|
|
| 344 |
|
|
| 345 |
|
|
| 346 |
0 |
optionsPanel.setBorder( |
| 347 |
|
new TitledBorder(MessageManager.getString("label.options"))); |
| 348 |
0 |
optionsPanel.setOpaque(true); |
| 349 |
0 |
paramsPanel.setBorder( |
| 350 |
|
new TitledBorder(MessageManager.getString("label.parameters"))); |
| 351 |
0 |
paramsPanel.setOpaque(true); |
| 352 |
|
|
| 353 |
|
|
| 354 |
|
|
| 355 |
0 |
JPanel optsAndparams = new JPanel(); |
| 356 |
0 |
optsAndparams.setLayout(new BorderLayout()); |
| 357 |
0 |
optsAndparams.add(optionsPanel, BorderLayout.NORTH); |
| 358 |
0 |
optsAndparams.add(paramsPanel, BorderLayout.CENTER); |
| 359 |
0 |
JPanel jp = new JPanel(new BorderLayout()); |
| 360 |
0 |
jp.add(optsAndparams, BorderLayout.CENTER); |
| 361 |
0 |
paramPane.getViewport().setView(jp); |
| 362 |
0 |
paramPane.setBorder(null); |
| 363 |
0 |
setLayout(new BorderLayout()); |
| 364 |
0 |
JPanel jobPanel = new JPanel(); |
| 365 |
0 |
jobPanel.setPreferredSize(null); |
| 366 |
0 |
jobPanel.setLayout(new BorderLayout()); |
| 367 |
0 |
jobPanel.add(setDetails, BorderLayout.NORTH); |
| 368 |
0 |
jobPanel.add(paramPane, BorderLayout.CENTER); |
| 369 |
|
|
| 370 |
|
|
| 371 |
0 |
add(setNamePanel, BorderLayout.NORTH); |
| 372 |
0 |
add(jobPanel, BorderLayout.CENTER); |
| 373 |
|
|
| 374 |
0 |
JPanel dialogpanel = new JPanel(); |
| 375 |
0 |
dialogpanel.add(startjob); |
| 376 |
0 |
dialogpanel.add(canceljob); |
| 377 |
|
|
| 378 |
|
|
| 379 |
0 |
final int windowHeight = Desktop.getInstance() == null ? DEFAULT_HEIGHT |
| 380 |
|
: Desktop.getInstance().getHeight(); |
| 381 |
0 |
setPreferredSize(new Dimension(540, windowHeight)); |
| 382 |
0 |
add(dialogpanel, BorderLayout.SOUTH); |
| 383 |
0 |
validate(); |
| 384 |
|
} |
| 385 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 386 |
0 |
protected void revert_actionPerformed(ActionEvent e)... |
| 387 |
|
{ |
| 388 |
0 |
reInitDialog(lastParmSet); |
| 389 |
0 |
updateWebServiceMenus(); |
| 390 |
|
} |
| 391 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 392 |
0 |
protected void update_actionPerformed(ActionEvent e)... |
| 393 |
|
{ |
| 394 |
0 |
if (isUserPreset) |
| 395 |
|
{ |
| 396 |
0 |
String curname = ((String) setName.getSelectedItem()).trim(); |
| 397 |
0 |
_updatePreset(lastParmSet, curname); |
| 398 |
0 |
lastParmSet = curname; |
| 399 |
0 |
isUserPreset = true; |
| 400 |
0 |
initArgSetModified(); |
| 401 |
0 |
syncSetNamesWithStore(); |
| 402 |
|
} |
| 403 |
|
} |
| 404 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 405 |
0 |
private void _deleteUserPreset(String lastParmSet2)... |
| 406 |
|
{ |
| 407 |
0 |
paramStore.deletePreset(lastParmSet2); |
| 408 |
|
} |
| 409 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 410 |
0 |
protected void delete_actionPerformed(ActionEvent e)... |
| 411 |
|
{ |
| 412 |
0 |
if (isUserPreset) |
| 413 |
|
{ |
| 414 |
|
|
| 415 |
0 |
_deleteUserPreset(lastParmSet); |
| 416 |
|
} |
| 417 |
0 |
reInitDialog(null); |
| 418 |
0 |
updateWebServiceMenus(); |
| 419 |
|
} |
| 420 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
| 421 |
0 |
protected void create_actionPerformed(ActionEvent e)... |
| 422 |
|
{ |
| 423 |
0 |
String curname = ((String) setName.getSelectedItem()).trim(); |
| 424 |
0 |
if (curname.length() > 0) |
| 425 |
|
{ |
| 426 |
0 |
_storeCurrentPreset(curname); |
| 427 |
0 |
lastParmSet = curname; |
| 428 |
0 |
isUserPreset = true; |
| 429 |
0 |
reInitDialog(curname); |
| 430 |
0 |
initArgSetModified(); |
| 431 |
0 |
updateWebServiceMenus(); |
| 432 |
|
} |
| 433 |
|
else |
| 434 |
|
{ |
| 435 |
|
|
| 436 |
0 |
jalview.bin.Console.errPrintln("Invalid name. Not saved."); |
| 437 |
|
} |
| 438 |
|
} |
| 439 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 440 |
0 |
protected void canceljob_actionPerformed(ActionEvent e)... |
| 441 |
|
{ |
| 442 |
0 |
startJob = false; |
| 443 |
0 |
if (frame != null) |
| 444 |
|
{ |
| 445 |
0 |
frame.setVisible(false); |
| 446 |
|
} |
| 447 |
0 |
completionStage.complete(false); |
| 448 |
|
} |
| 449 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 450 |
0 |
protected void startjob_actionPerformed(ActionEvent e)... |
| 451 |
|
{ |
| 452 |
0 |
startJob = true; |
| 453 |
0 |
if (frame != null) |
| 454 |
|
{ |
| 455 |
0 |
frame.setVisible(false); |
| 456 |
|
} |
| 457 |
0 |
completionStage.complete(true); |
| 458 |
|
} |
| 459 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 460 |
0 |
void initForService(WsParamSetI paramSet, List<ArgumentI> jobArgset)... |
| 461 |
|
{ |
| 462 |
0 |
settingDialog = true; |
| 463 |
|
|
| 464 |
0 |
init(paramSet, jobArgset); |
| 465 |
|
|
| 466 |
|
} |
| 467 |
|
|
| |
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 8 |
Complexity Density: 0.32 |
|
| 468 |
0 |
void init(WsParamSetI p, List<ArgumentI> jobArgset)... |
| 469 |
|
{ |
| 470 |
0 |
Hashtable<String, String> exnames = new Hashtable<>(); |
| 471 |
0 |
for (int i = 0, iSize = setName.getItemCount(); i < iSize; i++) |
| 472 |
|
{ |
| 473 |
0 |
exnames.put(setName.getItemAt(i), setName.getItemAt(i)); |
| 474 |
|
} |
| 475 |
0 |
servicePresets = new Hashtable<>(); |
| 476 |
|
|
| 477 |
0 |
if (!exnames.contains(SVC_DEF)) |
| 478 |
|
{ |
| 479 |
0 |
setName.addItem(SVC_DEF); |
| 480 |
0 |
exnames.put(SVC_DEF, SVC_DEF); |
| 481 |
0 |
servicePresets.put(SVC_DEF, SVC_DEF); |
| 482 |
|
} |
| 483 |
|
|
| 484 |
0 |
for (WsParamSetI pr : paramStore.getPresets()) |
| 485 |
|
{ |
| 486 |
0 |
if (!pr.isModifiable()) |
| 487 |
|
{ |
| 488 |
0 |
servicePresets.put(pr.getName(), "preset"); |
| 489 |
|
} |
| 490 |
|
else |
| 491 |
|
{ |
| 492 |
|
} |
| 493 |
0 |
if (!exnames.contains(pr.getName())) |
| 494 |
|
{ |
| 495 |
0 |
setName.addItem(pr.getName()); |
| 496 |
|
} |
| 497 |
|
} |
| 498 |
|
|
| 499 |
|
|
| 500 |
|
|
| 501 |
0 |
if (p != null) |
| 502 |
|
{ |
| 503 |
0 |
reInitDialog(p.getName()); |
| 504 |
0 |
initArgSetModified(); |
| 505 |
|
} |
| 506 |
|
else |
| 507 |
|
{ |
| 508 |
0 |
if (jobArgset != null && jobArgset.size() > 0) |
| 509 |
|
{ |
| 510 |
0 |
curSetName = "Supplied Settings"; |
| 511 |
0 |
isUserPreset = false; |
| 512 |
0 |
updateTable(p, jobArgset); |
| 513 |
0 |
setName.setSelectedItem(curSetName); |
| 514 |
0 |
updateButtonDisplay(); |
| 515 |
|
} |
| 516 |
|
else |
| 517 |
|
{ |
| 518 |
0 |
curSetName = null; |
| 519 |
0 |
reInitDialog(null); |
| 520 |
|
} |
| 521 |
|
} |
| 522 |
0 |
settingDialog = false; |
| 523 |
|
|
| 524 |
|
} |
| 525 |
|
|
| |
|
| 0% |
Uncovered Elements: 61 (61) |
Complexity: 13 |
Complexity Density: 0.32 |
|
| 526 |
0 |
private void updateTable(WsParamSetI p, List<ArgumentI> jobArgset)... |
| 527 |
|
{ |
| 528 |
0 |
boolean setDefaultParams = false; |
| 529 |
0 |
if (lastParmSet == null) |
| 530 |
|
{ |
| 531 |
0 |
isUserPreset = false; |
| 532 |
|
|
| 533 |
0 |
setName.setSelectedItem(lastSetName = SVC_DEF); |
| 534 |
|
} |
| 535 |
0 |
if (p == null && SVC_DEF.equals("" + setName.getSelectedItem())) |
| 536 |
|
{ |
| 537 |
|
|
| 538 |
0 |
setDefaultParams = true; |
| 539 |
|
} |
| 540 |
|
|
| 541 |
0 |
List<ArgumentI> args = paramStore.getServiceParameters(); |
| 542 |
|
|
| 543 |
|
|
| 544 |
|
{ |
| 545 |
0 |
int cw = 0; |
| 546 |
0 |
boolean optset = false; |
| 547 |
0 |
for (ArgumentI myarg : args) |
| 548 |
|
{ |
| 549 |
|
|
| 550 |
0 |
if (myarg instanceof ParameterI) |
| 551 |
|
{ |
| 552 |
0 |
ParameterI parm = (ParameterI) myarg; |
| 553 |
0 |
opanp.addParameter(parm).validate(); |
| 554 |
|
} |
| 555 |
|
else |
| 556 |
|
{ |
| 557 |
0 |
if (myarg instanceof OptionI) |
| 558 |
|
{ |
| 559 |
0 |
OptionI opt = (OptionI) myarg; |
| 560 |
0 |
OptionBox ob = opanp.addOption(opt); |
| 561 |
0 |
ob.resetToDefault(setDefaultParams); |
| 562 |
0 |
if (maxOptWidth < ob.getPreferredSize().width) |
| 563 |
|
{ |
| 564 |
0 |
maxOptWidth = ob.getPreferredSize().width; |
| 565 |
|
} |
| 566 |
0 |
ob.validate(); |
| 567 |
0 |
cw += ob.getPreferredSize().width + 5; |
| 568 |
|
} |
| 569 |
|
else |
| 570 |
|
{ |
| 571 |
0 |
jalview.bin.Console |
| 572 |
|
.errPrintln("Ignoring unknown service argument type " |
| 573 |
|
+ myarg.getClass().getName()); |
| 574 |
|
} |
| 575 |
|
} |
| 576 |
|
} |
| 577 |
0 |
args = null; |
| 578 |
|
} |
| 579 |
0 |
if (p != null) |
| 580 |
|
{ |
| 581 |
0 |
isUserPreset = false; |
| 582 |
|
|
| 583 |
0 |
setName.setSelectedItem(lastSetName = p.getName()); |
| 584 |
0 |
setDescr.setText(lastDescrText = p.getDescription()); |
| 585 |
|
|
| 586 |
0 |
try |
| 587 |
|
{ |
| 588 |
0 |
args = p.getArguments(); |
| 589 |
|
} catch (Exception e) |
| 590 |
|
{ |
| 591 |
0 |
e.printStackTrace(); |
| 592 |
|
} |
| 593 |
|
|
| 594 |
|
|
| 595 |
|
} |
| 596 |
|
|
| 597 |
0 |
if (jobArgset != null) |
| 598 |
|
{ |
| 599 |
0 |
argSetModified(jobArgset, true); |
| 600 |
0 |
args = jobArgset; |
| 601 |
|
} |
| 602 |
|
|
| 603 |
0 |
if (args != null) |
| 604 |
|
{ |
| 605 |
0 |
for (ArgumentI arg : args) |
| 606 |
|
{ |
| 607 |
0 |
if (arg instanceof ParameterI) |
| 608 |
|
{ |
| 609 |
0 |
opanp.setParameter((ParameterI) arg); |
| 610 |
|
} |
| 611 |
|
else |
| 612 |
|
{ |
| 613 |
0 |
if (arg instanceof OptionI) |
| 614 |
|
{ |
| 615 |
|
|
| 616 |
|
|
| 617 |
|
|
| 618 |
0 |
opanp.selectOption((OptionI) arg, arg.getValue()); |
| 619 |
|
} |
| 620 |
|
} |
| 621 |
|
|
| 622 |
|
} |
| 623 |
|
} |
| 624 |
|
|
| 625 |
0 |
refreshParamLayout(); |
| 626 |
0 |
revalidate(); |
| 627 |
|
} |
| 628 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 629 |
0 |
private boolean isModified()... |
| 630 |
|
{ |
| 631 |
0 |
return modifiedElements.size() > 0; |
| 632 |
|
} |
| 633 |
|
|
| 634 |
|
|
| 635 |
|
|
| 636 |
|
|
| 637 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 638 |
0 |
private void initArgSetModified()... |
| 639 |
|
{ |
| 640 |
0 |
curSetName = null; |
| 641 |
0 |
modifiedElements.clear(); |
| 642 |
0 |
updateButtonDisplay(); |
| 643 |
|
} |
| 644 |
|
|
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 645 |
0 |
private void updateButtonDisplay()... |
| 646 |
|
{ |
| 647 |
0 |
boolean _update = false, _create = false, _delete = false, |
| 648 |
|
_revert = false; |
| 649 |
0 |
if (modifiedElements.size() > 0) |
| 650 |
|
{ |
| 651 |
|
|
| 652 |
0 |
_revert = true; |
| 653 |
0 |
_update = isUserPreset; |
| 654 |
0 |
if (!isUserPreset || modifiedElements.containsKey(setName)) |
| 655 |
|
{ |
| 656 |
|
|
| 657 |
0 |
_create = true; |
| 658 |
|
} |
| 659 |
|
} |
| 660 |
|
else |
| 661 |
|
{ |
| 662 |
|
|
| 663 |
|
} |
| 664 |
|
|
| 665 |
0 |
_delete = isUserPreset; |
| 666 |
|
|
| 667 |
0 |
createpref.setVisible(_create); |
| 668 |
0 |
updatepref.setVisible(_update); |
| 669 |
0 |
deletepref.setVisible(_delete); |
| 670 |
0 |
revertpref.setVisible(_revert); |
| 671 |
0 |
validate(); |
| 672 |
|
} |
| 673 |
|
|
| |
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 8 |
Complexity Density: 0.73 |
|
| 674 |
0 |
@Override... |
| 675 |
|
public void argSetModified(Object modifiedElement, boolean b) |
| 676 |
|
{ |
| 677 |
0 |
if (settingDialog) |
| 678 |
|
{ |
| 679 |
0 |
return; |
| 680 |
|
} |
| 681 |
0 |
if (!b) |
| 682 |
|
{ |
| 683 |
0 |
modifiedElements.remove(modifiedElement); |
| 684 |
|
} |
| 685 |
|
else |
| 686 |
|
{ |
| 687 |
0 |
if (b && modifiedElement == setName |
| 688 |
|
&& modifiedElements.contains(modifiedElement)) |
| 689 |
|
{ |
| 690 |
|
|
| 691 |
0 |
b = false; |
| 692 |
|
} |
| 693 |
0 |
modifiedElements.put(modifiedElement, modifiedElement); |
| 694 |
|
} |
| 695 |
|
|
| 696 |
0 |
if (b && modifiedElements.size() > 0) |
| 697 |
|
{ |
| 698 |
0 |
makeSetNameValid(!isUserPreset); |
| 699 |
0 |
setNamePanel.revalidate(); |
| 700 |
|
} |
| 701 |
0 |
updateButtonDisplay(); |
| 702 |
|
} |
| 703 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 704 |
0 |
private boolean isServicePreset(String selectedItem)... |
| 705 |
|
{ |
| 706 |
0 |
return selectedItem.equals(SVC_DEF) |
| 707 |
|
|| servicePresets.containsKey(selectedItem); |
| 708 |
|
} |
| 709 |
|
|
| 710 |
|
|
| 711 |
|
|
| 712 |
|
|
| 713 |
|
|
| |
|
| 0% |
Uncovered Elements: 45 (45) |
Complexity: 10 |
Complexity Density: 0.37 |
|
| 714 |
0 |
private void makeSetNameValid(boolean newuserset)... |
| 715 |
|
{ |
| 716 |
0 |
boolean stn = settingDialog; |
| 717 |
0 |
boolean renamed = false; |
| 718 |
0 |
settingDialog = true; |
| 719 |
0 |
String nm = (curSetName != null ? curSetName |
| 720 |
|
: (String) setName.getSelectedItem()); |
| 721 |
|
|
| 722 |
0 |
if (isServicePreset(nm)) |
| 723 |
|
{ |
| 724 |
0 |
nm = "User " + nm; |
| 725 |
0 |
renamed = true; |
| 726 |
|
} |
| 727 |
0 |
String tnm = nm; |
| 728 |
0 |
if (newuserset) |
| 729 |
|
{ |
| 730 |
0 |
int i = 0; |
| 731 |
0 |
while (paramStore.getPreset(tnm) != null) |
| 732 |
|
{ |
| 733 |
0 |
tnm = nm + " (" + (++i) + ")"; |
| 734 |
0 |
renamed = true; |
| 735 |
|
} |
| 736 |
0 |
if (i > 0) |
| 737 |
|
{ |
| 738 |
0 |
nm = tnm; |
| 739 |
|
} |
| 740 |
|
} |
| 741 |
|
|
| 742 |
0 |
boolean makeupdate = false; |
| 743 |
|
|
| 744 |
0 |
for (int i = 0, iS = setName.getItemCount(); i < iS; i++) |
| 745 |
|
{ |
| 746 |
0 |
String snm = setName.getItemAt(i); |
| 747 |
0 |
if (snm.equals(nm)) |
| 748 |
|
{ |
| 749 |
0 |
makeupdate = true; |
| 750 |
|
|
| 751 |
|
} |
| 752 |
|
} |
| 753 |
0 |
if (!makeupdate) |
| 754 |
|
{ |
| 755 |
0 |
setName.addItem(curSetName = nm); |
| 756 |
0 |
setName.setSelectedItem(curSetName); |
| 757 |
|
} |
| 758 |
0 |
if (renamed) |
| 759 |
|
{ |
| 760 |
0 |
settingDialog = false; |
| 761 |
0 |
argSetModified(setName, renamed); |
| 762 |
|
} |
| 763 |
0 |
settingDialog = stn; |
| 764 |
|
} |
| 765 |
|
|
| 766 |
|
|
| 767 |
|
|
| 768 |
|
|
| |
|
| 0% |
Uncovered Elements: 51 (51) |
Complexity: 5 |
Complexity Density: 0.12 |
|
| 769 |
0 |
@Override... |
| 770 |
|
public void refreshParamLayout() |
| 771 |
|
{ |
| 772 |
0 |
final int rightMargin = 40; |
| 773 |
0 |
final int availableWidth = paramPane.getViewport().getSize().width |
| 774 |
|
- rightMargin |
| 775 |
|
- optionsPanel.getBorder().getBorderInsets(optionsPanel).left |
| 776 |
|
+ optionsPanel.getBorder().getBorderInsets(optionsPanel).right; |
| 777 |
|
|
| 778 |
0 |
if (opanp.getOptSet().size() > 0) |
| 779 |
|
{ |
| 780 |
0 |
int hgap = 5; |
| 781 |
0 |
int currentWidth = hgap; |
| 782 |
|
|
| 783 |
|
|
| 784 |
|
|
| 785 |
|
|
| 786 |
|
|
| 787 |
0 |
optionsPanel.setLayout(new MigLayout("nogrid", "", "")); |
| 788 |
0 |
optionsPanel.removeAll(); |
| 789 |
0 |
JPanel lastAdded = null; |
| 790 |
|
|
| 791 |
|
|
| 792 |
|
|
| 793 |
|
|
| 794 |
|
|
| 795 |
|
|
| 796 |
0 |
for (OptionBox pbox : opanp.getOptSet().values()) |
| 797 |
|
{ |
| 798 |
0 |
pbox.validate(); |
| 799 |
0 |
int boxWidth = pbox.getSize().width; |
| 800 |
0 |
currentWidth += boxWidth + hgap; |
| 801 |
0 |
boolean wrapAfterLast = currentWidth > availableWidth |
| 802 |
|
&& lastAdded != null; |
| 803 |
|
|
| 804 |
|
|
| 805 |
|
|
| 806 |
|
|
| 807 |
0 |
if (wrapAfterLast) |
| 808 |
|
{ |
| 809 |
0 |
optionsPanel.remove(lastAdded); |
| 810 |
0 |
optionsPanel.add(lastAdded, "wrap"); |
| 811 |
0 |
currentWidth = hgap + boxWidth; |
| 812 |
|
} |
| 813 |
0 |
optionsPanel.add(pbox); |
| 814 |
0 |
lastAdded = pbox; |
| 815 |
|
} |
| 816 |
0 |
optionsPanel.revalidate(); |
| 817 |
|
} |
| 818 |
|
else |
| 819 |
|
{ |
| 820 |
0 |
optionsPanel.setVisible(false); |
| 821 |
|
} |
| 822 |
|
|
| 823 |
0 |
if (opanp.getParamSet().size() > 0) |
| 824 |
|
{ |
| 825 |
0 |
paramsPanel.removeAll(); |
| 826 |
0 |
paramsPanel.setLayout(new MigLayout("", "", "")); |
| 827 |
0 |
int hgap = 5; |
| 828 |
0 |
int currentWidth = hgap; |
| 829 |
|
|
| 830 |
0 |
JPanel lastAdded = null; |
| 831 |
0 |
for (ParamBox pbox : opanp.getParamSet().values()) |
| 832 |
|
{ |
| 833 |
0 |
pbox.validate(); |
| 834 |
0 |
int boxWidth = pbox.getSize().width; |
| 835 |
0 |
currentWidth += boxWidth + hgap; |
| 836 |
0 |
boolean wrapAfterLast = currentWidth > availableWidth |
| 837 |
|
&& lastAdded != null; |
| 838 |
0 |
if (wrapAfterLast) |
| 839 |
|
{ |
| 840 |
0 |
paramsPanel.remove(lastAdded); |
| 841 |
0 |
paramsPanel.add(lastAdded, "wrap"); |
| 842 |
0 |
currentWidth = pbox.getSize().width + hgap; |
| 843 |
|
} |
| 844 |
0 |
paramsPanel.add(pbox); |
| 845 |
0 |
lastAdded = pbox; |
| 846 |
|
} |
| 847 |
|
|
| 848 |
|
|
| 849 |
|
|
| 850 |
|
|
| 851 |
|
|
| 852 |
|
|
| 853 |
|
|
| 854 |
|
|
| 855 |
|
|
| 856 |
|
|
| 857 |
|
|
| 858 |
|
|
| 859 |
0 |
paramsPanel.revalidate(); |
| 860 |
|
} |
| 861 |
|
else |
| 862 |
|
{ |
| 863 |
0 |
paramsPanel.setVisible(false); |
| 864 |
|
} |
| 865 |
|
|
| 866 |
|
|
| 867 |
|
|
| 868 |
|
|
| 869 |
|
|
| 870 |
0 |
paramPane.getViewport().setAutoscrolls(true); |
| 871 |
0 |
paramPane.revalidate(); |
| 872 |
0 |
revalidate(); |
| 873 |
|
} |
| 874 |
|
|
| 875 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 876 |
0 |
public boolean isServiceDefaults()... |
| 877 |
|
{ |
| 878 |
0 |
return (!isModified() |
| 879 |
|
&& (lastParmSet != null && lastParmSet.equals(SVC_DEF))); |
| 880 |
|
} |
| 881 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 882 |
0 |
public List<ArgumentI> getJobParams()... |
| 883 |
|
{ |
| 884 |
0 |
return opanp.getCurrentSettings(); |
| 885 |
|
} |
| 886 |
|
|
| 887 |
|
|
| 888 |
|
|
| 889 |
|
|
| 890 |
|
|
| 891 |
|
|
| 892 |
|
|
| 893 |
|
|
| 894 |
|
@param |
| 895 |
|
|
| 896 |
|
@param |
| 897 |
|
|
| 898 |
|
@param |
| 899 |
|
|
| 900 |
|
|
| 901 |
|
|
| 902 |
|
|
| 903 |
|
|
| 904 |
|
|
| 905 |
|
|
| 906 |
|
|
| 907 |
|
|
| 908 |
|
|
| 909 |
|
|
| 910 |
|
|
| 911 |
|
|
| 912 |
|
|
| 913 |
|
|
| 914 |
|
|
| 915 |
|
|
| 916 |
|
@param |
| 917 |
|
|
| 918 |
|
|
| 919 |
|
|
| 920 |
|
|
| 921 |
|
|
| |
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 6 |
Complexity Density: 0.46 |
|
| 922 |
0 |
private void syncSetNamesWithStore()... |
| 923 |
|
{ |
| 924 |
0 |
int n = 0; |
| 925 |
|
|
| 926 |
|
|
| 927 |
0 |
Vector<String> items = new Vector<>(); |
| 928 |
0 |
while (n < setName.getItemCount()) |
| 929 |
|
{ |
| 930 |
0 |
String item = setName.getItemAt(n); |
| 931 |
0 |
if (!item.equals(SVC_DEF) && !paramStore.presetExists(item)) |
| 932 |
|
{ |
| 933 |
0 |
setName.removeItemAt(n); |
| 934 |
|
} |
| 935 |
|
else |
| 936 |
|
{ |
| 937 |
0 |
items.addElement(item); |
| 938 |
0 |
n++; |
| 939 |
|
} |
| 940 |
|
} |
| 941 |
0 |
if (!items.contains(SVC_DEF)) |
| 942 |
|
{ |
| 943 |
0 |
setName.addItem(SVC_DEF); |
| 944 |
|
} |
| 945 |
0 |
for (WsParamSetI upn : paramStore.getPresets()) |
| 946 |
|
{ |
| 947 |
0 |
if (!items.contains(upn.getName())) |
| 948 |
|
{ |
| 949 |
0 |
setName.addItem(upn.getName()); |
| 950 |
|
} |
| 951 |
|
} |
| 952 |
|
} |
| 953 |
|
|
| 954 |
|
|
| 955 |
|
|
| 956 |
|
|
| 957 |
|
boolean isUserPreset = false; |
| 958 |
|
|
| |
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 5 |
Complexity Density: 0.21 |
|
| 959 |
0 |
private void reInitDialog(String nextPreset)... |
| 960 |
|
{ |
| 961 |
0 |
settingDialog = true; |
| 962 |
|
|
| 963 |
0 |
WsParamSetI pset = null; |
| 964 |
0 |
if (nextPreset != null && nextPreset.length() > 0) |
| 965 |
|
{ |
| 966 |
0 |
pset = paramStore.getPreset(nextPreset); |
| 967 |
|
} |
| 968 |
0 |
if (pset != null) |
| 969 |
|
{ |
| 970 |
0 |
if (pset.isModifiable()) |
| 971 |
|
{ |
| 972 |
0 |
isUserPreset = true; |
| 973 |
0 |
setDescr.setText(pset.getDescription()); |
| 974 |
0 |
updateTable(null, pset.getArguments()); |
| 975 |
0 |
lastParmSet = nextPreset; |
| 976 |
|
} |
| 977 |
|
else |
| 978 |
|
{ |
| 979 |
0 |
isUserPreset = false; |
| 980 |
0 |
setDescr.setText(""); |
| 981 |
|
|
| 982 |
0 |
updateTable(pset, null); |
| 983 |
0 |
lastParmSet = nextPreset; |
| 984 |
|
} |
| 985 |
|
} |
| 986 |
|
else |
| 987 |
|
{ |
| 988 |
0 |
isUserPreset = false; |
| 989 |
|
|
| 990 |
0 |
setDescr.setText(""); |
| 991 |
0 |
updateTable(null, null); |
| 992 |
0 |
lastParmSet = SVC_DEF; |
| 993 |
|
} |
| 994 |
|
|
| 995 |
0 |
initArgSetModified(); |
| 996 |
0 |
syncSetNamesWithStore(); |
| 997 |
0 |
setName.setSelectedItem(lastParmSet); |
| 998 |
0 |
setNamePanel.validate(); |
| 999 |
0 |
validate(); |
| 1000 |
0 |
settingDialog = false; |
| 1001 |
|
} |
| 1002 |
|
|
| 1003 |
|
|
| 1004 |
|
|
| 1005 |
|
|
| 1006 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 1007 |
0 |
protected void updateWebServiceMenus()... |
| 1008 |
|
{ |
| 1009 |
0 |
if (Desktop.getInstance() == null) |
| 1010 |
|
{ |
| 1011 |
0 |
return; |
| 1012 |
|
} |
| 1013 |
0 |
for (AlignFrame alignFrame : Desktop.getDesktopAlignFrames()) |
| 1014 |
|
{ |
| 1015 |
0 |
alignFrame.buildWebServicesMenu(); |
| 1016 |
|
} |
| 1017 |
|
} |
| 1018 |
|
|
| 1019 |
|
String curSetName = null; |
| 1020 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 6 |
Complexity Density: 0.67 |
|
| 1021 |
0 |
@Override... |
| 1022 |
|
public void itemStateChanged(ItemEvent e) |
| 1023 |
|
{ |
| 1024 |
0 |
if (e.getSource() == setName |
| 1025 |
|
&& e.getStateChange() == ItemEvent.SELECTED) |
| 1026 |
|
{ |
| 1027 |
0 |
final String setname = (String) setName.getSelectedItem(); |
| 1028 |
0 |
if (Console.isDebugEnabled()) |
| 1029 |
|
{ |
| 1030 |
0 |
Console.debug("Item state changed for " + setname + " (handling ? " |
| 1031 |
|
+ !settingDialog + ")"); |
| 1032 |
|
} |
| 1033 |
0 |
if (settingDialog) |
| 1034 |
|
{ |
| 1035 |
|
|
| 1036 |
0 |
return; |
| 1037 |
|
} |
| 1038 |
0 |
if (setname == null) |
| 1039 |
|
{ |
| 1040 |
0 |
return; |
| 1041 |
|
} |
| 1042 |
0 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
| 1043 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1044 |
0 |
@Override... |
| 1045 |
|
public void run() |
| 1046 |
|
{ |
| 1047 |
0 |
doPreferenceComboStateChange(setname); |
| 1048 |
|
} |
| 1049 |
|
}); |
| 1050 |
|
} |
| 1051 |
|
} |
| 1052 |
|
|
| |
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 5 |
Complexity Density: 0.36 |
|
| 1053 |
0 |
private void doPreferenceComboStateChange(String setname)... |
| 1054 |
|
{ |
| 1055 |
|
|
| 1056 |
0 |
if (isModified()) |
| 1057 |
|
{ |
| 1058 |
0 |
String lsetname = (curSetName != null) ? curSetName : lastParmSet; |
| 1059 |
0 |
if (lsetname.equals(setname)) |
| 1060 |
|
{ |
| 1061 |
|
|
| 1062 |
0 |
return; |
| 1063 |
|
} |
| 1064 |
0 |
settingDialog = true; |
| 1065 |
0 |
jalview.bin.Console.outPrintln("Prompting to save " + lsetname); |
| 1066 |
0 |
if (JvOptionPane.showConfirmDialog(this, "Parameter set '" + lsetname |
| 1067 |
|
+ "' is modifed, and your changes will be lost.\nReally change preset ?", |
| 1068 |
|
"Warning: Unsaved Changes", |
| 1069 |
|
JvOptionPane.OK_CANCEL_OPTION) != JvOptionPane.OK_OPTION) |
| 1070 |
|
{ |
| 1071 |
|
|
| 1072 |
0 |
settingDialog = true; |
| 1073 |
0 |
setName.setSelectedItem(lsetname); |
| 1074 |
0 |
settingDialog = false; |
| 1075 |
|
|
| 1076 |
0 |
return; |
| 1077 |
|
|
| 1078 |
|
|
| 1079 |
|
|
| 1080 |
|
} |
| 1081 |
|
} |
| 1082 |
0 |
settingDialog = true; |
| 1083 |
0 |
reInitDialog(setname); |
| 1084 |
0 |
settingDialog = false; |
| 1085 |
|
|
| 1086 |
|
} |
| 1087 |
|
|
| 1088 |
|
|
| 1089 |
|
|
| 1090 |
|
|
| 1091 |
|
@param |
| 1092 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1093 |
0 |
private void _storeCurrentPreset(String curSetName2)... |
| 1094 |
|
{ |
| 1095 |
0 |
paramStore.storePreset(curSetName2, setDescr.getText(), getJobParams()); |
| 1096 |
|
} |
| 1097 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1098 |
0 |
private void _updatePreset(String lastParmSet2, String curname)... |
| 1099 |
|
{ |
| 1100 |
0 |
paramStore.updatePreset(lastParmSet2, curname, setDescr.getText(), |
| 1101 |
|
getJobParams()); |
| 1102 |
|
|
| 1103 |
|
} |
| 1104 |
|
|
| 1105 |
|
|
| 1106 |
|
|
| 1107 |
|
|
| 1108 |
|
String lastSetName = null; |
| 1109 |
|
|
| 1110 |
|
|
| 1111 |
|
|
| 1112 |
|
|
| 1113 |
|
String lastDescrText = null; |
| 1114 |
|
|
| |
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 7 |
Complexity Density: 0.35 |
|
| 1115 |
0 |
@Override... |
| 1116 |
|
public void actionPerformed(ActionEvent e) |
| 1117 |
|
{ |
| 1118 |
0 |
if (e.getSource() instanceof Component) |
| 1119 |
|
{ |
| 1120 |
0 |
Component src = (Component) e.getSource(); |
| 1121 |
0 |
if (src.getParent() == setName) |
| 1122 |
|
{ |
| 1123 |
|
|
| 1124 |
0 |
String newname = e.getActionCommand().trim(); |
| 1125 |
0 |
String msg = null; |
| 1126 |
0 |
if (isServicePreset(newname)) |
| 1127 |
|
{ |
| 1128 |
0 |
final String oldname = curSetName != null ? curSetName |
| 1129 |
|
: lastParmSet; |
| 1130 |
0 |
final Component ourframe = this; |
| 1131 |
0 |
settingDialog = true; |
| 1132 |
0 |
setName.getEditor().setItem(oldname); |
| 1133 |
0 |
settingDialog = false; |
| 1134 |
0 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
| 1135 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1136 |
0 |
@Override... |
| 1137 |
|
public void run() |
| 1138 |
|
{ |
| 1139 |
0 |
JvOptionPane.showMessageDialog(ourframe, |
| 1140 |
|
MessageManager.getString( |
| 1141 |
|
"label.invalid_name_preset_exists"), |
| 1142 |
|
MessageManager.getString("label.invalid_name"), |
| 1143 |
|
JvOptionPane.WARNING_MESSAGE); |
| 1144 |
|
} |
| 1145 |
|
}); |
| 1146 |
|
|
| 1147 |
0 |
return; |
| 1148 |
|
} |
| 1149 |
0 |
curSetName = newname; |
| 1150 |
0 |
jalview.bin.Console.errPrintln("New name for user setting " |
| 1151 |
|
+ curSetName + " (was " + setName.getSelectedItem() + ")"); |
| 1152 |
0 |
if (curSetName.equals(setName.getSelectedItem())) |
| 1153 |
|
{ |
| 1154 |
0 |
curSetName = null; |
| 1155 |
|
} |
| 1156 |
0 |
if (curSetName != null) |
| 1157 |
|
{ |
| 1158 |
0 |
argSetModified(setName, true); |
| 1159 |
0 |
return; |
| 1160 |
|
} |
| 1161 |
|
|
| 1162 |
|
} |
| 1163 |
|
} |
| 1164 |
|
} |
| 1165 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 1.5 |
|
| 1166 |
0 |
private void checkDescrModified()... |
| 1167 |
|
{ |
| 1168 |
0 |
if (!settingDialog) |
| 1169 |
|
{ |
| 1170 |
|
|
| 1171 |
0 |
argSetModified(setDescr, |
| 1172 |
0 |
(lastDescrText == null |
| 1173 |
|
? setDescr.getText().trim().length() > 0 |
| 1174 |
|
: !setDescr.getText().equals(lastDescrText))); |
| 1175 |
|
|
| 1176 |
|
} |
| 1177 |
|
} |
| 1178 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1179 |
0 |
@Override... |
| 1180 |
|
public void insertUpdate(DocumentEvent e) |
| 1181 |
|
{ |
| 1182 |
0 |
checkDescrModified(); |
| 1183 |
|
} |
| 1184 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1185 |
0 |
@Override... |
| 1186 |
|
public void removeUpdate(DocumentEvent e) |
| 1187 |
|
{ |
| 1188 |
0 |
checkDescrModified(); |
| 1189 |
|
} |
| 1190 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1191 |
0 |
@Override... |
| 1192 |
|
public void changedUpdate(DocumentEvent e) |
| 1193 |
|
{ |
| 1194 |
0 |
checkDescrModified(); |
| 1195 |
|
} |
| 1196 |
|
|
| 1197 |
|
|
| 1198 |
|
|
| 1199 |
|
@return |
| 1200 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 5 |
Complexity Density: 1.67 |
|
| 1201 |
0 |
public WsParamSetI getPreset()... |
| 1202 |
|
{ |
| 1203 |
0 |
if (isUserPreset || isModified() |
| 1204 |
|
|| (lastParmSet != null && lastParmSet.equals(SVC_DEF))) |
| 1205 |
|
{ |
| 1206 |
0 |
return null; |
| 1207 |
|
} |
| 1208 |
|
else |
| 1209 |
|
{ |
| 1210 |
0 |
return paramStore.getPreset(lastParmSet); |
| 1211 |
|
} |
| 1212 |
|
} |
| 1213 |
|
} |