View Javadoc
1   /**
2    * The contents of this file are subject to the Mozilla Public License Version 1.1
3    * (the "License"); you may not use this file except in compliance with the License.
4    * You may obtain a copy of the License at http://www.mozilla.org/MPL/
5    * Software distributed under the License is distributed on an "AS IS" basis,
6    * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
7    * specific language governing rights and limitations under the License.
8    *
9    * The Original Code is ""  Description:
10   * ""
11   *
12   * The Initial Developer of the Original Code is University Health Network. Copyright (C)
13   * 2001.  All Rights Reserved.
14   *
15   * Contributor(s): ______________________________________.
16   *
17   * Alternatively, the contents of this file may be used under the terms of the
18   * GNU General Public License (the  "GPL"), in which case the provisions of the GPL are
19   * applicable instead of those above.  If you wish to allow use of your version of this
20   * file only under the terms of the GPL and not to allow others to use your version
21   * of this file under the MPL, indicate your decision by deleting  the provisions above
22   * and replace  them with the notice and other provisions required by the GPL License.
23   * If you do not delete the provisions above, a recipient may use your version of
24   * this file under either the MPL or the GPL.
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  	 * Create the dialog.
54  	 * 
55  	 * @param theHandler
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 //		myConnectionPanel.markDisableStartingAndStopping();
109 //		myConnectionPanel.setLabelText("Create a new connection to send messages to");
110 
111 		mycontentPanel.add(myConnectionPanel, BorderLayout.CENTER);
112 
113 	}
114 
115 	public void destroy() {
116 		myConnectionPanel.destroy();
117 	}
118 
119 }