1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package ca.uhn.hl7v2.testpanel.ui.conn;
27
28 import java.awt.BorderLayout;
29 import java.awt.FlowLayout;
30 import java.awt.event.ActionEvent;
31 import java.awt.event.ActionListener;
32 import java.awt.event.WindowAdapter;
33 import java.awt.event.WindowEvent;
34
35 import javax.swing.JButton;
36 import javax.swing.JDialog;
37 import javax.swing.JPanel;
38 import javax.swing.border.EmptyBorder;
39
40 import ca.uhn.hl7v2.testpanel.controller.Controller;
41 import ca.uhn.hl7v2.testpanel.model.conn.OutboundConnection;
42 import ca.uhn.hl7v2.testpanel.ui.IDestroyable;
43 import ca.uhn.hl7v2.testpanel.util.IOkCancelCallback;
44
45 public class CreateOutboundConnectionDialog extends JDialog implements IDestroyable {
46
47 private Hl7ConnectionPanel myConnectionPanel;
48 private final JPanel mycontentPanel = new JPanel();
49 private boolean myDone;
50 private Controller myController;
51
52
53
54
55
56
57 public CreateOutboundConnectionDialog(Controller theController, final OutboundConnection theConnection, final IOkCancelCallback<OutboundConnection> theHandler) {
58 myController = theController;
59
60 addWindowListener(new WindowAdapter() {
61 @Override
62 public void windowClosing(WindowEvent e) {
63 if (!myDone) {
64 theHandler.cancel(theConnection);
65 }
66 }
67 });
68 setModal(true);
69 setBounds(100, 100, 687, 397);
70 getContentPane().setLayout(new BorderLayout());
71 mycontentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
72 getContentPane().add(mycontentPanel, BorderLayout.CENTER);
73 mycontentPanel.setLayout(new BorderLayout(0, 0));
74 {
75 JPanel buttonPane = new JPanel();
76 buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
77 getContentPane().add(buttonPane, BorderLayout.SOUTH);
78 {
79 JButton okButton = new JButton("OK");
80 okButton.addActionListener(new ActionListener() {
81
82 public void actionPerformed(ActionEvent e) {
83 theHandler.ok(theConnection);
84 myDone = true;
85 setVisible(false);
86 }
87 });
88 okButton.setActionCommand("OK");
89 buttonPane.add(okButton);
90 getRootPane().setDefaultButton(okButton);
91 }
92 {
93 JButton cancelButton = new JButton("Cancel");
94 cancelButton.addActionListener(new ActionListener() {
95 public void actionPerformed(ActionEvent e) {
96 theHandler.cancel(theConnection);
97 myDone = true;
98 setVisible(false);
99 }
100 });
101 cancelButton.setActionCommand("Cancel");
102 buttonPane.add(cancelButton);
103 }
104 }
105
106 myConnectionPanel = new Hl7ConnectionPanel(myController);
107 myConnectionPanel.setConnection(theConnection);
108
109
110
111 mycontentPanel.add(myConnectionPanel, BorderLayout.CENTER);
112
113 }
114
115 public void destroy() {
116 myConnectionPanel.destroy();
117 }
118
119 }