diff --git a/customize/nameSequences.properties b/customize/nameSequences.properties new file mode 100644 index 00000000..71815ed6 --- /dev/null +++ b/customize/nameSequences.properties @@ -0,0 +1,6 @@ +RomRaider = +Profile = +Logger = +EcuFlashBase = 0) { + String fileType = "RomRaider"; + boolean breakSearch = false; + try { + final Scanner scan = new Scanner(f); + // Scan the file looking for invalid string sequences, + // the value of a properties file key. + while(scan.hasNext()) { + breakSearch = false; + final String line = scan.nextLine().toLowerCase().toString(); + for (Object key : props.keySet()) { + if (line.contains(props.getProperty((String) key))) { + fileType = (String) key; + breakSearch = true; + break; + } + } + if (breakSearch) break; + } + scan.close(); + + } catch (FileNotFoundException e) { + // Since the user selected it, it should be found. + e.printStackTrace(); + } + if (!fileType.equalsIgnoreCase("RomRaider")) { + JOptionPane.showMessageDialog(this, MessageFormat.format( + rb.getString("INVALIDMSG"), fileType, f.getName()), + rb.getString("INVALIDFILE"), + JOptionPane.WARNING_MESSAGE); + continue; + } + } + fileNames.add(f.getAbsolutePath()); + + settings.setLastDefinitionDir(f.getParentFile()); + } updateListModel(); } @@ -294,4 +341,28 @@ public class DefinitionManager extends javax.swing.JFrame implements ActionListe private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables + /** + * Load String search sequences from a user customized properties file. + * The file will populate a search list if it is present. + * String search Sequences in the file are in type=sequence sets. + * @exception FileNotFoundException if the directory or file is not present + * @exception IOException if there's some kind of IO error + */ + private Properties loadSequences() { + final Properties sequences = new Properties(); + try { + final FileInputStream propFile = new FileInputStream("./customize/nameSequences.properties"); + sequences.load(propFile); + propFile.close(); + } catch (FileNotFoundException e) { + JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), + "FileNotFoundException", + JOptionPane.ERROR_MESSAGE); + } catch (IOException e) { + JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), + "IOException", + JOptionPane.ERROR_MESSAGE); + } + return sequences; + } }