/** The default changed name. */
private static final String DEFAULT_CHANGED_NAME = null;
- /** The default container. */
- private static final String DEFAULT_CONTAINER = "";
-
- /** The default edition range. */
- private static final int DEFAULT_EDITION_RANGE = 3;
-
- /** The default for the replace edition state. */
- private static final boolean DEFAULT_REPLACE_EDITION = false;
-
/** The insert state. */
private boolean insert;
/** The current MIME type. */
private String mimeType;
- /** The container. */
- private String container;
-
- /** The edition range. */
- private int editionRange;
-
- /** The replace edition state. */
- private boolean replaceEdition;
-
/**
* Creates new file options.
*
changedName = DEFAULT_CHANGED_NAME;
this.defaultMimeType = defaultMimeType;
mimeType = defaultMimeType;
- container = DEFAULT_CONTAINER;
- editionRange = DEFAULT_EDITION_RANGE;
- replaceEdition = DEFAULT_REPLACE_EDITION;
}
/**
}
/**
- * Returns the name of the container this file should be put in.
- *
- * @return The name of the container
- */
- public String getContainer() {
- return container;
- }
-
- /**
- * Sets the name of the container this file should be put in.
- *
- * @param container
- * The name of the container
- */
- public void setContainer(String container) {
- if (container == null) {
- this.container = DEFAULT_CONTAINER;
- } else {
- this.container = container;
- }
- }
-
- /**
- * Sets whether the file should have “$[EDITION+<i>n</i>]” tags replaced.
- *
- * @param replaceEdition
- * <code>true</code> to replace tags, <code>false</code> not to
- * replace
- */
- public void setReplaceEdition(boolean replaceEdition) {
- this.replaceEdition = replaceEdition;
- }
-
- /**
- * Returns whether the file should have “$[EDITION+<i>n</i>]” tags replaced.
- *
- * @return <code>true</code> if tags should be replaced, <code>false</code>
- * otherwise
- */
- public boolean getReplaceEdition() {
- return replaceEdition;
- }
-
- /**
- * Sets the range of editions that should be replaced.
- *
- * @param editionRange
- * The range editions to replace
- */
- public void setEditionRange(int editionRange) {
- this.editionRange = editionRange;
- }
-
- /**
- * Returns the range of editions that should be replaced.
- *
- * @return The range of editions to replace
- */
- public int getEditionRange() {
- return editionRange;
- }
-
- /**
* Returns whether the options for this file have been modified, i.e. are
* not at their default values.
*
if (!defaultMimeType.equals(mimeType)) {
return true;
}
- if (!DEFAULT_CONTAINER.equals(container)) {
- return true;
- }
- if (replaceEdition != DEFAULT_REPLACE_EDITION) {
- return true;
- }
- if (editionRange != DEFAULT_EDITION_RANGE) {
- return true;
- }
if (insertRedirect != DEFAULT_INSERT_REDIRECT) {
return true;
}
package de.todesbaum.jsite.application;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
import de.todesbaum.jsite.gui.FileScanner;
import de.todesbaum.jsite.gui.FileScannerListener;
import de.todesbaum.util.freenet.fcp2.Message;
import de.todesbaum.util.freenet.fcp2.RedirectFileEntry;
import de.todesbaum.util.freenet.fcp2.Verbosity;
-import de.todesbaum.util.io.Closer;
-import de.todesbaum.util.io.ReplacingOutputStream;
-import de.todesbaum.util.io.StreamCopier;
import de.todesbaum.util.io.StreamCopier.ProgressListener;
/**
private InputStream createFileInputStream(String filename, FileOption fileOption, int edition, long[] length) throws IOException {
File file = new File(project.getLocalPath(), filename);
length[0] = file.length();
- if (!fileOption.getReplaceEdition()) {
- return new FileInputStream(file);
- }
- ByteArrayOutputStream filteredByteOutputStream = new ByteArrayOutputStream(Math.min(Integer.MAX_VALUE, (int) length[0]));
- ReplacingOutputStream outputStream = new ReplacingOutputStream(filteredByteOutputStream);
- FileInputStream fileInput = new FileInputStream(file);
- try {
- outputStream.addReplacement("$[EDITION]", String.valueOf(edition));
- outputStream.addReplacement("$[URI]", project.getFinalRequestURI(0));
- for (int index = 1; index <= fileOption.getEditionRange(); index++) {
- outputStream.addReplacement("$[URI+" + index + "]", project.getFinalRequestURI(index));
- outputStream.addReplacement("$[EDITION+" + index + "]", String.valueOf(edition + index));
- }
- StreamCopier.copy(fileInput, outputStream, length[0]);
- } finally {
- Closer.close(fileInput);
- Closer.close(outputStream);
- Closer.close(filteredByteOutputStream);
- }
- byte[] filteredBytes = filteredByteOutputStream.toByteArray();
- length[0] = filteredBytes.length;
- return new ByteArrayInputStream(filteredBytes);
- }
-
- /**
- * Creates an input stream for a container.
- *
- * @param containerFiles
- * All container definitions
- * @param containerName
- * The name of the container to create
- * @param edition
- * The current edition
- * @param containerLength
- * An array containing a single long which is used to
- * <em>return</em> the final length of the container stream,
- * after all replacements
- * @return The input stream for the container
- * @throws IOException
- * if an I/O error occurs
- */
- private InputStream createContainerInputStream(Map<String, List<String>> containerFiles, String containerName, int edition, long[] containerLength) throws IOException {
- File tempFile = File.createTempFile("jsite", ".zip", (tempDirectory == null) ? null : new File(tempDirectory));
- tempFile.deleteOnExit();
- FileOutputStream fileOutputStream = new FileOutputStream(tempFile);
- ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream);
- try {
- for (String filename : containerFiles.get(containerName)) {
- File dataFile = new File(project.getLocalPath(), filename);
- if (dataFile.exists()) {
- ZipEntry zipEntry = new ZipEntry(filename);
- long[] fileLength = new long[1];
- InputStream wrappedInputStream = createFileInputStream(filename, project.getFileOption(filename), edition, fileLength);
- try {
- zipOutputStream.putNextEntry(zipEntry);
- StreamCopier.copy(wrappedInputStream, zipOutputStream, fileLength[0]);
- } finally {
- zipOutputStream.closeEntry();
- wrappedInputStream.close();
- }
- }
- }
- } finally {
- zipOutputStream.closeEntry();
- Closer.close(zipOutputStream);
- Closer.close(fileOutputStream);
- }
-
- containerLength[0] = tempFile.length();
- return new FileInputStream(tempFile);
+ return new FileInputStream(file);
}
/**
private FileEntry createFileEntry(String filename, int edition, Map<String, List<String>> containerFiles) {
FileEntry fileEntry = null;
FileOption fileOption = project.getFileOption(filename);
- if (filename.startsWith("/container/:")) {
- String containerName = filename.substring("/container/:".length());
try {
long[] containerLength = new long[1];
InputStream containerInputStream = createContainerInputStream(containerFiles, containerName, edition, containerLength);
}
/**
- * Creates container definitions.
- *
- * @param files
- * The list of all files
- * @param containers
- * The list of all containers
- * @param containerFiles
- * Empty map that will be filled with container definitions
- */
- private void createContainers(List<String> files, List<String> containers, Map<String, List<String>> containerFiles) {
- for (String filename : new ArrayList<String>(files)) {
- FileOption fileOption = project.getFileOption(filename);
- String containerName = fileOption.getContainer();
- if (!containerName.equals("")) {
- if (!containers.contains(containerName)) {
- containers.add(containerName);
- containerFiles.put(containerName, new ArrayList<String>());
- /* hmm. looks like a hack to me. */
- files.add("/container/:" + containerName);
- }
- containerFiles.get(containerName).add(filename);
- files.remove(filename);
- }
- }
- }
-
- /**
* Validates the given project. The project will be checked for any invalid
* conditions, such as invalid insert or request keys, missing path names,
* missing default file, and so on.
}
String indexFile = project.getIndexFile();
boolean hasIndexFile = (indexFile != null) && (indexFile.length() > 0);
- if (hasIndexFile && !project.getFileOption(indexFile).getContainer().equals("")) {
- checkReport.addIssue("warning.container-index", false);
- }
List<String> allowedIndexContentTypes = Arrays.asList("text/html", "application/xhtml+xml");
if (hasIndexFile && !allowedIndexContentTypes.contains(project.getFileOption(indexFile).getMimeType())) {
checkReport.addIssue("warning.index-not-html", false);
Client client = new Client(connection);
- /* create containers */
- final List<String> containers = new ArrayList<String>();
- final Map<String, List<String>> containerFiles = new HashMap<String, List<String>>();
- createContainers(files, containers, containerFiles);
-
/* collect files */
int edition = project.getEdition();
String dirURI = "USK@" + project.getInsertURI() + "/" + project.getPath() + "/" + edition + "/";
import java.awt.BorderLayout;
import java.awt.Dimension;
-import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.KeyEvent;
import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.Action;
-import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
-import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;
-import javax.swing.border.EmptyBorder;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
*
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
-public class ProjectFilesPage extends TWizardPage implements ActionListener, ListSelectionListener, DocumentListener, FileScannerListener, ChangeListener {
+public class ProjectFilesPage extends TWizardPage implements ActionListener, ListSelectionListener, DocumentListener, FileScannerListener {
/** The project. */
private Project project;
/** The “scan files” action. */
private Action scanAction;
- /** The “edit container” action. */
- private Action editContainerAction;
-
- /** The “add container” action. */
- private Action addContainerAction;
-
- /** The “delete container” action. */
- protected Action deleteContainerAction;
-
/** The “ignore hidden files” checkbox. */
private JCheckBox ignoreHiddenFilesCheckBox;
/** The “mime type” combo box. */
private JComboBox fileOptionsMIMETypeComboBox;
- /** The “mime type” combo box model. */
- private DefaultComboBoxModel containerComboBoxModel;
-
- /** The “container” combo box. */
- private JComboBox fileOptionsContainerComboBox;
-
- /** The “edition replacement range” spinner. */
- private JSpinner replaceEditionRangeSpinner;
-
- /** The “replacement” check box. */
- private JCheckBox replacementCheckBox;
-
/**
* Creates a new project file page.
*
scanAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_S);
scanAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.rescan.tooltip"));
- addContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.add-container")) {
-
- @SuppressWarnings("synthetic-access")
- public void actionPerformed(ActionEvent actionEvent) {
- actionAddContainer();
- }
- };
- addContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.add-container.tooltip"));
- addContainerAction.setEnabled(false);
-
- editContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.edit-container")) {
-
- @SuppressWarnings("synthetic-access")
- public void actionPerformed(ActionEvent actionEvent) {
- actionEditContainer();
- }
- };
- editContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.edit-container.tooltip"));
- editContainerAction.setEnabled(false);
-
- deleteContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.delete-container")) {
-
- @SuppressWarnings("synthetic-access")
- public void actionPerformed(ActionEvent actionEvent) {
- actionDeleteContainer();
- }
- };
- deleteContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.delete-container.tooltip"));
- deleteContainerAction.setEnabled(false);
-
I18nContainer.getInstance().registerRunnable(new Runnable() {
@SuppressWarnings("synthetic-access")
public void run() {
scanAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.rescan"));
scanAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.rescan.tooltip"));
- addContainerAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.add-container"));
- addContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.add-container.tooltip"));
- editContainerAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.edit-container"));
- editContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.edit-container.tooltip"));
- deleteContainerAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.delete-container"));
- deleteContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.delete-container.tooltip"));
}
});
}
fileOptionsPanel.add(mimeTypeLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
fileOptionsPanel.add(fileOptionsMIMETypeComboBox, new GridBagConstraints(1, 7, 4, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
- containerComboBoxModel = new DefaultComboBoxModel();
- fileOptionsContainerComboBox = new JComboBox(containerComboBoxModel);
- fileOptionsContainerComboBox.setToolTipText(I18n.getMessage("jsite.project-files.container.tooltip"));
- fileOptionsContainerComboBox.setName("project-files.container");
- fileOptionsContainerComboBox.addActionListener(this);
- fileOptionsContainerComboBox.setEnabled(false);
- fileOptionsContainerComboBox.setVisible(false);
-
- final TLabel containerLabel = new TLabel(I18n.getMessage("jsite.project-files.container") + ":", KeyEvent.VK_C, fileOptionsContainerComboBox);
- containerLabel.setVisible(false);
- JButton addContainerButton = new JButton(addContainerAction);
- addContainerButton.setVisible(false);
- JButton editContainerButton = new JButton(editContainerAction);
- editContainerButton.setVisible(false);
- JButton deleteContainerButton = new JButton(deleteContainerAction);
- deleteContainerButton.setVisible(false);
- fileOptionsPanel.add(containerLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
- fileOptionsPanel.add(fileOptionsContainerComboBox, new GridBagConstraints(1, 8, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
- fileOptionsPanel.add(addContainerButton, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
- fileOptionsPanel.add(editContainerButton, new GridBagConstraints(3, 8, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
- fileOptionsPanel.add(deleteContainerButton, new GridBagConstraints(4, 8, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
-
- JPanel fileOptionsReplacementPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 6, 6));
- fileOptionsReplacementPanel.setBorder(new EmptyBorder(-6, -6, -6, -6));
-
- replacementCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.replacement"));
- replacementCheckBox.setName("project-files.replace-edition");
- replacementCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.replacement.tooltip"));
- replacementCheckBox.addActionListener(this);
- replacementCheckBox.setEnabled(false);
- replacementCheckBox.setVisible(false);
- fileOptionsReplacementPanel.add(replacementCheckBox);
-
- replaceEditionRangeSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));
- replaceEditionRangeSpinner.setName("project-files.replace-edition-range");
- replaceEditionRangeSpinner.setToolTipText(I18n.getMessage("jsite.project-files.replacement.edition-range.tooltip"));
- replaceEditionRangeSpinner.addChangeListener(this);
- replaceEditionRangeSpinner.setEnabled(false);
- replaceEditionRangeSpinner.setVisible(false);
- final JLabel editionRangeLabel = new JLabel(I18n.getMessage("jsite.project-files.replacement.edition-range"));
- editionRangeLabel.setVisible(false);
- fileOptionsReplacementPanel.add(editionRangeLabel);
- fileOptionsReplacementPanel.add(replaceEditionRangeSpinner);
-
- fileOptionsPanel.add(fileOptionsReplacementPanel, new GridBagConstraints(0, 9, 5, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 18, 0, 0), 0, 0));
-
I18nContainer.getInstance().registerRunnable(new Runnable() {
@SuppressWarnings("synthetic-access")
fileOptionsRenameCheckBox.setToolTipText("jsite.project-files.rename.tooltip");
fileOptionsMIMETypeComboBox.setToolTipText(I18n.getMessage("jsite.project-files.mime-type.tooltip"));
mimeTypeLabel.setText(I18n.getMessage("jsite.project-files.mime-type") + ":");
- fileOptionsContainerComboBox.setToolTipText(I18n.getMessage("jsite.project-files.container.tooltip"));
- containerLabel.setText(I18n.getMessage("jsite.project-files.container") + ":");
- replacementCheckBox.setText(I18n.getMessage("jsite.project-files.replacement"));
- replacementCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.replacement.tooltip"));
- replaceEditionRangeSpinner.setToolTipText(I18n.getMessage("jsite.project-files.replacement.edition-range.tooltip"));
- editionRangeLabel.setText(I18n.getMessage("jsite.project-files.replacement.edition-range"));
}
});
return files;
}
- /**
- * Updates the container combo box model.
- */
- private void rebuildContainerComboBox() {
- /* scan files for containers */
- List<String> files = getProjectFiles();
- List<String> containers = new ArrayList<String>(); // ComboBoxModel
- // sucks. No
- // contains()!
- containers.add("");
- for (String filename : files) {
- String container = project.getFileOption(filename).getContainer();
- if (!containers.contains(container)) {
- containers.add(container);
- }
- }
- Collections.sort(containers);
- containerComboBoxModel.removeAllElements();
- for (String container : containers) {
- containerComboBoxModel.addElement(container);
- }
- }
-
//
// ACTIONS
//
}
/**
- * 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) {
- return;
- }
- containerName = containerName.trim();
- String filename = (String) projectFileList.getSelectedValue();
- FileOption fileOption = project.getFileOption(filename);
- fileOption.setContainer(containerName);
- rebuildContainerComboBox();
- fileOptionsContainerComboBox.setSelectedItem(containerName);
- }
-
- /**
- * Edits the container.
- */
- private void actionEditContainer() {
- String selectedFilename = (String) projectFileList.getSelectedValue();
- FileOption fileOption = project.getFileOption(selectedFilename);
- String oldContainerName = fileOption.getContainer();
- String containerName = JOptionPane.showInputDialog(wizard, I18n.getMessage("jsite.project-files.action.edit-container.message") + ":", oldContainerName);
- if (containerName == null) {
- return;
- }
- if (containerName.equals("")) {
- fileOption.setContainer("");
- fileOptionsContainerComboBox.setSelectedItem("");
- return;
- }
- List<String> files = getProjectFiles();
- for (String filename : files) {
- fileOption = project.getFileOption(filename);
- if (fileOption.getContainer().equals(oldContainerName)) {
- fileOption.setContainer(containerName);
- }
- }
- rebuildContainerComboBox();
- 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();
- List<String> files = getProjectFiles();
- for (String filename : files) {
- FileOption fileOption = project.getFileOption(filename);
- if (fileOption.getContainer().equals(containerName)) {
- fileOption.setContainer("");
- }
- }
- fileOptionsContainerComboBox.setSelectedItem("");
- }
- }
-
- /**
* {@inheritDoc}
* <p>
* Updates the file list.
public void run() {
projectFileList.setListData(files.toArray(new String[files.size()]));
projectFileList.clearSelection();
- rebuildContainerComboBox();
}
});
Set<String> entriesToRemove = new HashSet<String>();
} else if ("insert".equals(checkBox.getName())) {
boolean isInsert = checkBox.isSelected();
fileOption.setInsert(isInsert);
- if (!isInsert) {
- fileOptionsContainerComboBox.setSelectedItem("");
- }
fileOptionsInsertRedirectCheckBox.setEnabled(!isInsert);
} else if ("insert-redirect".equals(checkBox.getName())) {
boolean isInsertRedirect = checkBox.isSelected();
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);
- replaceEditionRangeSpinner.setEnabled(replaceEdition);
}
} 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);
- }
}
}
}
fileOptionsInsertCheckBox.setEnabled(enabled);
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()));
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);
fileOptionsRenameTextField.setEnabled(false);
fileOptionsRenameTextField.setText("");
fileOptionsMIMETypeComboBox.getModel().setSelectedItem(DefaultMIMETypes.DEFAULT_MIME_TYPE);
- fileOptionsContainerComboBox.setSelectedItem("");
- replacementCheckBox.setSelected(false);
- replaceEditionRangeSpinner.setValue(0);
}
}
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());
- }
- }
-
}
jsite.project-files.description=<html>On this page you can specify parameters for the files within the project, such as<br>externally generated keys or MIME types, if the automatic detection failed.</html>
jsite.project-files.action.rescan=Re-scan
jsite.project-files.action.rescan.tooltip=Re-scan the project directory for new files
-jsite.project-files.action.add-container=Add
-jsite.project-files.action.add-container.tooltip=Adds a new container to the project and this file to it
-jsite.project-files.action.add-container.message=Enter the name of the new container
-jsite.project-files.action.edit-container=Edit
-jsite.project-files.action.edit-container.tooltip=Changes the name of the container
-jsite.project-files.action.edit-container.message=Enter the new name of the container
-jsite.project-files.action.delete-container=Delete
-jsite.project-files.action.delete-container.tooltip=Deletes this container
-jsite.project-files.action.delete-container.message=Do you really want to delete this container?
jsite.project-files.ignore-hidden-files=Ignore hidden files
jsite.project-files.ignore-hidden-files.tooltip=When selected, hidden files are not inserted
jsite.project-files.file-options=File Options
jsite.project-files.mime-type.tooltip=Select the correct MIME type here if the detection failed
jsite.project-files.container=Container
jsite.project-files.container.tooltip=Selects a container for the current file
-jsite.project-files.replacement=Replacements
-jsite.project-files.replacement.tooltip=Activates replacements in file
-jsite.project-files.replacement.edition-range=Range
-jsite.project-files.replacement.edition-range.tooltip=Also replace $[EDITION+1], $[EDITION+2]\u2026
jsite.project-files.scan-error=<html><b>Error scanning files</b><br><br>Either the directory of the project does not exist<br>or some files/directories in it are not accessible.<br>Please go back and select the correct directory.</html>
jsite.project-files.insert-now=Insert now
jsite.project-files.invalid-default-file=Only files in the root directory may be selected as default files.
jsite.key-dialog.label.actions=<html><b>Actions</b></html>
jsite.warning.empty-index=<html><b>No default file</b><br><br>You did not specify a default file for this project.<br>While it is possible to insert a project without a default<br>file you should specify one to ease browsing.</html>
-jsite.warning.container-index=<html><b>Default file in container</b><br><br>Your default file was placed in a container!<br>This might make other people shun your page.</html>
jsite.warning.index-not-html=<html><b>Default file is not HTML</b><br><br>Your default file does not have the MIME type "text/html"!<br>Loading your Freesite in a browser may give unexpected results.</html>
jsite.error.no-node-selected=<html><b>No node selected</b><br><br>Please select a node from the menu!</html>
jsite.project-files.description=<html>Auf dieser Seite k\u00f6nnen Parameter f\u00fcr die einzelnen Dateien dieses Projekts angegeben werden, z.B.<br>extern erstellte Schl\u00fcssel oder der korrekte MIME-Typ, wenn er nicht automatisch richtig erkannt wurde.</html>
jsite.project-files.action.rescan=Erneut einlesen
jsite.project-files.action.rescan.tooltip=Die Liste mit Dateien dieses Projekts neu einlesen
-jsite.project-files.action.add-container=Hinzuf\u00fcgen
-jsite.project-files.action.add-container.tooltip=Erzeugt einen neuen Container und f\u00fcgt diese Datei hinzu
-jsite.project-files.action.add-container.message=Bitte geben Sie den Namen des neuen Containers an
-jsite.project-files.action.edit-container=\u00c4ndern
-jsite.project-files.action.edit-container.tooltip=\u00c4ndert den Namen des Containers
-jsite.project-files.action.edit-container.message=Bitte geben Sie den neuen Namen des Containers an
-jsite.project-files.action.delete-container=L\u00f6schen
-jsite.project-files.action.delete-container.tooltip=L\u00f6scht diesen Container
-jsite.project-files.action.delete-container.message=Wollen Sie diesen Container wirklich l\u00f6schen?
jsite.project-files.ignore-hidden-files=Versteckte Dateien ignorieren
jsite.project-files.ignore-hidden-files.tooltip=Verhindert, dass versteckte Dateien hochgeladen werden
jsite.project-files.file-options=Dateioptionen
jsite.project-files.mime-type.tooltip=Den richtigen MIME-Typ hier ausw\u00e4hlen, wenn die automatische Erkennenung falsch ist
jsite.project-files.container=Container
jsite.project-files.container.tooltip=W\u00e4hlt einen Container f\u00fcr diese Datei aus
-jsite.project-files.replacement=Ersetzungen
-jsite.project-files.replacement.tooltip=Aktiviert Ersetzungen in Datei
-jsite.project-files.replacement.edition-range=Reichweite
-jsite.project-files.replacement.edition-range.tooltip=Ersetzt auch $[EDITION+1], $[EDITION+2], usw.
jsite.project-files.scan-error=<html><b>Fehler beim Einlesen der Dateien</b><br><br>Entweder existiert das Projektverzeichnis nicht,<br>oder einige Dateien und/oder Verzeichnisse sind nicht lesbar!<br>Bitte gehen Sie zur\u00fcck und beheben Sie den Fehler!</html>
jsite.project-files.insert-now=Jetzt einf\u00fcgen
jsite.project-files.invalid-default-file=Nur Dateien im obersten Verzeichnis d\u00fcrfen als Index-Dateien ausgew\u00e4hlt werden.
jsite.key-dialog.label.actions=<html><b>Aktionen</b></html>
jsite.warning.empty-index=<html><b>Keine Index-Datei gew\u00e4hlt</b><br><br>Sie haben keine Index-Datei f\u00fcr das Projekt angegeben.<br>Obwohl es m\u00f6glich ist, das zu machen, sollten Sie doch<br>eine Index-Datei angeben, um das Browsen zu erleichtern.</html>
-jsite.warning.container-index=<html><b>Index-Datei in Container</b><br><br>Ihre Index-Datei befindet sich in einem Container! Das kann<br>dazu f\u00fchren, dass Ihre Freesite von anderen Leuten gemieden wird.</html>
jsite.warning.index-not-html=<html><b>Index-Datei ist kein HTML</b><br><br>Ihre Index-Datei hat nicht den MIME-Typ "text/html"!<br>Das kann beim Besuch Ihrer Freesite zu<br>unerwarteten Ergebnissen f\u00fchren.</html>
jsite.error.no-node-selected=<html><b>Kein Node ausgew\u00e4hlt</b><br><br>Bitte w\u00e4hlen Sie einen Node aus dem Men\u00fc!</html>
jsite.project-files.description=<html>Dans cette page vous pouvez sp\u00e9cifier les informations concernant la configuration des noeuds telles que:<br>Le type de contenu mime si l'auto d\u00e9tection \u00e0 \u00e9chou\u00e9e.</html>
jsite.project-files.action.rescan=Re-scan
jsite.project-files.action.rescan.tooltip=V\u00e9rifier la pr\u00e9sence de nouveau fichiers
-jsite.project-files.action.add-container=Ajouter
-jsite.project-files.action.add-container.tooltip=Ajouter un nouveau container au projet
-jsite.project-files.action.add-container.message=Entrez le nom du container
-jsite.project-files.action.edit-container=Editer
-jsite.project-files.action.edit-container.tooltip=Changer le nom du container
-jsite.project-files.action.edit-container.message=Entrez le nouveau nom du container
-jsite.project-files.action.delete-container=Supprimer
-jsite.project-files.action.delete-container.tooltip=Supprimer ce container.
-jsite.project-files.action.delete-container.message=Voulez vous r\u00e9ellement supprimer ce container?
jsite.project-files.ignore-hidden-files=Ignorer les fichiers cach\u00e9s
jsite.project-files.ignore-hidden-files.tooltip=Si s\u00e9lectionn\u00e9, les fichiers cach\u00e9s ne sont pas ins\u00e9r\u00e9s
jsite.project-files.file-options=Option des fichiers
jsite.project-files.mime-type.tooltip=S\u00e9lectionez le type MIME du fichier si la d\u00e9tection \u00e0 \u00e9chou\u00e9e
jsite.project-files.container=Container
jsite.project-files.container.tooltip=S\u00e9lectionnez un container pour le fichier
-jsite.project-files.replacement=Remplacer
-jsite.project-files.replacement.tooltip=Activer les remplacements
-jsite.project-files.replacement.edition-range=Plage
-jsite.project-files.replacement.edition-range.tooltip=Remplacer de $[EDITION+1] \u00e0 $[EDITION+2]
jsite.project-files.scan-error=<html><b>Erreur lors du parcours des fichiers</b><br><br>Soit le r\u00e9pertoire du projet n'existe pas,<br>ou des fichiers/r\u00e9pertoires sont inaccessibles.<br>Veuillez revenir en arri\u00e8re et s\u00e9lectionner un autre r\u00e9pertoire.</html>
jsite.project-files.insert-now=Ins\u00e9rer
jsite.key-dialog.label.actions=<html><b>Actions</b></html>
jsite.warning.empty-index=<html><b>Pas de fichier par d\u00e9faut</b><br><br>Avez vous sp\u00e9cifi\u00e9 un fichier par d\u00e9faut pour le projet?<br>M\u00eame s'il est possible de ne pas en sp\u00e9cifier, c'est g\u00e9n\u00e9ralement une mauvaise id\u00e9e.</html>
-jsite.warning.container-index=<html><b>Fichier principal du container</b><br><br>Votre fichier par d\u00e9faut \u00e0 \u00e9t\u00e9 plac\u00e9 dans un container!<br>Ceci peut avoir pour effet de cacher cette page aux utilisateurs.</html>
jsite.warning.index-not-html=<html><b>Le fichier principal n'est pas un fichier HTML!</b><br><br>Votre fichier par d\u00e9faut n'est pas du type MIME "text/html"!<br>Chargez ce type de fichiers dans un navigateur peut \u00eatre dangereux.</html>
jsite.error.no-node-selected=<html><b>Pas de noeud s\u00e9lectionn\u00e9</b><br><br>S\u00e9lectionnez un noeud dans le menu!</html>
fileOption.setChangedName(fileOptionNode.getNode("changed-name").getValue());
}
fileOption.setMimeType(fileOptionNode.getNode("mime-type").getValue(""));
- fileOption.setContainer(fileOptionNode.getNode("container").getValue());
- if (fileOptionNode.getNode("replace-edition") != null) {
- fileOption.setReplaceEdition(Boolean.parseBoolean(fileOptionNode.getNode("replace-edition").getValue()));
- fileOption.setEditionRange(Integer.parseInt(fileOptionNode.getNode("edition-range").getValue()));
- }
fileOptions.put(filename, fileOption);
}
}
fileOptionNode.append("custom-key", fileOption.getCustomKey());
fileOptionNode.append("changed-name", fileOption.getChangedName());
fileOptionNode.append("mime-type", fileOption.getMimeType());
- fileOptionNode.append("container", fileOption.getContainer());
- fileOptionNode.append("replace-edition", String.valueOf(fileOption.getReplaceEdition()));
- fileOptionNode.append("edition-range", String.valueOf(fileOption.getEditionRange()));
}
}
}
+++ /dev/null
-/*
- * todesbaum-lib -
- * Copyright (C) 2006 David Roden
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-package de.todesbaum.util.io;
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-
-/**
- * @author David Roden <droden@gmail.com>
- * @version $Id$
- */
-public class ReplacingOutputStream extends FilterOutputStream {
-
- private Map<String, String> replacements = new HashMap<String, String>();
- private StringBuffer ringBuffer = new StringBuffer();
-
- /**
- * @param out
- */
- public ReplacingOutputStream(OutputStream out) {
- super(out);
- }
-
- public void addReplacement(String token, String value) {
- replacements.put(token, value);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void write(int b) throws IOException {
- ringBuffer.append((char) b);
- Iterator<Entry<String, String>> entries = replacements.entrySet().iterator();
- boolean found = false;
- Entry<String, String> entry = null;
- while (!found && entries.hasNext()) {
- entry = entries.next();
- if (entry.getKey().startsWith(ringBuffer.toString())) {
- found = true;
- }
- }
- if (!found) {
- String buffer = ringBuffer.toString();
- for (int index = 0, size = buffer.length(); index < size; index++) {
- super.write(buffer.charAt(index));
- }
- ringBuffer.setLength(0);
- } else {
- if (entry.getKey().equals(ringBuffer.toString())) {
- String buffer = entry.getValue();
- for (int index = 0, size = buffer.length(); index < size; index++) {
- super.write(buffer.charAt(index));
- }
- ringBuffer.setLength(0);
- }
- }
- }
-
-}