EMMA Coverage Report (generated Sat Oct 08 11:41:37 CEST 2011)
[all classes][net.sf.jomic.ui]

COVERAGE SUMMARY FOR SOURCE FILE [OpenComicFileChooserAccessory.java]

nameclass, %method, %block, %line, %
OpenComicFileChooserAccessory.java100% (1/1)50%  (1/2)68%  (68/100)59%  (13/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OpenComicFileChooserAccessory100% (1/1)50%  (1/2)68%  (68/100)59%  (13/22)
propertyChange (PropertyChangeEvent): void 0%   (0/1)0%   (0/32)0%   (0/9)
OpenComicFileChooserAccessory (): void 100% (1/1)100% (68/68)100% (13/13)

1// Jomic - a viewer for comic book archives.
2// Copyright (C) 2004-2011 Thomas Aglassinger
3//
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 3 of the License, or
7// (at your option) any later version.
8//
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.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16package net.sf.jomic.ui;
17 
18import java.awt.BorderLayout;
19import java.awt.GridLayout;
20import java.beans.PropertyChangeEvent;
21import java.beans.PropertyChangeListener;
22import java.io.File;
23 
24import javax.swing.JCheckBox;
25import javax.swing.JFileChooser;
26import javax.swing.JPanel;
27 
28import net.sf.jomic.common.PropertyConstants;
29import net.sf.jomic.tools.LocaleTools;
30 
31/**
32 *  JPanel to be used as accessory in the "open comic" dialog containing additional options.
33 *
34 * @author    Thomas Aglassinger
35 */
36public class OpenComicFileChooserAccessory extends JPanel implements PropertyChangeListener
37{
38    private JCheckBox adjustArchiveSuffixCheckBox;
39    private LocaleTools localeTools;
40    private JCheckBox openInFullScreenCheckBox;
41    private TitleImageView titleImageView;
42 
43    public OpenComicFileChooserAccessory() {
44        super(new BorderLayout());
45        localeTools = LocaleTools.instance();
46 
47        String adjustArchiveSuffixLabel = localeTools.getMessage("dialogs.open.adjustArchiveSuffix");
48        String openInFullScreenLabel = localeTools.getMessage("dialogs.open.openInFullScreen");
49        JPanel optionPane = new JPanel(new GridLayout(0, 1));
50 
51        adjustArchiveSuffixCheckBox = new BooleanSettingCheckBox(
52                adjustArchiveSuffixLabel, PropertyConstants.ADJUST_ARCHIVE_SUFFIX,
53                Commands.TOGGLE_ADJUST_ARCHIVE_SUFFIX);
54        openInFullScreenCheckBox = new BooleanSettingCheckBox(
55                openInFullScreenLabel, PropertyConstants.OPEN_IN_FULL_SCREEN,
56                Commands.TOGGLE_OPEN_IN_FULL_SCREEN);
57        titleImageView = new TitleImageView();
58        optionPane.add(openInFullScreenCheckBox);
59        optionPane.add(adjustArchiveSuffixCheckBox);
60        add(optionPane, BorderLayout.PAGE_END);
61        add(titleImageView, BorderLayout.CENTER);
62    }
63 
64    public synchronized void propertyChange(PropertyChangeEvent changeEvent) {
65        String nameOfChangedProperty = changeEvent.getPropertyName();
66 
67        if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(nameOfChangedProperty)) {
68            titleImageView.setComicFile(null);
69        } else if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(nameOfChangedProperty)) {
70            File newComicFile = (File) changeEvent.getNewValue();
71 
72            // HACK: Some platforms seem to fire a "file  changed" event even for directories.
73            if ((newComicFile != null) && !newComicFile.isFile()) {
74                newComicFile = null;
75            }
76 
77            titleImageView.setComicFile(newComicFile);
78        }
79    }
80}

[all classes][net.sf.jomic.ui]
EMMA 2.0.4217 (C) Vladimir Roubtsov