Coverage Report - de.glossmaker.gui.gloss.bibOptions.ButtonPanel
 
Classes in this File Line Coverage Branch Coverage Complexity
ButtonPanel
0%
0/33
0%
0/6
1,75
 
 1  
 package de.glossmaker.gui.gloss.bibOptions;
 2  
 
 3  
 import java.awt.event.ActionEvent;
 4  
 import java.awt.event.ActionListener;
 5  
 import java.beans.PropertyChangeEvent;
 6  
 import java.beans.PropertyChangeListener;
 7  
 
 8  
 import javax.swing.JFrame;
 9  
 import javax.swing.JPanel;
 10  
 import javax.swing.JButton;
 11  
 
 12  
 import de.glossmaker.gloss.language.Translation;
 13  
 import de.glossmaker.gloss.listener.EActionCommands;
 14  
 import de.glossmaker.gloss.observer.GlossItemsChangePublisher;
 15  
 import de.glossmaker.gui.gloss.help.HelpSystem;
 16  
 
 17  
 /**
 18  
  * 
 19  
  * @author Markus Flingelli
 20  
  *
 21  
  */
 22  
 public class ButtonPanel extends JPanel implements PropertyChangeListener, ActionListener {
 23  
         private static final long serialVersionUID = -8736723284717561542L;
 24  
         private JButton mOk;
 25  
         private JButton mCancel;
 26  
         private JButton mHelp;
 27  0
         private Translation mTranslation = null;
 28  0
         private JFrame mFrame = null;
 29  
 
 30  0
         public ButtonPanel(JFrame frame) {
 31  0
                 mFrame = frame;
 32  0
                 mTranslation = Translation.getInstance();
 33  0
                 GlossItemsChangePublisher.getInstance(null).addPropertyChangeListener(this);
 34  0
                 setLayout(null);
 35  
                 
 36  0
                 mOk = new JButton("OK");
 37  0
                 mOk.setActionCommand("OK");
 38  0
                 mOk.addActionListener(this);
 39  0
                 mOk.setBounds(10, 10, 125, 23);
 40  0
                 add(mOk);
 41  
                 
 42  0
                 mCancel = new JButton("Cancel");
 43  0
                 mCancel.setActionCommand("CANCEL");
 44  0
                 mCancel.addActionListener(this);
 45  0
                 mCancel.setBounds(145, 10, 125, 23);
 46  0
                 add(mCancel);
 47  
                 
 48  0
                 mHelp = new JButton("Help");
 49  0
                 HelpSystem.getInstance().enableHelpOnButton(mHelp, "section.bibtex", null);
 50  0
                 mHelp.setBounds(279, 10, 125, 23);
 51  0
                 add(mHelp);
 52  
                 
 53  0
                 changeLanguage();
 54  0
         }
 55  
         
 56  
         private void changeLanguage() {
 57  0
                 mOk.setText(mTranslation.getValue("options.bibtex.button.ok.text"));
 58  0
                 mCancel.setText(mTranslation.getValue("options.bibtex.button.cancel.text"));
 59  0
                 mHelp.setText(mTranslation.getValue("options.bibtex.button.help.text"));
 60  0
         }
 61  
         
 62  
 
 63  
         @Override
 64  
         public void actionPerformed(ActionEvent event) {
 65  0
                 if (event.getActionCommand().equals("OK") || event.getActionCommand().equals("CANCEL")) {
 66  0
                         mFrame.setVisible(false);
 67  
                 } 
 68  0
         }
 69  
 
 70  
         @Override
 71  
         public void propertyChange(PropertyChangeEvent event) {
 72  0
                 if (event.getPropertyName().equals(EActionCommands.LANGUAGE_CHANGED.toString())) {
 73  0
                         changeLanguage();
 74  
                 }
 75  0
         }
 76  
 }