| 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 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
0 |
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 |
0 |
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
} |
| 41 |
0 |
catch (Exception e) |
| 42 |
|
{ |
| 43 |
|
|
| 44 |
0 |
} |
| 45 |
|
|
| 46 |
|
|
| 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 |
|
|
| 57 |
0 |
objectStore = new DataObjectStore( "data" ); |
| 58 |
0 |
editingContext = new EOEditingContext( objectStore ); |
| 59 |
|
|
| 60 |
|
|
| 61 |
0 |
TestPanel testPanel = new TestPanel(); |
| 62 |
0 |
final TestController controller = new TestController( testPanel ); |
| 63 |
|
|
| 64 |
|
|
| 65 |
0 |
JFrame frame = new JFrame(); |
| 66 |
0 |
frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); |
| 67 |
|
|
| 68 |
|
|
| 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(); |
| 98 |
|
|
| 99 |
|
|
| 100 |
0 |
frame.addWindowListener( new WindowAdapter() |
| 101 |
|
{ |
| 102 |
|
|
| 103 |
0 |
public void windowClosing(WindowEvent e) |
| 104 |
|
{ |
| 105 |
0 |
System.exit( 0 ); |
| 106 |
0 |
} |
| 107 |
|
}); |
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
0 |
} |
| 119 |
|
|
| 120 |
|
} |