X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fgui%2FProjectFilesPage.java;h=fcbc3693c06c6156094f1eec567bb15176c51238;hb=a4f3632796dfe5fbdcd1f6b7fd4b386b21808a09;hp=0ca95083a1fe053267a8cf59e16b6acca013d83c;hpb=234d3fd1cdf0595b167e7eb169d106c70483f24b;p=jSite.git diff --git a/src/de/todesbaum/jsite/gui/ProjectFilesPage.java b/src/de/todesbaum/jsite/gui/ProjectFilesPage.java index 0ca9508..fcbc369 100644 --- a/src/de/todesbaum/jsite/gui/ProjectFilesPage.java +++ b/src/de/todesbaum/jsite/gui/ProjectFilesPage.java @@ -27,7 +27,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.text.MessageFormat; -import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -320,19 +319,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis }); } - /** - * Returns a list of all project files. - * - * @return All project files - */ - private List getProjectFiles() { - List files = new ArrayList(); - for (int index = 0, size = projectFileList.getModel().getSize(); index < size; index++) { - files.add((String) projectFileList.getModel().getElementAt(index)); - } - return files; - } - // // ACTIONS // @@ -366,11 +352,7 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis @SuppressWarnings("synthetic-access") public void run() { - String[] filenames = new String[files.size()]; - for (int fileIndex = 0; fileIndex < files.size(); ++fileIndex) { - filenames[fileIndex] = files.get(fileIndex).getFilename(); - } - projectFileList.setListData(filenames); + projectFileList.setListData(files.toArray()); projectFileList.clearSelection(); } }); @@ -378,7 +360,14 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis Iterator filenames = new HashSet(project.getFileOptions().keySet()).iterator(); while (filenames.hasNext()) { String filename = filenames.next(); - if (!files.contains(filename)) { + boolean found = false; + for (ScannedFile scannedFile : files) { + if (scannedFile.getFilename().equals(filename)) { + found = true; + break; + } + } + if (!found) { entriesToRemove.add(filename); } } @@ -407,11 +396,11 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis * no file is selected */ private FileOption getSelectedFile() { - String filename = (String) projectFileList.getSelectedValue(); - if (filename == null) { + ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue(); + if (scannedFile == null) { return null; } - return project.getFileOption(filename); + return project.getFileOption(scannedFile.getFilename()); } // @@ -428,10 +417,11 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis actionScan(); return; } - String filename = (String) projectFileList.getSelectedValue(); - if (filename == null) { + ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue(); + if (scannedFile == null) { return; } + String filename = scannedFile.getFilename(); FileOption fileOption = project.getFileOption(filename); if (source instanceof JCheckBox) { JCheckBox checkBox = (JCheckBox) source; @@ -477,9 +467,9 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis * {@inheritDoc} */ public void valueChanged(ListSelectionEvent e) { - String filename = (String) projectFileList.getSelectedValue(); - boolean enabled = filename != null; - boolean insert = fileOptionsInsertCheckBox.isSelected(); + ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue(); + boolean enabled = scannedFile != null; + String filename = (scannedFile == null) ? null : scannedFile.getFilename(); defaultFileCheckBox.setEnabled(enabled); fileOptionsInsertCheckBox.setEnabled(enabled); fileOptionsRenameCheckBox.setEnabled(enabled); @@ -523,11 +513,11 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis * The document event to process */ private void processDocumentUpdate(DocumentEvent documentEvent) { - String filename = (String) projectFileList.getSelectedValue(); - if (filename == null) { + ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue(); + if (scannedFile == null) { return; } - FileOption fileOption = project.getFileOption(filename); + FileOption fileOption = project.getFileOption(scannedFile.getFilename()); Document document = documentEvent.getDocument(); try { String text = document.getText(0, document.getLength());