*/
package jalview.jbgui;
-import jalview.bin.Cache;
import jalview.fts.core.FTSDataColumnPreferences;
import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
import jalview.fts.service.pdb.PDBFTSRestClient;
import jalview.gui.JvSwingUtils;
import jalview.gui.StructureViewer.ViewerType;
import jalview.io.BackupFilenameFilter;
-import jalview.io.BackupFiles;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
/*
* Backups tab components
* a lot of these are member variables instead of local variables only so that they
- * can be enabled/disabled easily
+ * can be enabled/disabled easily in one go
*/
protected JCheckBox enableBackupFiles = new JCheckBox();
protected JSpinner backupfilesRollMaxSpinner = new JSpinner();
+ protected JLabel oldBackupFilesLabel = new JLabel();
+
protected JalviewBooleanRadioButtons backupfilesConfirmDelete = new JalviewBooleanRadioButtons();
protected JLabel exampleLabel = new JLabel();
- protected JScrollPane exampleScrollPane = new JScrollPane();
-
protected JTextArea backupfilesExampleLabel = new JTextArea();
/**
private JPanel initBackupsTab()
{
JPanel backupsTab = new JPanel();
- backupsTab.setBorder(new TitledBorder(MessageManager
- .getString("label.backup_files")));
+ // backupsTab.setBorder(new TitledBorder(MessageManager
+ // .getString("label.backup_files")));
backupsTab.setLayout(new GridBagLayout());
enableBackupFiles.setFont(LABEL_FONT);
enableBackupFiles.setText(
MessageManager.getString("label.enable_backupfiles"));
- enableBackupFiles
- .setSelected(Cache.getDefault(BackupFiles.ENABLED, true));
enableBackupFiles.addActionListener(new ActionListener()
{
@Override
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.NORTHWEST;
+ gbc.fill = GridBagConstraints.NONE;
// enable checkbox 1 row
gbc.gridwidth = 1;
gbc.gridy = 0;
backupsTab.add(enableBackupFiles, gbc);
- // whole suffix panel next row
initBackupsTabSuffixPanel();
+ initBackupsTabKeepFilesPanel();
+ initBackupsTabFilenameExamplesPanel();
+
+ /*
+ // set widths of the panels to the max one
+ int maxw = suffixPanel.getWidth();
+ if (maxw < keepfilesPanel.getWidth())
+ {
+ maxw = keepfilesPanel.getWidth();
+ }
+ if (maxw < exampleFilesPanel.getWidth())
+ {
+ maxw = exampleFilesPanel.getWidth();
+ }
+ suffixPanel.setSize(suffixPanel.getHeight(), maxw);
+ keepfilesPanel.setSize(keepfilesPanel.getHeight(), maxw);
+ exampleFilesPanel.setSize(exampleFilesPanel.getHeight(), maxw);
+ */
+
+ // whole suffix panel next row
gbc.gridy = 1;
backupsTab.add(suffixPanel, gbc);
// keep files panel
- initBackupsTabKeepFilesPanel();
gbc.gridy = 2;
backupsTab.add(keepfilesPanel, gbc);
// whole examples panel next row
- initBackupsTabFilenameExamplesPanel();
gbc.gridy = 3;
backupsTab.add(exampleFilesPanel, gbc);
+ // fill empty space
+ gbc.gridy = 4;
+ gbc.weighty = 1.0;
+ backupsTab.add(new JPanel(), gbc);
+
+ backupsOptionsSetEnabled(enableBackupFiles.isSelected());
return backupsTab;
}
suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT);
suffixTemplateLabel.setFont(LABEL_FONT);
- String suffix = Cache.getDefault(BackupFiles.SUFFIX, BackupFiles.getNumPlaceHolder());
- suffixTemplate.setText(suffix);
final String tooltip = JvSwingUtils.wrapTooltip(true, MessageManager
.getString("label.suffix_template_tooltip"));
suffixTemplate.setToolTipText(tooltip);
"Exception setting suffix digits max from default.suffix_index_digits_max label, setting to "
+ defaultmax);
}
- setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax,
- Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3));
+ ChangeListener c = new ChangeListener()
+ {
+ @Override
+ public void stateChanged(ChangeEvent e)
+ {
+ updateBackupFilesExampleLabel();
+ }
+
+ };
+ setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c);
- suffixReverse.setSelected(
- Cache.getDefault(BackupFiles.REVERSE_ORDER, false));
suffixReverse.setLabels(
MessageManager.getString("label.reverse_roll"),
MessageManager.getString("label.increment_index"));
new TitledBorder(MessageManager.getString("label.keep_files")));
keepfilesPanel.setLayout(new GridBagLayout());
- backupfilesKeepAll
- .setSelected(Cache.getDefault(BackupFiles.NO_MAX, true));
backupfilesKeepAll.setLabels(
MessageManager.getString("label.keep_all_backup_files"),
MessageManager.getString(
}
});
- setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999,
- Cache.getDefault(BackupFiles.ROLL_MAX, 3));
+ ChangeListener c = new ChangeListener()
+ {
+ @Override
+ public void stateChanged(ChangeEvent e)
+ {
+ updateBackupFilesExampleLabel();
+ }
+
+ };
+ setIntegerSpinner(backupfilesRollMaxSpinner, 1, 999, 4, true, c);
- backupfilesConfirmDelete.setSelected(
- Cache.getDefault(BackupFiles.CONFIRM_DELETE_OLD, true));
backupfilesConfirmDelete.setLabels(
MessageManager.getString("label.confirm_delete"),
MessageManager.getString("label.auto_delete"));
keepfilesPanel.add(backupfilesKeepAll.getFalseButton(), kgbc);
kgbc.gridx = 1;
- // kgbc.fill = GridBagConstraints.HORIZONTAL;
+ kgbc.gridwidth = GridBagConstraints.REMAINDER;
keepfilesPanel.add(backupfilesRollMaxSpinner, kgbc);
// third row (indented)
kgbc.gridwidth = GridBagConstraints.REMAINDER;
kgbc.fill = GridBagConstraints.HORIZONTAL;
kgbc.weightx = 1.0;
+ /*
keepfilesPanel.add(backupfilesConfirmDelete.getTrueButton(), kgbc);
-
+
// fourth row (indented)
kgbc.gridy = 3;
keepfilesPanel.add(backupfilesConfirmDelete.getFalseButton(), kgbc);
+ */
+
+ JPanel jp = new JPanel();
+ jp.setLayout(new FlowLayout());
+ oldBackupFilesLabel
+ .setText(MessageManager.getString("label.old_backup_files"));
+ oldBackupFilesLabel.setFont(LABEL_FONT);
+ oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
+ jp.add(oldBackupFilesLabel);
+ jp.add(backupfilesConfirmDelete.getTrueButton());
+ jp.add(backupfilesConfirmDelete.getFalseButton());
+ keepfilesPanel.add(jp, kgbc);
+
return keepfilesPanel;
}
private JPanel initBackupsTabFilenameExamplesPanel()
{
exampleFilesPanel.setBorder(new TitledBorder(
- MessageManager.getString("label.examples")));
+ MessageManager.getString("label.example_filenames")));
exampleFilesPanel.setLayout(new GridBagLayout());
+ /*
exampleLabel.setText(
MessageManager.getString("label.suffix_example_filenames"));
exampleLabel.setFont(LABEL_FONT);
exampleLabel.setHorizontalAlignment(SwingConstants.LEFT);
+ */
backupfilesExampleLabel.setEditable(false);
- backupfilesExampleLabel.setPreferredSize(new Dimension(300, 100));
+ backupfilesExampleLabel.setPreferredSize(new Dimension(400, 85));
backupfilesExampleLabel.setAlignmentX(LEFT_ALIGNMENT);
backupfilesExampleLabel.setAlignmentY(TOP_ALIGNMENT);
backupfilesExampleLabel.setFont(LABEL_FONT_ITALIC);
backupfilesExampleLabel.setBackground(exampleLabel.getBackground());
- /*
- exampleScrollPane.setBounds(0, 0, 200, 100);
- exampleScrollPane.setPreferredSize(new Dimension(800, 800));
- exampleScrollPane.add(backupfilesExampleLabel);
- */
updateBackupFilesExampleLabel();
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST;
+ gbc.fill = GridBagConstraints.NONE;
gbc.gridy = 0;
+ /*
exampleFilesPanel.add(exampleLabel, gbc);
gbc.gridy = 1;
+ */
exampleFilesPanel.add(backupfilesExampleLabel, gbc);
- // exampleFilesPanel.add(exampleScrollPane, gbc);
return exampleFilesPanel;
}
"Failed casting (Integer) backupfilesRollMaxSpinner.getValue()");
}
- int surround = 3;
+ int surround = 2;
StringBuilder exampleSB = new StringBuilder();
boolean firstLine = true;
if (reverse)
int max = keepAll ? exampleindex : rollMax;
for (int index = min; index <= max; index++)
{
- if (index == min + surround && index <= max - surround)
+ if (index == min + surround && index < max)
{
exampleSB.append("\n...");
}
- else if (index > min + surround && index <= max - surround)
+ else if (index > min + surround && index < max)
{
// nothing
}
for (int index = min; index <= max; index++)
{
- if (index == min + surround && index <= max - surround)
+ if (index == min + surround && index < max)
{
exampleSB.append("\n...");
}
- else if (index > min + surround && index <= max - surround)
+ else if (index > min + surround && index < max)
{
// nothing
}
backupfilesExampleLabel.setText(exampleSB.toString());
}
- protected void setIntegerSpinner(JSpinner s, int min,
- int max, int def)
+ protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
+ boolean useExistingVal, ChangeListener c)
+ {
+ int i = def;
+ if (useExistingVal)
+ {
+ try
+ {
+ i = Integer.parseInt((String) s.getValue());
+ } catch (Exception e)
+ {
+ System.out.println(
+ "Exception casting the initial value of s.getValue()");
+ }
+ }
+
+ setIntegerSpinner(s, min, max, i, c);
+ }
+
+ protected void setIntegerSpinner(JSpinner s, int min, int max, int def,
+ ChangeListener c)
{
// integer spinner for number of digits
if (def > max)
SpinnerModel sModel = new SpinnerNumberModel(def, min, max, 1);
s.setModel(sModel);
- s.addChangeListener(new ChangeListener()
- {
- @Override
- public void stateChanged(ChangeEvent e)
- {
- updateBackupFilesExampleLabel();
- }
-
- });
+ s.addChangeListener(c);
}
private void keepRollMaxOptionsEnabled(boolean enabled)
{
+ oldBackupFilesLabel.setEnabled(enabled);
backupfilesRollMaxSpinner.setEnabled(enabled);
backupfilesConfirmDelete.setEnabled(enabled);
}
- private void backupsOptionsSetEnabled(boolean enabled)
+
+ protected void backupsOptionsSetEnabled(boolean enabled)
{
suffixPanel.setEnabled(enabled);
keepfilesPanel.setEnabled(enabled);
suffixReverse.setEnabled(enabled);
backupfilesKeepAll.setEnabled(enabled);
backupfilesRollMaxSpinner.setEnabled(enabled);
+ oldBackupFilesLabel.setEnabled(enabled);
backupfilesConfirmDelete.setEnabled(enabled);
exampleLabel.setEnabled(enabled);
- exampleScrollPane.setEnabled(enabled);
backupfilesExampleLabel.setEnabled(enabled);
keepRollMaxOptionsEnabled(enabled && !backupfilesKeepAll.isSelected());