Coverage Report - de.glossmaker.gui.gloss.main.BibTeXItemsFrame
 
Classes in this File Line Coverage Branch Coverage Complexity
BibTeXItemsFrame
0%
0/19
N/A
1
BibTeXItemsFrame$1
0%
0/3
N/A
1
 
 1  
 package de.glossmaker.gui.gloss.main;
 2  
 
 3  
 import java.awt.BorderLayout;
 4  
 import java.awt.Dimension;
 5  
 import java.awt.event.WindowAdapter;
 6  
 import java.awt.event.WindowEvent;
 7  
 
 8  
 import javax.swing.JFrame;
 9  
 
 10  
 import org.bushe.swing.event.EventBus;
 11  
 import org.bushe.swing.event.EventTopicSubscriber;
 12  
 
 13  
 
 14  
 import de.glossmaker.gloss.datastructure.gui.Config;
 15  
 import de.glossmaker.gloss.language.Translation;
 16  
 import de.glossmaker.gui.bibtex.EUserInteration;
 17  
 import de.glossmaker.gui.bibtex.main.BibTeXItemsPanel;
 18  
 import de.glossmaker.gui.gloss.help.HelpSystem;
 19  
 
 20  
 /**
 21  
  * 
 22  
  * @author Markus Flingelli
 23  
  *
 24  
  */
 25  0
 public class BibTeXItemsFrame extends JFrame implements EventTopicSubscriber<String>{
 26  
         private static final long serialVersionUID = 3524937009503448523L;
 27  
         private static final String WINDOW_NAME = "BibTeX-Editor";
 28  
         
 29  
         private void saveWindowPosition() {
 30  0
                 Config.getInstance().setWindowPosition(
 31  
                                 WINDOW_NAME, 
 32  
                                 getX(), 
 33  
                                 getY(),
 34  
                                 getWidth(),
 35  
                                 getHeight());
 36  0
         }
 37  
         
 38  0
         public BibTeXItemsFrame(String fileName) {
 39  0
                 this.setTitle(Translation.getInstance().getValue("bibtex.editor.title.text"));
 40  0
                 EventBus.subscribe(EUserInteration.CLOSE_WINDOW.toString(), this);
 41  
                 
 42  0
                 setLocation(Config.getInstance().getWindowPositionX(WINDOW_NAME, 20), 
 43  
                                 Config.getInstance().getWindowPositionY(WINDOW_NAME, 20));
 44  
                 
 45  0
                 BibTeXItemsPanel bibTeXItemsPanel = new BibTeXItemsPanel(fileName);
 46  0
                 getContentPane().add(bibTeXItemsPanel, BorderLayout.CENTER);
 47  0
                 setPreferredSize(new Dimension(
 48  
                                 Config.getInstance().getWindowPositionWidth(WINDOW_NAME, 500),
 49  
                                 Config.getInstance().getWindowPositionHeight(WINDOW_NAME, 400)));
 50  0
                 setSize(getPreferredSize());
 51  0
                 HelpSystem.getInstance().enableHelpKey(getRootPane(), "section.bibeditor", null);
 52  0
                 HelpSystem.getInstance().setRootPane(getRootPane());
 53  0
                 setVisible(true);                
 54  0
                 this.addWindowListener(new WindowAdapter() {
 55  
                         @Override
 56  
                         public void windowClosing(WindowEvent event) {
 57  0
                                 saveWindowPosition();
 58  0
                         }                
 59  
                 });
 60  0
         }
 61  
 
 62  
         @Override
 63  
         public void onEvent(String topic, String data) {
 64  0
                 saveWindowPosition();
 65  0
                 this.setVisible(false);
 66  0
         }
 67  
 }