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;
protected JButton revertButton = new JButton();
- protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
+ protected JComboBox<Object> backupfilesPresetsCombo = new JComboBox<>();
private int backupfilesPresetsComboLastSelected = 0;
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
presetsComboLabel = new JLabel(title + ":");
presetsPanel.add(presetsComboLabel, gbc);
+ List<Object> entries = Arrays
+ .asList(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()
{
presetsPanel.add(backupfilesPresetsCombo, gbc);
revertButton.setText(MessageManager.getString("label.cancel_changes"));
+ revertButton.setToolTipText(
+ MessageManager.getString("label.cancel_changes_description"));
revertButton.addActionListener(new ActionListener()
{
@Override
backupfilesCustomOptionsSetEnabled();
}
});
+ customiseCheckbox.setToolTipText(
+ MessageManager.getString("label.customise_description"));
// customise checkbox
gbc.gridx = 0;
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());
{
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))
}
else
{
- System.out.println(
+ Cache.log.error(
"Preset '" + value + "' [key:" + key + "] not implemented");
}
updateBackupFilesExampleLabel();
}
- protected int getComboIntStringKey(JComboBox<IntKeyStringValueEntry> c)
+ protected int getComboIntStringKey(
+ JComboBox<Object> 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<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);
- if (e.getKey() == key)
+ 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;
}
}
@Override
public void keyTyped(KeyEvent e)
{
- int count = 300;
char c = e.getKeyChar();
if (c == ':' || c == '/' || c == '\\')
{
i = Integer.parseInt((String) s.getValue());
} catch (Exception e)
{
- System.out.println(
+ Cache.log.error(
"Exception casting the initial value of s.getValue()");
}
}
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;
}