X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fjbgui%2FGPreferences.java;h=1b4a8bdee1f0eececff7b10d1e65be9cf6d38a32;hb=refs%2Fheads%2Freleases%2FRelease_2_11_1_4_debianpatches;hp=5685e844bb8bd7220f1a7ec1e1c3996f8f458fa5;hpb=e0eedaf4fedaaa46439f40226637376c8eb268be;p=jalview.git diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 5685e84..1b4a8bd 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -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 backupfilesPresetsCombo = new JComboBox<>(); + protected JComboBox 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, @@ -1720,27 +1724,13 @@ public class GPreferences extends JPanel setComboIntStringKey(backupfilesPresetsCombo, Cache.getDefault(BackupFiles.NS + "_PRESET", BackupFilesPresetEntry.BACKUPFILESSCHEMEDEFAULT)); - // backupsTabUpdatePresets(); - System.out - .println("LOADLASTSAVEDBACKUPSOPTIONS SETTING BACKUPS OPTIONS"); backupsSetOptions(savedPreset); backupsOptionsSetEnabled(); updateBackupFilesExampleLabel(); } - private void setBackupfilesCustomPreset() - { - if (customiseCheckbox.isSelected() && getComboIntStringKey( - backupfilesPresetsCombo) == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM) - { - BackupFilesPresetEntry.backupfilesPresetEntriesValues - .put(BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, - getBackupfilesCurrentEntry()); - } - } - private boolean warnAboutSuffixReverseChange() { BackupFilesPresetEntry bfpe = BackupFilesPresetEntry @@ -1867,11 +1857,19 @@ public class GPreferences extends JPanel presetsComboLabel = new JLabel(title + ":"); presetsPanel.add(presetsComboLabel, gbc); + List entries = Arrays + .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries); + List 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() { @@ -1910,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 @@ -1947,6 +1947,8 @@ public class GPreferences extends JPanel backupfilesCustomOptionsSetEnabled(); } }); + customiseCheckbox.setToolTipText( + MessageManager.getString("label.customise_description")); // customise checkbox gbc.gridx = 0; @@ -1963,7 +1965,7 @@ public class GPreferences extends JPanel private JPanel initBackupsTabFilenameExamplesPanel() { String title = MessageManager - .getString("label.summary_of_backups_scheme"); + .getString("label.scheme_examples"); TitledBorder tb = new TitledBorder(title); exampleFilesPanel.setBorder(tb); exampleFilesPanel.setLayout(new GridBagLayout()); @@ -1989,8 +1991,8 @@ public class GPreferences extends JPanel { IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo .getSelectedItem(); - int key = entry.getKey(); - String value = entry.getValue(); + int key = entry.k; + String value = entry.v; if (BackupFilesPresetEntry.backupfilesPresetEntriesValues .containsKey(key)) @@ -2001,7 +2003,7 @@ public class GPreferences extends JPanel } else { - System.out.println( + Cache.log.error( "Preset '" + value + "' [key:" + key + "] not implemented"); } @@ -2011,21 +2013,42 @@ public class GPreferences extends JPanel updateBackupFilesExampleLabel(); } - protected int getComboIntStringKey(JComboBox c) + protected int getComboIntStringKey( + JComboBox backupfilesPresetsCombo2) { - IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem(); - return e != null ? e.getKey() : 0; + 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 c, + protected void setComboIntStringKey( + JComboBox backupfilesPresetsCombo2, int key) { - for (int i = 0; i < c.getItemCount(); i++) + for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++) { - IntKeyStringValueEntry e = c.getItemAt(i); - if (e.getKey() == key) + IntKeyStringValueEntry e; + try + { + e = (IntKeyStringValueEntry) backupfilesPresetsCombo2.getItemAt(i); + } catch (Exception ex) { - c.setSelectedIndex(i); + Cache.log.error( + "Problem casting Combo entry to IntKeyStringValueEntry. Skipping item. "); + continue; + } + if (e.k == key) + { + backupfilesPresetsCombo2.setSelectedIndex(i); break; } } @@ -2076,7 +2099,6 @@ public class GPreferences extends JPanel @Override public void keyTyped(KeyEvent e) { - int count = 300; char c = e.getKeyChar(); if (c == ':' || c == '/' || c == '\\') { @@ -2465,10 +2487,10 @@ public class GPreferences extends JPanel { try { - i = Integer.parseInt((String) s.getValue()); + i = ((Integer) s.getValue()).intValue(); } catch (Exception e) { - System.out.println( + Cache.log.error( "Exception casting the initial value of s.getValue()"); } } @@ -2484,6 +2506,10 @@ public class GPreferences extends JPanel { max = def; } + if (def < min) + { + def = min; + } SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1); s.setModel(sModel); @@ -2500,7 +2526,7 @@ public class GPreferences extends JPanel i = (Integer) s.getValue(); } catch (Exception e) { - System.out.println("Failed casting (Integer) JSpinner s.getValue()"); + Cache.log.error("Failed casting (Integer) JSpinner s.getValue()"); } return i; }