JAL-3111 JAL-3280 hide the version check preference option in ‘Connections’ tab
[jalview.git] / src / jalview / jbgui / GPreferences.java
index 7a4d99a..9f98ffa 100755 (executable)
@@ -53,6 +53,8 @@ import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.util.Arrays;
+import java.util.List;
 
 import javax.swing.AbstractCellEditor;
 import javax.swing.BorderFactory;
@@ -301,7 +303,7 @@ public class GPreferences extends JPanel
 
   protected JButton revertButton = new JButton();
 
-  protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
+  protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
 
   private int backupfilesPresetsComboLastSelected = 0;
 
@@ -627,6 +629,8 @@ public class GPreferences extends JPanel
                     GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
                     new Insets(0, 2, 5, 5), 70, 1));
 
+    versioncheck.setVisible(false);
+
     // Add padding so the panel doesn't look ridiculous
     JPanel spacePanel = new JPanel();
     connectTab.add(spacePanel,
@@ -1853,11 +1857,19 @@ public class GPreferences extends JPanel
     presetsComboLabel = new JLabel(title + ":");
     presetsPanel.add(presetsComboLabel, gbc);
 
+    List<Object> entries = Arrays
+            .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
+    List<String> tooltips = Arrays.asList(
+            BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
+    backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
+            tooltips);
+    /*
     for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++)
     {
       backupfilesPresetsCombo
               .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]);
     }
+    */
 
     backupfilesPresetsCombo.addActionListener(new ActionListener()
     {
@@ -1896,6 +1908,8 @@ public class GPreferences extends JPanel
     presetsPanel.add(backupfilesPresetsCombo, gbc);
 
     revertButton.setText(MessageManager.getString("label.cancel_changes"));
+    revertButton.setToolTipText(
+            MessageManager.getString("label.cancel_changes_description"));
     revertButton.addActionListener(new ActionListener()
     {
       @Override
@@ -1933,6 +1947,8 @@ public class GPreferences extends JPanel
         backupfilesCustomOptionsSetEnabled();
       }
     });
+    customiseCheckbox.setToolTipText(
+            MessageManager.getString("label.customise_description"));
 
     // customise checkbox
     gbc.gridx = 0;
@@ -1997,21 +2013,42 @@ public class GPreferences extends JPanel
     updateBackupFilesExampleLabel();
   }
 
-  protected int getComboIntStringKey(JComboBox<IntKeyStringValueEntry> c)
+  protected int getComboIntStringKey(
+          JComboBox<Object> backupfilesPresetsCombo2)
   {
-    IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem();
+    IntKeyStringValueEntry e;
+    try
+    {
+      e = (IntKeyStringValueEntry) backupfilesPresetsCombo2
+              .getSelectedItem();
+    } catch (Exception ex)
+    {
+      Cache.log.error(
+              "Problem casting Combo entry to IntKeyStringValueEntry.");
+      e = null;
+    }
     return e != null ? e.k : 0;
   }
 
-  protected void setComboIntStringKey(JComboBox<IntKeyStringValueEntry> c,
+  protected void setComboIntStringKey(
+          JComboBox<Object> backupfilesPresetsCombo2,
           int key)
   {
-    for (int i = 0; i < c.getItemCount(); i++)
+    for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
     {
-      IntKeyStringValueEntry e = c.getItemAt(i);
+      IntKeyStringValueEntry e;
+      try
+      {
+        e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i);
+      } catch (Exception ex)
+      {
+        Cache.log.error(
+                "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. ");
+        continue;
+      }
       if (e.k == key)
       {
-        c.setSelectedIndex(i);
+        backupfilesPresetsCombo2.setSelectedIndex(i);
         break;
       }
     }