Coverage Report - net.wotonomy.test.Test
 
Classes in this File Line Coverage Branch Coverage Complexity
Test
0% 
0% 
2
 
 1  0
 package net.wotonomy.test;
 2  
 
 3  
 import java.awt.BorderLayout;
 4  
 import java.awt.event.ActionEvent;
 5  
 import java.awt.event.ActionListener;
 6  
 import java.awt.event.KeyEvent;
 7  
 import java.awt.event.WindowAdapter;
 8  
 import java.awt.event.WindowEvent;
 9  
 
 10  
 import javax.swing.JFrame;
 11  
 import javax.swing.JMenu;
 12  
 import javax.swing.JMenuBar;
 13  
 import javax.swing.JMenuItem;
 14  
 import javax.swing.KeyStroke;
 15  
 import javax.swing.UIManager;
 16  
 
 17  
 import net.wotonomy.control.EOEditingContext;
 18  
 import net.wotonomy.control.EOObjectStore;
 19  
 
 20  
 /**
 21  
 * A simple test-bed for wotonomy.
 22  
 * Shows a JFrame containing the TestPanel
 23  
 * which is controlled by the TestController.
 24  
 */
 25  0
 public class Test 
 26  
 {
 27  
     static EOObjectStore objectStore;
 28  
     static EOEditingContext editingContext;
 29  
     static public void main( String[] argv )
 30  
     {
 31  
 //        NSRunLoop.currentRunLoop();
 32  
         
 33  
         // system l&f
 34  
         try
 35  
         {
 36  
 //           UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
 37  0
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
 38  
 //           UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
 39  
 //            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
 40  
         }
 41  0
         catch (Exception e)
 42  
         {
 43  
                         // no system l&f - fail silently
 44  0
         }
 45  
         
 46  
         // launch notification monitor if desired
 47  0
         for ( int i = 0; i < argv.length; i++ )
 48  
         {
 49  0
             if ( argv[i].indexOf( "monitor" ) != -1 )
 50  
             {
 51  0
                 new net.wotonomy.ui.swing.NotificationInspector();                
 52  
            }
 53  
         }
 54  0
                 new net.wotonomy.ui.swing.NotificationInspector();                
 55  
         
 56  
         // set up editing context hierarchy
 57  0
         objectStore = new DataObjectStore( "data" );
 58  0
         editingContext = new EOEditingContext( objectStore );
 59  
 
 60  
                 // connect panel to controller
 61  0
         TestPanel testPanel = new TestPanel();
 62  0
                 final TestController controller = new TestController( testPanel );
 63  
         
 64  
                 // create frame and show
 65  0
         JFrame frame = new JFrame();
 66  0
         frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
 67  
                 
 68  
                 // setup menus
 69  
                 JMenu menu;
 70  
         JMenuItem menuItem;
 71  0
                 JMenuBar menuBar = new JMenuBar();
 72  0
                 menu = new JMenu( "File" );
 73  0
                 menu.add( "New" );
 74  0
         menuItem = new JMenuItem( "Save" );
 75  0
         menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_S, KeyEvent.CTRL_MASK ) );
 76  0
         menuItem.addActionListener( new ActionListener()
 77  
         {
 78  0
                         public void actionPerformed( ActionEvent evt )
 79  
                         {
 80  0
                 controller.displayGroup.dataSource().editingContext().saveChanges();        
 81  0
             }
 82  
         });
 83  
 
 84  0
                 menu.add( menuItem );
 85  0
                 menu.add( "Close" );
 86  0
                 menuBar.add( menu );
 87  0
                 menu = new JMenu( "Edit" );
 88  0
                 menu.add( "Cut" );
 89  0
                 menu.add( "Copy" );
 90  0
                 menu.add( "Paste" );
 91  0
                 menuBar.add( menu );
 92  0
                 frame.setJMenuBar( menuBar );
 93  
         
 94  0
                 frame.getContentPane().add( testPanel, BorderLayout.CENTER );
 95  0
                 frame.setTitle( "Test Frame" );
 96  0
         frame.setBounds( 50, 50, 750, 500 );
 97  0
                 frame.show(); // comment out this to avoid memory leak from jdk1.2.2 bug
 98  
 
 99  
                 // add WindowListener for frame
 100  0
                 frame.addWindowListener( new WindowAdapter()
 101  
                 {
 102  
                         // exit on close
 103  0
                         public void windowClosing(WindowEvent e)
 104  
                         {        
 105  0
                                 System.exit( 0 );
 106  0
                         }
 107  
                 });
 108  
 
 109  
         /* uncomment this to avoid memory leak from jdk1.2.2 bug
 110  
         frame.getContentPane().removeAll();
 111  
         */
 112  
 /*        
 113  
         NSNotificationCenter.defaultCenter().addObserver(
 114  
             frame, 
 115  
             new NSSelector( "hitMe", new Class[] { NSNotification.class } ),
 116  
             null, null );
 117  
 */        
 118  0
     }
 119  
     
 120  
 }