1 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 public class Test
26 {
27 static EOObjectStore objectStore;
28 static EOEditingContext editingContext;
29 static public void main( String[] argv )
30 {
31
32
33
34 try
35 {
36
37 UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
38
39
40 }
41 catch (Exception e)
42 {
43
44 }
45
46
47 for ( int i = 0; i < argv.length; i++ )
48 {
49 if ( argv[i].indexOf( "monitor" ) != -1 )
50 {
51 new net.wotonomy.ui.swing.NotificationInspector();
52 }
53 }
54 new net.wotonomy.ui.swing.NotificationInspector();
55
56
57 objectStore = new DataObjectStore( "data" );
58 editingContext = new EOEditingContext( objectStore );
59
60
61 TestPanel testPanel = new TestPanel();
62 final TestController controller = new TestController( testPanel );
63
64
65 JFrame frame = new JFrame();
66 frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
67
68
69 JMenu menu;
70 JMenuItem menuItem;
71 JMenuBar menuBar = new JMenuBar();
72 menu = new JMenu( "File" );
73 menu.add( "New" );
74 menuItem = new JMenuItem( "Save" );
75 menuItem.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_S, KeyEvent.CTRL_MASK ) );
76 menuItem.addActionListener( new ActionListener()
77 {
78 public void actionPerformed( ActionEvent evt )
79 {
80 controller.displayGroup.dataSource().editingContext().saveChanges();
81 }
82 });
83
84 menu.add( menuItem );
85 menu.add( "Close" );
86 menuBar.add( menu );
87 menu = new JMenu( "Edit" );
88 menu.add( "Cut" );
89 menu.add( "Copy" );
90 menu.add( "Paste" );
91 menuBar.add( menu );
92 frame.setJMenuBar( menuBar );
93
94 frame.getContentPane().add( testPanel, BorderLayout.CENTER );
95 frame.setTitle( "Test Frame" );
96 frame.setBounds( 50, 50, 750, 500 );
97 frame.show();
98
99
100 frame.addWindowListener( new WindowAdapter()
101 {
102
103 public void windowClosing(WindowEvent e)
104 {
105 System.exit( 0 );
106 }
107 });
108
109
110
111
112
113
114
115
116
117
118 }
119
120 }