Coverage Report - de.glossmaker.gui.gloss.bibOptions.BibTeXOptions
 
Classes in this File Line Coverage Branch Coverage Complexity
BibTeXOptions
0%
0/33
0%
0/6
1,75
 
 1  
 package de.glossmaker.gui.gloss.bibOptions;
 2  
 
 3  
 import javax.swing.JFileChooser;
 4  
 import javax.swing.JPanel;
 5  
 import javax.swing.JLabel;
 6  
 import javax.swing.JTextField;
 7  
 import javax.swing.JButton;
 8  
 import java.awt.event.ActionEvent;
 9  
 import java.awt.event.ActionListener;
 10  
 import java.beans.PropertyChangeEvent;
 11  
 import java.beans.PropertyChangeListener;
 12  
 
 13  
 import de.glossmaker.gloss.datastructure.gui.Config;
 14  
 import de.glossmaker.gloss.language.Translation;
 15  
 import de.glossmaker.gloss.listener.EActionCommands;
 16  
 import de.glossmaker.gloss.observer.GlossItemsChangePublisher;
 17  
 import de.glossmaker.gui.gloss.GlossFileChooser;
 18  
 
 19  
 /**
 20  
  * This class represents the panel where the user can choose the BibTeX file.
 21  
  * 
 22  
  * @author Markus Flingelli
 23  
  *
 24  
  */
 25  
 public class BibTeXOptions extends JPanel implements ActionListener, PropertyChangeListener {
 26  
         private static final long serialVersionUID = 4398560369260590233L;
 27  0
         private JTextField mTextField = null;
 28  
         private JLabel mBibTeXFileLabel;
 29  0
         private Translation mTranslation = null;
 30  
         
 31  
         
 32  0
         public BibTeXOptions() {
 33  0
                 mTranslation = Translation.getInstance();
 34  0
                 GlossItemsChangePublisher.getInstance(null).addPropertyChangeListener(this);
 35  0
                 setLayout(null);
 36  
                 
 37  0
                 mBibTeXFileLabel = new JLabel("BibTeX file");
 38  0
                 mBibTeXFileLabel.setBounds(10, 11, 136, 14);
 39  0
                 add(mBibTeXFileLabel);
 40  
                 
 41  0
                 mTextField = new JTextField();
 42  0
                 mTextField.setEditable(false);
 43  0
                 mTextField.setBounds(10, 31, 484, 20);
 44  0
                 mTextField.setText(Config.getInstance().getBibTeXFile());
 45  0
                 add(mTextField);
 46  0
                 mTextField.setColumns(10);
 47  
                 
 48  0
                 JButton chooseFile = new JButton("...");
 49  0
                 chooseFile.addActionListener(this);
 50  0
                 chooseFile.setActionCommand("CHOOSE_FILE");
 51  0
                 chooseFile.setBounds(504, 30, 34, 23);
 52  0
                 add(chooseFile);
 53  
                 
 54  0
                 changeLanguage();
 55  0
         }
 56  
 
 57  
         private void changeLanguage() {
 58  0
                 mBibTeXFileLabel.setText(Translation.getInstance().getValue("options.bibtex.filename.text"));
 59  0
         }
 60  
         
 61  
         @Override
 62  
         public void actionPerformed(ActionEvent event) {
 63  0
                 if (event.getActionCommand().equals("CHOOSE_FILE")) {
 64  0
                         GlossFileChooser fc = new GlossFileChooser(
 65  
                                         mTranslation.getValue("filechooser.bib.open.title="),
 66  
                                         mTranslation.getValue("filechooser.bib.description.text"),
 67  
                                         "bib");
 68  0
                         if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
 69  0
                                 mTextField.setText(fc.getSelectedFile().getAbsolutePath());
 70  0
                                 Config.getInstance().setBibTeXFile(fc.getSelectedFile().getAbsolutePath());
 71  
                         }
 72  
                 }
 73  0
         }
 74  
 
 75  
         @Override
 76  
         public void propertyChange(PropertyChangeEvent event) {
 77  0
                 if (event.getPropertyName().equals(EActionCommands.LANGUAGE_CHANGED.toString())) {
 78  0
                         changeLanguage();
 79  
                 }
 80  0
         }
 81  
         
 82  
 }