From e29f805236e7328f34c0664e72f46925d7d28e07 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Sat, 25 May 2019 14:40:48 +0100 Subject: [PATCH] JAL-3141 Added tooltips on Schemes dropdown and Customise checkbox --- resources/lang/Messages.properties | 8 ++++- resources/lang/Messages_es.properties | 7 +++++ src/jalview/gui/JvSwingUtils.java | 44 ++++++++++++++++++++++++++++ src/jalview/io/BackupFilesPresetEntry.java | 7 +++++ src/jalview/jbgui/GPreferences.java | 12 ++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 6bcdf4b..9a52475 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1360,7 +1360,7 @@ label.reverse_roll = "Roll" appended text numbers - newest backup file is always label.keep_files = Deleting old backup files label.keep_all_backup_files = Do not delete old backup files label.keep_only_this_number_of_backup_files = Keep only this number of most recent backup files -label.autodelete_old_backup_files = Autodelete old backup files: +label.autodelete_old_backup_files = Auto-delete old backup files: label.always_ask = Always ask label.auto_delete = Automatically delete label.filename = filename @@ -1375,6 +1375,12 @@ label.default = Default label.single_file = Single backup label.keep_all_versions = Keep all versions label.rolled_backups = Rolled backup files +label.customise_description = Select Customise, make changes, and click on OK to save your own custom scheme +label.custom_description = Your own saved scheme +label.default_description = Keep the last three versions of the file +label.single_file_description = Keep the last version of the file +label.keep_all_versions_description = Keep all previous versions of the file +label.rolled_backups_description = Keep the last nine versions of the file from _bak.1 (newest) to _bak.9 (oldest) label.previously_saved_scheme = Previously saved scheme label.no_backup_files = NO BACKUP FILES label.include_backup_files = Include backup files diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index a14efe5..e669fda 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -1376,6 +1376,13 @@ label.default = Defecto label.single_file = Solo uno respaldo label.keep_all_versions = Mantener todas las versiones label.rolled_backups = Ciclos respaldos +# TODO: Translate these _description s +label.customise_description = Seleccione Personalizar, haga cambios y haga clic en OK para guardar su propio esquema personalizado +label.custom_description = Tu propio esquema guardado +label.default_description = Conserve las últimas tres versiones del archivo +label.single_file_description = Conserve la última versión del archivo +label.keep_all_versions_description = Mantener todas las versiones anteriores del archivo +label.rolled_backups_description = Mantenga las últimas nueve versiones del archivo desde _bak.1 (más reciente) a _bak.9 (más antigua) label.previously_saved_scheme = Esquema previamente guardado label.no_backup_files = NO ARCHIVOS DE RESPALDOS label.include_backup_files = Incluir archivos de respaldos diff --git a/src/jalview/gui/JvSwingUtils.java b/src/jalview/gui/JvSwingUtils.java index 4658668..8ec40cb 100644 --- a/src/jalview/gui/JvSwingUtils.java +++ b/src/jalview/gui/JvSwingUtils.java @@ -20,6 +20,7 @@ */ package jalview.gui; +import jalview.io.IntKeyStringValueEntry; import jalview.util.MessageManager; import java.awt.BorderLayout; @@ -355,6 +356,49 @@ public final class JvSwingUtils } /** + * A helper method to build a drop-down choice of values, with tooltips for the + * entries + * + * @param entries + * @param tooltips + */ + public static JComboBox buildIntKeyStringValueComboWithTooltips( + List entries, List tooltips) + { + JComboBox combo = new JComboBox<>(); + final ComboBoxTooltipRenderer renderer = new ComboBoxTooltipRenderer(); + combo.setRenderer(renderer); + for (IntKeyStringValueEntry attName : entries) + { + combo.addItem(attName); + } + renderer.setTooltips(tooltips); + final MouseAdapter mouseListener = new MouseAdapter() + { + @Override + public void mouseEntered(MouseEvent e) + { + int j = combo.getSelectedIndex(); + if (j > -1) + { + combo.setToolTipText(tooltips.get(j)); + } + } + + @Override + public void mouseExited(MouseEvent e) + { + combo.setToolTipText(null); + } + }; + for (Component c : combo.getComponents()) + { + c.addMouseListener(mouseListener); + } + return combo; + } + + /** * Adds a titled border to the component in the default font and position (top * left), optionally witht italic text * diff --git a/src/jalview/io/BackupFilesPresetEntry.java b/src/jalview/io/BackupFilesPresetEntry.java index a5bea91..e7d7a96 100644 --- a/src/jalview/io/BackupFilesPresetEntry.java +++ b/src/jalview/io/BackupFilesPresetEntry.java @@ -139,6 +139,13 @@ public class BackupFilesPresetEntry new IntKeyStringValueEntry(BACKUPFILESSCHEMECUSTOM, MessageManager.getString("label.custom")) }; + public static final String[] backupfilesPresetEntryDescriptions = { + MessageManager.getString("label.default_description"), + MessageManager.getString("label.single_file_description"), + MessageManager.getString("label.keep_all_versions_description"), + MessageManager.getString("label.rolled_backups_description"), + MessageManager.getString("label.custom_description") }; + public static final Map backupfilesPresetEntriesValues = new HashMap<>() { /** diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 7a4d99a..6a1a535 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; @@ -1853,11 +1855,19 @@ public class GPreferences extends JPanel presetsComboLabel = new JLabel(title + ":"); presetsPanel.add(presetsComboLabel, gbc); + List entries = Arrays + .asList(BackupFilesPresetEntry.backupfilesPresetEntries); + List tooltips = Arrays.asList( + BackupFilesPresetEntry.backupfilesPresetEntryDescriptions); + backupfilesPresetsCombo = JvSwingUtils + .buildIntKeyStringValueComboWithTooltips(entries, tooltips); + /* for (int i = 0; i < BackupFilesPresetEntry.backupfilesPresetEntries.length; i++) { backupfilesPresetsCombo .addItem(BackupFilesPresetEntry.backupfilesPresetEntries[i]); } + */ backupfilesPresetsCombo.addActionListener(new ActionListener() { @@ -1933,6 +1943,8 @@ public class GPreferences extends JPanel backupfilesCustomOptionsSetEnabled(); } }); + customiseCheckbox.setToolTipText( + MessageManager.getString("label.customise_description")); // customise checkbox gbc.gridx = 0; -- 1.7.10.2