Jalview 2.6 source licence
[jalview.git] / src / jalview / gui / WsJobParameters.java
index cf76f75..09499ff 100644 (file)
@@ -1,3 +1,20 @@
+/*
+ * 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;
@@ -49,6 +66,7 @@ import javax.swing.JPopupMenu;
 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;
@@ -106,6 +124,7 @@ import jalview.ws.params.WsParamSetI;
 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
@@ -122,7 +141,8 @@ public class WsJobParameters extends JPanel implements ItemListener,
   JSplitPane settingsPanel = new JSplitPane();
 
   JSplitPane jobPanel = new JSplitPane();
-
+  boolean split=true;
+  JTabbedPane tabpanels=new JTabbedPane();
   JPanel jobOptions = new JPanel();
 
   JScrollPane jobOptionsPane = new JScrollPane();
@@ -222,9 +242,19 @@ public class WsJobParameters extends JPanel implements ItemListener,
             (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)
@@ -234,22 +264,10 @@ public class WsJobParameters extends JPanel implements ItemListener,
     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()
             {
 
@@ -258,7 +276,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
                 update_actionPerformed(e);
               }
             });
-    deletepref = makeButton("Delete", "Delete the user preference",
+    deletepref = JvSwingUtils.makeButton("Delete", "Delete the currently selected user parameter set.",
             new ActionListener()
             {
 
@@ -267,7 +285,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
                 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()
             {
 
@@ -276,8 +294,8 @@ public class WsJobParameters extends JPanel implements ItemListener,
                 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)
@@ -285,20 +303,14 @@ public class WsJobParameters extends JPanel implements ItemListener,
                 revert_actionPerformed(e);
               }
             });
-    startjob.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
-    startjob.setText("Start");
-    startjob.setToolTipText("Start Job");
-    startjob.addActionListener(new ActionListener()
+    startjob = JvSwingUtils.makeButton("Start Job", "Start Job with current settings.",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()
+    canceljob = JvSwingUtils.makeButton("Cancel Job", "Close this dialog and cancel job.", new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
       {
@@ -314,6 +326,7 @@ 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.");
     JScrollPane setDescrView = new JScrollPane();
     // setDescrView.setPreferredSize(new Dimension(350, 200));
     setDescrView.getViewport().setView(setDescr);
@@ -323,7 +336,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
     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: ");
+    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);
@@ -347,7 +360,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
     SetNamePanel.add(setNameInfo);
     SetNamePanel.add(buttonArea);
     setDetails.add(setDescrView, BorderLayout.CENTER);
-    // setDetails.setPreferredSize(new Dimension(360, 100));
+    //setDetails.setPreferredSize(new Dimension(360, 100));
     jobParameters.setBorder(new TitledBorder("Parameters"));
     jobParameters.setLayout(new BorderLayout());
     paramPane.setPreferredSize(new Dimension(360, 300));
@@ -361,17 +374,23 @@ public class WsJobParameters extends JPanel implements ItemListener,
     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(SetNamePanel, BorderLayout.NORTH);    
     add(jobPanel, BorderLayout.CENTER);
     JPanel dialogpanel = new JPanel();
     dialogpanel.add(startjob);
@@ -867,12 +886,12 @@ public class WsJobParameters extends JPanel implements ItemListener,
       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()
       {
@@ -1159,7 +1178,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
     {
       if (javax.swing.SwingUtilities.isRightMouseButton(e))
       {
-        Desktop.showUrl(finfo.toString());
+        showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
       }
     }
 
@@ -1200,8 +1219,6 @@ public class WsJobParameters extends JPanel implements ItemListener,
 
     JLabel optlabel = new JLabel();
 
-    URL linkImageURL = getClass().getResource("/images/link.gif");
-
     final URL finfo;
 
     boolean hasLink = false;
@@ -1222,15 +1239,15 @@ public class WsJobParameters extends JPanel implements ItemListener,
       {
         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)
@@ -1758,6 +1775,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
     {
       isUserPreset = false;
       // Service defaults
+      setDescr.setText("");
       updateTable(null, null);
       lastParmSet = SVC_DEF;
     }
@@ -1956,4 +1974,4 @@ public class WsJobParameters extends JPanel implements ItemListener,
       return paramStore.getPreset(lastParmSet);
     }
   }
-}
\ No newline at end of file
+}