JAL-629 Position GUI widgets for PDF file options. Remove icon from StructureChooser...
authorBen Soares <b.soares@dundee.ac.uk>
Fri, 24 Feb 2023 17:23:52 +0000 (17:23 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Fri, 24 Feb 2023 17:23:52 +0000 (17:23 +0000)
src/jalview/gui/StructureChooser.java
src/jalview/jbgui/GStructureChooser.java

index 04cc94e..aadae01 100644 (file)
@@ -943,6 +943,7 @@ public class StructureChooser extends GStructureChooser
     AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel
             .getCmb_assSeq().getSelectedItem();
     lbl_fromFileStatus.setIcon(errorImage);
+    setPdbOptionsEnabled(false);
     if (selectedSequences.length == 1 || (assSeqOpt != null && !assSeqOpt
             .getName().equalsIgnoreCase("-Select Associated Seq-")))
     {
@@ -951,12 +952,14 @@ public class StructureChooser extends GStructureChooser
       {
         btn_add.setEnabled(true);
         lbl_fromFileStatus.setIcon(goodImage);
+        setPdbOptionsEnabled(true);
       }
     }
     else
     {
       btn_pdbFromFile.setEnabled(false);
       lbl_fromFileStatus.setIcon(errorImage);
+      setPdbOptionsEnabled(false);
     }
   }
 
@@ -1586,7 +1589,7 @@ public class StructureChooser extends GStructureChooser
   public static void openStructureFileForSequence(AlignmentPanel ap,
           SequenceI seq, File sFile)
   {
-    //Open the chooser headlessly. Not sure this is actually needed ?
+    // Open the chooser headlessly. Not sure this is actually needed ?
     StructureChooser sc = new StructureChooser(new SequenceI[] { seq }, seq,
             ap, false);
     StructureSelectionManager ssm = ap.getStructureSelectionManager();
@@ -1607,6 +1610,6 @@ public class StructureChooser extends GStructureChooser
             new PDBEntry[]
             { fileEntry }, ap, new SequenceI[] { seq });
 
-    sc.mainFrame.dispose(); 
+    sc.mainFrame.dispose();
   }
 }
index 5af9cec..cfb4665 100644 (file)
@@ -27,6 +27,8 @@ import java.awt.Component;
 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.Insets;
 import java.awt.Point;
@@ -42,7 +44,6 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.swing.BoxLayout;
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
@@ -124,6 +125,8 @@ public abstract class GStructureChooser extends JPanel
 
   protected JButton btn_pdbFromFile = new JButton();
 
+  protected JLabel lbl_chooseTempFacType = new JLabel();
+
   protected JComboBox<StructureImportSettings.TFType> combo_tempFacAs = new JComboBox<>();
 
   protected JButton btn_paeMatrixFile = new JButton();
@@ -274,6 +277,7 @@ public abstract class GStructureChooser extends JPanel
     try
     {
       jbInit();
+      mainFrame.setFrameIcon(null);
       mainFrame.setVisible(false);
       mainFrame.invalidate();
       mainFrame.pack();
@@ -554,9 +558,10 @@ public abstract class GStructureChooser extends JPanel
       }
     });
 
-    JLabel lbl_chooseTempFacType = new JLabel(new StringBuilder()
+    lbl_chooseTempFacType.setText(new StringBuilder()
             .append(MessageManager.getString("label.choose_tempfac_type"))
-            .append(" ").append("label.optional").toString());
+            .append(" ").append(MessageManager.getString("label.optional"))
+            .toString());
 
     for (TFType t : TFType.values())
     {
@@ -667,17 +672,30 @@ public abstract class GStructureChooser extends JPanel
     pnl_fileChooser.add(btn_pdbFromFile);
     pnl_fileChooser.add(lbl_fromFileStatus);
 
-    JPanel pnl_pdbOptions = new JPanel();
-    pnl_pdbOptions
-            .setLayout(new BoxLayout(pnl_pdbOptions, BoxLayout.PAGE_AXIS));
-    pnl_pdbOptions.add(lbl_chooseTempFacType);
-    pnl_pdbOptions.add(combo_tempFacAs);
-    pnl_pdbOptions.add(btn_paeMatrixFile);
+    JPanel pnl_fileOptions = new JPanel();
+    pnl_fileOptions.setLayout(new GridBagLayout());
+    GridBagConstraints gbc = new GridBagConstraints();
+    gbc.gridx = 0;
+    gbc.gridy = 0;
+    gbc.weightx = 0.0;
+    gbc.weighty = 0.0;
+    gbc.insets = new Insets(0, 0, 18, 0);
+    gbc.fill = GridBagConstraints.NONE;
+    gbc.anchor = GridBagConstraints.FIRST_LINE_START;
+    pnl_fileOptions.add(pnl_fileChooser, gbc);
+    gbc.gridy++;
+    gbc.insets = new Insets(0, 0, 2, 0);
+    pnl_fileOptions.add(lbl_chooseTempFacType, gbc);
+    gbc.gridy++;
+    gbc.insets = new Insets(0, 0, 18, 0);
+    pnl_fileOptions.add(combo_tempFacAs, gbc);
+    gbc.gridy++;
+    gbc.weighty = 1.0;
+    pnl_fileOptions.add(btn_paeMatrixFile, gbc);
 
     JPanel pnl_fileChooserBL = new JPanel(new BorderLayout());
     pnl_fileChooserBL.add(fileChooserAssSeqPanel, BorderLayout.PAGE_START);
-    pnl_fileChooserBL.add(pnl_fileChooser, BorderLayout.CENTER);
-    // pnl_fileChooserBL.add(pnl_pdbOptions, BorderLayout.PAGE_END);
+    pnl_fileChooserBL.add(pnl_fileOptions, BorderLayout.CENTER);
 
     JPanel pnl_idInput = new JPanel(new FlowLayout());
     pnl_idInput.add(txt_search);
@@ -998,4 +1016,11 @@ public abstract class GStructureChooser extends JPanel
   {
     return mainFrame;
   }
+
+  public void setPdbOptionsEnabled(boolean b)
+  {
+    lbl_chooseTempFacType.setEnabled(b);
+    combo_tempFacAs.setEnabled(b);
+    btn_paeMatrixFile.setEnabled(b);
+  }
 }