files = getProjectFiles();
- for (String filename : files) {
- FileOption fileOption = project.getFileOption(filename);
- if (fileOption.getContainer().equals(containerName)) {
- fileOption.setContainer("");
- }
- }
- fileOptionsContainerComboBox.setSelectedItem("");
- }
- }
-
- /**
* {@inheritDoc}
*
* Updates the file list.
@@ -476,21 +365,27 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
public void fileScannerFinished(FileScanner fileScanner) {
final boolean error = fileScanner.isError();
if (!error) {
- final List files = fileScanner.getFiles();
+ final List files = fileScanner.getFiles();
SwingUtilities.invokeLater(new Runnable() {
@SuppressWarnings("synthetic-access")
public void run() {
- projectFileList.setListData(files.toArray(new String[files.size()]));
+ projectFileList.setListData(files.toArray());
projectFileList.clearSelection();
- rebuildContainerComboBox();
}
});
Set entriesToRemove = new HashSet();
- Iterator filenames = project.getFileOptions().keySet().iterator();
+ 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);
}
}
@@ -511,6 +406,21 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
});
}
+ /**
+ * Returns the {@link FileOption file options} for the currently selected
+ * file.
+ *
+ * @return The {@link FileOption}s for the selected file, or {@code null} if
+ * no file is selected
+ */
+ private FileOption getSelectedFile() {
+ ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue();
+ if (scannedFile == null) {
+ return null;
+ }
+ return project.getFileOption(scannedFile.getFilename());
+ }
+
//
// INTERFACE ActionListener
//
@@ -519,45 +429,53 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
* {@inheritDoc}
*/
public void actionPerformed(ActionEvent actionEvent) {
- String filename = (String) projectFileList.getSelectedValue();
- if (filename == null) {
+ Object source = actionEvent.getSource();
+ if ((source instanceof JCheckBox) && ("ignore-hidden-files".equals(((JCheckBox) source).getName()))) {
+ project.setIgnoreHiddenFiles(((JCheckBox) source).isSelected());
+ actionScan();
+ return;
+ }
+ ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue();
+ if (scannedFile == null) {
return;
}
+ String filename = scannedFile.getFilename();
FileOption fileOption = project.getFileOption(filename);
- Object source = actionEvent.getSource();
if (source instanceof JCheckBox) {
JCheckBox checkBox = (JCheckBox) source;
if ("default-file".equals(checkBox.getName())) {
if (checkBox.isSelected()) {
- project.setIndexFile(filename);
+ if (filename.indexOf('/') > -1) {
+ JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.invalid-default-file"), null, JOptionPane.ERROR_MESSAGE);
+ checkBox.setSelected(false);
+ } else {
+ project.setIndexFile(filename);
+ }
} else {
- project.setIndexFile(null);
+ if (filename.equals(project.getIndexFile())) {
+ project.setIndexFile(null);
+ }
}
} else if ("insert".equals(checkBox.getName())) {
boolean isInsert = checkBox.isSelected();
- fileOptionsCustomKeyTextField.setEnabled(!isInsert);
fileOption.setInsert(isInsert);
- if (!isInsert) {
- fileOptionsContainerComboBox.setSelectedItem("");
- }
- } else if ("project-files.replace-edition".equals(checkBox.getName())) {
- boolean replaceEdition = checkBox.isSelected();
- fileOption.setReplaceEdition(replaceEdition);
- replaceEditionRangeSpinner.setEnabled(replaceEdition);
+ fileOptionsInsertRedirectCheckBox.setEnabled(!isInsert);
+ } else if ("force-insert".equals(checkBox.getName())) {
+ boolean isForceInsert = checkBox.isSelected();
+ fileOption.setForceInsert(isForceInsert);
+ } else if ("insert-redirect".equals(checkBox.getName())) {
+ boolean isInsertRedirect = checkBox.isSelected();
+ fileOption.setInsertRedirect(isInsertRedirect);
+ fileOptionsCustomKeyTextField.setEnabled(isInsertRedirect);
+ } else if ("rename".equals(checkBox.getName())) {
+ boolean isRenamed = checkBox.isSelected();
+ fileOptionsRenameTextField.setEnabled(isRenamed);
+ fileOption.setChangedName(isRenamed ? fileOptionsRenameTextField.getText() : "");
}
} else if (source instanceof JComboBox) {
JComboBox comboBox = (JComboBox) source;
if ("project-files.mime-type".equals(comboBox.getName())) {
fileOption.setMimeType((String) comboBox.getSelectedItem());
- } else if ("project-files.container".equals(comboBox.getName())) {
- String containerName = (String) comboBox.getSelectedItem();
- fileOption.setContainer(containerName);
- boolean enabled = !"".equals(containerName);
- editContainerAction.setEnabled(enabled);
- deleteContainerAction.setEnabled(enabled);
- if (enabled) {
- fileOptionsInsertCheckBox.setSelected(true);
- }
}
}
}
@@ -569,37 +487,43 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("null")
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);
- fileOptionsCustomKeyTextField.setEnabled(enabled && !insert);
+ fileOptionsRenameCheckBox.setEnabled(enabled);
fileOptionsMIMETypeComboBox.setEnabled(enabled);
- fileOptionsContainerComboBox.setEnabled(enabled);
- addContainerAction.setEnabled(enabled);
- editContainerAction.setEnabled(enabled);
- deleteContainerAction.setEnabled(enabled);
- replacementCheckBox.setEnabled(enabled && insert);
if (filename != null) {
FileOption fileOption = project.getFileOption(filename);
defaultFileCheckBox.setSelected(filename.equals(project.getIndexFile()));
fileOptionsInsertCheckBox.setSelected(fileOption.isInsert());
+ fileOptionsForceInsertCheckBox.setEnabled(scannedFile.getHash().equals(fileOption.getLastInsertHash()));
+ fileOptionsForceInsertCheckBox.setSelected(fileOption.isForceInsert());
+ fileOptionsInsertRedirectCheckBox.setEnabled(!fileOption.isInsert());
+ fileOptionsInsertRedirectCheckBox.setSelected(fileOption.isInsertRedirect());
+ fileOptionsCustomKeyTextField.setEnabled(fileOption.isInsertRedirect());
fileOptionsCustomKeyTextField.setText(fileOption.getCustomKey());
+ fileOptionsRenameCheckBox.setSelected(fileOption.hasChangedName());
+ fileOptionsRenameTextField.setEnabled(fileOption.hasChangedName());
+ fileOptionsRenameTextField.setText(fileOption.getChangedName());
fileOptionsMIMETypeComboBox.getModel().setSelectedItem(fileOption.getMimeType());
- fileOptionsContainerComboBox.setSelectedItem(fileOption.getContainer());
- replacementCheckBox.setSelected(fileOption.getReplaceEdition());
- replaceEditionRangeSpinner.setValue(fileOption.getEditionRange());
- replaceEditionRangeSpinner.setEnabled(fileOption.getReplaceEdition());
} else {
defaultFileCheckBox.setSelected(false);
fileOptionsInsertCheckBox.setSelected(true);
+ fileOptionsForceInsertCheckBox.setEnabled(false);
+ fileOptionsForceInsertCheckBox.setSelected(false);
+ fileOptionsInsertRedirectCheckBox.setEnabled(false);
+ fileOptionsInsertRedirectCheckBox.setSelected(false);
+ fileOptionsCustomKeyTextField.setEnabled(false);
fileOptionsCustomKeyTextField.setText("CHK@");
+ fileOptionsRenameCheckBox.setEnabled(false);
+ fileOptionsRenameCheckBox.setSelected(false);
+ fileOptionsRenameTextField.setEnabled(false);
+ fileOptionsRenameTextField.setText("");
fileOptionsMIMETypeComboBox.getModel().setSelectedItem(DefaultMIMETypes.DEFAULT_MIME_TYPE);
- fileOptionsContainerComboBox.setSelectedItem("");
- replacementCheckBox.setSelected(false);
- replaceEditionRangeSpinner.setValue(0);
}
}
@@ -610,16 +534,16 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
/**
* 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) {
+ 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());
@@ -650,24 +574,4 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
processDocumentUpdate(documentEvent);
}
- //
- // INTERFACE ChangeListener
- //
-
- /**
- * {@inheritDoc}
- */
- public void stateChanged(ChangeEvent changeEvent) {
- String filename = (String) projectFileList.getSelectedValue();
- if (filename == null) {
- return;
- }
- FileOption fileOption = project.getFileOption(filename);
- Object source = changeEvent.getSource();
- if (source instanceof JSpinner) {
- JSpinner spinner = (JSpinner) source;
- fileOption.setEditionRange((Integer) spinner.getValue());
- }
- }
-
}