protected JPanel presetsPanel = new JPanel();
+ protected JButton revertButton = new JButton();
+
protected JComboBox<IntKeyStringValueEntry> backupfilesPresetsCombo = new JComboBox<>();
protected JPanel suffixPanel = new JPanel();
backupsTab.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
- gbc.weightx = 1.0;
+ gbc.weightx = 0.0;
gbc.weighty = 0.0;
- gbc.anchor = GridBagConstraints.NORTHWEST;
+ gbc.anchor = GridBagConstraints.FIRST_LINE_START;
gbc.fill = GridBagConstraints.NONE;
initBackupsTabPresetsPanel();
initBackupsTabKeepFilesPanel();
initBackupsTabFilenameExamplesPanel();
- gbc.weightx = 0.5;
enableBackupFiles.setFont(LABEL_FONT_BOLD);
enableBackupFiles
.setText(MessageManager.getString("label.enable_backupfiles"));
}
});
- // enable checkbox 1 row
+
+ // enable checkbox 1 col
gbc.gridwidth = 1;
+ gbc.gridheight = 1;
gbc.gridx = 0;
- gbc.gridy = 0;
+ gbc.gridy = 0; // row 0
backupsTab.add(enableBackupFiles, gbc);
+ // summary of scheme box (over two rows)
gbc.gridx = 1;
- gbc.weightx = 1.0;
+ gbc.weightx = 0.0;
gbc.gridheight = 2;
- // gbc.anchor = GridBagConstraints.NORTHEAST;
- // gbc.fill = GridBagConstraints.HORIZONTAL;
+ gbc.anchor = GridBagConstraints.FIRST_LINE_END;
+ gbc.fill = GridBagConstraints.BOTH;
backupsTab.add(exampleFilesPanel, gbc);
+ gbc.gridheight = 1;
+ gbc.anchor = GridBagConstraints.FIRST_LINE_START;
+ gbc.fill = GridBagConstraints.NONE;
+
+ // fill empty space on right
+ gbc.gridx++;
+ gbc.weightx = 1.0;
+ backupsTab.add(new JPanel(), gbc);
+ // schemes box
+ gbc.weightx = 0.0;
gbc.gridx = 0;
- gbc.gridy = 1;
+ gbc.gridy++; // row 1
backupsTab.add(presetsPanel, gbc);
- gbc.anchor = GridBagConstraints.NORTHWEST;
- gbc.fill = GridBagConstraints.NONE;
+ // gbc.anchor = GridBagConstraints.NORTHWEST;
+ // now using whole row
gbc.gridwidth = 2;
gbc.gridheight = 1;
- // whole suffix panel next row
+ // keep files box
gbc.gridx = 0;
- gbc.gridy = 2;
+ gbc.gridy++; // row 2
backupsTab.add(keepfilesPanel, gbc);
- // keep files panel
- gbc.gridy = 3;
+ // filename strategy box
+ gbc.gridy++; // row 3
backupsTab.add(suffixPanel, gbc);
// fill empty space
- gbc.gridy = 4;
+ gbc.gridy++; // row 4
gbc.weighty = 1.0;
backupsTab.add(new JPanel(), gbc);
return backupsTab;
}
+ private final int BACKUPFILESSCHEMECUSTOMISE = 0;
private final IntKeyStringValueEntry[] backupfilesPresetEntries = {
new IntKeyStringValueEntry(1,
MessageManager.getString("label.default")),
new IntKeyStringValueEntry(4,
MessageManager.getString("label.rolled_backups")),
// ...
- new IntKeyStringValueEntry(255,
- MessageManager.getString("label.previously_saved_scheme")),
+ // new IntKeyStringValueEntry(255,
+ // MessageManager.getString("label.previously_saved_scheme")),
// IMPORTANT, keep "Custom" entry with key 0 (even though it appears last)
- new IntKeyStringValueEntry(0,
+ new IntKeyStringValueEntry(BACKUPFILESSCHEMECUSTOMISE,
MessageManager.getString("label.customise")) };
private final Map<Integer, BackupFilesPresetEntry> backupfilesPresetEntriesValues = new HashMap<Integer, BackupFilesPresetEntry>()
private JPanel initBackupsTabPresetsPanel()
{
- presetsPanel.setBorder(
- new TitledBorder(MessageManager.getString("label.schemes")));
+
+ String title = MessageManager.getString("label.schemes");
+ // TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
+ // TitledBorder tb = new TitledBorder(title);
+ // tb.setTitleFont(LABEL_FONT);
+ // presetsPanel.setBorder(tb);
+
+ presetsPanel.setLayout(new GridBagLayout());
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.weightx = 0.0;
+ gbc.weighty = 0.0;
+ gbc.anchor = GridBagConstraints.BASELINE_LEADING;
+ gbc.fill = GridBagConstraints.NONE;
+ gbc.gridwidth = 1;
+ gbc.gridheight = 1;
+
+ // "Scheme: "
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ presetsPanel.add(new JLabel(title + ":"), gbc);
for (int i = 0; i < backupfilesPresetEntries.length; i++)
{
}
});
- presetsPanel.add(backupfilesPresetsCombo);
+ // dropdown list of preset schemes
+ gbc.gridx = 1;
+ presetsPanel.add(backupfilesPresetsCombo, gbc);
+
+ revertButton.setText(MessageManager.getString("label.cancel_changes"));
+ revertButton.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ loadLastSavedBackupsOptions();
+ }
+
+ });
+ revertButton.setFont(LABEL_FONT);
+
+ // "Cancel changes" button (aligned with combo box above)
+ gbc.gridx = 1;
+ gbc.gridy++;
+ presetsPanel.add(revertButton, gbc);
+
return presetsPanel;
}
+ private JPanel initBackupsTabFilenameExamplesPanel()
+ {
+ String title = MessageManager
+ .getString("label.summary_of_backups_scheme");
+ TitledBorder tb = new TitledBorder(title);
+ exampleFilesPanel.setBorder(tb);
+ exampleFilesPanel.setLayout(new GridBagLayout());
+
+
+ backupfilesExampleLabel.setEditable(false);
+ backupfilesExampleLabel
+ .setBackground(exampleFilesPanel.getBackground());
+
+ updateBackupFilesExampleLabel();
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.weightx = 1.0;
+ gbc.weighty = 1.0;
+ gbc.fill = GridBagConstraints.NONE;
+ gbc.anchor = GridBagConstraints.FIRST_LINE_START;
+
+ exampleFilesPanel.add(backupfilesExampleLabel, gbc);
+ return exampleFilesPanel;
+ }
+
private void backupsTabUpdatePresets()
{
IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo
.getSelectedItem();
int key = entry.getKey();
String value = entry.getValue();
- // 0 reserved for "Custom" and 255 reserved or "Previously saved scheme"
- boolean special = key == 0 || key == 255;
- if (special)
- {
- if (key == 0)
- {
- // backupsSetCustomOptions();
- }
- else if (key == 255)
- {
- loadLastSavedBackupsOptions();
- // switch to "Customise" scheme? probably not
- // setComboIntStringKey(backupfilesPresetsCombo, 0);
- }
- }
- else
+ // BACKUPFILESSCHEMECUSTOMISE (==0) reserved for "Custom"
+ if (key != BACKUPFILESSCHEMECUSTOMISE)
{
if (backupfilesPresetEntriesValues.containsKey(key))
{
return keepfilesPanel;
}
- private JPanel initBackupsTabFilenameExamplesPanel()
- {
- String title = MessageManager
- .getString("label.summary_of_backups_scheme");
- TitledBorder tb = new TitledBorder(new EmptyBorder(0, 0, 0, 0), title);
- // tb.setTitleFont(LABEL_FONT);
- exampleFilesPanel.setBorder(tb);
- exampleFilesPanel.setLayout(new GridBagLayout());
-
- // inordinately difficult to get this titledborder the right size for the
- // title
-
- backupfilesExampleLabel.setEditable(false);
- backupfilesExampleLabel.setPreferredSize(new Dimension(280, 85));
- backupfilesExampleLabel.setAlignmentX(LEFT_ALIGNMENT);
- backupfilesExampleLabel.setAlignmentY(TOP_ALIGNMENT);
-
- backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
- backupfilesExampleLabel
- .setBackground(exampleFilesPanel.getBackground());
-
- updateBackupFilesExampleLabel();
- exampleFilesPanel.setMinimumSize(new Dimension(280, 85));
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.anchor = GridBagConstraints.EAST;
-
- gbc.gridy = 0;
- exampleFilesPanel.add(backupfilesExampleLabel, gbc);
- return exampleFilesPanel;
- }
-
protected void updateBackupFilesExampleLabel()
{
int exampleindex = 12;