2 * jSite - ProjectFilesPage.java - Copyright © 2006–2012 David Roden
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package de.todesbaum.jsite.gui;
21 import java.awt.BorderLayout;
22 import java.awt.Dimension;
23 import java.awt.GridBagConstraints;
24 import java.awt.GridBagLayout;
25 import java.awt.Insets;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28 import java.awt.event.KeyEvent;
29 import java.text.MessageFormat;
30 import java.util.HashSet;
31 import java.util.Iterator;
32 import java.util.List;
35 import javax.swing.AbstractAction;
36 import javax.swing.Action;
37 import javax.swing.JButton;
38 import javax.swing.JCheckBox;
39 import javax.swing.JComboBox;
40 import javax.swing.JComponent;
41 import javax.swing.JLabel;
42 import javax.swing.JList;
43 import javax.swing.JOptionPane;
44 import javax.swing.JPanel;
45 import javax.swing.JScrollPane;
46 import javax.swing.JTextField;
47 import javax.swing.ListSelectionModel;
48 import javax.swing.SwingUtilities;
49 import javax.swing.event.DocumentEvent;
50 import javax.swing.event.DocumentListener;
51 import javax.swing.event.ListSelectionEvent;
52 import javax.swing.event.ListSelectionListener;
53 import javax.swing.text.BadLocationException;
54 import javax.swing.text.Document;
56 import de.todesbaum.jsite.application.FileOption;
57 import de.todesbaum.jsite.application.Project;
58 import de.todesbaum.jsite.gui.FileScanner.ScannedFile;
59 import de.todesbaum.jsite.i18n.I18n;
60 import de.todesbaum.jsite.i18n.I18nContainer;
61 import de.todesbaum.util.mime.DefaultMIMETypes;
62 import de.todesbaum.util.swing.TLabel;
63 import de.todesbaum.util.swing.TWizard;
64 import de.todesbaum.util.swing.TWizardPage;
67 * Wizard page that lets the user manage the files of a project.
69 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
71 public class ProjectFilesPage extends TWizardPage implements ActionListener, ListSelectionListener, DocumentListener, FileScannerListener {
74 private Project project;
76 /** The “scan files” action. */
77 private Action scanAction;
79 /** The “ignore hidden files” checkbox. */
80 private JCheckBox ignoreHiddenFilesCheckBox;
82 /** The list of project files. */
83 private JList projectFileList;
85 /** The “default file” checkbox. */
86 private JCheckBox defaultFileCheckBox;
88 /** The “insert” checkbox. */
89 private JCheckBox fileOptionsInsertCheckBox;
91 /** The “force insert” checkbox. */
92 private JCheckBox fileOptionsForceInsertCheckBox;
94 /** The “insert redirect” checkbox. */
95 private JCheckBox fileOptionsInsertRedirectCheckBox;
97 /** The “custom key” textfield. */
98 private JTextField fileOptionsCustomKeyTextField;
100 /** The “rename” check box. */
101 private JCheckBox fileOptionsRenameCheckBox;
103 /** The “new name” text field. */
104 private JTextField fileOptionsRenameTextField;
106 /** The “mime type” combo box. */
107 private JComboBox fileOptionsMIMETypeComboBox;
110 * Creates a new project file page.
113 * The wizard the page belongs to
115 public ProjectFilesPage(final TWizard wizard) {
121 * Initializes the page and all its actions and components.
123 private void pageInit() {
125 setLayout(new BorderLayout(12, 12));
126 add(createProjectFilesPanel(), BorderLayout.CENTER);
130 * Creates all actions.
132 private void createActions() {
133 scanAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.rescan")) {
136 @SuppressWarnings("synthetic-access")
137 public void actionPerformed(ActionEvent actionEvent) {
141 scanAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_S);
142 scanAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.rescan.tooltip"));
144 I18nContainer.getInstance().registerRunnable(new Runnable() {
147 @SuppressWarnings("synthetic-access")
149 scanAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.rescan"));
150 scanAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.rescan.tooltip"));
159 public void pageAdded(TWizard wizard) {
161 this.wizard.setPreviousName(I18n.getMessage("jsite.wizard.previous"));
162 this.wizard.setNextName(I18n.getMessage("jsite.project-files.insert-now"));
163 this.wizard.setQuitName(I18n.getMessage("jsite.wizard.quit"));
167 * Creates the panel contains the project file list and options.
169 * @return The created panel
171 private JComponent createProjectFilesPanel() {
172 JPanel projectFilesPanel = new JPanel(new BorderLayout(12, 12));
174 projectFileList = new JList();
175 projectFileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
176 projectFileList.setMinimumSize(new Dimension(250, projectFileList.getPreferredSize().height));
177 projectFileList.addListSelectionListener(this);
179 projectFilesPanel.add(new JScrollPane(projectFileList), BorderLayout.CENTER);
181 JPanel fileOptionsAlignmentPanel = new JPanel(new BorderLayout(12, 12));
182 projectFilesPanel.add(fileOptionsAlignmentPanel, BorderLayout.PAGE_END);
183 JPanel fileOptionsPanel = new JPanel(new GridBagLayout());
184 fileOptionsAlignmentPanel.add(fileOptionsPanel, BorderLayout.PAGE_START);
186 ignoreHiddenFilesCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.ignore-hidden-files"));
187 ignoreHiddenFilesCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.ignore-hidden-files.tooltip"));
188 ignoreHiddenFilesCheckBox.setName("ignore-hidden-files");
189 ignoreHiddenFilesCheckBox.addActionListener(this);
190 fileOptionsPanel.add(ignoreHiddenFilesCheckBox, new GridBagConstraints(0, 0, 5, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
192 fileOptionsPanel.add(new JButton(scanAction), new GridBagConstraints(0, 1, 5, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
194 final JLabel fileOptionsLabel = new JLabel("<html><b>" + I18n.getMessage("jsite.project-files.file-options") + "</b></html>");
195 fileOptionsPanel.add(fileOptionsLabel, new GridBagConstraints(0, 2, 5, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
197 defaultFileCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.default"));
198 defaultFileCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.default.tooltip"));
199 defaultFileCheckBox.setName("default-file");
200 defaultFileCheckBox.addActionListener(this);
201 defaultFileCheckBox.setEnabled(false);
203 fileOptionsPanel.add(defaultFileCheckBox, new GridBagConstraints(0, 3, 5, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 18, 0, 0), 0, 0));
205 fileOptionsInsertCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.insert"), true);
206 fileOptionsInsertCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert.tooltip"));
207 fileOptionsInsertCheckBox.setName("insert");
208 fileOptionsInsertCheckBox.setMnemonic(KeyEvent.VK_I);
209 fileOptionsInsertCheckBox.addActionListener(this);
210 fileOptionsInsertCheckBox.setEnabled(false);
212 fileOptionsPanel.add(fileOptionsInsertCheckBox, new GridBagConstraints(0, 4, 5, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
214 fileOptionsForceInsertCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.force-insert"));
215 fileOptionsForceInsertCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.force-insert.tooltip"));
216 fileOptionsForceInsertCheckBox.setName("force-insert");
217 fileOptionsForceInsertCheckBox.setMnemonic(KeyEvent.VK_F);
218 fileOptionsForceInsertCheckBox.addActionListener(this);
219 fileOptionsForceInsertCheckBox.setEnabled(false);
221 fileOptionsPanel.add(fileOptionsForceInsertCheckBox, new GridBagConstraints(0, 5, 5, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
223 fileOptionsCustomKeyTextField = new JTextField(45);
224 fileOptionsCustomKeyTextField.setToolTipText(I18n.getMessage("jsite.project-files.custom-key.tooltip"));
225 fileOptionsCustomKeyTextField.setEnabled(false);
226 fileOptionsCustomKeyTextField.getDocument().addDocumentListener(this);
228 fileOptionsInsertRedirectCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.insert-redirect"), false);
229 fileOptionsInsertRedirectCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert-redirect.tooltip"));
230 fileOptionsInsertRedirectCheckBox.setName("insert-redirect");
231 fileOptionsInsertRedirectCheckBox.setMnemonic(KeyEvent.VK_R);
232 fileOptionsInsertRedirectCheckBox.addActionListener(this);
233 fileOptionsInsertRedirectCheckBox.setEnabled(false);
235 final TLabel customKeyLabel = new TLabel(I18n.getMessage("jsite.project-files.custom-key") + ":", KeyEvent.VK_K, fileOptionsCustomKeyTextField);
236 fileOptionsPanel.add(fileOptionsInsertRedirectCheckBox, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
237 fileOptionsPanel.add(customKeyLabel, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 6, 0, 0), 0, 0));
238 fileOptionsPanel.add(fileOptionsCustomKeyTextField, new GridBagConstraints(2, 6, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
240 fileOptionsRenameCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.rename"), false);
241 fileOptionsRenameCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.rename.tooltip"));
242 fileOptionsRenameCheckBox.setName("rename");
243 fileOptionsRenameCheckBox.setMnemonic(KeyEvent.VK_N);
244 fileOptionsRenameCheckBox.addActionListener(this);
245 fileOptionsRenameCheckBox.setEnabled(false);
247 fileOptionsRenameTextField = new JTextField();
248 fileOptionsRenameTextField.setEnabled(false);
249 fileOptionsRenameTextField.getDocument().addDocumentListener(new DocumentListener() {
251 @SuppressWarnings("synthetic-access")
252 private void storeText(DocumentEvent documentEvent) {
253 FileOption fileOption = getSelectedFile();
254 if (fileOption == null) {
255 /* no file selected. */
258 Document document = documentEvent.getDocument();
259 int documentLength = document.getLength();
261 fileOption.setChangedName(document.getText(0, documentLength).trim());
262 } catch (BadLocationException ble1) {
263 /* ignore, it should never happen. */
268 public void changedUpdate(DocumentEvent documentEvent) {
269 storeText(documentEvent);
273 public void insertUpdate(DocumentEvent documentEvent) {
274 storeText(documentEvent);
278 public void removeUpdate(DocumentEvent documentEvent) {
279 storeText(documentEvent);
284 fileOptionsPanel.add(fileOptionsRenameCheckBox, new GridBagConstraints(0, 7, 2, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
285 fileOptionsPanel.add(fileOptionsRenameTextField, new GridBagConstraints(2, 7, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
287 fileOptionsMIMETypeComboBox = new JComboBox(DefaultMIMETypes.getAllMIMETypes());
288 fileOptionsMIMETypeComboBox.setToolTipText(I18n.getMessage("jsite.project-files.mime-type.tooltip"));
289 fileOptionsMIMETypeComboBox.setName("project-files.mime-type");
290 fileOptionsMIMETypeComboBox.addActionListener(this);
291 fileOptionsMIMETypeComboBox.setEditable(true);
292 fileOptionsMIMETypeComboBox.setEnabled(false);
294 final TLabel mimeTypeLabel = new TLabel(I18n.getMessage("jsite.project-files.mime-type") + ":", KeyEvent.VK_M, fileOptionsMIMETypeComboBox);
295 fileOptionsPanel.add(mimeTypeLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
296 fileOptionsPanel.add(fileOptionsMIMETypeComboBox, new GridBagConstraints(1, 8, 4, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
298 I18nContainer.getInstance().registerRunnable(new Runnable() {
301 @SuppressWarnings("synthetic-access")
303 ignoreHiddenFilesCheckBox.setText(I18n.getMessage("jsite.project-files.ignore-hidden-files"));
304 ignoreHiddenFilesCheckBox.setToolTipText(I18n.getMessage("jsite.projet-files.ignore-hidden-files.tooltip"));
305 fileOptionsLabel.setText("<html><b>" + I18n.getMessage("jsite.project-files.file-options") + "</b></html>");
306 defaultFileCheckBox.setText(I18n.getMessage("jsite.project-files.default"));
307 defaultFileCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.default.tooltip"));
308 fileOptionsInsertCheckBox.setText(I18n.getMessage("jsite.project-files.insert"));
309 fileOptionsInsertCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert.tooltip"));
310 fileOptionsForceInsertCheckBox.setText(I18n.getMessage("jsite.project-files.force-insert"));
311 fileOptionsForceInsertCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.force-insert.tooltip"));
312 fileOptionsInsertRedirectCheckBox.setText(I18n.getMessage("jsite.project-files.insert-redirect"));
313 fileOptionsInsertRedirectCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert-redirect.tooltip"));
314 fileOptionsCustomKeyTextField.setToolTipText(I18n.getMessage("jsite.project-files.custom-key.tooltip"));
315 customKeyLabel.setText(I18n.getMessage("jsite.project-files.custom-key") + ":");
316 fileOptionsRenameCheckBox.setText("jsite.project-files.rename");
317 fileOptionsRenameCheckBox.setToolTipText("jsite.project-files.rename.tooltip");
318 fileOptionsMIMETypeComboBox.setToolTipText(I18n.getMessage("jsite.project-files.mime-type.tooltip"));
319 mimeTypeLabel.setText(I18n.getMessage("jsite.project-files.mime-type") + ":");
323 return projectFilesPanel;
327 * Sets the project whose files to manage.
330 * The project whose files to manage
332 public void setProject(final Project project) {
333 this.project = project;
334 setHeading(MessageFormat.format(I18n.getMessage("jsite.project-files.heading"), project.getName()));
335 setDescription(I18n.getMessage("jsite.project-files.description"));
336 ignoreHiddenFilesCheckBox.setSelected(project.isIgnoreHiddenFiles());
337 I18nContainer.getInstance().registerRunnable(new Runnable() {
341 setHeading(MessageFormat.format(I18n.getMessage("jsite.project-files.heading"), project.getName()));
342 setDescription(I18n.getMessage("jsite.project-files.description"));
352 * Rescans the project’s files.
354 private void actionScan() {
355 projectFileList.clearSelection();
356 projectFileList.setListData(new Object[0]);
358 wizard.setNextEnabled(false);
359 wizard.setPreviousEnabled(false);
360 wizard.setQuitEnabled(false);
362 FileScanner fileScanner = new FileScanner(project);
363 fileScanner.addFileScannerListener(this);
364 new Thread(fileScanner).start();
370 * Updates the file list.
373 public void fileScannerFinished(FileScanner fileScanner) {
374 final boolean error = fileScanner.isError();
376 final List<ScannedFile> files = fileScanner.getFiles();
377 SwingUtilities.invokeLater(new Runnable() {
380 @SuppressWarnings("synthetic-access")
382 projectFileList.setListData(files.toArray());
383 projectFileList.clearSelection();
386 Set<String> entriesToRemove = new HashSet<String>();
387 Iterator<String> filenames = new HashSet<String>(project.getFileOptions().keySet()).iterator();
388 while (filenames.hasNext()) {
389 String filename = filenames.next();
390 boolean found = false;
391 for (ScannedFile scannedFile : files) {
392 if (scannedFile.getFilename().equals(filename)) {
398 entriesToRemove.add(filename);
401 for (String filename : entriesToRemove) {
402 project.setFileOption(filename, null);
405 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.scan-error"), null, JOptionPane.ERROR_MESSAGE);
407 SwingUtilities.invokeLater(new Runnable() {
410 @SuppressWarnings("synthetic-access")
412 wizard.setPreviousEnabled(true);
413 wizard.setNextEnabled(!error);
414 wizard.setQuitEnabled(true);
420 * Returns the {@link FileOption file options} for the currently selected
423 * @return The {@link FileOption}s for the selected file, or {@code null} if
424 * no file is selected
426 private FileOption getSelectedFile() {
427 ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue();
428 if (scannedFile == null) {
431 return project.getFileOption(scannedFile.getFilename());
435 // INTERFACE ActionListener
442 public void actionPerformed(ActionEvent actionEvent) {
443 Object source = actionEvent.getSource();
444 if ((source instanceof JCheckBox) && ("ignore-hidden-files".equals(((JCheckBox) source).getName()))) {
445 project.setIgnoreHiddenFiles(((JCheckBox) source).isSelected());
449 ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue();
450 if (scannedFile == null) {
453 String filename = scannedFile.getFilename();
454 FileOption fileOption = project.getFileOption(filename);
455 if (source instanceof JCheckBox) {
456 JCheckBox checkBox = (JCheckBox) source;
457 if ("default-file".equals(checkBox.getName())) {
458 if (checkBox.isSelected()) {
459 if (filename.indexOf('/') > -1) {
460 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.invalid-default-file"), null, JOptionPane.ERROR_MESSAGE);
461 checkBox.setSelected(false);
463 project.setIndexFile(filename);
466 if (filename.equals(project.getIndexFile())) {
467 project.setIndexFile(null);
470 } else if ("insert".equals(checkBox.getName())) {
471 boolean isInsert = checkBox.isSelected();
472 fileOption.setInsert(isInsert);
473 fileOptionsInsertRedirectCheckBox.setEnabled(!isInsert);
474 } else if ("force-insert".equals(checkBox.getName())) {
475 boolean isForceInsert = checkBox.isSelected();
476 fileOption.setForceInsert(isForceInsert);
477 } else if ("insert-redirect".equals(checkBox.getName())) {
478 boolean isInsertRedirect = checkBox.isSelected();
479 fileOption.setInsertRedirect(isInsertRedirect);
480 fileOptionsCustomKeyTextField.setEnabled(isInsertRedirect);
481 } else if ("rename".equals(checkBox.getName())) {
482 boolean isRenamed = checkBox.isSelected();
483 fileOptionsRenameTextField.setEnabled(isRenamed);
484 fileOption.setChangedName(isRenamed ? fileOptionsRenameTextField.getText() : "");
486 } else if (source instanceof JComboBox) {
487 JComboBox comboBox = (JComboBox) source;
488 if ("project-files.mime-type".equals(comboBox.getName())) {
489 fileOption.setMimeType((String) comboBox.getSelectedItem());
495 // INTERFACE ListSelectionListener
502 @SuppressWarnings("null")
503 public void valueChanged(ListSelectionEvent e) {
504 ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue();
505 boolean enabled = scannedFile != null;
506 String filename = (scannedFile == null) ? null : scannedFile.getFilename();
507 defaultFileCheckBox.setEnabled(enabled);
508 fileOptionsInsertCheckBox.setEnabled(enabled);
509 fileOptionsRenameCheckBox.setEnabled(enabled);
510 fileOptionsMIMETypeComboBox.setEnabled(enabled);
511 if (filename != null) {
512 FileOption fileOption = project.getFileOption(filename);
513 defaultFileCheckBox.setSelected(filename.equals(project.getIndexFile()));
514 fileOptionsInsertCheckBox.setSelected(fileOption.isInsert());
515 fileOptionsForceInsertCheckBox.setEnabled(scannedFile.getHash().equals(fileOption.getLastInsertHash()));
516 fileOptionsForceInsertCheckBox.setSelected(fileOption.isForceInsert());
517 fileOptionsInsertRedirectCheckBox.setEnabled(!fileOption.isInsert());
518 fileOptionsInsertRedirectCheckBox.setSelected(fileOption.isInsertRedirect());
519 fileOptionsCustomKeyTextField.setEnabled(fileOption.isInsertRedirect());
520 fileOptionsCustomKeyTextField.setText(fileOption.getCustomKey());
521 fileOptionsRenameCheckBox.setSelected(fileOption.hasChangedName());
522 fileOptionsRenameTextField.setEnabled(fileOption.hasChangedName());
523 fileOptionsRenameTextField.setText(fileOption.getChangedName());
524 fileOptionsMIMETypeComboBox.getModel().setSelectedItem(fileOption.getMimeType());
526 defaultFileCheckBox.setSelected(false);
527 fileOptionsInsertCheckBox.setSelected(true);
528 fileOptionsForceInsertCheckBox.setEnabled(false);
529 fileOptionsForceInsertCheckBox.setSelected(false);
530 fileOptionsInsertRedirectCheckBox.setEnabled(false);
531 fileOptionsInsertRedirectCheckBox.setSelected(false);
532 fileOptionsCustomKeyTextField.setEnabled(false);
533 fileOptionsCustomKeyTextField.setText("CHK@");
534 fileOptionsRenameCheckBox.setEnabled(false);
535 fileOptionsRenameCheckBox.setSelected(false);
536 fileOptionsRenameTextField.setEnabled(false);
537 fileOptionsRenameTextField.setText("");
538 fileOptionsMIMETypeComboBox.getModel().setSelectedItem(DefaultMIMETypes.DEFAULT_MIME_TYPE);
543 // INTERFACE DocumentListener
547 * Updates the options of the currently selected file with the changes made
548 * in the “custom key” textfield.
550 * @param documentEvent
551 * The document event to process
553 private void processDocumentUpdate(DocumentEvent documentEvent) {
554 ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue();
555 if (scannedFile == null) {
558 FileOption fileOption = project.getFileOption(scannedFile.getFilename());
559 Document document = documentEvent.getDocument();
561 String text = document.getText(0, document.getLength());
562 fileOption.setCustomKey(text);
563 } catch (BadLocationException ble1) {
572 public void changedUpdate(DocumentEvent documentEvent) {
573 processDocumentUpdate(documentEvent);
580 public void insertUpdate(DocumentEvent documentEvent) {
581 processDocumentUpdate(documentEvent);
588 public void removeUpdate(DocumentEvent documentEvent) {
589 processDocumentUpdate(documentEvent);