Coverage Report - net.sf.jabref.wizard.integrity.gui.IntegrityWizard
 
Classes in this File Line Coverage Branch Coverage Complexity
IntegrityWizard
92%
53/57
62%
5/8
2.5
IntegrityWizard$1
100%
3/3
N/A
2.5
 
 1  
 /*
 2  
  Copyright (C) 2004 R. Nagel
 3  
 
 4  
  All programs in this directory and
 5  
  subdirectories are published under the GNU General Public License as
 6  
  described below.
 7  
 
 8  
  This program is free software; you can redistribute it and/or modify
 9  
  it under the terms of the GNU General Public License as published by
 10  
  the Free Software Foundation; either version 2 of the License, or (at
 11  
  your option) any later version.
 12  
 
 13  
  This program is distributed in the hope that it will be useful, but
 14  
  WITHOUT ANY WARRANTY; without even the implied warranty of
 15  
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 16  
  General Public License for more details.
 17  
 
 18  
  You should have received a copy of the GNU General Public License
 19  
  along with this program; if not, write to the Free Software
 20  
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 21  
  USA
 22  
 
 23  
  Further information about the GNU GPL is available at:
 24  
  http://www.gnu.org/copyleft/gpl.ja.html
 25  
 
 26  
  */
 27  
 
 28  
 // created by : r.nagel 14.09.2004
 29  
 //
 30  
 // function :
 31  
 //
 32  
 // modified:
 33  
 //
 34  
 
 35  
 package net.sf.jabref.wizard.integrity.gui ;
 36  
 
 37  
 import java.awt.*;
 38  
 import java.awt.event.ActionEvent;
 39  
 import java.awt.event.ActionListener;
 40  
 import java.io.IOException;
 41  
 import java.net.URL;
 42  
 
 43  
 import javax.swing.*;
 44  
 import javax.swing.border.EtchedBorder;
 45  
 
 46  
 import net.sf.jabref.*;
 47  
 
 48  82628
 public class IntegrityWizard extends JDialog implements ActionListener {
 49  
 
 50  
   private BibtexDatabase dbase ;
 51  
   private BasePanel basePanel;
 52  
   private JButton closeButton ;
 53  
   private JButton startButton ;
 54  
   private IntegrityMessagePanel warnPanel ;
 55  
 
 56  
   public IntegrityWizard( JabRefFrame frame, BasePanel basePanel)
 57  
   {
 58  325535
     super( frame, "dialog", false ) ;  // no modal
 59  
 
 60  325535
     this.basePanel = basePanel;
 61  325535
     dbase = basePanel.database();
 62  
 
 63  
     try
 64  
     {
 65  325535
       jbInit() ;
 66  325535
       pack() ;
 67  
     }
 68  0
     catch ( Exception ex )
 69  
     {
 70  0
       ex.printStackTrace() ;
 71  325535
     }
 72  325535
   }
 73  
 
 74  
   private void jbInit() {
 75  
 //    this.setModal( true ) ;
 76  325535
     this.setResizable( false ) ;
 77  
 
 78  
     // messages
 79  325535
     this.setTitle( Globals.lang("Integrity_check") ) ;//Globals.lang( "Plain_text_import" ) + " " + typeStr ) ;
 80  
     //warnPanel = new IntegrityMessagePanel() ;
 81  
     //this.setTitle( "Experimental feature - Integrity Check") ;//Globals.lang( "Plain_text_import" ) + " " + typeStr ) ;
 82  325535
     warnPanel = new IntegrityMessagePanel(basePanel) ;
 83  
 
 84  
 
 85  
     // ButtonPanel
 86  325535
     JPanel buttonPanel = new JPanel() ;
 87  325535
     GridBagLayout gbl = new GridBagLayout() ;
 88  325535
     GridBagConstraints con = new GridBagConstraints() ;
 89  325535
     con.weightx = 0 ;
 90  325535
     con.insets = new Insets( 5, 10, 0, 10 ) ;
 91  325535
     con.fill = GridBagConstraints.HORIZONTAL ;
 92  
 
 93  
     // Buttons
 94  325535
     startButton = new JButton(Globals.lang("Scan")) ;
 95  325535
     startButton.addActionListener( this) ;
 96  325535
     closeButton = new JButton(Globals.lang("Close"));
 97  325535
     closeButton.addActionListener( this) ;
 98  
 
 99  
     // insert Buttons
 100  325535
     con.gridwidth = GridBagConstraints.REMAINDER ;
 101  325535
     gbl.setConstraints( startButton, con ) ;
 102  325535
     buttonPanel.add( startButton ) ;
 103  
 
 104  325535
     gbl.setConstraints( closeButton, con ) ;
 105  325535
     buttonPanel.add( closeButton ) ;
 106  
 
 107  
     // ----------------------------------------------------------------------
 108  
     // add a short info, if available
 109  
 
 110  325535
     JEditorPane infoText = null ;
 111  
 
 112  325535
     URL infoURL = JabRef.class.getResource(GUIGlobals.getLocaleHelpPath()
 113  
                                            +GUIGlobals.shortIntegrityCheck);
 114  325535
     if (infoURL != null)
 115  
       try
 116  
       {
 117  325535
         infoText = new JEditorPane() ;
 118  325535
         infoText.setEditable(false);
 119  325535
         infoText.setPreferredSize( new Dimension(220, 60));
 120  325535
         infoText.setMinimumSize( new Dimension(180, 50));
 121  325535
         infoText.setPage(infoURL);
 122  325535
         infoText.setBackground(GUIGlobals.infoField);
 123  325535
         infoText.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
 124  
 //        bottomPanel.add( infoText, BorderLayout.CENTER ) ;
 125  
       }
 126  0
       catch (IOException e)
 127  
       {
 128  0
         infoText = null ;
 129  325535
       }
 130  
 
 131  
     // -----------------------------------------------------------------------
 132  
 
 133  
     // content
 134  325535
     Container content = this.getContentPane() ;
 135  325535
     content.setLayout( new BorderLayout());
 136  
 
 137  325535
     if (infoText != null) // only if some help available
 138  
     {
 139  325535
       content.add( infoText, BorderLayout.PAGE_START ) ;
 140  
     }
 141  325535
     content.add(warnPanel, BorderLayout.CENTER) ;
 142  325535
     content.add(buttonPanel, BorderLayout.PAGE_END) ;
 143  325535
   }
 144  
 
 145  
 
 146  
 // ---------------------------------------------------------------------------
 147  
 // ---------------------------------------------------------------------------
 148  
 
 149  
   public void actionPerformed( ActionEvent e )
 150  
   {
 151  193256
     Object sender = e.getSource() ;
 152  
 
 153  193256
     if (sender == closeButton)
 154  
     {
 155  151942
       dispose() ;
 156  
     }
 157  41314
     else if (sender == startButton)
 158  
     {
 159  41314
       startButton.setEnabled(false);
 160  41314
       Runnable scanWork = new Runnable()
 161  41314
       {
 162  
         public void run()
 163  
         {
 164  41314
           warnPanel.updateView(dbase);
 165  41314
         }
 166  
       } ;
 167  41314
       SwingUtilities.invokeLater(scanWork);
 168  41314
       startButton.setEnabled(true);
 169  
     }
 170  193256
   }
 171  
 
 172  
 
 173  
 
 174  
 }