1b5b8c64a0dedf7815126fc8c51dcc4908ecb41e
[jSite.git] / src / de / todesbaum / jsite / gui / ProjectFilesPage.java
1 /*
2  * jSite - a tool for uploading websites into Freenet
3  * Copyright (C) 2006 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package de.todesbaum.jsite.gui;
21
22 import java.awt.BorderLayout;
23 import java.awt.Dimension;
24 import java.awt.FlowLayout;
25 import java.awt.GridBagConstraints;
26 import java.awt.GridBagLayout;
27 import java.awt.Insets;
28 import java.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
30 import java.awt.event.KeyEvent;
31 import java.text.MessageFormat;
32 import java.util.ArrayList;
33 import java.util.Collections;
34 import java.util.List;
35
36 import javax.swing.AbstractAction;
37 import javax.swing.Action;
38 import javax.swing.DefaultComboBoxModel;
39 import javax.swing.JButton;
40 import javax.swing.JCheckBox;
41 import javax.swing.JComboBox;
42 import javax.swing.JComponent;
43 import javax.swing.JLabel;
44 import javax.swing.JList;
45 import javax.swing.JOptionPane;
46 import javax.swing.JPanel;
47 import javax.swing.JScrollPane;
48 import javax.swing.JSpinner;
49 import javax.swing.JTextField;
50 import javax.swing.ListSelectionModel;
51 import javax.swing.SpinnerNumberModel;
52 import javax.swing.SwingUtilities;
53 import javax.swing.border.EmptyBorder;
54 import javax.swing.event.ChangeEvent;
55 import javax.swing.event.ChangeListener;
56 import javax.swing.event.DocumentEvent;
57 import javax.swing.event.DocumentListener;
58 import javax.swing.event.ListSelectionEvent;
59 import javax.swing.event.ListSelectionListener;
60 import javax.swing.text.BadLocationException;
61 import javax.swing.text.Document;
62
63 import de.todesbaum.jsite.application.EditionProject;
64 import de.todesbaum.jsite.application.FileOption;
65 import de.todesbaum.jsite.application.Project;
66 import de.todesbaum.jsite.i18n.I18n;
67 import de.todesbaum.util.mime.DefaultMIMETypes;
68 import de.todesbaum.util.swing.TLabel;
69 import de.todesbaum.util.swing.TWizard;
70 import de.todesbaum.util.swing.TWizardPage;
71
72 /**
73  * @author David Roden <droden@gmail.com>
74  * @version $Id: ProjectFilesPage.java 404 2006-03-26 02:11:03Z bombe $
75  */
76 public class ProjectFilesPage extends TWizardPage implements ActionListener, ListSelectionListener, DocumentListener, FileScannerListener, ChangeListener {
77
78         protected TWizard wizard;
79
80         protected Project project;
81
82         private Action scanAction;
83         private Action editContainerAction;
84         private Action addContainerAction;
85         private Action deleteContainerAction;
86
87         protected JList projectFileList;
88         private JCheckBox defaultFileCheckBox;
89         private JCheckBox fileOptionsInsertCheckBox;
90         private JTextField fileOptionsCustomKeyTextField;
91         private JComboBox fileOptionsMIMETypeComboBox;
92         protected DefaultComboBoxModel containerComboBoxModel;
93         private JComboBox fileOptionsContainerComboBox;
94         private JSpinner replaceEditionRangeSpinner;
95         private JCheckBox replacementCheckBox;
96
97         public ProjectFilesPage() {
98                 super();
99                 pageInit();
100         }
101
102         private void pageInit() {
103                 createActions();
104                 setLayout(new BorderLayout(12, 12));
105                 add(createProjectFilesPanel(), BorderLayout.CENTER);
106         }
107
108         private void createActions() {
109                 scanAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.rescan")) {
110
111                         public void actionPerformed(ActionEvent actionEvent) {
112                                 actionScan();
113                         }
114                 };
115                 scanAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_S);
116                 scanAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.rescan.tooltip"));
117
118                 addContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.add-container")) {
119
120                         public void actionPerformed(ActionEvent actionEvent) {
121                                 actionAddContainer();
122                         }
123                 };
124                 addContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.add-container.tooltip"));
125                 addContainerAction.setEnabled(false);
126
127                 editContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.edit-container")) {
128
129                         public void actionPerformed(ActionEvent actionEvent) {
130                                 actionEditContainer();
131                         }
132                 };
133                 editContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.edit-container.tooltip"));
134                 editContainerAction.setEnabled(false);
135
136                 deleteContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.delete-container")) {
137
138                         public void actionPerformed(ActionEvent actionEvent) {
139                                 actionDeleteContainer();
140                         }
141                 };
142                 deleteContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.delete-container.tooltip"));
143                 deleteContainerAction.setEnabled(false);
144         }
145
146         public void pageAdded(TWizard wizard) {
147                 this.wizard = wizard;
148                 actionScan();
149         }
150
151         private JComponent createProjectFilesPanel() {
152                 JPanel projectFilesPanel = new JPanel(new BorderLayout(12, 12));
153
154                 projectFileList = new JList();
155                 projectFileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
156                 projectFileList.setMinimumSize(new Dimension(250, projectFileList.getPreferredSize().height));
157                 projectFileList.addListSelectionListener(this);
158
159                 projectFilesPanel.add(new JScrollPane(projectFileList), BorderLayout.CENTER);
160
161                 JPanel fileOptionsAlignmentPanel = new JPanel(new BorderLayout(12, 12));
162                 projectFilesPanel.add(fileOptionsAlignmentPanel, BorderLayout.PAGE_END);
163                 JPanel fileOptionsPanel = new JPanel(new GridBagLayout());
164                 fileOptionsAlignmentPanel.add(fileOptionsPanel, BorderLayout.PAGE_START);
165
166                 fileOptionsPanel.add(new JButton(scanAction), new GridBagConstraints(0, 0, 5, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
167
168                 fileOptionsPanel.add(new JLabel("<html><b>" + I18n.getMessage("jsite.project-files.file-options") + "</b></html>"), new GridBagConstraints(0, 1, 5, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
169
170                 defaultFileCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.default"));
171                 defaultFileCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.default.tooltip"));
172                 defaultFileCheckBox.setName("default-file");
173                 defaultFileCheckBox.addActionListener(this);
174                 defaultFileCheckBox.setEnabled(false);
175
176                 fileOptionsPanel.add(defaultFileCheckBox, new GridBagConstraints(0, 2, 5, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 18, 0, 0), 0, 0));
177
178                 fileOptionsInsertCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.insert"), true);
179                 fileOptionsInsertCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert.tooltip"));
180                 fileOptionsInsertCheckBox.setName("insert");
181                 fileOptionsInsertCheckBox.setMnemonic(KeyEvent.VK_I);
182                 fileOptionsInsertCheckBox.addActionListener(this);
183                 fileOptionsInsertCheckBox.setEnabled(false);
184
185                 fileOptionsPanel.add(fileOptionsInsertCheckBox, new GridBagConstraints(0, 3, 5, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
186
187                 fileOptionsCustomKeyTextField = new JTextField(45);
188                 fileOptionsCustomKeyTextField.setToolTipText(I18n.getMessage("jsite.project-files.custom-key.tooltip"));
189                 fileOptionsCustomKeyTextField.setEnabled(false);
190                 fileOptionsCustomKeyTextField.getDocument().addDocumentListener(this);
191
192                 fileOptionsPanel.add(new TLabel(I18n.getMessage("jsite.project-files.custom-key"), KeyEvent.VK_K, fileOptionsCustomKeyTextField), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
193                 fileOptionsPanel.add(fileOptionsCustomKeyTextField, new GridBagConstraints(1, 4, 4, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
194
195                 fileOptionsMIMETypeComboBox = new JComboBox(DefaultMIMETypes.getAllMIMETypes());
196                 fileOptionsMIMETypeComboBox.setToolTipText(I18n.getMessage("jsite.project-files.mime-type.tooltip"));
197                 fileOptionsMIMETypeComboBox.setName("project-files.mime-type");
198                 fileOptionsMIMETypeComboBox.addActionListener(this);
199                 fileOptionsMIMETypeComboBox.setEnabled(false);
200
201                 fileOptionsPanel.add(new TLabel(I18n.getMessage("jsite.project-files.mime-type"), KeyEvent.VK_M, fileOptionsMIMETypeComboBox), new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
202                 fileOptionsPanel.add(fileOptionsMIMETypeComboBox, new GridBagConstraints(1, 5, 4, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
203
204                 containerComboBoxModel = new DefaultComboBoxModel();
205                 fileOptionsContainerComboBox = new JComboBox(containerComboBoxModel);
206                 fileOptionsContainerComboBox.setToolTipText(I18n.getMessage("jsite.project-files.container.tooltip"));
207                 fileOptionsContainerComboBox.setName("project-files.container");
208                 fileOptionsContainerComboBox.addActionListener(this);
209                 fileOptionsContainerComboBox.setEnabled(false);
210
211                 fileOptionsPanel.add(new TLabel(I18n.getMessage("jsite.project-files.container"), KeyEvent.VK_C, fileOptionsContainerComboBox), new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
212                 fileOptionsPanel.add(fileOptionsContainerComboBox, new GridBagConstraints(1, 6, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
213                 fileOptionsPanel.add(new JButton(addContainerAction), new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
214                 fileOptionsPanel.add(new JButton(editContainerAction), new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
215                 fileOptionsPanel.add(new JButton(deleteContainerAction), new GridBagConstraints(4, 6, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
216
217                 JPanel fileOptionsReplacementPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 6, 6));
218                 fileOptionsReplacementPanel.setBorder(new EmptyBorder(-6, -6, -6, -6));
219
220                 replacementCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.replacement"));
221                 replacementCheckBox.setName("project-files.replace-edition");
222                 replacementCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.replacement.tooltip"));
223                 replacementCheckBox.addActionListener(this);
224                 replacementCheckBox.setEnabled(false);
225                 fileOptionsReplacementPanel.add(replacementCheckBox);
226
227                 replaceEditionRangeSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));
228                 replaceEditionRangeSpinner.setName("project-files.replace-edition-range");
229                 replaceEditionRangeSpinner.setToolTipText(I18n.getMessage("jsite.project-files.replacement.edition-range.tooltip"));
230                 replaceEditionRangeSpinner.addChangeListener(this);
231                 replaceEditionRangeSpinner.setEnabled(false);
232                 fileOptionsReplacementPanel.add(new JLabel(I18n.getMessage("jsite.project-files.replacement.edition-range")));
233                 fileOptionsReplacementPanel.add(replaceEditionRangeSpinner);
234
235                 fileOptionsPanel.add(fileOptionsReplacementPanel, new GridBagConstraints(0, 7, 5, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 18, 0, 0), 0, 0));
236
237                 return projectFilesPanel;
238         }
239
240         public void setProject(Project project) {
241                 this.project = project;
242                 setHeading(MessageFormat.format(I18n.getMessage("jsite.project-files.heading"), project.getName()));
243                 setDescription(I18n.getMessage("jsite.project-files.description"));
244         }
245
246         private List<String> getProjectFiles() {
247                 List<String> files = new ArrayList<String>();
248                 for (int index = 0, size = projectFileList.getModel().getSize(); index < size; index++) {
249                         files.add((String) projectFileList.getModel().getElementAt(index));
250                 }
251                 return files;
252         }
253
254         protected void rebuildContainerComboBox() {
255                 /* scan files for containers */
256                 List<String> files = getProjectFiles();
257                 List<String> containers = new ArrayList<String>(); // ComboBoxModel
258                 // sucks. No
259                 // contains()!
260                 containers.add("");
261                 for (String filename: files) {
262                         String container = project.getFileOption(filename).getContainer();
263                         if (!containers.contains(container)) {
264                                 containers.add(container);
265                         }
266                 }
267                 Collections.sort(containers);
268                 containerComboBoxModel.removeAllElements();
269                 for (String container: containers) {
270                         containerComboBoxModel.addElement(container);
271                 }
272         }
273
274         //
275         // ACTIONS
276         //
277
278         protected void actionScan() {
279                 projectFileList.clearSelection();
280                 projectFileList.setListData(new Object[0]);
281
282                 wizard.setNextEnabled(false);
283                 wizard.setPreviousEnabled(false);
284                 wizard.setQuitEnabled(false);
285
286                 FileScanner fileScanner = new FileScanner(project);
287                 fileScanner.addFileScannerListener(this);
288                 new Thread(fileScanner).start();
289         }
290
291         protected void actionAddContainer() {
292                 String containerName = JOptionPane.showInputDialog(wizard, I18n.getMessage("jsite.project-files.action.add-container.message") + ":", null, JOptionPane.INFORMATION_MESSAGE);
293                 if (containerName == null) {
294                         return;
295                 }
296                 containerName = containerName.trim();
297                 String filename = (String) projectFileList.getSelectedValue();
298                 FileOption fileOption = project.getFileOption(filename);
299                 fileOption.setContainer(containerName);
300                 rebuildContainerComboBox();
301                 fileOptionsContainerComboBox.setSelectedItem(containerName);
302         }
303
304         protected void actionEditContainer() {
305                 String selectedFilename = (String) projectFileList.getSelectedValue();
306                 FileOption fileOption = project.getFileOption(selectedFilename);
307                 String oldContainerName = fileOption.getContainer();
308                 String containerName = JOptionPane.showInputDialog(wizard, I18n.getMessage("jsite.project-files.action.edit-container.message") + ":", oldContainerName);
309                 if (containerName == null) {
310                         return;
311                 }
312                 if (containerName.equals("")) {
313                         fileOption.setContainer("");
314                         fileOptionsContainerComboBox.setSelectedItem("");
315                         return;
316                 }
317                 List<String> files = getProjectFiles();
318                 for (String filename: files) {
319                         fileOption = project.getFileOption(filename);
320                         if (fileOption.getContainer().equals(oldContainerName)) {
321                                 fileOption.setContainer(containerName);
322                         }
323                 }
324                 rebuildContainerComboBox();
325                 fileOptionsContainerComboBox.setSelectedItem(containerName);
326         }
327
328         protected void actionDeleteContainer() {
329                 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.action.delete-container.message"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
330                         String containerName = (String) fileOptionsContainerComboBox.getSelectedItem();
331                         List<String> files = getProjectFiles();
332                         for (String filename: files) {
333                                 FileOption fileOption = project.getFileOption(filename);
334                                 if (fileOption.getContainer().equals(containerName)) {
335                                         fileOption.setContainer("");
336                                 }
337                         }
338                         fileOptionsContainerComboBox.setSelectedItem("");
339                 }
340         }
341
342         public void fileScannerFinished(FileScanner fileScanner) {
343                 final boolean error = fileScanner.isError();
344                 if (!error) {
345                         final List<String> files = fileScanner.getFiles();
346                         SwingUtilities.invokeLater(new Runnable() {
347
348                                 public void run() {
349                                         projectFileList.setListData(files.toArray(new String[files.size()]));
350                                         projectFileList.clearSelection();
351                                         rebuildContainerComboBox();
352                                 }
353                         });
354                 } else {
355                         JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.scan-error"), null, JOptionPane.ERROR_MESSAGE);
356                 }
357                 SwingUtilities.invokeLater(new Runnable() {
358
359                         public void run() {
360                                 wizard.setPreviousEnabled(true);
361                                 wizard.setNextEnabled(!error);
362                                 wizard.setQuitEnabled(true);
363                         }
364                 });
365         }
366
367         //
368         // INTERFACE ActionListener
369         //
370
371         /**
372          * {@inheritDoc}
373          */
374         public void actionPerformed(ActionEvent actionEvent) {
375                 String filename = (String) projectFileList.getSelectedValue();
376                 if (filename == null) {
377                         return;
378                 }
379                 FileOption fileOption = project.getFileOption(filename);
380                 Object source = actionEvent.getSource();
381                 if (source instanceof JCheckBox) {
382                         JCheckBox checkBox = (JCheckBox) source;
383                         if ("default-file".equals(checkBox.getName())) {
384                                 if (checkBox.isSelected()) {
385                                         project.setIndexFile(filename);
386                                 } else {
387                                         project.setIndexFile(null);
388                                 }
389                         } else if ("insert".equals(checkBox.getName())) {
390                                 boolean isInsert = checkBox.isSelected();
391                                 fileOptionsCustomKeyTextField.setEnabled(!isInsert);
392                                 fileOption.setInsert(isInsert);
393                                 if (!isInsert) {
394                                         fileOptionsContainerComboBox.setSelectedItem("");
395                                 }
396                         } else if ("project-files.replace-edition".equals(checkBox.getName())) {
397                                 boolean replaceEdition = checkBox.isSelected();
398                                 fileOption.setReplaceEdition(replaceEdition);
399                                 replaceEditionRangeSpinner.setEnabled(replaceEdition);
400                         }
401                 } else if (source instanceof JComboBox) {
402                         JComboBox comboBox = (JComboBox) source;
403                         if ("project-files.mime-type".equals(comboBox.getName())) {
404                                 fileOption.setMimeType((String) comboBox.getSelectedItem());
405                         } else if ("project-files.container".equals(comboBox.getName())) {
406                                 String containerName = (String) comboBox.getSelectedItem();
407                                 fileOption.setContainer(containerName);
408                                 boolean enabled = !"".equals(containerName);
409                                 editContainerAction.setEnabled(enabled);
410                                 deleteContainerAction.setEnabled(enabled);
411                                 if (enabled) {
412                                         fileOptionsInsertCheckBox.setSelected(true);
413                                 }
414                         }
415                 }
416         }
417
418         //
419         // INTERFACE ListSelectionListener
420         //
421
422         /**
423          * {@inheritDoc}
424          */
425         public void valueChanged(ListSelectionEvent e) {
426                 String filename = (String) projectFileList.getSelectedValue();
427                 boolean enabled = filename != null;
428                 boolean insert = fileOptionsInsertCheckBox.isSelected();
429                 defaultFileCheckBox.setEnabled(enabled);
430                 fileOptionsInsertCheckBox.setEnabled(enabled);
431                 fileOptionsCustomKeyTextField.setEnabled(enabled && !insert);
432                 fileOptionsMIMETypeComboBox.setEnabled(enabled);
433                 fileOptionsContainerComboBox.setEnabled(enabled);
434                 addContainerAction.setEnabled(enabled);
435                 editContainerAction.setEnabled(enabled);
436                 deleteContainerAction.setEnabled(enabled);
437                 replacementCheckBox.setEnabled(enabled && insert && (project instanceof EditionProject));
438                 if (filename != null) {
439                         FileOption fileOption = project.getFileOption(filename);
440                         defaultFileCheckBox.setSelected(filename.equals(project.getIndexFile()));
441                         fileOptionsInsertCheckBox.setSelected(fileOption.isInsert());
442                         fileOptionsCustomKeyTextField.setText(fileOption.getCustomKey());
443                         fileOptionsMIMETypeComboBox.getModel().setSelectedItem(fileOption.getMimeType());
444                         fileOptionsContainerComboBox.setSelectedItem(fileOption.getContainer());
445                         replacementCheckBox.setSelected(fileOption.getReplaceEdition());
446                         replaceEditionRangeSpinner.setValue(fileOption.getEditionRange());
447                         replaceEditionRangeSpinner.setEnabled(fileOption.getReplaceEdition());
448                 } else {
449                         defaultFileCheckBox.setSelected(false);
450                         fileOptionsInsertCheckBox.setSelected(true);
451                         fileOptionsCustomKeyTextField.setText("CHK@");
452                         fileOptionsMIMETypeComboBox.getModel().setSelectedItem(DefaultMIMETypes.DEFAULT_MIME_TYPE);
453                         fileOptionsContainerComboBox.setSelectedItem("");
454                         replacementCheckBox.setSelected(false);
455                         replaceEditionRangeSpinner.setValue(0);
456                 }
457         }
458
459         //
460         // INTERFACE DocumentListener
461         //
462
463         private void processDocumentUpdate(DocumentEvent documentEvent) {
464                 String filename = (String) projectFileList.getSelectedValue();
465                 if (filename == null)
466                         return;
467                 FileOption fileOption = project.getFileOption(filename);
468                 Document document = documentEvent.getDocument();
469                 try {
470                         String text = document.getText(0, document.getLength());
471                         fileOption.setCustomKey(text);
472                 } catch (BadLocationException ble1) {
473                 }
474         }
475
476         /**
477          * {@inheritDoc}
478          */
479         public void changedUpdate(DocumentEvent documentEvent) {
480                 processDocumentUpdate(documentEvent);
481         }
482
483         /**
484          * {@inheritDoc}
485          */
486         public void insertUpdate(DocumentEvent documentEvent) {
487                 processDocumentUpdate(documentEvent);
488         }
489
490         /**
491          * {@inheritDoc}
492          */
493         public void removeUpdate(DocumentEvent documentEvent) {
494                 processDocumentUpdate(documentEvent);
495         }
496
497         //
498         // INTERFACE ChangeListener
499         //
500
501         /**
502          * {@inheritDoc}
503          */
504         public void stateChanged(ChangeEvent changeEvent) {
505                 String filename = (String) projectFileList.getSelectedValue();
506                 if (filename == null)
507                         return;
508                 FileOption fileOption = project.getFileOption(filename);
509                 Object source = changeEvent.getSource();
510                 if (source instanceof JSpinner) {
511                         JSpinner spinner = (JSpinner) source;
512                         fileOption.setEditionRange((Integer) spinner.getValue());
513                 }
514         }
515
516 }