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")) {
135 @SuppressWarnings("synthetic-access")
136 public void actionPerformed(ActionEvent actionEvent) {
140 scanAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_S);
141 scanAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.rescan.tooltip"));
143 I18nContainer.getInstance().registerRunnable(new Runnable() {
145 @SuppressWarnings("synthetic-access")
147 scanAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.rescan"));
148 scanAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.rescan.tooltip"));
157 public void pageAdded(TWizard wizard) {
159 this.wizard.setPreviousName(I18n.getMessage("jsite.wizard.previous"));
160 this.wizard.setNextName(I18n.getMessage("jsite.project-files.insert-now"));
161 this.wizard.setQuitName(I18n.getMessage("jsite.wizard.quit"));
165 * Creates the panel contains the project file list and options.
167 * @return The created panel
169 private JComponent createProjectFilesPanel() {
170 JPanel projectFilesPanel = new JPanel(new BorderLayout(12, 12));
172 projectFileList = new JList();
173 projectFileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
174 projectFileList.setMinimumSize(new Dimension(250, projectFileList.getPreferredSize().height));
175 projectFileList.addListSelectionListener(this);
177 projectFilesPanel.add(new JScrollPane(projectFileList), BorderLayout.CENTER);
179 JPanel fileOptionsAlignmentPanel = new JPanel(new BorderLayout(12, 12));
180 projectFilesPanel.add(fileOptionsAlignmentPanel, BorderLayout.PAGE_END);
181 JPanel fileOptionsPanel = new JPanel(new GridBagLayout());
182 fileOptionsAlignmentPanel.add(fileOptionsPanel, BorderLayout.PAGE_START);
184 ignoreHiddenFilesCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.ignore-hidden-files"));
185 ignoreHiddenFilesCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.ignore-hidden-files.tooltip"));
186 ignoreHiddenFilesCheckBox.setName("ignore-hidden-files");
187 ignoreHiddenFilesCheckBox.addActionListener(this);
188 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));
190 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));
192 final JLabel fileOptionsLabel = new JLabel("<html><b>" + I18n.getMessage("jsite.project-files.file-options") + "</b></html>");
193 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));
195 defaultFileCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.default"));
196 defaultFileCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.default.tooltip"));
197 defaultFileCheckBox.setName("default-file");
198 defaultFileCheckBox.addActionListener(this);
199 defaultFileCheckBox.setEnabled(false);
201 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));
203 fileOptionsInsertCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.insert"), true);
204 fileOptionsInsertCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert.tooltip"));
205 fileOptionsInsertCheckBox.setName("insert");
206 fileOptionsInsertCheckBox.setMnemonic(KeyEvent.VK_I);
207 fileOptionsInsertCheckBox.addActionListener(this);
208 fileOptionsInsertCheckBox.setEnabled(false);
210 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));
212 fileOptionsForceInsertCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.force-insert"));
213 fileOptionsForceInsertCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.force-insert.tooltip"));
214 fileOptionsForceInsertCheckBox.setName("force-insert");
215 fileOptionsForceInsertCheckBox.setMnemonic(KeyEvent.VK_F);
216 fileOptionsForceInsertCheckBox.addActionListener(this);
217 fileOptionsForceInsertCheckBox.setEnabled(false);
219 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));
221 fileOptionsCustomKeyTextField = new JTextField(45);
222 fileOptionsCustomKeyTextField.setToolTipText(I18n.getMessage("jsite.project-files.custom-key.tooltip"));
223 fileOptionsCustomKeyTextField.setEnabled(false);
224 fileOptionsCustomKeyTextField.getDocument().addDocumentListener(this);
226 fileOptionsInsertRedirectCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.insert-redirect"), false);
227 fileOptionsInsertRedirectCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert-redirect.tooltip"));
228 fileOptionsInsertRedirectCheckBox.setName("insert-redirect");
229 fileOptionsInsertRedirectCheckBox.setMnemonic(KeyEvent.VK_R);
230 fileOptionsInsertRedirectCheckBox.addActionListener(this);
231 fileOptionsInsertRedirectCheckBox.setEnabled(false);
233 final TLabel customKeyLabel = new TLabel(I18n.getMessage("jsite.project-files.custom-key") + ":", KeyEvent.VK_K, fileOptionsCustomKeyTextField);
234 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));
235 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));
236 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));
238 fileOptionsRenameCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.rename"), false);
239 fileOptionsRenameCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.rename.tooltip"));
240 fileOptionsRenameCheckBox.setName("rename");
241 fileOptionsRenameCheckBox.setMnemonic(KeyEvent.VK_N);
242 fileOptionsRenameCheckBox.addActionListener(this);
243 fileOptionsRenameCheckBox.setEnabled(false);
245 fileOptionsRenameTextField = new JTextField();
246 fileOptionsRenameTextField.setEnabled(false);
247 fileOptionsRenameTextField.getDocument().addDocumentListener(new DocumentListener() {
249 @SuppressWarnings("synthetic-access")
250 private void storeText(DocumentEvent documentEvent) {
251 FileOption fileOption = getSelectedFile();
252 Document document = documentEvent.getDocument();
253 int documentLength = document.getLength();
255 fileOption.setChangedName(document.getText(0, documentLength).trim());
256 } catch (BadLocationException ble1) {
257 /* ignore, it should never happen. */
261 public void changedUpdate(DocumentEvent documentEvent) {
262 storeText(documentEvent);
265 public void insertUpdate(DocumentEvent documentEvent) {
266 storeText(documentEvent);
269 public void removeUpdate(DocumentEvent documentEvent) {
270 storeText(documentEvent);
275 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));
276 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));
278 fileOptionsMIMETypeComboBox = new JComboBox(DefaultMIMETypes.getAllMIMETypes());
279 fileOptionsMIMETypeComboBox.setToolTipText(I18n.getMessage("jsite.project-files.mime-type.tooltip"));
280 fileOptionsMIMETypeComboBox.setName("project-files.mime-type");
281 fileOptionsMIMETypeComboBox.addActionListener(this);
282 fileOptionsMIMETypeComboBox.setEditable(true);
283 fileOptionsMIMETypeComboBox.setEnabled(false);
285 final TLabel mimeTypeLabel = new TLabel(I18n.getMessage("jsite.project-files.mime-type") + ":", KeyEvent.VK_M, fileOptionsMIMETypeComboBox);
286 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));
287 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));
289 I18nContainer.getInstance().registerRunnable(new Runnable() {
291 @SuppressWarnings("synthetic-access")
293 ignoreHiddenFilesCheckBox.setText(I18n.getMessage("jsite.project-files.ignore-hidden-files"));
294 ignoreHiddenFilesCheckBox.setToolTipText(I18n.getMessage("jsite.projet-files.ignore-hidden-files.tooltip"));
295 fileOptionsLabel.setText("<html><b>" + I18n.getMessage("jsite.project-files.file-options") + "</b></html>");
296 defaultFileCheckBox.setText(I18n.getMessage("jsite.project-files.default"));
297 defaultFileCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.default.tooltip"));
298 fileOptionsInsertCheckBox.setText(I18n.getMessage("jsite.project-files.insert"));
299 fileOptionsInsertCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert.tooltip"));
300 fileOptionsForceInsertCheckBox.setText(I18n.getMessage("jsite.project-files.force-insert"));
301 fileOptionsForceInsertCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.force-insert.tooltip"));
302 fileOptionsInsertRedirectCheckBox.setText(I18n.getMessage("jsite.project-files.insert-redirect"));
303 fileOptionsInsertRedirectCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert-redirect.tooltip"));
304 fileOptionsCustomKeyTextField.setToolTipText(I18n.getMessage("jsite.project-files.custom-key.tooltip"));
305 customKeyLabel.setText(I18n.getMessage("jsite.project-files.custom-key") + ":");
306 fileOptionsRenameCheckBox.setText("jsite.project-files.rename");
307 fileOptionsRenameCheckBox.setToolTipText("jsite.project-files.rename.tooltip");
308 fileOptionsMIMETypeComboBox.setToolTipText(I18n.getMessage("jsite.project-files.mime-type.tooltip"));
309 mimeTypeLabel.setText(I18n.getMessage("jsite.project-files.mime-type") + ":");
313 return projectFilesPanel;
317 * Sets the project whose files to manage.
320 * The project whose files to manage
322 public void setProject(final Project project) {
323 this.project = project;
324 setHeading(MessageFormat.format(I18n.getMessage("jsite.project-files.heading"), project.getName()));
325 setDescription(I18n.getMessage("jsite.project-files.description"));
326 ignoreHiddenFilesCheckBox.setSelected(project.isIgnoreHiddenFiles());
327 I18nContainer.getInstance().registerRunnable(new Runnable() {
330 setHeading(MessageFormat.format(I18n.getMessage("jsite.project-files.heading"), project.getName()));
331 setDescription(I18n.getMessage("jsite.project-files.description"));
341 * Rescans the project’s files.
343 private void actionScan() {
344 projectFileList.clearSelection();
345 projectFileList.setListData(new Object[0]);
347 wizard.setNextEnabled(false);
348 wizard.setPreviousEnabled(false);
349 wizard.setQuitEnabled(false);
351 FileScanner fileScanner = new FileScanner(project);
352 fileScanner.addFileScannerListener(this);
353 new Thread(fileScanner).start();
359 * Updates the file list.
361 public void fileScannerFinished(FileScanner fileScanner) {
362 final boolean error = fileScanner.isError();
364 final List<ScannedFile> files = fileScanner.getFiles();
365 SwingUtilities.invokeLater(new Runnable() {
367 @SuppressWarnings("synthetic-access")
369 projectFileList.setListData(files.toArray());
370 projectFileList.clearSelection();
373 Set<String> entriesToRemove = new HashSet<String>();
374 Iterator<String> filenames = new HashSet<String>(project.getFileOptions().keySet()).iterator();
375 while (filenames.hasNext()) {
376 String filename = filenames.next();
377 boolean found = false;
378 for (ScannedFile scannedFile : files) {
379 if (scannedFile.getFilename().equals(filename)) {
385 entriesToRemove.add(filename);
388 for (String filename : entriesToRemove) {
389 project.setFileOption(filename, null);
392 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.scan-error"), null, JOptionPane.ERROR_MESSAGE);
394 SwingUtilities.invokeLater(new Runnable() {
396 @SuppressWarnings("synthetic-access")
398 wizard.setPreviousEnabled(true);
399 wizard.setNextEnabled(!error);
400 wizard.setQuitEnabled(true);
406 * Returns the {@link FileOption file options} for the currently selected
409 * @return The {@link FileOption}s for the selected file, or {@code null} if
410 * no file is selected
412 private FileOption getSelectedFile() {
413 ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue();
414 if (scannedFile == null) {
417 return project.getFileOption(scannedFile.getFilename());
421 // INTERFACE ActionListener
427 public void actionPerformed(ActionEvent actionEvent) {
428 Object source = actionEvent.getSource();
429 if ((source instanceof JCheckBox) && ("ignore-hidden-files".equals(((JCheckBox) source).getName()))) {
430 project.setIgnoreHiddenFiles(((JCheckBox) source).isSelected());
434 ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue();
435 if (scannedFile == null) {
438 String filename = scannedFile.getFilename();
439 FileOption fileOption = project.getFileOption(filename);
440 if (source instanceof JCheckBox) {
441 JCheckBox checkBox = (JCheckBox) source;
442 if ("default-file".equals(checkBox.getName())) {
443 if (checkBox.isSelected()) {
444 if (filename.indexOf('/') > -1) {
445 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.invalid-default-file"), null, JOptionPane.ERROR_MESSAGE);
446 checkBox.setSelected(false);
448 project.setIndexFile(filename);
451 if (filename.equals(project.getIndexFile())) {
452 project.setIndexFile(null);
455 } else if ("insert".equals(checkBox.getName())) {
456 boolean isInsert = checkBox.isSelected();
457 fileOption.setInsert(isInsert);
458 fileOptionsInsertRedirectCheckBox.setEnabled(!isInsert);
459 } else if ("force-insert".equals(checkBox.getName())) {
460 boolean isForceInsert = checkBox.isSelected();
461 fileOption.setForceInsert(isForceInsert);
462 } else if ("insert-redirect".equals(checkBox.getName())) {
463 boolean isInsertRedirect = checkBox.isSelected();
464 fileOption.setInsertRedirect(isInsertRedirect);
465 fileOptionsCustomKeyTextField.setEnabled(isInsertRedirect);
466 } else if ("rename".equals(checkBox.getName())) {
467 boolean isRenamed = checkBox.isSelected();
468 fileOptionsRenameTextField.setEnabled(isRenamed);
469 fileOption.setChangedName(isRenamed ? fileOptionsRenameTextField.getText() : "");
471 } else if (source instanceof JComboBox) {
472 JComboBox comboBox = (JComboBox) source;
473 if ("project-files.mime-type".equals(comboBox.getName())) {
474 fileOption.setMimeType((String) comboBox.getSelectedItem());
480 // INTERFACE ListSelectionListener
486 @SuppressWarnings("null")
487 public void valueChanged(ListSelectionEvent e) {
488 ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue();
489 boolean enabled = scannedFile != null;
490 String filename = (scannedFile == null) ? null : scannedFile.getFilename();
491 defaultFileCheckBox.setEnabled(enabled);
492 fileOptionsInsertCheckBox.setEnabled(enabled);
493 fileOptionsRenameCheckBox.setEnabled(enabled);
494 fileOptionsMIMETypeComboBox.setEnabled(enabled);
495 if (filename != null) {
496 FileOption fileOption = project.getFileOption(filename);
497 defaultFileCheckBox.setSelected(filename.equals(project.getIndexFile()));
498 fileOptionsInsertCheckBox.setSelected(fileOption.isInsert());
499 fileOptionsForceInsertCheckBox.setEnabled(scannedFile.getHash().equals(fileOption.getLastInsertHash()));
500 fileOptionsForceInsertCheckBox.setSelected(fileOption.isForceInsert());
501 fileOptionsInsertRedirectCheckBox.setEnabled(!fileOption.isInsert());
502 fileOptionsInsertRedirectCheckBox.setSelected(fileOption.isInsertRedirect());
503 fileOptionsCustomKeyTextField.setEnabled(fileOption.isInsertRedirect());
504 fileOptionsCustomKeyTextField.setText(fileOption.getCustomKey());
505 fileOptionsRenameCheckBox.setSelected(fileOption.hasChangedName());
506 fileOptionsRenameTextField.setEnabled(fileOption.hasChangedName());
507 fileOptionsRenameTextField.setText(fileOption.getChangedName());
508 fileOptionsMIMETypeComboBox.getModel().setSelectedItem(fileOption.getMimeType());
510 defaultFileCheckBox.setSelected(false);
511 fileOptionsInsertCheckBox.setSelected(true);
512 fileOptionsForceInsertCheckBox.setEnabled(false);
513 fileOptionsForceInsertCheckBox.setSelected(false);
514 fileOptionsInsertRedirectCheckBox.setEnabled(false);
515 fileOptionsInsertRedirectCheckBox.setSelected(false);
516 fileOptionsCustomKeyTextField.setEnabled(false);
517 fileOptionsCustomKeyTextField.setText("CHK@");
518 fileOptionsRenameCheckBox.setEnabled(false);
519 fileOptionsRenameCheckBox.setSelected(false);
520 fileOptionsRenameTextField.setEnabled(false);
521 fileOptionsRenameTextField.setText("");
522 fileOptionsMIMETypeComboBox.getModel().setSelectedItem(DefaultMIMETypes.DEFAULT_MIME_TYPE);
527 // INTERFACE DocumentListener
531 * Updates the options of the currently selected file with the changes made
532 * in the “custom key” textfield.
534 * @param documentEvent
535 * The document event to process
537 private void processDocumentUpdate(DocumentEvent documentEvent) {
538 ScannedFile scannedFile = (ScannedFile) projectFileList.getSelectedValue();
539 if (scannedFile == null) {
542 FileOption fileOption = project.getFileOption(scannedFile.getFilename());
543 Document document = documentEvent.getDocument();
545 String text = document.getText(0, document.getLength());
546 fileOption.setCustomKey(text);
547 } catch (BadLocationException ble1) {
555 public void changedUpdate(DocumentEvent documentEvent) {
556 processDocumentUpdate(documentEvent);
562 public void insertUpdate(DocumentEvent documentEvent) {
563 processDocumentUpdate(documentEvent);
569 public void removeUpdate(DocumentEvent documentEvent) {
570 processDocumentUpdate(documentEvent);