X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FWsJobParameters.java;h=196eb32d09e712eb1b789af5868ea98436dd4a6f;hb=155a17a423e980849fd4dc5f857da1a72b0010b9;hp=f3f1ba8c443a77f985772cbbb163f16d9bb857f8;hpb=2f4f1d8fb6878271b64f327bc58c895f458137af;p=jalview.git
diff --git a/src/jalview/gui/WsJobParameters.java b/src/jalview/gui/WsJobParameters.java
index f3f1ba8..196eb32 100644
--- a/src/jalview/gui/WsJobParameters.java
+++ b/src/jalview/gui/WsJobParameters.java
@@ -1,36 +1,25 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.gui;
-import jalview.gui.OptsAndParamsPage.OptionBox;
-import jalview.gui.OptsAndParamsPage.ParamBox;
-import jalview.util.MessageManager;
-import jalview.ws.jws2.JabaParamStore;
-import jalview.ws.jws2.JabaPreset;
-import jalview.ws.jws2.Jws2Discoverer;
-import jalview.ws.jws2.jabaws2.Jws2Instance;
-import jalview.ws.params.ArgumentI;
-import jalview.ws.params.OptionI;
-import jalview.ws.params.ParamDatastoreI;
-import jalview.ws.params.ParameterI;
-import jalview.ws.params.WsParamSetI;
-
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
@@ -59,7 +48,6 @@ import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
@@ -68,14 +56,26 @@ import javax.swing.border.TitledBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
-import net.miginfocom.swing.MigLayout;
-
import compbio.metadata.Argument;
import compbio.metadata.Option;
import compbio.metadata.Parameter;
import compbio.metadata.Preset;
import compbio.metadata.PresetManager;
import compbio.metadata.RunnerConfig;
+import jalview.bin.Console;
+import jalview.gui.OptsAndParamsPage.OptionBox;
+import jalview.gui.OptsAndParamsPage.ParamBox;
+import jalview.util.MessageManager;
+import jalview.ws.jws2.JabaParamStore;
+import jalview.ws.jws2.JabaPreset;
+import jalview.ws.jws2.Jws2Discoverer;
+import jalview.ws.jws2.jabaws2.Jws2Instance;
+import jalview.ws.params.ArgumentI;
+import jalview.ws.params.OptionI;
+import jalview.ws.params.ParamDatastoreI;
+import jalview.ws.params.ParameterI;
+import jalview.ws.params.WsParamSetI;
+import net.miginfocom.swing.MigLayout;
/**
* job parameter editing/browsing dialog box. User can browse existing settings
@@ -185,7 +185,8 @@ public class WsJobParameters extends JPanel implements ItemListener,
* @param jobArgset
*/
public WsJobParameters(JFrame parent, ParamDatastoreI paramStorei,
- Jws2Instance service, WsParamSetI preset, List jobArgset)
+ Jws2Instance service, WsParamSetI preset,
+ List jobArgset)
{
super();
jbInit();
@@ -216,13 +217,15 @@ public class WsJobParameters extends JPanel implements ItemListener,
frame = new JDialog(Desktop.instance, true);
- frame.setTitle("Edit parameters for " + service.getActionText());
+ frame.setTitle(MessageManager.formatMessage("label.edit_params_for",
+ new String[]
+ { service.getActionText() }));
Rectangle deskr = Desktop.instance.getBounds();
Dimension pref = this.getPreferredSize();
- frame.setBounds(new Rectangle(
- (int) (deskr.getCenterX() - pref.width / 2), (int) (deskr
- .getCenterY() - pref.height / 2), pref.width,
- pref.height));
+ frame.setBounds(
+ new Rectangle((int) (deskr.getCenterX() - pref.width / 2),
+ (int) (deskr.getCenterY() - pref.height / 2),
+ pref.width, pref.height));
frame.setContentPane(this);
// should perhaps recover defaults from user prefs.
@@ -230,6 +233,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
frame.validate();
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
// jobPanel.setDividerLocation(0.25);
@@ -263,64 +267,80 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
});
- updatepref = JvSwingUtils.makeButton("Update",
- "Update this existing user parameter set.",
+ updatepref = JvSwingUtils.makeButton(
+ MessageManager.getString("action.update"),
+ MessageManager.getString("label.update_user_parameter_set"),
new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
update_actionPerformed(e);
}
});
- deletepref = JvSwingUtils.makeButton("Delete",
- "Delete the currently selected user parameter set.",
+ deletepref = JvSwingUtils.makeButton(
+ MessageManager.getString("action.delete"),
+ MessageManager.getString("label.delete_user_parameter_set"),
new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
delete_actionPerformed(e);
}
});
- createpref = JvSwingUtils.makeButton("Create",
- "Create a new parameter set with the current settings.",
+ createpref = JvSwingUtils.makeButton(
+ MessageManager.getString("action.create"),
+ MessageManager.getString("label.create_user_parameter_set"),
new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
create_actionPerformed(e);
}
});
- revertpref = JvSwingUtils.makeButton("Revert",
- "Undo all changes to the current parameter set",
+ revertpref = JvSwingUtils.makeButton(
+ MessageManager.getString("action.revert"),
+ MessageManager
+ .getString("label.revert_changes_user_parameter_set"),
new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
revert_actionPerformed(e);
}
});
- startjob = JvSwingUtils.makeButton("Start Job",
- "Start Job with current settings.", new ActionListener()
+ startjob = JvSwingUtils.makeButton(
+ MessageManager.getString("action.start_job"),
+ MessageManager.getString("label.start_job_current_settings"),
+ new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
startjob_actionPerformed(e);
}
});
- canceljob = JvSwingUtils.makeButton("Cancel Job",
- "Close this dialog and cancel job.", new ActionListener()
+ canceljob = JvSwingUtils.makeButton(
+ MessageManager.getString("action.cancel_job"),
+ MessageManager.getString("label.cancel_job_close_dialog"),
+ new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
canceljob_actionPerformed(e);
}
});
- setDetails.setBorder(new TitledBorder("Details"));
+ setDetails.setBorder(
+ new TitledBorder(MessageManager.getString("label.details")));
setDetails.setLayout(new BorderLayout());
setDescr.setColumns(40);
setDescr.setWrapStyleWord(true);
@@ -328,9 +348,9 @@ public class WsJobParameters extends JPanel implements ItemListener,
setDescr.setBackground(getBackground());
setDescr.setEditable(true);
setDescr.getDocument().addDocumentListener(this);
- setDescr.setToolTipText("Click to edit the notes for this parameter set.");
+ setDescr.setToolTipText(
+ MessageManager.getString("label.edit_notes_parameter_set"));
JScrollPane setDescrView = new JScrollPane();
- // setDescrView.setPreferredSize(new Dimension(350, 200));
setDescrView.getViewport().setView(setDescr);
setName.setEditable(true);
setName.addItemListener(this);
@@ -339,7 +359,8 @@ public class WsJobParameters extends JPanel implements ItemListener,
GridBagLayout gbl = new GridBagLayout();
SetNamePanel.setLayout(gbl);
- JLabel setNameLabel = new JLabel(MessageManager.getString("label.current_parameter_set_name"));
+ JLabel setNameLabel = new JLabel(
+ MessageManager.getString("label.current_parameter_set_name"));
setNameLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
setNameInfo.add(setNameLabel);
@@ -378,12 +399,14 @@ public class WsJobParameters extends JPanel implements ItemListener,
// paramPane.setPreferredSize(new Dimension(360, 400));
// paramPane.setPreferredSize(null);
- jobOptions.setBorder(new TitledBorder("Options"));
+ jobOptions.setBorder(
+ new TitledBorder(MessageManager.getString("label.options")));
jobOptions.setOpaque(true);
- paramList.setBorder(new TitledBorder("Parameters"));
+ paramList.setBorder(
+ new TitledBorder(MessageManager.getString("label.parameters")));
paramList.setOpaque(true);
- JPanel bjo = new JPanel(new BorderLayout()), bjp = new JPanel(
- new BorderLayout());
+ JPanel bjo = new JPanel(new BorderLayout()),
+ bjp = new JPanel(new BorderLayout());
bjo.add(jobOptions, BorderLayout.CENTER);
bjp.add(paramList, BorderLayout.CENTER);
bjp.setOpaque(true);
@@ -411,6 +434,11 @@ public class WsJobParameters extends JPanel implements ItemListener,
JPanel dialogpanel = new JPanel();
dialogpanel.add(startjob);
dialogpanel.add(canceljob);
+ // JAL-1580: setMaximumSize() doesn't work, so just size for the worst case:
+ // check for null is for JUnit usage
+ final int windowHeight = Desktop.instance == null ? 540
+ : Desktop.instance.getHeight();
+ setPreferredSize(new Dimension(540, windowHeight));
add(dialogpanel, BorderLayout.SOUTH);
validate();
}
@@ -418,7 +446,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
protected void revert_actionPerformed(ActionEvent e)
{
reInitDialog(lastParmSet);
-
+ updateWebServiceMenus();
}
protected void update_actionPerformed(ActionEvent e)
@@ -447,6 +475,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
_deleteUserPreset(lastParmSet);
}
reInitDialog(null); // service default
+ updateWebServiceMenus();
}
protected void create_actionPerformed(ActionEvent e)
@@ -457,12 +486,14 @@ public class WsJobParameters extends JPanel implements ItemListener,
_storeCurrentPreset(curname);
lastParmSet = curname;
isUserPreset = true;
+ reInitDialog(curname);
initArgSetModified();
+ updateWebServiceMenus();
}
else
{
// TODO: show warning
- System.err.println("Invalid name. Not saved.");
+ jalview.bin.Console.errPrintln("Invalid name. Not saved.");
}
}
@@ -503,8 +534,8 @@ public class WsJobParameters extends JPanel implements ItemListener,
List jobArgset = null;
settingDialog = true;
{ // instantiate the abstract proxy for Jaba objects
- jobArgset = jabajobArgset == null ? null : JabaParamStore
- .getJwsArgsfromJaba(jabajobArgset);
+ jobArgset = jabajobArgset == null ? null
+ : JabaParamStore.getJwsArgsfromJaba(jabajobArgset);
p = jabap; // (jabap != null) ? paramStore.getPreset(jabap.getName()) :
// null;
}
@@ -512,7 +543,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
Hashtable exnames = new Hashtable();
for (int i = 0, iSize = setName.getItemCount(); i < iSize; i++)
{
- exnames.put((String) setName.getItemAt(i), setName.getItemAt(i));
+ exnames.put(setName.getItemAt(i), setName.getItemAt(i));
}
servicePresets = new Hashtable();
// Add the default entry - if not present already.
@@ -568,17 +599,17 @@ public class WsJobParameters extends JPanel implements ItemListener,
@SuppressWarnings("unchecked")
private void updateTable(WsParamSetI p, List jobArgset)
{
- boolean setDefaultParams=false;
+ boolean setDefaultParams = false;
if (lastParmSet == null)
{
isUserPreset = false;
// First call - so provide Service default settings
setName.setSelectedItem(lastSetName = SVC_DEF);
}
- if (p==null && SVC_DEF.equals(""+setName.getSelectedItem()))
+ if (p == null && SVC_DEF.equals("" + setName.getSelectedItem()))
{
// indicate that service defaults should be set if available
- setDefaultParams=true;
+ setDefaultParams = true;
}
// populate table from default parameter set.
List args = paramStore.getServiceParameters();
@@ -586,9 +617,9 @@ public class WsJobParameters extends JPanel implements ItemListener,
// split to params and required arguments
{
int cw = 0;
- boolean optset=false;
+ boolean optset = false;
for (ArgumentI myarg : args)
- {
+ {
// Ideally, Argument would implement isRequired !
if (myarg instanceof ParameterI)
{
@@ -611,7 +642,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
else
{
- System.err.println("Ignoring unknown service argument type "
+ jalview.bin.Console.errPrintln("Ignoring unknown service argument type "
+ myarg.getClass().getName());
}
}
@@ -654,7 +685,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
if (arg instanceof OptionI)
{
- // System.out.println("Setting option "
+ // jalview.bin.Console.outPrintln("Setting option "
// + System.identityHashCode(arg) + ":" + arg.getName()
// + " with " + arg.getDefaultValue());
opanp.selectOption((OptionI) arg, arg.getValue());
@@ -687,7 +718,8 @@ public class WsJobParameters extends JPanel implements ItemListener,
private void updateButtonDisplay()
{
- boolean _update = false, _create = false, _delete = false, _revert = false;
+ boolean _update = false, _create = false, _delete = false,
+ _revert = false;
if (modifiedElements.size() > 0)
{
// set modified
@@ -713,6 +745,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
validate();
}
+ @Override
public void argSetModified(Object modifiedElement, boolean b)
{
if (settingDialog)
@@ -757,8 +790,8 @@ public class WsJobParameters extends JPanel implements ItemListener,
boolean stn = settingDialog;
boolean renamed = false;
settingDialog = true;
- String nm = (curSetName != null ? curSetName : (String) setName
- .getSelectedItem());
+ String nm = (curSetName != null ? curSetName
+ : (String) setName.getSelectedItem());
// check if the name is reserved - if it is, rename it.
if (isServicePreset(nm))
{
@@ -804,16 +837,17 @@ public class WsJobParameters extends JPanel implements ItemListener,
settingDialog = stn;
}
+ @Override
public void refreshParamLayout()
{
// optsAndparams.setPreferredSize(null);
FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
int sep = fl.getVgap();
boolean fh = true;
- int os = 0, s = jobOptions.getBorder().getBorderInsets(jobOptions).bottom
- + jobOptions.getBorder().getBorderInsets(jobOptions).top
- + 2
- * sep;
+ int os = 0,
+ s = jobOptions.getBorder().getBorderInsets(jobOptions).bottom
+ + jobOptions.getBorder().getBorderInsets(jobOptions).top
+ + 2 * sep;
/**
* final height for viewport
*/
@@ -822,8 +856,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
- jobOptions.getBorder().getBorderInsets(jobOptions).left
+ jobOptions.getBorder().getBorderInsets(jobOptions).right;
- int w = 2
- * fl.getHgap()
+ int w = 2 * fl.getHgap()
+ (MAX_OPTWIDTH > OptsAndParamsPage.PARAM_WIDTH ? MAX_OPTWIDTH
: OptsAndParamsPage.PARAM_WIDTH);
int hgap = fl.getHgap(), cw = hgap;
@@ -841,7 +874,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
if (cw + 120 > panewidth)
{
jobOptions.add(pbox, "wrap");
- // System.out.println("Wrap on "+pbox.option.getName());
+ // jalview.bin.Console.outPrintln("Wrap on "+pbox.option.getName());
cw = hgap + pbox.getSize().width;
fh = true;
}
@@ -913,7 +946,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
// TODO: waste some time trying to eliminate any unnecessary .validate calls
// here
- // System.out.println("Size will be : "+w+","+os);
+ // jalview.bin.Console.outPrintln("Size will be : "+w+","+os);
// optsAndparams.setPreferredSize(null);
// paramPane.getViewport().setView(optsAndparams);
paramPane.getViewport().setAutoscrolls(true);
@@ -925,6 +958,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
* testing method - grab a service and parameter set and show the window
*
* @param args
+ * @j2sIgnore
*/
public static void main(String[] args)
{
@@ -933,16 +967,16 @@ public class WsJobParameters extends JPanel implements ItemListener,
int p = 0;
if (args.length > 0)
{
- Vector services = new Vector();
+ Vector services = new Vector<>();
services.addElement(args[p++]);
- Jws2Discoverer.setServiceUrls(services);
+ Jws2Discoverer.getDiscoverer().setServiceUrls(services);
}
try
{
disc.run();
} catch (Exception e)
{
- System.err.println("Aborting. Problem discovering services.");
+ jalview.bin.Console.errPrintln("Aborting. Problem discovering services.");
e.printStackTrace();
return;
}
@@ -989,9 +1023,9 @@ public class WsJobParameters extends JPanel implements ItemListener,
pr = en.next();
}
{
- System.out.println("Testing opts dupes for "
- + lastserv.getUri() + " : "
- + lastserv.getActionText() + ":" + pr.getName());
+ jalview.bin.Console.outPrintln("Testing opts dupes for "
+ + lastserv.getUri() + " : " + lastserv.getActionText()
+ + ":" + pr.getName());
List