From 1e85313efa2b32b8a92f5f51b942134a3325a165 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 22 Jan 2010 22:24:54 +0100 Subject: [PATCH] =?utf8?q?Add=20check=20box=20and=20text=20field=20for=20?= =?utf8?q?=E2=80=9Cchanged=20name=E2=80=9D=20attribute.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/de/todesbaum/jsite/gui/ProjectFilesPage.java | 91 +++++++++++++++++++++--- src/de/todesbaum/jsite/i18n/jSite.properties | 3 + src/de/todesbaum/jsite/i18n/jSite_de.properties | 3 + 3 files changed, 89 insertions(+), 8 deletions(-) diff --git a/src/de/todesbaum/jsite/gui/ProjectFilesPage.java b/src/de/todesbaum/jsite/gui/ProjectFilesPage.java index b2fe3d9..fd9ae2f 100644 --- a/src/de/todesbaum/jsite/gui/ProjectFilesPage.java +++ b/src/de/todesbaum/jsite/gui/ProjectFilesPage.java @@ -112,6 +112,12 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis /** The “custom key” textfield. */ private JTextField fileOptionsCustomKeyTextField; + /** The “rename” check box. */ + private JCheckBox fileOptionsRenameCheckBox; + + /** The “new name” text field. */ + private JTextField fileOptionsRenameTextField; + /** The “mime type” combo box. */ private JComboBox fileOptionsMIMETypeComboBox; @@ -283,6 +289,46 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis fileOptionsPanel.add(customKeyLabel, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 6, 0, 0), 0, 0)); fileOptionsPanel.add(fileOptionsCustomKeyTextField, new GridBagConstraints(2, 5, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); + fileOptionsRenameCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.rename"), false); + fileOptionsRenameCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.rename.tooltip")); + fileOptionsRenameCheckBox.setName("rename"); + fileOptionsRenameCheckBox.setMnemonic(KeyEvent.VK_N); + fileOptionsRenameCheckBox.addActionListener(this); + fileOptionsRenameCheckBox.setEnabled(false); + + fileOptionsRenameTextField = new JTextField(); + fileOptionsRenameTextField.setEnabled(false); + fileOptionsRenameTextField.getDocument().addDocumentListener(new DocumentListener() { + + @SuppressWarnings("synthetic-access") + private void storeText(DocumentEvent documentEvent) { + FileOption fileOption = getSelectedFile(); + Document document = documentEvent.getDocument(); + int documentLength = document.getLength(); + try { + fileOption.setChangedName(document.getText(0, documentLength).trim()); + } catch (BadLocationException ble1) { + /* ignore, it should never happen. */ + } + } + + public void changedUpdate(DocumentEvent documentEvent) { + storeText(documentEvent); + } + + public void insertUpdate(DocumentEvent documentEvent) { + storeText(documentEvent); + } + + public void removeUpdate(DocumentEvent documentEvent) { + storeText(documentEvent); + } + + }); + + fileOptionsPanel.add(fileOptionsRenameCheckBox, new GridBagConstraints(0, 6, 2, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0)); + fileOptionsPanel.add(fileOptionsRenameTextField, new GridBagConstraints(2, 6, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); + fileOptionsMIMETypeComboBox = new JComboBox(DefaultMIMETypes.getAllMIMETypes()); fileOptionsMIMETypeComboBox.setToolTipText(I18n.getMessage("jsite.project-files.mime-type.tooltip")); fileOptionsMIMETypeComboBox.setName("project-files.mime-type"); @@ -291,8 +337,8 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis fileOptionsMIMETypeComboBox.setEnabled(false); final TLabel mimeTypeLabel = new TLabel(I18n.getMessage("jsite.project-files.mime-type") + ":", KeyEvent.VK_M, fileOptionsMIMETypeComboBox); - fileOptionsPanel.add(mimeTypeLabel, new GridBagConstraints(0, 6, 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, 6, 4, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); + 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); @@ -310,11 +356,11 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis editContainerButton.setVisible(false); JButton deleteContainerButton = new JButton(deleteContainerAction); deleteContainerButton.setVisible(false); - fileOptionsPanel.add(containerLabel, 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(fileOptionsContainerComboBox, new GridBagConstraints(1, 7, 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, 7, 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, 7, 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, 7, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); + 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)); @@ -338,7 +384,7 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis fileOptionsReplacementPanel.add(editionRangeLabel); fileOptionsReplacementPanel.add(replaceEditionRangeSpinner); - fileOptionsPanel.add(fileOptionsReplacementPanel, new GridBagConstraints(0, 8, 5, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 18, 0, 0), 0, 0)); + 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() { @@ -355,6 +401,8 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis fileOptionsInsertRedirectCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert-redirect.tooltip")); fileOptionsCustomKeyTextField.setToolTipText(I18n.getMessage("jsite.project-files.custom-key.tooltip")); customKeyLabel.setText(I18n.getMessage("jsite.project-files.custom-key") + ":"); + fileOptionsRenameCheckBox.setText("jsite.project-files.rename"); + 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")); @@ -548,6 +596,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 // @@ -586,6 +649,10 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis 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); @@ -621,6 +688,7 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis boolean insert = fileOptionsInsertCheckBox.isSelected(); defaultFileCheckBox.setEnabled(enabled); fileOptionsInsertCheckBox.setEnabled(enabled); + fileOptionsRenameCheckBox.setEnabled(enabled); fileOptionsMIMETypeComboBox.setEnabled(enabled); fileOptionsContainerComboBox.setEnabled(enabled); addContainerAction.setEnabled(enabled); @@ -635,6 +703,9 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis 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()); @@ -647,6 +718,10 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis 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); diff --git a/src/de/todesbaum/jsite/i18n/jSite.properties b/src/de/todesbaum/jsite/i18n/jSite.properties index db78119..291f30f 100644 --- a/src/de/todesbaum/jsite/i18n/jSite.properties +++ b/src/de/todesbaum/jsite/i18n/jSite.properties @@ -152,6 +152,8 @@ jsite.project-files.insert-redirect=Redirect jsite.project-files.insert-redirect.tooltip=Check if you want to insert a redirect for this file jsite.project-files.custom-key=Custom key jsite.project-files.custom-key.tooltip=The externally created key for the file +jsite.project-files.rename=Rename +jsite.project-files.rename.tooltip=Renames the file in the uploaded site jsite.project-files.mime-type=MIME type jsite.project-files.mime-type.tooltip=Select the correct MIME type here if the detection failed jsite.project-files.container=Container @@ -192,3 +194,4 @@ jsite.error.index-missing=Your default file is missing

A defaul jsite.error.index-not-inserted=Default file not inserted

You have chosen not to insert the default file!
You need to either choose to insert it or select
a different default file! jsite.error.no-custom-key=No custom key for file

You specified not to insert {0}
but failed to enter a key to redirect to! jsite.error.no-files-to-insert=No files to insert

You do not have any files selected for insertion!
Please select at least one file to insert. +jsite.error.duplicate-file=Duplicate file

The file {0} is inserted twice!
Please check your filenames and redirects. diff --git a/src/de/todesbaum/jsite/i18n/jSite_de.properties b/src/de/todesbaum/jsite/i18n/jSite_de.properties index 6c303ff..ee7f2be 100644 --- a/src/de/todesbaum/jsite/i18n/jSite_de.properties +++ b/src/de/todesbaum/jsite/i18n/jSite_de.properties @@ -152,6 +152,8 @@ jsite.project-files.insert-redirect=Umleitung jsite.project-files.insert-redirect.tooltip=F\u00fcgt eine Umleitung ein jsite.project-files.custom-key=Extern erstellter Schl\u00fcssel jsite.project-files.custom-key.tooltip=Der extern erstellte Schl\u00fcssel f\u00fcr diese Datei +jsite.project-files.rename=Umbenennen +jsite.project-files.rename.tooltip=Benennt die Datei in der eingef\u00fcgten Seite um jsite.project-files.mime-type=MIME-Typ jsite.project-files.mime-type.tooltip=Den richtigen MIME-Typ hier ausw\u00e4hlen, wenn die automatische Erkennenung falsch ist jsite.project-files.container=Container @@ -192,3 +194,4 @@ jsite.error.index-missing=Index-Datei fehlt!

Sie haben eine jsite.error.index-not-inserted=Index-Datei nicht eingef\u00fcgt

Die index-Datei ist nicht zum Einf\u00fcgen ausgew\u00e4hlt!
Sie m\u00fcssen entweder w\u00e4hlen, die Index-Datei einzuf\u00fcgen,
oder Sie m\u00fcssen eine andere Index-Datei ausw\u00e4hlen! jsite.error.no-custom-key=Kein externer Schl\u00fcssel

Sie haben angegeben, dass die Datei {0}
nicht eingef\u00fcgt werden soll. Allerdings haben Sie
keinen extern erstellten Schl\u00fcssel angegeben. jsite.error.no-files-to-insert=Keine Dateien einzuf\u00fcgen

Es sind keine Dateien zum Einf\u00fcgen ausgew\u00e4hlt! Bitte
w\u00e4hlen Sie mindestens eine Datei zum Einf\u00fcgen aus! +jsite.error.duplicate-file=Doppelte Datei

Die Datei {0} wird zweimal eingef\u00fcgt!
Bitte \u00fcberpr\u00fcfen Sie Ihre Umleitungen und Dateinamen! -- 2.7.4