+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ *
+ * 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.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
package jalview.gui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.util.Map;
import java.util.Vector;
+import javax.swing.InputVerifier;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JSplitPane;
+import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class WsJobParameters extends JPanel implements ItemListener,
ActionListener, DocumentListener
{
+ URL linkImageURL = getClass().getResource("/images/link.gif");
+
private static final String SVC_DEF = "Defaults"; // this is the null
// parameter set as shown to
// user
JSplitPane jobPanel = new JSplitPane();
+ boolean split = true;
+
+ JTabbedPane tabpanels = new JTabbedPane();
+
JPanel jobOptions = new JPanel();
JScrollPane jobOptionsPane = new JScrollPane();
* @param service
* @param preset
*/
- public WsJobParameters(JFrame parent, Jws2Instance service, WsParamSetI preset,
- List<Argument> jobArgset)
+ public WsJobParameters(JFrame parent, Jws2Instance service,
+ WsParamSetI preset, List<Argument> jobArgset)
{
this(parent, null, service, preset, jobArgset);
}
(int) (deskr.getCenterY() - 250), 480, 500));
frame.setContentPane(this);
// should recover defaults from user prefs.
+ // settingsPanel.setDividerLocation(0.4);
+ // jobPanel.setDividerLocation(0.5);
frame.validate();
- settingsPanel.setDividerLocation(0.4);
- jobPanel.setDividerLocation(0.3);
+ if (split)
+ {
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ settingsPanel.setDividerLocation(0.5);
+ jobPanel.setDividerLocation(setDescr.getLineCount() > 3 ? 0.35
+ : 0.16);
+ }
+ });
+ }
+ else
+ {
+ tabpanels.setSelectedComponent(jobOptionsPane);
+ }
frame.setVisible(true);
if (response > 0)
return false;
}
- protected JButton makeButton(String label, String tooltip,
- ActionListener action)
- {
- JButton button = new JButton();
- button.setText(label);
- button.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- button.setForeground(Color.black);
- button.setHorizontalAlignment(SwingConstants.CENTER);
- button.setToolTipText(tooltip);
- button.addActionListener(action);
- return button;
- }
-
private void jbInit()
{
- updatepref = makeButton("Update", "Update the stored user preference",
+ updatepref = JvSwingUtils.makeButton("Update",
+ "Update this existing user parameter set.",
new ActionListener()
{
update_actionPerformed(e);
}
});
- deletepref = makeButton("Delete", "Delete the user preference",
+ deletepref = JvSwingUtils.makeButton("Delete",
+ "Delete the currently selected user parameter set.",
new ActionListener()
{
delete_actionPerformed(e);
}
});
- createpref = makeButton("Create", "Create a new preference",
+ createpref = JvSwingUtils.makeButton("Create",
+ "Create a new parameter set with the current settings.",
new ActionListener()
{
create_actionPerformed(e);
}
});
- revertpref = makeButton("Revert",
- "Undo all changes to the current set", new ActionListener()
+ revertpref = JvSwingUtils.makeButton("Revert",
+ "Undo all changes to the current parameter set",
+ new ActionListener()
{
public void actionPerformed(ActionEvent e)
revert_actionPerformed(e);
}
});
- startjob.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- startjob.setText("Start");
- startjob.setToolTipText("Start Job");
- startjob.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- startjob_actionPerformed(e);
- }
- });
- canceljob.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
- canceljob.setText("Cancel");
- canceljob.setToolTipText("Cancel Job");
- canceljob.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- canceljob_actionPerformed(e);
- }
- });
+ startjob = JvSwingUtils.makeButton("Start Job",
+ "Start Job with current settings.", new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ startjob_actionPerformed(e);
+ }
+ });
+ canceljob = JvSwingUtils.makeButton("Cancel Job",
+ "Close this dialog and cancel job.", new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ canceljob_actionPerformed(e);
+ }
+ });
setDetails.setBorder(new TitledBorder("Details"));
setDetails.setLayout(new BorderLayout());
setDescr.setBackground(getBackground());
setDescr.setEditable(true);
setDescr.getDocument().addDocumentListener(this);
+ setDescr.setToolTipText("Click to edit the notes for this parameter set.");
JScrollPane setDescrView = new JScrollPane();
// setDescrView.setPreferredSize(new Dimension(350, 200));
setDescrView.getViewport().setView(setDescr);
setName.addItemListener(this);
setName.getEditor().addActionListener(this);
JPanel setNameInfo = new JPanel(new FlowLayout(FlowLayout.LEFT));
- SetNamePanel.setLayout(new GridLayout(2, 1));
- SetNamePanel.setMinimumSize(new Dimension(300, 40));
- JLabel setNameLabel = new JLabel("Parameter set: ");
+ GridBagLayout gbl = new GridBagLayout();
+ SetNamePanel.setLayout(gbl);
+ SetNamePanel.setMinimumSize(new Dimension(300, 60));
+ JLabel setNameLabel = new JLabel("Current parameter set name :");
setNameLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
// setNameLabel.setHorizontalAlignment(FlowLayout.LEFT);
setNameInfo.add(setNameLabel);
JPanel buttonArea = new JPanel(new GridLayout(1, 1));
buttonArea.add(setsavebuts);
SetNamePanel.add(setNameInfo);
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.gridheight = 2;
+ gbl.setConstraints(setNameInfo, gbc);
SetNamePanel.add(buttonArea);
+ gbc = new GridBagConstraints();
+ gbc.gridx=0;
+ gbc.gridy=2;
+ gbc.gridheight = 1;
+ gbl.setConstraints(buttonArea, gbc);
setDetails.add(setDescrView, BorderLayout.CENTER);
// setDetails.setPreferredSize(new Dimension(360, 100));
jobParameters.setBorder(new TitledBorder("Parameters"));
jobOptionsPanel.setBorder(new TitledBorder("Options"));
jobOptionsPane.getViewport().setView(jobOptions);
jobOptionsPanel.add(jobOptionsPane, BorderLayout.CENTER);
- settingsPanel.setLeftComponent(jobOptionsPanel);
- settingsPanel.setRightComponent(jobParameters);
- settingsPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
setLayout(new BorderLayout());
- // setPreferredSize(new Dimension(400, 600));
- // setSize(new Dimension(400, 600));
jobPanel.setLeftComponent(setDetails);
- jobPanel.setRightComponent(settingsPanel);
+ if (split)
+ {
+ settingsPanel.setLeftComponent(jobOptionsPanel);
+ settingsPanel.setRightComponent(jobParameters);
+ settingsPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
+ jobPanel.setRightComponent(settingsPanel);
+ }
+ else
+ {
+ jobPanel.setRightComponent(tabpanels);
+ jobOptionsPane.setName("Options");
+ tabpanels.add(jobOptionsPane);
+ paramPane.setName("Parameters");
+ tabpanels.add(paramPane);
+ }
jobPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
add(SetNamePanel, BorderLayout.NORTH);
add(jobPanel, BorderLayout.CENTER);
}
}
-
private void _deleteUserPreset(String lastParmSet2)
{
paramStore.deletePreset(lastParmSet2);
{ // instantiate the abstract proxy for Jaba objects
jobArgset = jabajobArgset == null ? null : JabaParamStore
.getJwsArgsfromJaba(jabajobArgset);
- p = jabap; // (jabap != null) ? paramStore.getPreset(jabap.getName()) : null;
+ p = jabap; // (jabap != null) ? paramStore.getPreset(jabap.getName()) :
+ // null;
}
// TODO: Recover window geometry prefs for this service
// jobPanel.setDividerLocation(proportionalLocation)
jobOptions.setPreferredSize(new Dimension(PARAM_WIDTH, optSet.size()
* OPTSET_HEIGHT));
- jobOptions.setLayout(new GridLayout(optSet.size(), 1));
+ FlowLayout fl;
+ jobOptions.setLayout(fl=new FlowLayout(FlowLayout.LEFT));
+
refreshParamLayout();
paramPane.validate();
revalidate();
boolean stn = settingDialog;
boolean renamed = false;
settingDialog = true;
- String nm = (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))
{
finfo = parm.getFurtherDetails();
if (finfo != null)
{
- showDesc.setToolTipText("<html><p>Click to show brief description, and right click to open link for further information.</p></html>");
+ showDesc.setToolTipText("<html>"
+ + JvSwingUtils
+ .wrapTooltip("Click to show brief description<br><img src=\""
+ + linkImageURL
+ + "\"/> Right click for further information.")
+ + "</html>");
showDesc.addMouseListener(this);
}
else
{
- showDesc.setToolTipText("<html><p>Click to show brief description.</p></html>");
+ showDesc.setToolTipText("<html>"
+ + JvSwingUtils
+ .wrapTooltip("Click to show brief description.")
+ + "</html>");
}
showDesc.addActionListener(new ActionListener()
{
{
valueField.setText(valueField.getText().trim());
iVal = Integer.valueOf(valueField.getText());
- if (validator.getMin()!=null && validator.getMin().intValue()>iVal)
+ if (validator.getMin() != null
+ && validator.getMin().intValue() > iVal)
{
iVal = validator.getMin().intValue();
- // TODO: provide visual indication that hard limit was reached for this parameter
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
}
- if (validator.getMax()!=null && validator.getMax().intValue()<iVal)
+ if (validator.getMax() != null
+ && validator.getMax().intValue() < iVal)
{
iVal = validator.getMax().intValue();
- // TODO: provide visual indication that hard limit was reached for this parameter
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
}
} catch (Exception e)
{
try
{
fVal = Float.valueOf(valueField.getText());
- if (validator.getMin()!=null && validator.getMin().floatValue()>fVal)
+ if (validator.getMin() != null
+ && validator.getMin().floatValue() > fVal)
{
fVal = validator.getMin().floatValue();
- // TODO: provide visual indication that hard limit was reached for this parameter
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
}
- if (validator.getMax()!=null && validator.getMax().floatValue()<fVal)
+ if (validator.getMax() != null
+ && validator.getMax().floatValue() < fVal)
{
fVal = validator.getMax().floatValue();
- // TODO: provide visual indication that hard limit was reached for this parameter
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
}
} catch (Exception e)
{
{
if (javax.swing.SwingUtilities.isRightMouseButton(e))
{
- Desktop.showUrl(finfo.toString());
+ showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
}
}
JLabel optlabel = new JLabel();
- URL linkImageURL = getClass().getResource("/images/link.gif");
-
final URL finfo;
boolean hasLink = false;
{
hasLink = true;
// optlabel.setToolTipText("<html><p>"+opt.getDescription()+"</p><img src=\""+linkImageURL+"\"/></html>");
- enabled.setToolTipText("<html><p>" + opt.getDescription()
- + "</p><img src=\"" + linkImageURL + "\"/></html>");
+ enabled.setToolTipText("<html>"
+ + JvSwingUtils.wrapTooltip(opt.getDescription()
+ + "<br><img src=\"" + linkImageURL + "\"/>")
+ + "</html>");
// optlabel.addMouseListener(this);
enabled.addMouseListener(this);
}
else
{
// optlabel.setToolTipText(opt.getDescription());
- enabled.setToolTipText(opt.getDescription());
+ enabled.setToolTipText("<html>"
+ + JvSwingUtils.wrapTooltip(opt.getDescription())
+ + "</html>");
}
add(enabled, BorderLayout.NORTH);
if (opt.getPossibleValues().size() > 1)
e.printStackTrace();
}
}
- WsJobParameters pgui = new WsJobParameters(lastserv, new JabaPreset(lastserv, pr));
+ WsJobParameters pgui = new WsJobParameters(lastserv,
+ new JabaPreset(lastserv, pr));
JFrame jf = new JFrame("Parameters for "
+ lastserv.getActionText());
JPanel cont = new JPanel();
{
isUserPreset = false;
// Service defaults
+ setDescr.setText("");
updateTable(null, null);
lastParmSet = SVC_DEF;
}
{
if (e.getSource() == setName && e.getStateChange() == e.SELECTED)
{
- String setname = (String) setName.getSelectedItem();
+ final String setname = (String) setName.getSelectedItem();
System.out.println("Item state changed for " + setname
+ " (handling ? " + !settingDialog + ")");
if (settingDialog)
{
return;
}
- // user has selected a different item from combo-box
- if (isModified())
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
{
- String lsetname = (curSetName != null) ? curSetName : lastParmSet;
- if (lsetname.equals(setname))
+ public void run()
{
- // setname was just edited - so ignore this event.
- return;
+ doPreferenceComboStateChange(setname);
}
- settingDialog = true;
- System.out.println("Prompting to save " + lsetname);
- if (javax.swing.JOptionPane.showConfirmDialog(this,
- "Parameter set '" + lsetname + "' is modifed\nsave ?",
- "Save changes ?", javax.swing.JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)
- {
- System.out.println("Saving for " + lsetname);
- _storeCurrentPreset(lsetname);
+ });
+ }
+ }
- }
+ private void doPreferenceComboStateChange(String setname)
+ {
+ // user has selected a different item from combo-box
+ if (isModified())
+ {
+ String lsetname = (curSetName != null) ? curSetName : lastParmSet;
+ if (lsetname.equals(setname))
+ {
+ // setname was just edited - so ignore this event.
+ return;
}
settingDialog = true;
- reInitDialog(setname);
- settingDialog = false;
+ System.out.println("Prompting to save " + lsetname);
+ if (javax.swing.JOptionPane
+ .showConfirmDialog(
+ this,
+ "Parameter set '"
+ + lsetname
+ + "' is modifed, and your changes will be lost.\nReally change preset ?",
+ "Warning: Unsaved Changes",
+ javax.swing.JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION)
+ {
+ // revert the combobox to the current item
+ settingDialog = true;
+ setName.setSelectedItem(lsetname);
+ settingDialog = false;
+ // and leave.
+ return;
+ // System.out.println("Saving for " + lsetname);
+ // _storeCurrentPreset(lsetname);
+ }
}
+ settingDialog = true;
+ reInitDialog(setname);
+ settingDialog = false;
+
}
+
private void _renameExistingPreset(String oldName, String curSetName2)
{
- paramStore.updatePreset(oldName, curSetName2, setDescr.getText(), getJobParams());
+ paramStore.updatePreset(oldName, curSetName2, setDescr.getText(),
+ getJobParams());
}
/**
{
paramStore.storePreset(curSetName2, setDescr.getText(), getJobParams());
}
+
private void _updatePreset(String lastParmSet2, String curname)
{
- paramStore.updatePreset(lastParmSet2, curname, setDescr.getText(), getJobParams());
-
+ paramStore.updatePreset(lastParmSet2, curname, setDescr.getText(),
+ getJobParams());
+
}
/**
String msg = null;
if (isServicePreset(newname))
{
- JOptionPane.showConfirmDialog(this,
- "Invalid name - preset already exists.", "Invalid name",
- JOptionPane.OK_OPTION);
- // reset name
- setName.setSelectedItem(curSetName);
+ final String oldname = curSetName != null ? curSetName
+ : lastParmSet;
+ final Component ourframe = this;
+ settingDialog = true;
+ setName.getEditor().setItem(oldname);
+ settingDialog = false;
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ JOptionPane.showMessageDialog(ourframe,
+ "Invalid name - preset already exists.",
+ "Invalid name", JOptionPane.WARNING_MESSAGE);
+ }
+ });
+
return;
}
curSetName = newname;
return paramStore.getPreset(lastParmSet);
}
}
-}
\ No newline at end of file
+}