files = getProjectFiles();
- for (String filename: files) {
+ for (String filename : files) {
FileOption fileOption = project.getFileOption(filename);
if (fileOption.getContainer().equals(containerName)) {
fileOption.setContainer("");
@@ -339,23 +468,41 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
}
}
+ /**
+ * {@inheritDoc}
+ *
+ * Updates the file list.
+ */
public void fileScannerFinished(FileScanner fileScanner) {
final boolean error = fileScanner.isError();
if (!error) {
final List files = fileScanner.getFiles();
SwingUtilities.invokeLater(new Runnable() {
+ @SuppressWarnings("synthetic-access")
public void run() {
projectFileList.setListData(files.toArray(new String[files.size()]));
projectFileList.clearSelection();
rebuildContainerComboBox();
}
});
+ Set entriesToRemove = new HashSet();
+ Iterator filenames = project.getFileOptions().keySet().iterator();
+ while (filenames.hasNext()) {
+ String filename = filenames.next();
+ if (!files.contains(filename)) {
+ entriesToRemove.add(filename);
+ }
+ }
+ for (String filename : entriesToRemove) {
+ project.setFileOption(filename, null);
+ }
} else {
JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.scan-error"), null, JOptionPane.ERROR_MESSAGE);
}
SwingUtilities.invokeLater(new Runnable() {
+ @SuppressWarnings("synthetic-access")
public void run() {
wizard.setPreviousEnabled(true);
wizard.setNextEnabled(!error);
@@ -434,7 +581,7 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
addContainerAction.setEnabled(enabled);
editContainerAction.setEnabled(enabled);
deleteContainerAction.setEnabled(enabled);
- replacementCheckBox.setEnabled(enabled && insert && (project instanceof EditionProject));
+ replacementCheckBox.setEnabled(enabled && insert);
if (filename != null) {
FileOption fileOption = project.getFileOption(filename);
defaultFileCheckBox.setSelected(filename.equals(project.getIndexFile()));
@@ -460,16 +607,25 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
// INTERFACE DocumentListener
//
+ /**
+ * Updates the options of the currently selected file with the changes made
+ * in the âcustom keyâ textfield.
+ *
+ * @param documentEvent
+ * The document event to process
+ */
private void processDocumentUpdate(DocumentEvent documentEvent) {
String filename = (String) projectFileList.getSelectedValue();
- if (filename == null)
+ if (filename == null) {
return;
+ }
FileOption fileOption = project.getFileOption(filename);
Document document = documentEvent.getDocument();
try {
String text = document.getText(0, document.getLength());
fileOption.setCustomKey(text);
} catch (BadLocationException ble1) {
+ /* ignore. */
}
}
@@ -503,8 +659,9 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
*/
public void stateChanged(ChangeEvent changeEvent) {
String filename = (String) projectFileList.getSelectedValue();
- if (filename == null)
+ if (filename == null) {
return;
+ }
FileOption fileOption = project.getFileOption(filename);
Object source = changeEvent.getSource();
if (source instanceof JSpinner) {