2 * jSite - a tool for uploading websites into Freenet
3 * Copyright (C) 2006 David Roden
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.
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.
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.
20 package de.todesbaum.jsite.gui;
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.Iterator;
35 import java.util.List;
37 import javax.swing.AbstractAction;
38 import javax.swing.Action;
39 import javax.swing.DefaultComboBoxModel;
40 import javax.swing.JButton;
41 import javax.swing.JCheckBox;
42 import javax.swing.JComboBox;
43 import javax.swing.JComponent;
44 import javax.swing.JLabel;
45 import javax.swing.JList;
46 import javax.swing.JOptionPane;
47 import javax.swing.JPanel;
48 import javax.swing.JScrollPane;
49 import javax.swing.JSpinner;
50 import javax.swing.JTextField;
51 import javax.swing.ListSelectionModel;
52 import javax.swing.SpinnerNumberModel;
53 import javax.swing.SwingUtilities;
54 import javax.swing.border.EmptyBorder;
55 import javax.swing.event.ChangeEvent;
56 import javax.swing.event.ChangeListener;
57 import javax.swing.event.DocumentEvent;
58 import javax.swing.event.DocumentListener;
59 import javax.swing.event.ListSelectionEvent;
60 import javax.swing.event.ListSelectionListener;
61 import javax.swing.text.BadLocationException;
62 import javax.swing.text.Document;
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.jsite.i18n.I18nContainer;
68 import de.todesbaum.util.mime.DefaultMIMETypes;
69 import de.todesbaum.util.swing.TLabel;
70 import de.todesbaum.util.swing.TWizard;
71 import de.todesbaum.util.swing.TWizardPage;
74 * @author David Roden <droden@gmail.com>
77 public class ProjectFilesPage extends TWizardPage implements ActionListener, ListSelectionListener, DocumentListener, FileScannerListener, ChangeListener {
79 protected Project project;
81 protected Action scanAction;
82 protected Action editContainerAction;
83 protected Action addContainerAction;
84 protected Action deleteContainerAction;
86 protected JList projectFileList;
87 private JCheckBox defaultFileCheckBox;
88 private JCheckBox fileOptionsInsertCheckBox;
89 private JTextField fileOptionsCustomKeyTextField;
90 private JComboBox fileOptionsMIMETypeComboBox;
91 protected DefaultComboBoxModel containerComboBoxModel;
92 private JComboBox fileOptionsContainerComboBox;
93 private JSpinner replaceEditionRangeSpinner;
94 private JCheckBox replacementCheckBox;
96 public ProjectFilesPage(final TWizard wizard) {
101 private void pageInit() {
103 setLayout(new BorderLayout(12, 12));
104 add(createProjectFilesPanel(), BorderLayout.CENTER);
107 private void createActions() {
108 scanAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.rescan")) {
110 public void actionPerformed(ActionEvent actionEvent) {
114 scanAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_S);
115 scanAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.rescan.tooltip"));
117 addContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.add-container")) {
119 public void actionPerformed(ActionEvent actionEvent) {
120 actionAddContainer();
123 addContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.add-container.tooltip"));
124 addContainerAction.setEnabled(false);
126 editContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.edit-container")) {
128 public void actionPerformed(ActionEvent actionEvent) {
129 actionEditContainer();
132 editContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.edit-container.tooltip"));
133 editContainerAction.setEnabled(false);
135 deleteContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.delete-container")) {
137 public void actionPerformed(ActionEvent actionEvent) {
138 actionDeleteContainer();
141 deleteContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.delete-container.tooltip"));
142 deleteContainerAction.setEnabled(false);
144 I18nContainer.getInstance().registerRunnable(new Runnable() {
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"));
149 addContainerAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.add-container"));
150 addContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.add-container.tooltip"));
151 editContainerAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.edit-container"));
152 editContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.edit-container.tooltip"));
153 deleteContainerAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.delete-container"));
154 deleteContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.delete-container.tooltip"));
160 public void pageAdded(TWizard wizard) {
162 this.wizard.setPreviousName(I18n.getMessage("jsite.wizard.previous"));
163 this.wizard.setNextName(I18n.getMessage("jsite.project-files.insert-now"));
164 this.wizard.setQuitName(I18n.getMessage("jsite.wizard.quit"));
167 private JComponent createProjectFilesPanel() {
168 JPanel projectFilesPanel = new JPanel(new BorderLayout(12, 12));
170 projectFileList = new JList();
171 projectFileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
172 projectFileList.setMinimumSize(new Dimension(250, projectFileList.getPreferredSize().height));
173 projectFileList.addListSelectionListener(this);
175 projectFilesPanel.add(new JScrollPane(projectFileList), BorderLayout.CENTER);
177 JPanel fileOptionsAlignmentPanel = new JPanel(new BorderLayout(12, 12));
178 projectFilesPanel.add(fileOptionsAlignmentPanel, BorderLayout.PAGE_END);
179 JPanel fileOptionsPanel = new JPanel(new GridBagLayout());
180 fileOptionsAlignmentPanel.add(fileOptionsPanel, BorderLayout.PAGE_START);
182 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));
184 final JLabel fileOptionsLabel = new JLabel("<html><b>" + I18n.getMessage("jsite.project-files.file-options") + "</b></html>");
185 fileOptionsPanel.add(fileOptionsLabel, new GridBagConstraints(0, 1, 5, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
187 defaultFileCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.default"));
188 defaultFileCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.default.tooltip"));
189 defaultFileCheckBox.setName("default-file");
190 defaultFileCheckBox.addActionListener(this);
191 defaultFileCheckBox.setEnabled(false);
193 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));
195 fileOptionsInsertCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.insert"), true);
196 fileOptionsInsertCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert.tooltip"));
197 fileOptionsInsertCheckBox.setName("insert");
198 fileOptionsInsertCheckBox.setMnemonic(KeyEvent.VK_I);
199 fileOptionsInsertCheckBox.addActionListener(this);
200 fileOptionsInsertCheckBox.setEnabled(false);
202 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));
204 fileOptionsCustomKeyTextField = new JTextField(45);
205 fileOptionsCustomKeyTextField.setToolTipText(I18n.getMessage("jsite.project-files.custom-key.tooltip"));
206 fileOptionsCustomKeyTextField.setEnabled(false);
207 fileOptionsCustomKeyTextField.getDocument().addDocumentListener(this);
209 final TLabel customKeyLabel = new TLabel(I18n.getMessage("jsite.project-files.custom-key") + ":", KeyEvent.VK_K, fileOptionsCustomKeyTextField);
210 fileOptionsPanel.add(customKeyLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
211 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));
213 fileOptionsMIMETypeComboBox = new JComboBox(DefaultMIMETypes.getAllMIMETypes());
214 fileOptionsMIMETypeComboBox.setToolTipText(I18n.getMessage("jsite.project-files.mime-type.tooltip"));
215 fileOptionsMIMETypeComboBox.setName("project-files.mime-type");
216 fileOptionsMIMETypeComboBox.addActionListener(this);
217 fileOptionsMIMETypeComboBox.setEnabled(false);
219 final TLabel mimeTypeLabel = new TLabel(I18n.getMessage("jsite.project-files.mime-type") + ":", KeyEvent.VK_M, fileOptionsMIMETypeComboBox);
220 fileOptionsPanel.add(mimeTypeLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
221 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));
223 containerComboBoxModel = new DefaultComboBoxModel();
224 fileOptionsContainerComboBox = new JComboBox(containerComboBoxModel);
225 fileOptionsContainerComboBox.setToolTipText(I18n.getMessage("jsite.project-files.container.tooltip"));
226 fileOptionsContainerComboBox.setName("project-files.container");
227 fileOptionsContainerComboBox.addActionListener(this);
228 fileOptionsContainerComboBox.setEnabled(false);
230 final TLabel containerLabel = new TLabel(I18n.getMessage("jsite.project-files.container") + ":", KeyEvent.VK_C, fileOptionsContainerComboBox);
231 fileOptionsPanel.add(containerLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
232 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));
233 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));
234 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));
235 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));
237 JPanel fileOptionsReplacementPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 6, 6));
238 fileOptionsReplacementPanel.setBorder(new EmptyBorder(-6, -6, -6, -6));
240 replacementCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.replacement"));
241 replacementCheckBox.setName("project-files.replace-edition");
242 replacementCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.replacement.tooltip"));
243 replacementCheckBox.addActionListener(this);
244 replacementCheckBox.setEnabled(false);
245 fileOptionsReplacementPanel.add(replacementCheckBox);
247 replaceEditionRangeSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));
248 replaceEditionRangeSpinner.setName("project-files.replace-edition-range");
249 replaceEditionRangeSpinner.setToolTipText(I18n.getMessage("jsite.project-files.replacement.edition-range.tooltip"));
250 replaceEditionRangeSpinner.addChangeListener(this);
251 replaceEditionRangeSpinner.setEnabled(false);
252 final JLabel editionRangeLabel = new JLabel(I18n.getMessage("jsite.project-files.replacement.edition-range"));
253 fileOptionsReplacementPanel.add(editionRangeLabel);
254 fileOptionsReplacementPanel.add(replaceEditionRangeSpinner);
256 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));
258 I18nContainer.getInstance().registerRunnable(new Runnable() {
261 fileOptionsLabel.setText("<html><b>" + I18n.getMessage("jsite.project-files.file-options") + "</b></html>");
262 defaultFileCheckBox.setText(I18n.getMessage("jsite.project-files.default"));
263 defaultFileCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.default.tooltip"));
264 fileOptionsInsertCheckBox.setText(I18n.getMessage("jsite.project-files.insert"));
265 fileOptionsInsertCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.insert.tooltip"));
266 fileOptionsCustomKeyTextField.setToolTipText(I18n.getMessage("jsite.project-files.custom-key.tooltip"));
267 customKeyLabel.setText(I18n.getMessage("jsite.project-files.custom-key") + ":");
268 fileOptionsMIMETypeComboBox.setToolTipText(I18n.getMessage("jsite.project-files.mime-type.tooltip"));
269 mimeTypeLabel.setText(I18n.getMessage("jsite.project-files.mime-type") + ":");
270 fileOptionsContainerComboBox.setToolTipText(I18n.getMessage("jsite.project-files.container.tooltip"));
271 containerLabel.setText(I18n.getMessage("jsite.project-files.container") + ":");
272 replacementCheckBox.setText(I18n.getMessage("jsite.project-files.replacement"));
273 replacementCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.replacement.tooltip"));
274 replaceEditionRangeSpinner.setToolTipText(I18n.getMessage("jsite.project-files.replacement.edition-range.tooltip"));
275 editionRangeLabel.setText(I18n.getMessage("jsite.project-files.replacement.edition-range"));
279 return projectFilesPanel;
282 public void setProject(final Project project) {
283 this.project = project;
284 setHeading(MessageFormat.format(I18n.getMessage("jsite.project-files.heading"), project.getName()));
285 setDescription(I18n.getMessage("jsite.project-files.description"));
286 I18nContainer.getInstance().registerRunnable(new Runnable() {
289 setHeading(MessageFormat.format(I18n.getMessage("jsite.project-files.heading"), project.getName()));
290 setDescription(I18n.getMessage("jsite.project-files.description"));
295 private List<String> getProjectFiles() {
296 List<String> files = new ArrayList<String>();
297 for (int index = 0, size = projectFileList.getModel().getSize(); index < size; index++) {
298 files.add((String) projectFileList.getModel().getElementAt(index));
303 protected void rebuildContainerComboBox() {
304 /* scan files for containers */
305 List<String> files = getProjectFiles();
306 List<String> containers = new ArrayList<String>(); // ComboBoxModel
310 for (String filename: files) {
311 String container = project.getFileOption(filename).getContainer();
312 if (!containers.contains(container)) {
313 containers.add(container);
316 Collections.sort(containers);
317 containerComboBoxModel.removeAllElements();
318 for (String container: containers) {
319 containerComboBoxModel.addElement(container);
327 protected void actionScan() {
328 projectFileList.clearSelection();
329 projectFileList.setListData(new Object[0]);
331 wizard.setNextEnabled(false);
332 wizard.setPreviousEnabled(false);
333 wizard.setQuitEnabled(false);
335 FileScanner fileScanner = new FileScanner(project);
336 fileScanner.addFileScannerListener(this);
337 new Thread(fileScanner).start();
340 protected void actionAddContainer() {
341 String containerName = JOptionPane.showInputDialog(wizard, I18n.getMessage("jsite.project-files.action.add-container.message") + ":", null, JOptionPane.INFORMATION_MESSAGE);
342 if (containerName == null) {
345 containerName = containerName.trim();
346 String filename = (String) projectFileList.getSelectedValue();
347 FileOption fileOption = project.getFileOption(filename);
348 fileOption.setContainer(containerName);
349 rebuildContainerComboBox();
350 fileOptionsContainerComboBox.setSelectedItem(containerName);
353 protected void actionEditContainer() {
354 String selectedFilename = (String) projectFileList.getSelectedValue();
355 FileOption fileOption = project.getFileOption(selectedFilename);
356 String oldContainerName = fileOption.getContainer();
357 String containerName = JOptionPane.showInputDialog(wizard, I18n.getMessage("jsite.project-files.action.edit-container.message") + ":", oldContainerName);
358 if (containerName == null) {
361 if (containerName.equals("")) {
362 fileOption.setContainer("");
363 fileOptionsContainerComboBox.setSelectedItem("");
366 List<String> files = getProjectFiles();
367 for (String filename: files) {
368 fileOption = project.getFileOption(filename);
369 if (fileOption.getContainer().equals(oldContainerName)) {
370 fileOption.setContainer(containerName);
373 rebuildContainerComboBox();
374 fileOptionsContainerComboBox.setSelectedItem(containerName);
377 protected void actionDeleteContainer() {
378 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.action.delete-container.message"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
379 String containerName = (String) fileOptionsContainerComboBox.getSelectedItem();
380 List<String> files = getProjectFiles();
381 for (String filename: files) {
382 FileOption fileOption = project.getFileOption(filename);
383 if (fileOption.getContainer().equals(containerName)) {
384 fileOption.setContainer("");
387 fileOptionsContainerComboBox.setSelectedItem("");
391 public void fileScannerFinished(FileScanner fileScanner) {
392 final boolean error = fileScanner.isError();
394 final List<String> files = fileScanner.getFiles();
395 SwingUtilities.invokeLater(new Runnable() {
398 projectFileList.setListData(files.toArray(new String[files.size()]));
399 projectFileList.clearSelection();
400 rebuildContainerComboBox();
403 Iterator<String> filenames = project.getFileOptions().keySet().iterator();
404 while (filenames.hasNext()) {
405 String filename = filenames.next();
406 if (!files.contains(filename)) {
407 project.setFileOption(filename, null);
411 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.scan-error"), null, JOptionPane.ERROR_MESSAGE);
413 SwingUtilities.invokeLater(new Runnable() {
416 wizard.setPreviousEnabled(true);
417 wizard.setNextEnabled(!error);
418 wizard.setQuitEnabled(true);
424 // INTERFACE ActionListener
430 public void actionPerformed(ActionEvent actionEvent) {
431 String filename = (String) projectFileList.getSelectedValue();
432 if (filename == null) {
435 FileOption fileOption = project.getFileOption(filename);
436 Object source = actionEvent.getSource();
437 if (source instanceof JCheckBox) {
438 JCheckBox checkBox = (JCheckBox) source;
439 if ("default-file".equals(checkBox.getName())) {
440 if (checkBox.isSelected()) {
441 project.setIndexFile(filename);
443 project.setIndexFile(null);
445 } else if ("insert".equals(checkBox.getName())) {
446 boolean isInsert = checkBox.isSelected();
447 fileOptionsCustomKeyTextField.setEnabled(!isInsert);
448 fileOption.setInsert(isInsert);
450 fileOptionsContainerComboBox.setSelectedItem("");
452 } else if ("project-files.replace-edition".equals(checkBox.getName())) {
453 boolean replaceEdition = checkBox.isSelected();
454 fileOption.setReplaceEdition(replaceEdition);
455 replaceEditionRangeSpinner.setEnabled(replaceEdition);
457 } else if (source instanceof JComboBox) {
458 JComboBox comboBox = (JComboBox) source;
459 if ("project-files.mime-type".equals(comboBox.getName())) {
460 fileOption.setMimeType((String) comboBox.getSelectedItem());
461 } else if ("project-files.container".equals(comboBox.getName())) {
462 String containerName = (String) comboBox.getSelectedItem();
463 fileOption.setContainer(containerName);
464 boolean enabled = !"".equals(containerName);
465 editContainerAction.setEnabled(enabled);
466 deleteContainerAction.setEnabled(enabled);
468 fileOptionsInsertCheckBox.setSelected(true);
475 // INTERFACE ListSelectionListener
481 public void valueChanged(ListSelectionEvent e) {
482 String filename = (String) projectFileList.getSelectedValue();
483 boolean enabled = filename != null;
484 boolean insert = fileOptionsInsertCheckBox.isSelected();
485 defaultFileCheckBox.setEnabled(enabled);
486 fileOptionsInsertCheckBox.setEnabled(enabled);
487 fileOptionsCustomKeyTextField.setEnabled(enabled && !insert);
488 fileOptionsMIMETypeComboBox.setEnabled(enabled);
489 fileOptionsContainerComboBox.setEnabled(enabled);
490 addContainerAction.setEnabled(enabled);
491 editContainerAction.setEnabled(enabled);
492 deleteContainerAction.setEnabled(enabled);
493 replacementCheckBox.setEnabled(enabled && insert);
494 if (filename != null) {
495 FileOption fileOption = project.getFileOption(filename);
496 defaultFileCheckBox.setSelected(filename.equals(project.getIndexFile()));
497 fileOptionsInsertCheckBox.setSelected(fileOption.isInsert());
498 fileOptionsCustomKeyTextField.setText(fileOption.getCustomKey());
499 fileOptionsMIMETypeComboBox.getModel().setSelectedItem(fileOption.getMimeType());
500 fileOptionsContainerComboBox.setSelectedItem(fileOption.getContainer());
501 replacementCheckBox.setSelected(fileOption.getReplaceEdition());
502 replaceEditionRangeSpinner.setValue(fileOption.getEditionRange());
503 replaceEditionRangeSpinner.setEnabled(fileOption.getReplaceEdition());
505 defaultFileCheckBox.setSelected(false);
506 fileOptionsInsertCheckBox.setSelected(true);
507 fileOptionsCustomKeyTextField.setText("CHK@");
508 fileOptionsMIMETypeComboBox.getModel().setSelectedItem(DefaultMIMETypes.DEFAULT_MIME_TYPE);
509 fileOptionsContainerComboBox.setSelectedItem("");
510 replacementCheckBox.setSelected(false);
511 replaceEditionRangeSpinner.setValue(0);
516 // INTERFACE DocumentListener
519 private void processDocumentUpdate(DocumentEvent documentEvent) {
520 String filename = (String) projectFileList.getSelectedValue();
521 if (filename == null) {
524 FileOption fileOption = project.getFileOption(filename);
525 Document document = documentEvent.getDocument();
527 String text = document.getText(0, document.getLength());
528 fileOption.setCustomKey(text);
529 } catch (BadLocationException ble1) {
536 public void changedUpdate(DocumentEvent documentEvent) {
537 processDocumentUpdate(documentEvent);
543 public void insertUpdate(DocumentEvent documentEvent) {
544 processDocumentUpdate(documentEvent);
550 public void removeUpdate(DocumentEvent documentEvent) {
551 processDocumentUpdate(documentEvent);
555 // INTERFACE ChangeListener
561 public void stateChanged(ChangeEvent changeEvent) {
562 String filename = (String) projectFileList.getSelectedValue();
563 if (filename == null) {
566 FileOption fileOption = project.getFileOption(filename);
567 Object source = changeEvent.getSource();
568 if (source instanceof JSpinner) {
569 JSpinner spinner = (JSpinner) source;
570 fileOption.setEditionRange((Integer) spinner.getValue());