From: Ben Soares Date: Tue, 8 Jan 2019 23:13:08 +0000 (+0000) Subject: JAL-3141 Made some suggested changes from code review X-Git-Tag: Release_2_11_0~17^2~97^2~40 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3069ade337eb42af30baf34a69f0a7f4cefe3948;p=jalview.git JAL-3141 Made some suggested changes from code review --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 35b885c..3c32651 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1374,8 +1374,6 @@ label.suffix_format = Suffix format label.suffix_template = Suffix template (use %n to represent the backup/version index) label.suffix_template_tooltip = %n in the template will be replaced by the index number. The suffix will appear before the filename extension. label.index_digits = Number of digits to use for the index -default.suffix_index_digits_min = 1 -default.suffix_index_digits_max = 6 label.example_filenames = Example filenames label.suffix_example_filenames = Some example filenames using these settings: label.increment_index = Increment suffix indexes (like version files) - newest file has largest index. diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index e109cd3..74d55f3 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -1376,8 +1376,6 @@ label.suffix_format = Formato de sufijo label.suffix_template = Plantilla de sufijo (usa %n para representar el índice) label.suffix_template_tooltip = Esto será reemplazado por el número de índice. El sufijo aparecerá antes de la extensión. label.index_digits = Número de dígitos a utilizar para el índice. -default.suffix_index_digits_min = 1 -default.suffix_index_digits_max = 6 label.example_filenames = Ejemplos de nombres de archivos label.suffix_example_filenames = Algunos nombres de archivos de ejemplo usando estas configuraciones: label.increment_index = El archivo más nuevo tiene el índice más grande diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 255c8fc..7258957 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -555,7 +555,7 @@ public class Preferences extends GPreferences enableBackupFiles .setSelected(Cache.getDefault(BackupFiles.ENABLED, true)); suffixTemplate.setText(Cache.getDefault(BackupFiles.SUFFIX, - "-v" + BackupFiles.getNumPlaceHolder())); + "-v" + BackupFiles.NUM_PLACEHOLDER)); suffixDigitsSpinner .setValue(Cache.getDefault(BackupFiles.SUFFIX_DIGITS, 3)); suffixReverse.setSelected( diff --git a/src/jalview/io/BackupFilenameFilter.java b/src/jalview/io/BackupFilenameFilter.java index 1fed65c..db1645a 100644 --- a/src/jalview/io/BackupFilenameFilter.java +++ b/src/jalview/io/BackupFilenameFilter.java @@ -61,83 +61,3 @@ public class BackupFilenameFilter implements FilenameFilter } -class BackupFilenameParts -{ - String base; - - String templateStart; - - int num; - - int digits; - - String templateEnd; - - String extension; - - boolean isBackupFile; - - public BackupFilenameParts(File file, String base, String template, int digits, - String extension) - { - this(file.getName(), base, template, digits, extension); - } - - public BackupFilenameParts(String filename, String base, String template, - int digits, String extension) - { - this.isBackupFile = false; - - // calculate minimum length of a backup filename - int minlength = base.length() + template.length() - - BackupFiles.NUM_PLACEHOLDER.length() + digits - + extension.length(); - - if (!(filename.startsWith(base) && filename.endsWith(extension) - && filename.length() >= minlength)) - { - // non-starter - return; - } - - int numcharstart = template.indexOf(BackupFiles.NUM_PLACEHOLDER); - String templateStart = template; - String templateEnd = ""; - if (numcharstart > -1) - { - templateStart = template.substring(0, numcharstart); - templateEnd = template.substring( - numcharstart + BackupFiles.NUM_PLACEHOLDER.length()); - } - - int startLength = base.length() + templateStart.length(); - int endLength = templateEnd.length() + extension.length(); - String numString = filename.substring(startLength, - filename.length() - endLength); - - if (filename.length() >= startLength + digits + endLength - && filename.startsWith(base + templateStart) - && filename.endsWith(templateEnd + extension) - && numString.matches("[0-9]+")) - { - this.base = base; - this.templateStart = templateStart; - this.num = Integer.parseInt(numString); - this.digits = digits; - this.templateStart = templateStart; - this.templateEnd = templateEnd; - this.isBackupFile = true; - } - - } - - public boolean isBackupFile() - { - return this.isBackupFile; - } - - public int indexNum() - { - return this.num; - } -} \ No newline at end of file diff --git a/src/jalview/io/BackupFiles.java b/src/jalview/io/BackupFiles.java index 0b6b090..28eefd6 100644 --- a/src/jalview/io/BackupFiles.java +++ b/src/jalview/io/BackupFiles.java @@ -39,7 +39,7 @@ public class BackupFiles public static String SUFFIX_DIGITS = NS + "_SUFFIX_DIGITS"; - protected static String NUM_PLACEHOLDER = "%n"; + public static final String NUM_PLACEHOLDER = "%n"; public static String REVERSE_ORDER = NS + "_REVERSE_ORDER"; @@ -185,11 +185,6 @@ public class BackupFiles return path; } - public static String getNumPlaceHolder() - { - return NUM_PLACEHOLDER; - } - public boolean setWriteSuccess(boolean flag) { boolean old = this.tempFileWriteSuccess; diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index e789d6a..7ee27d6 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -1818,27 +1818,7 @@ public class GPreferences extends JPanel suffixDigitsLabel.setHorizontalAlignment(SwingConstants.LEFT); suffixDigitsLabel.setFont(LABEL_FONT); int defaultmin = 1; - try - { - defaultmin = Integer.parseInt( - MessageManager.getString("default.suffix_index_digits_min")); - } catch (Exception e) - { - defaultmin = 1; - System.out.println( - "Exception setting suffix digits min from default.suffix_index_digits_min label, setting to " - + defaultmin); - } int defaultmax = 6; - try { - defaultmax = Integer.parseInt( - MessageManager.getString("default.suffix_index_digits_max")); - } catch (Exception e) { - defaultmax = 6; - System.out.println( - "Exception setting suffix digits max from default.suffix_index_digits_max label, setting to " - + defaultmax); - } ChangeListener c = new ChangeListener() { @Override diff --git a/test/jalview/io/BackupFilesTest.java b/test/jalview/io/BackupFilesTest.java index f15716b..a78936e 100644 --- a/test/jalview/io/BackupFilesTest.java +++ b/test/jalview/io/BackupFilesTest.java @@ -19,7 +19,7 @@ import java.util.HashMap; import java.util.List; import java.util.TreeMap; -import org.junit.Assert; +import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test;