files = getProjectFiles();
@@ -332,6 +476,9 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
// ACTIONS
//
+ /**
+ * Rescans the projectâs files.
+ */
private void actionScan() {
projectFileList.clearSelection();
projectFileList.setListData(new Object[0]);
@@ -345,6 +492,9 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
new Thread(fileScanner).start();
}
+ /**
+ * Adds a container.
+ */
private void actionAddContainer() {
String containerName = JOptionPane.showInputDialog(wizard, I18n.getMessage("jsite.project-files.action.add-container.message") + ":", null, JOptionPane.INFORMATION_MESSAGE);
if (containerName == null) {
@@ -358,6 +508,9 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
fileOptionsContainerComboBox.setSelectedItem(containerName);
}
+ /**
+ * Edits the container.
+ */
private void actionEditContainer() {
String selectedFilename = (String) projectFileList.getSelectedValue();
FileOption fileOption = project.getFileOption(selectedFilename);
@@ -382,6 +535,9 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
fileOptionsContainerComboBox.setSelectedItem(containerName);
}
+ /**
+ * Deletes the container.
+ */
private void actionDeleteContainer() {
if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.action.delete-container.message"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
String containerName = (String) fileOptionsContainerComboBox.getSelectedItem();
@@ -396,6 +552,11 @@ 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) {
@@ -410,7 +571,7 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
}
});
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)) {
@@ -434,6 +595,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() {
+ String filename = (String) projectFileList.getSelectedValue();
+ if (filename == null) {
+ return null;
+ }
+ return project.getFileOption(filename);
+ }
+
//
// INTERFACE ActionListener
//
@@ -442,27 +618,47 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
* {@inheritDoc}
*/
public void actionPerformed(ActionEvent actionEvent) {
+ Object source = actionEvent.getSource();
+ if ((source instanceof JCheckBox) && ("ignore-hidden-files".equals(((JCheckBox) source).getName()))) {
+ project.setIgnoreHiddenFiles(((JCheckBox) source).isSelected());
+ actionScan();
+ return;
+ }
String filename = (String) projectFileList.getSelectedValue();
if (filename == null) {
return;
}
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("");
}
+ fileOptionsInsertRedirectCheckBox.setEnabled(!isInsert);
+ } 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 ("project-files.replace-edition".equals(checkBox.getName())) {
boolean replaceEdition = checkBox.isSelected();
fileOption.setReplaceEdition(replaceEdition);
@@ -498,7 +694,7 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
boolean insert = fileOptionsInsertCheckBox.isSelected();
defaultFileCheckBox.setEnabled(enabled);
fileOptionsInsertCheckBox.setEnabled(enabled);
- fileOptionsCustomKeyTextField.setEnabled(enabled && !insert);
+ fileOptionsRenameCheckBox.setEnabled(enabled);
fileOptionsMIMETypeComboBox.setEnabled(enabled);
fileOptionsContainerComboBox.setEnabled(enabled);
addContainerAction.setEnabled(enabled);
@@ -509,7 +705,13 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
FileOption fileOption = project.getFileOption(filename);
defaultFileCheckBox.setSelected(filename.equals(project.getIndexFile()));
fileOptionsInsertCheckBox.setSelected(fileOption.isInsert());
+ 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());
@@ -518,7 +720,14 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
} else {
defaultFileCheckBox.setSelected(false);
fileOptionsInsertCheckBox.setSelected(true);
+ 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);
@@ -530,6 +739,13 @@ 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) {
@@ -541,6 +757,7 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
String text = document.getText(0, document.getLength());
fileOption.setCustomKey(text);
} catch (BadLocationException ble1) {
+ /* ignore. */
}
}