From: Ben Soares Date: Thu, 24 Jan 2019 09:37:05 +0000 (+0000) Subject: JAL-3141 Reformatted code in eclipse X-Git-Tag: Release_2_11_0~17^2~97^2~19 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=656e362ece73c630f032d8bf30322143a297d92e;p=jalview.git JAL-3141 Reformatted code in eclipse --- diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 1a1fa45..e9b08a7 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -365,13 +365,12 @@ public class Desktop extends jalview.jbgui.GDesktop // This line prevents Windows Look&Feel resizing all new windows to maximum // if previous window was maximised - desktop.setDesktopManager( - new MyDesktopManager( - (Platform.isWindows() ? new DefaultDesktopManager() - : Platform.isAMac() - ? new AquaInternalFrameManager( - desktop.getDesktopManager()) - : desktop.getDesktopManager()))); + desktop.setDesktopManager(new MyDesktopManager( + (Platform.isWindows() ? new DefaultDesktopManager() + : Platform.isAMac() + ? new AquaInternalFrameManager( + desktop.getDesktopManager()) + : desktop.getDesktopManager()))); Rectangle dims = getLastKnownDimensions(""); if (dims != null) @@ -1614,9 +1613,12 @@ public class Desktop extends jalview.jbgui.GDesktop { java.io.File projectFile = getProjectFile(); // autoSave indicates we already have a file and don't need to ask - boolean autoSave = projectFile != null && !saveAs && BackupFiles.getEnabled(); + boolean autoSave = projectFile != null && !saveAs + && BackupFiles.getEnabled(); - //System.out.println("autoSave="+autoSave+", projectFile='"+projectFile+"', saveAs="+saveAs+", Backups "+(BackupFiles.getEnabled()?"enabled":"disabled")); + // System.out.println("autoSave="+autoSave+", projectFile='"+projectFile+"', + // saveAs="+saveAs+", Backups + // "+(BackupFiles.getEnabled()?"enabled":"disabled")); boolean approveSave = false; if (!autoSave) @@ -1637,7 +1639,8 @@ public class Desktop extends jalview.jbgui.GDesktop } } - if (approveSave || autoSave) { + if (approveSave || autoSave) + { final Desktop me = this; final java.io.File chosenFile = projectFile; new Thread(new Runnable() @@ -1663,14 +1666,12 @@ public class Desktop extends jalview.jbgui.GDesktop backupfiles.rollBackupsAndRenameTempFile(); } catch (OutOfMemoryError oom) { - new OOMWarning( - "Whilst saving current state to " + chosenFile.getName(), - oom); + new OOMWarning("Whilst saving current state to " + + chosenFile.getName(), oom); } catch (Exception ex) { - Cache.log.error( - "Problems whilst trying to save to " + chosenFile.getName(), - ex); + Cache.log.error("Problems whilst trying to save to " + + chosenFile.getName(), ex); JvOptionPane.showMessageDialog(me, MessageManager.formatMessage( "label.error_whilst_saving_current_state_to", @@ -1712,8 +1713,7 @@ public class Desktop extends jalview.jbgui.GDesktop final String[] desc = new String[] { "Jalview Project", "Jalview Project (old)" }; JalviewFileChooser chooser = new JalviewFileChooser( - Cache.getProperty("LAST_DIRECTORY"), suffix, - desc, + Cache.getProperty("LAST_DIRECTORY"), suffix, desc, "Jalview Project"); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager.getString("label.restore_state")); @@ -2564,7 +2564,6 @@ public class Desktop extends jalview.jbgui.GDesktop } } - /** * Accessor method to quickly get all the AlignmentFrames loaded. * @@ -3402,15 +3401,15 @@ public class Desktop extends jalview.jbgui.GDesktop try { - java.net.URL url = (URL) t.getTransferData(urlFlavour); + java.net.URL url = (URL) t.getTransferData(urlFlavour); // nb: java 8 osx bug https://bugs.openjdk.java.net/browse/JDK-8156099 // means url may be null. - if (url != null) - { - protocols.add(DataSourceType.URL); - files.add(url.toString()); - Cache.log.debug("Drop handled as URL dataflavor " - + files.get(files.size() - 1)); + if (url != null) + { + protocols.add(DataSourceType.URL); + files.add(url.toString()); + Cache.log.debug("Drop handled as URL dataflavor " + + files.get(files.size() - 1)); return; } else @@ -3421,7 +3420,7 @@ public class Desktop extends jalview.jbgui.GDesktop "Please ignore plist error - occurs due to problem with java 8 on OSX"); } ; - } + } } catch (Throwable ex) { Cache.log.debug("URL drop handler failed.", ex); @@ -3545,7 +3544,8 @@ public class Desktop extends jalview.jbgui.GDesktop && (source.endsWith(".lnk") || source.endsWith(".url") || source.endsWith(".site"))) { - try { + try + { File lf = new File(files.get(f)); // process link file to get a URL Cache.log.debug("Found potential link file: " + lf); @@ -3555,10 +3555,11 @@ public class Desktop extends jalview.jbgui.GDesktop files.set(f, fullname); Cache.log.debug("Parsed real filename " + fullname + " to extract protocol: " + protocols.get(f)); - } - catch (Exception ex) + } catch (Exception ex) { - Cache.log.error("Couldn't parse "+files.get(f)+" as a link file.",ex); + Cache.log.error( + "Couldn't parse " + files.get(f) + " as a link file.", + ex); } } } diff --git a/src/jalview/io/BackupFilenameFilter.java b/src/jalview/io/BackupFilenameFilter.java index 916d660..41c6859 100644 --- a/src/jalview/io/BackupFilenameFilter.java +++ b/src/jalview/io/BackupFilenameFilter.java @@ -54,4 +54,3 @@ public class BackupFilenameFilter implements FilenameFilter } } - diff --git a/src/jalview/io/BackupFilenameParts.java b/src/jalview/io/BackupFilenameParts.java index a91414a..6f7da93 100644 --- a/src/jalview/io/BackupFilenameParts.java +++ b/src/jalview/io/BackupFilenameParts.java @@ -16,7 +16,8 @@ public class BackupFilenameParts boolean isBackupFile; - public BackupFilenameParts(File file, String base, String template, int digits) + public BackupFilenameParts(File file, String base, String template, + int digits) { this(file.getName(), base, template, digits); } @@ -37,10 +38,10 @@ public class BackupFilenameParts numcharstart + BackupFiles.NUM_PLACEHOLDER.length()); digits = suggesteddigits; } - + // calculate minimum length of a backup filename int minlength = base.length() + template.length() - - BackupFiles.NUM_PLACEHOLDER.length() + digits ; + - BackupFiles.NUM_PLACEHOLDER.length() + digits; if (!(filename.startsWith(base) && filename.length() >= minlength)) { @@ -50,8 +51,9 @@ public class BackupFilenameParts int startLength = base.length() + templateStart.length(); int endLength = templateEnd.length(); - String numString = numcharstart > -1?filename.substring(startLength, - filename.length() - endLength):""; + String numString = numcharstart > -1 + ? filename.substring(startLength, filename.length() - endLength) + : ""; if (filename.length() >= startLength + digits + endLength && filename.startsWith(base + templateStart) @@ -60,12 +62,12 @@ public class BackupFilenameParts { this.base = base; this.templateStart = templateStart; - this.num = numString.length() > 0?Integer.parseInt(numString):0; + this.num = numString.length() > 0 ? Integer.parseInt(numString) : 0; this.digits = digits; this.templateEnd = templateEnd; this.isBackupFile = true; } - + } public boolean isBackupFile() diff --git a/src/jalview/io/BackupFiles.java b/src/jalview/io/BackupFiles.java index aafe8f2..e913fbc 100644 --- a/src/jalview/io/BackupFiles.java +++ b/src/jalview/io/BackupFiles.java @@ -8,8 +8,8 @@ import jalview.util.MessageManager; import java.io.File; import java.io.IOException; import java.util.Arrays; -import java.util.Map; import java.util.HashMap; +import java.util.Map; import java.util.TreeMap; /* @@ -44,7 +44,8 @@ public class BackupFiles public static final String REVERSE_ORDER = NS + "_REVERSE_ORDER"; - public static final String CONFIRM_DELETE_OLD = NS + "_CONFIRM_DELETE_OLD"; + public static final String CONFIRM_DELETE_OLD = NS + + "_CONFIRM_DELETE_OLD"; private static final String DEFAULT_TEMP_FILE = "jalview_temp_file_" + NS; @@ -95,10 +96,8 @@ public class BackupFiles this(file, ".v" + NUM_PLACEHOLDER, false, 4, 3, false); } - public BackupFiles(File file, - String defaultSuffix, boolean defaultNoMax, int defaultMax, - int defaultDigits, - boolean defaultReverseOrder) + public BackupFiles(File file, String defaultSuffix, boolean defaultNoMax, + int defaultMax, int defaultDigits, boolean defaultReverseOrder) { classInit(); this.file = file; @@ -205,7 +204,6 @@ public class BackupFiles return tempFile.renameTo(file); } - // roll the backupfiles public boolean rollBackupFiles() { @@ -238,14 +236,14 @@ public class BackupFiles // Create/move backups up one File[] oldFilesToDelete = null; - + // find existing backup files BackupFilenameFilter bff = new BackupFilenameFilter(basename, suffix, digits); File[] backupFiles = dirFile.listFiles(bff); int nextIndexNum = 0; String confirmDeleteExtraInfo = null; - + if (backupFiles.length == 0) { // No other backup files. Just need to move existing file to backupfile_1 @@ -253,7 +251,8 @@ public class BackupFiles } else { - TreeMap bfTreeMap = sortBackupFilesAsTreeMap(backupFiles, basename); + TreeMap bfTreeMap = sortBackupFilesAsTreeMap( + backupFiles, basename); if (reverseOrder) { @@ -294,11 +293,12 @@ public class BackupFiles // if (m == 0 && backupfile_n.exists()) if ((!noMax) && n == tempMax && backupfile_n.exists()) { - // move the largest (max) rolled file to a temp file and add to the delete list + // move the largest (max) rolled file to a temp file and add to the + // delete list try { File temp = File.createTempFile(backupfilename, TEMP_FILE_EXT, - dirFile); + dirFile); backupfile_n.renameTo(temp); oldFilesToDelete = new File[] { temp }; @@ -330,7 +330,6 @@ public class BackupFiles // version style numbering (with earliest file deletion if max files // reached) - bfTreeMap.values().toArray(backupFiles); // noMax == true means keep all backup files @@ -361,7 +360,9 @@ public class BackupFiles return ret; } - private void deleteOldFiles(File[] oldFilesToDelete, String confirmDeleteExtraInfo) { + private void deleteOldFiles(File[] oldFilesToDelete, + String confirmDeleteExtraInfo) + { if (oldFilesToDelete != null && oldFilesToDelete.length > 0) { // delete old backup/version files @@ -411,32 +412,38 @@ public class BackupFiles } } - private TreeMap sortBackupFilesAsTreeMap(File[] backupFiles, String basename) { - // sort the backup files (based on integer found in the suffix) using a - // precomputed Hashmap for speed - Map bfHashMap = new HashMap<>(); - for (int i = 0; i < backupFiles.length; i++) - { - File f = backupFiles[i]; - BackupFilenameParts bfp = new BackupFilenameParts(f, basename, suffix, digits); - bfHashMap.put(bfp.indexNum(), f); - } - TreeMap bfTreeMap = new TreeMap<>(); - bfTreeMap.putAll(bfHashMap); - return bfTreeMap; + private TreeMap sortBackupFilesAsTreeMap(File[] backupFiles, + String basename) + { + // sort the backup files (based on integer found in the suffix) using a + // precomputed Hashmap for speed + Map bfHashMap = new HashMap<>(); + for (int i = 0; i < backupFiles.length; i++) + { + File f = backupFiles[i]; + BackupFilenameParts bfp = new BackupFilenameParts(f, basename, suffix, + digits); + bfHashMap.put(bfp.indexNum(), f); + } + TreeMap bfTreeMap = new TreeMap<>(); + bfTreeMap.putAll(bfHashMap); + return bfTreeMap; } public boolean rollBackupsAndRenameTempFile() { boolean write = this.getWriteSuccess(); - + boolean roll = false; - if (write) { + if (write) + { roll = this.rollBackupFiles(); - } else { + } + else + { return false; } - + /* * Not sure that this confirmation is desirable. By this stage the new file is * already written successfully, but something (e.g. disk full) has happened while @@ -448,7 +455,8 @@ public class BackupFiles int confirm = JvOptionPane.showConfirmDialog(Desktop.desktop, MessageManager.getString( "label.backupfiles_confirm_save_file_backupfiles_roll_wrong"), - MessageManager.getString("label.backupfiles_confirm_save_file"), + MessageManager + .getString("label.backupfiles_confirm_save_file"), JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE); if (confirm == JvOptionPane.YES_OPTION) @@ -467,8 +475,7 @@ public class BackupFiles } public static TreeMap getBackupFilesAsTreeMap( - String fileName, - String suffix, int digits) + String fileName, String suffix, int digits) { File[] backupFiles = null; @@ -489,11 +496,12 @@ public class BackupFiles String filename = file.getName(); String basename = filename; - + // find existing backup files - BackupFilenameFilter bff = new BackupFilenameFilter(basename, suffix, digits); + BackupFilenameFilter bff = new BackupFilenameFilter(basename, suffix, + digits); backupFiles = dirFile.listFiles(bff); // is clone needed? - + // sort the backup files (based on integer found in the suffix) using a // precomputed Hashmap for speed Map bfHashMap = new HashMap<>(); @@ -510,6 +518,4 @@ public class BackupFiles return bfTreeMap; } - } - diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 58737ee..43b521a 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -36,7 +36,6 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; -import java.awt.FontMetrics; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; @@ -49,9 +48,8 @@ import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.Map; import java.util.HashMap; +import java.util.Map; import javax.swing.AbstractCellEditor; import javax.swing.BorderFactory; @@ -279,7 +277,6 @@ public class GPreferences extends JPanel protected JCheckBox sortByTree = new JCheckBox(); - /* * Web Services tab */ @@ -533,11 +530,8 @@ public class GPreferences extends JPanel embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson")); embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23)); - TitledBorder backupFilesBorder = new TitledBorder( - MessageManager - .getString("label.backup_files")); - + MessageManager.getString("label.backup_files")); jPanel11.add(jLabel1); jPanel11.add(blcjv); @@ -1070,14 +1064,13 @@ public class GPreferences extends JPanel hiddenColour_actionPerformed(hiddenColour); } }); - + useLegacyGap = new JCheckBox( MessageManager.getString("label.ov_legacy_gap")); useLegacyGap.setFont(LABEL_FONT); useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT); useLegacyGap.setVerticalTextPosition(SwingConstants.TOP); - gapLabel = new JLabel( - MessageManager.getString("label.gap_colour")); + gapLabel = new JLabel(MessageManager.getString("label.gap_colour")); gapLabel.setFont(LABEL_FONT); gapLabel.setHorizontalAlignment(SwingConstants.LEFT); gapLabel.setVerticalTextPosition(SwingConstants.TOP); @@ -1700,8 +1693,8 @@ public class GPreferences extends JPanel 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()); GridBagConstraints gbc = new GridBagConstraints(); @@ -1717,8 +1710,8 @@ public class GPreferences extends JPanel gbc.weightx = 0.5; enableBackupFiles.setFont(LABEL_FONT_BOLD); - enableBackupFiles.setText( - MessageManager.getString("label.enable_backupfiles")); + enableBackupFiles + .setText(MessageManager.getString("label.enable_backupfiles")); enableBackupFiles.addActionListener(new ActionListener() { @Override @@ -1739,8 +1732,8 @@ public class GPreferences extends JPanel gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridheight = 2; - //gbc.anchor = GridBagConstraints.NORTHEAST; - //gbc.fill = GridBagConstraints.HORIZONTAL; + // gbc.anchor = GridBagConstraints.NORTHEAST; + // gbc.fill = GridBagConstraints.HORIZONTAL; backupsTab.add(exampleFilesPanel, gbc); gbc.gridx = 0; @@ -1764,7 +1757,7 @@ public class GPreferences extends JPanel // whole examples panel next row gbc.gridy = 3; backupsTab.add(exampleFilesPanel, gbc); - + // fill empty space gbc.gridy = 4; gbc.weighty = 1.0; @@ -1775,44 +1768,52 @@ public class GPreferences extends JPanel return backupsTab; } - private final IntKeyStringValueEntry[] backupfilesPresetEntries = - { - new IntKeyStringValueEntry(1, MessageManager.getString("label.default")), - new IntKeyStringValueEntry(2, MessageManager.getString("label.single_file")), - new IntKeyStringValueEntry(3, MessageManager.getString("label.keep_everything")), - new IntKeyStringValueEntry(4, MessageManager.getString("label.rolled_backups")), - // ... - // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last) - new IntKeyStringValueEntry(0, MessageManager.getString("label.custom")) - }; + private final IntKeyStringValueEntry[] backupfilesPresetEntries = { + new IntKeyStringValueEntry(1, + MessageManager.getString("label.default")), + new IntKeyStringValueEntry(2, + MessageManager.getString("label.single_file")), + new IntKeyStringValueEntry(3, + MessageManager.getString("label.keep_everything")), + new IntKeyStringValueEntry(4, + MessageManager.getString("label.rolled_backups")), + // ... + // IMPORTANT, keep "Custom" entry with key 0 (even though it appears last) + new IntKeyStringValueEntry(0, + MessageManager.getString("label.custom")) }; private final Map backupfilesPresetEntriesValues = new HashMap() - {{ - put(1, new BackupFilesPresetEntry(".v"+BackupFiles.NUM_PLACEHOLDER, 3, false, false, 4, false)); + { + { + put(1, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER, + 3, false, false, 4, false)); put(2, new BackupFilesPresetEntry("~", 1, false, false, 1, false)); - put(3, new BackupFilesPresetEntry(".v"+BackupFiles.NUM_PLACEHOLDER, 3, false, true, 10, true)); - put(4, new BackupFilesPresetEntry("_bak."+BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9, false)); - }}; + put(3, new BackupFilesPresetEntry(".v" + BackupFiles.NUM_PLACEHOLDER, + 3, false, true, 10, true)); + put(4, new BackupFilesPresetEntry( + "_bak." + BackupFiles.NUM_PLACEHOLDER, 1, true, false, 9, + false)); + } + }; private JPanel initBackupsTabPresetsPanel() { - presetsPanel.setBorder(new TitledBorder( - MessageManager.getString("label.presets"))); + presetsPanel.setBorder( + new TitledBorder(MessageManager.getString("label.presets"))); for (int i = 0; i < backupfilesPresetEntries.length; i++) { - backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]); + backupfilesPresetsCombo.addItem(backupfilesPresetEntries[i]); } backupfilesPresetsCombo.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - backupsTabUpdatePresets(); - } - } - ); + { + @Override + public void actionPerformed(ActionEvent e) + { + backupsTabUpdatePresets(); + } + }); presetsPanel.add(backupfilesPresetsCombo); return presetsPanel; @@ -1820,21 +1821,25 @@ public class GPreferences extends JPanel private void backupsTabUpdatePresets() { - IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo.getSelectedItem(); + IntKeyStringValueEntry entry = (IntKeyStringValueEntry) backupfilesPresetsCombo + .getSelectedItem(); int key = entry.getKey(); String value = entry.getValue(); - boolean custom = key==0; + boolean custom = key == 0; if (custom) { - //backupsSetCustomOptions(); - } else + // backupsSetCustomOptions(); + } + else { if (backupfilesPresetEntriesValues.containsKey(key)) { backupsSetOptions(backupfilesPresetEntriesValues.get(key)); - } else { - System.out.println("Preset '"+value+"' not implemented yet"); + } + else + { + System.out.println("Preset '" + value + "' not implemented yet"); } } @@ -1845,23 +1850,24 @@ public class GPreferences extends JPanel protected int getComboIntStringKey(JComboBox c) { IntKeyStringValueEntry e = (IntKeyStringValueEntry) c.getSelectedItem(); - return e!=null?e.getKey():0; + return e != null ? e.getKey() : 0; } - protected void setComboIntStringKey(JComboBox c, int key) + protected void setComboIntStringKey(JComboBox c, + int key) { - for (int i=0; i < c.getItemCount(); i++) + for (int i = 0; i < c.getItemCount(); i++) + { + IntKeyStringValueEntry e = c.getItemAt(i); + int k = e.getKey(); + String v = e.getValue(); + if (e.getKey() == key) { - IntKeyStringValueEntry e = c.getItemAt(i); - int k = e.getKey(); - String v = e.getValue(); - if (e.getKey() == key) - { - c.setSelectedIndex(i); - break; - } + c.setSelectedIndex(i); + break; } - backupsTabUpdatePresets(); + } + backupsTabUpdatePresets(); } private JPanel initBackupsTabSuffixPanel() @@ -1875,8 +1881,8 @@ public class GPreferences extends JPanel suffixTemplateLabel.setHorizontalAlignment(SwingConstants.LEFT); suffixTemplateLabel.setFont(LABEL_FONT); - final String tooltip = JvSwingUtils.wrapTooltip(true, MessageManager - .getString("label.suffix_template_tooltip")); + final String tooltip = JvSwingUtils.wrapTooltip(true, + MessageManager.getString("label.suffix_template_tooltip")); suffixTemplate.setToolTipText(tooltip); suffixTemplate.addActionListener(new ActionListener() { @@ -1933,8 +1939,7 @@ public class GPreferences extends JPanel }; setIntegerSpinner(suffixDigitsSpinner, defaultmin, defaultmax, 3, c); - suffixReverse.setLabels( - MessageManager.getString("label.reverse_roll"), + suffixReverse.setLabels(MessageManager.getString("label.reverse_roll"), MessageManager.getString("label.increment_index")); suffixReverse.addActionListener(new ActionListener() { @@ -1956,15 +1961,15 @@ public class GPreferences extends JPanel sgbc.weightx = 1.0; sgbc.weighty = 0.0; sgbc.fill = GridBagConstraints.NONE; - suffixPanel.add(suffixTemplateLabel,sgbc); - + suffixPanel.add(suffixTemplateLabel, sgbc); + sgbc.gridx = 1; sgbc.fill = GridBagConstraints.HORIZONTAL; suffixPanel.add(suffixTemplate, sgbc); - + // second row (number of digits spinner) sgbc.gridy = 1; - + sgbc.gridx = 0; sgbc.fill = GridBagConstraints.NONE; suffixPanel.add(suffixDigitsLabel, sgbc); @@ -2088,7 +2093,7 @@ public class GPreferences extends JPanel jp.add(backupfilesConfirmDelete.getTrueButton()); jp.add(backupfilesConfirmDelete.getFalseButton()); keepfilesPanel.add(jp, kgbc); - + return keepfilesPanel; } @@ -2096,17 +2101,18 @@ public class GPreferences extends JPanel { String title = MessageManager.getString("label.example_filenames"); TitledBorder tb = new TitledBorder(title); - //tb.setTitleFont(LABEL_FONT); + // tb.setTitleFont(LABEL_FONT); exampleFilesPanel.setBorder(tb); exampleFilesPanel.setLayout(new GridBagLayout()); - //inordinately difficult to get this titledborder the right size for the title + // 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()); @@ -2133,13 +2139,15 @@ public class GPreferences extends JPanel String suffix = suffixTemplate.getText(); int digits = 3; - try { + try + { suffixDigitsSpinner.commitEdit(); digits = (Integer) suffixDigitsSpinner.getValue(); digits = digits < 1 ? 1 : digits; } catch (Exception e) { - System.out.println("Failed casting (Integer) suffixTemplateSpinner.getValue()"); + System.out.println( + "Failed casting (Integer) suffixTemplateSpinner.getValue()"); } boolean reverse = suffixReverse.isSelected(); boolean keepAll = backupfilesKeepAll.isSelected(); @@ -2195,7 +2203,7 @@ public class GPreferences extends JPanel String newest = MessageManager.getString("label.braced_newest"); if (newest != null && newest.length() > 0) { - exampleSB.append(" "+newest); + exampleSB.append(" " + newest); } } else if (index == max) @@ -2203,7 +2211,7 @@ public class GPreferences extends JPanel String oldest = MessageManager.getString("label.braced_oldest"); if (oldest != null && oldest.length() > 0) { - exampleSB.append(" "+oldest); + exampleSB.append(" " + oldest); } } } @@ -2248,7 +2256,7 @@ public class GPreferences extends JPanel String oldest = MessageManager.getString("label.braced_oldest"); if (oldest != null && oldest.length() > 0) { - exampleSB.append(" "+oldest); + exampleSB.append(" " + oldest); } } else if (index == max) @@ -2256,7 +2264,7 @@ public class GPreferences extends JPanel String newest = MessageManager.getString("label.braced_newest"); if (newest != null && newest.length() > 0) { - exampleSB.append(" "+newest); + exampleSB.append(" " + newest); } } } @@ -2330,12 +2338,12 @@ public class GPreferences extends JPanel protected void backupsCustomOptionsSetEnabled(boolean enabled) { - backupsOptionsSetEnabled(enabled, false); + backupsOptionsSetEnabled(enabled, false); } protected void backupsOptionsSetEnabled(boolean enabled) { - backupsOptionsSetEnabled(enabled, true); + backupsOptionsSetEnabled(enabled, true); } protected void backupsOptionsSetEnabled(boolean enabled, boolean all) @@ -2343,11 +2351,11 @@ public class GPreferences extends JPanel if (all) { - presetsPanel.setEnabled(enabled); - exampleFilesPanel.setEnabled(enabled); + presetsPanel.setEnabled(enabled); + exampleFilesPanel.setEnabled(enabled); - backupfilesPresetsCombo.setEnabled(enabled); - backupfilesExampleLabel.setEnabled(enabled); + backupfilesPresetsCombo.setEnabled(enabled); + backupfilesExampleLabel.setEnabled(enabled); } suffixPanel.setEnabled(enabled); keepfilesPanel.setEnabled(enabled); @@ -2366,7 +2374,9 @@ public class GPreferences extends JPanel } } - protected void backupsSetOptions(String suffix, int digits, boolean reverse, boolean keepAll, int rollMax, boolean confirmDelete) + protected void backupsSetOptions(String suffix, int digits, + boolean reverse, boolean keepAll, int rollMax, + boolean confirmDelete) { suffixTemplate.setText(suffix); suffixDigitsSpinner.setValue(digits); @@ -2378,7 +2388,8 @@ public class GPreferences extends JPanel protected void backupsSetOptions(BackupFilesPresetEntry p) { - backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax, p.confirmDelete); + backupsSetOptions(p.suffix, p.digits, p.reverse, p.keepAll, p.rollMax, + p.confirmDelete); } protected void autoIdWidth_actionPerformed() @@ -2567,37 +2578,51 @@ public class GPreferences extends JPanel } } -class IntKeyStringValueEntry { +class IntKeyStringValueEntry +{ int k; + String v; + public IntKeyStringValueEntry(int k, String v) { this.k = k; this.v = v; } + @Override public String toString() { return this.getValue(); } + public int getKey() { return k; } + public String getValue() { return v; } } -class BackupFilesPresetEntry { +class BackupFilesPresetEntry +{ String suffix; + int digits; + boolean reverse; + boolean keepAll; + int rollMax; + boolean confirmDelete; - public BackupFilesPresetEntry(String suffix, int digits, boolean reverse, boolean keepAll, int rollMax, boolean confirmDelete) + + public BackupFilesPresetEntry(String suffix, int digits, boolean reverse, + boolean keepAll, int rollMax, boolean confirmDelete) { this.suffix = suffix; this.digits = digits;