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 static org.apache.commons.lang.StringUtils.*;
29  
30  import java.awt.CardLayout;
31  import java.awt.Color;
32  import java.awt.Component;
33  import java.awt.Dimension;
34  import java.awt.GridBagConstraints;
35  import java.awt.GridBagLayout;
36  import java.awt.Insets;
37  import java.awt.event.ActionEvent;
38  import java.awt.event.ActionListener;
39  import java.beans.PropertyChangeEvent;
40  import java.beans.PropertyChangeListener;
41  import java.net.MalformedURLException;
42  import java.net.URL;
43  import java.nio.charset.Charset;
44  import java.util.ArrayList;
45  import java.util.Collections;
46  import java.util.List;
47  
48  import javax.swing.ButtonGroup;
49  import javax.swing.ComboBoxModel;
50  import javax.swing.DefaultComboBoxModel;
51  import javax.swing.ImageIcon;
52  import javax.swing.JButton;
53  import javax.swing.JCheckBox;
54  import javax.swing.JComboBox;
55  import javax.swing.JFileChooser;
56  import javax.swing.JLabel;
57  import javax.swing.JPanel;
58  import javax.swing.JRadioButton;
59  import javax.swing.JTextField;
60  import javax.swing.SwingConstants;
61  import javax.swing.SwingUtilities;
62  import javax.swing.border.EtchedBorder;
63  import javax.swing.event.DocumentEvent;
64  
65  import org.apache.commons.lang.StringUtils;
66  
67  import ca.uhn.hl7v2.testpanel.api.WorkingStatusBean;
68  import ca.uhn.hl7v2.testpanel.controller.Controller;
69  import ca.uhn.hl7v2.testpanel.controller.Prefs;
70  import ca.uhn.hl7v2.testpanel.model.conn.AbstractConnection;
71  import ca.uhn.hl7v2.testpanel.model.conn.AbstractConnection.StatusEnum;
72  import ca.uhn.hl7v2.testpanel.model.conn.OutboundConnection;
73  import ca.uhn.hl7v2.testpanel.model.conn.TransportStyleEnum;
74  import ca.uhn.hl7v2.testpanel.ui.IDestroyable;
75  import ca.uhn.hl7v2.testpanel.util.SimpleDocumentListener;
76  import ca.uhn.hl7v2.testpanel.xsd.Hl7V2EncodingTypeEnum;
77  
78  public class Hl7ConnectionPanel extends JPanel implements IDestroyable {
79  	private static final Color ERROR_BG = new Color(1.0f, 0.8f, 0.8f);
80  	private static final String HOH_SIGNATURE_KEY_USE_ANY_AVAILABLE = "Use any available";
81  	private static final ImageIcon ICON_INFO_OK = new ImageIcon(Hl7ConnectionPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/info_ok.png"));
82  	private static final ImageIcon ICON_INFO_WARNING = new ImageIcon(Hl7ConnectionPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/info_warning.png"));
83  	private static final ImageIcon ICON_INFO_WORKING = new ImageIcon(Hl7ConnectionPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/info_working.png"));
84  
85  	private static final String IFACE_TYPE_CARD_HOH = "hohCard";
86  	private static final String IFACE_TYPE_CARD_MLLP = "name_1344598061103376000";
87  	private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(Hl7ConnectionPanel.class);
88  	private final ButtonGroup charsetButtonGroup = new ButtonGroup();
89  
90  	private final ButtonGroup encodingButtonGroup = new ButtonGroup();
91  	private JPanel hohAuthPanel;
92  	private JCheckBox myCaptureByteStreamCheckbox;
93  	private JComboBox myCharsetCombo;
94  	private JRadioButton myCharsetDetectRadio;
95  	private JRadioButton myCharsetSelectRadio;
96  	private AbstractConnection myConnection;
97  	private JTextField myDualIncomingTextBox;
98  	private JTextField myDualOutgoingTextBox;
99  	private JRadioButton myDualPortRadio;
100 	private JRadioButton myEr7Radio;
101 	private JRadioButton myHl7OverHttpRadioButton;
102 	private JCheckBox myHohAuthEnabledCheckbox;
103 	private JTextField myHohAuthPasswordTextbox;
104 	private JTextField myHohAuthUsernameTextbox;
105 	private JPanel myHoHCard;
106 	private JTextField myHohSecurityKeyPwTextBox;
107 	private JButton myHohSecurityKeystoreChooseBtn;
108 	private JTextField myHohSecurityKeystoreTextbox;
109 	private JLabel myHohSecurityProfileKeystoreStatus;
110 	private PropertyChangeListener myHohSecurityProfileKeystoreStatusListener;
111 	private JCheckBox myHohSignatureEnabled;
112 	private JComboBox myHohSignatureKeyAliasCombo;
113 	private JTextField myHohSignatureKeyPass;
114 	private JButton myHohSignatureKeystoreChooseButton;
115 	private JTextField myHohSignatureKeystorePasswordTextbox;
116 	private JTextField myHohSignatureKeystoreTextbox;
117 	private JLabel myHohSignatureStatusLabel;
118 	private JCheckBox myHohTlsCheckbox;
119 	private JTextField myHoHUrlTextField;
120 	private boolean myHohUrlTextFieldUpdating;
121 	private JTextField myHostBox;
122 	private JPanel myInterfaceTypeCardPanel;
123 	private JLabel mylabel;
124 	private JLabel mylabel_1;
125 	private JLabel mylabel_10;
126 	private JLabel mylabel_11;
127 	private JLabel mylabel_12;
128 
129 	// private JPanel securityProfilePanel;
130 
131 	private JLabel mylabel_13;
132 	private JLabel mylabel_2;
133 	private JLabel mylabel_3;
134 	private JLabel mylabel_4;
135 	private JLabel mylabel_5;
136 	private JLabel mylabel_6;
137 	private JLabel mylabel_7;
138 	private JLabel mylabel_8;
139 	private JLabel mylabel_9;
140 	private JPanel myMllpCard;
141 	private JPanel mypanel;
142 	private JPanel mypanel_1;
143 	private JPanel mypanel_2;
144 	private JPanel mypanel_3;
145 	private final ButtonGroup myPortButtonGroup = new ButtonGroup();
146 	private JRadioButton mySinglePortRadio;
147 	private JTextField mySinglePortTextBox;
148 	private PropertyChangeListener myStatusLinePropertyChangeListener;
149 	private PropertyChangeListener myStatusPropertyChangeListener;
150 	private JCheckBox myTlsCheckbox;
151 	private boolean myUpdatingHohSignatureKeyAliasCombo;
152 	private JRadioButton myXmlRadio;
153 	private JPanel tlsKeystorePanel;
154 	private KeystoreStatusListener myHohSignatureStatusListener;
155 	private PropertyChangeListener myHohSignerAvailableAliasesListener;
156 
157 	/**
158 	 * Create the panel.
159 	 */
160 	public Hl7ConnectionPanel(Controller theController) {
161 		setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
162 		GridBagLayout gridBagLayout = new GridBagLayout();
163 		gridBagLayout.columnWidths = new int[] { 150, 0 };
164 		gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
165 		gridBagLayout.columnWeights = new double[] { 0.0, 1.0 };
166 		gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
167 		setLayout(gridBagLayout);
168 
169 		mySinglePortRadio = new JRadioButton("Single Port MLLP");
170 		mySinglePortRadio.addActionListener(new ActionListener() {
171 			public void actionPerformed(ActionEvent e) {
172 				updatePortsModel();
173 				updatePortsUi();
174 			}
175 		});
176 		myPortButtonGroup.add(mySinglePortRadio);
177 		GridBagConstraints gbc_SinglePortRadio = new GridBagConstraints();
178 		gbc_SinglePortRadio.anchor = GridBagConstraints.WEST;
179 		gbc_SinglePortRadio.insets = new Insets(0, 0, 5, 5);
180 		gbc_SinglePortRadio.gridx = 0;
181 		gbc_SinglePortRadio.gridy = 0;
182 		add(mySinglePortRadio, gbc_SinglePortRadio);
183 
184 		JPanel panel_4 = new JPanel();
185 		panel_4.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
186 		GridBagConstraints gbc_panel_4 = new GridBagConstraints();
187 		gbc_panel_4.fill = GridBagConstraints.BOTH;
188 		gbc_panel_4.insets = new Insets(0, 0, 5, 0);
189 		gbc_panel_4.gridx = 1;
190 		gbc_panel_4.gridy = 0;
191 		add(panel_4, gbc_panel_4);
192 		GridBagLayout gbl_panel_4 = new GridBagLayout();
193 		gbl_panel_4.columnWidths = new int[] { 0, 0, 0 };
194 		gbl_panel_4.rowHeights = new int[] { 0, 0 };
195 		gbl_panel_4.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
196 		gbl_panel_4.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
197 		panel_4.setLayout(gbl_panel_4);
198 
199 		mySinglePortTextBox = new JTextField();
200 		mySinglePortTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
201 			@Override
202 			public void update(DocumentEvent theE) {
203 				String text = mySinglePortTextBox.getText();
204 				text = text.replaceAll("[^0-9]+", "");
205 				if (!StringUtils.equals(mySinglePortTextBox.getText(), text)) {
206 					final String newVal = text;
207 					SwingUtilities.invokeLater(new Runnable() {
208 						public void run() {
209 							mySinglePortTextBox.setText(newVal);
210 						}
211 					});
212 				}
213 				if (mySinglePortRadio.isSelected()) {
214 					if (text.length() > 0) {
215 						myConnection.setIncomingOrSinglePort(Integer.parseInt(text));
216 					} else {
217 						myConnection.setIncomingOrSinglePort(-1);
218 					}
219 				}
220 			}
221 		});
222 
223 		mylabel = new JLabel("Port");
224 		mylabel.setHorizontalAlignment(SwingConstants.CENTER);
225 		mylabel.setPreferredSize(new Dimension(60, 16));
226 		mylabel.setMinimumSize(new Dimension(60, 16));
227 		mylabel.setMaximumSize(new Dimension(60, 16));
228 		GridBagConstraints gbc_label = new GridBagConstraints();
229 		gbc_label.anchor = GridBagConstraints.EAST;
230 		gbc_label.insets = new Insets(0, 0, 0, 5);
231 		gbc_label.gridx = 0;
232 		gbc_label.gridy = 0;
233 		panel_4.add(mylabel, gbc_label);
234 		GridBagConstraints gbc_SinglePortTextBox = new GridBagConstraints();
235 		gbc_SinglePortTextBox.insets = new Insets(0, 5, 0, 0);
236 		gbc_SinglePortTextBox.anchor = GridBagConstraints.WEST;
237 		gbc_SinglePortTextBox.gridx = 1;
238 		gbc_SinglePortTextBox.gridy = 0;
239 		panel_4.add(mySinglePortTextBox, gbc_SinglePortTextBox);
240 		mySinglePortTextBox.setMinimumSize(new Dimension(100, 28));
241 		mySinglePortTextBox.setMaximumSize(new Dimension(100, 2147483647));
242 		mySinglePortTextBox.setColumns(10);
243 
244 		myDualPortRadio = new JRadioButton("Dual Port MLLP");
245 		myDualPortRadio.addActionListener(new ActionListener() {
246 			public void actionPerformed(ActionEvent e) {
247 				updatePortsModel();
248 				updatePortsUi();
249 			}
250 		});
251 		myPortButtonGroup.add(myDualPortRadio);
252 		GridBagConstraints gbc_DualPortRadio = new GridBagConstraints();
253 		gbc_DualPortRadio.anchor = GridBagConstraints.WEST;
254 		gbc_DualPortRadio.insets = new Insets(0, 0, 5, 5);
255 		gbc_DualPortRadio.gridx = 0;
256 		gbc_DualPortRadio.gridy = 1;
257 		add(myDualPortRadio, gbc_DualPortRadio);
258 
259 		JPanel panel = new JPanel();
260 		panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
261 		GridBagConstraints gbc_BottomPanel = new GridBagConstraints();
262 		gbc_BottomPanel.insets = new Insets(0, 0, 5, 0);
263 		gbc_BottomPanel.fill = GridBagConstraints.BOTH;
264 		gbc_BottomPanel.gridx = 1;
265 		gbc_BottomPanel.gridy = 1;
266 		add(panel, gbc_BottomPanel);
267 		GridBagLayout gbl_panel = new GridBagLayout();
268 		gbl_panel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0 };
269 		gbl_panel.rowHeights = new int[] { 0, 0 };
270 		gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
271 		gbl_panel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
272 		panel.setLayout(gbl_panel);
273 
274 		JLabel lblInbound = new JLabel("Inbound");
275 		lblInbound.setHorizontalAlignment(SwingConstants.CENTER);
276 		lblInbound.setPreferredSize(new Dimension(60, 16));
277 		lblInbound.setMinimumSize(new Dimension(60, 16));
278 		lblInbound.setMaximumSize(new Dimension(60, 16));
279 		GridBagConstraints gbc_lblInbound = new GridBagConstraints();
280 		gbc_lblInbound.insets = new Insets(0, 5, 0, 5);
281 		gbc_lblInbound.anchor = GridBagConstraints.EAST;
282 		gbc_lblInbound.gridx = 0;
283 		gbc_lblInbound.gridy = 0;
284 		panel.add(lblInbound, gbc_lblInbound);
285 
286 		myDualIncomingTextBox = new JTextField();
287 		myDualIncomingTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
288 			@Override
289 			public void update(DocumentEvent theE) {
290 				String text = myDualIncomingTextBox.getText();
291 				text = text.replaceAll("[^0-9]+", "");
292 				if (!StringUtils.equals(myDualIncomingTextBox.getText(), text)) {
293 					final String newVal = text;
294 					SwingUtilities.invokeLater(new Runnable() {
295 						public void run() {
296 							myDualIncomingTextBox.setText(newVal);
297 						}
298 					});
299 				}
300 				if (myDualPortRadio.isSelected()) {
301 					if (text.length() > 0) {
302 						myConnection.setIncomingOrSinglePort(Integer.parseInt(text));
303 					} else {
304 						myConnection.setIncomingOrSinglePort(-1);
305 					}
306 				}
307 			}
308 		});
309 		myDualIncomingTextBox.setMaximumSize(new Dimension(100, 2147483647));
310 		myDualIncomingTextBox.setMinimumSize(new Dimension(100, 28));
311 		GridBagConstraints gbc_DualIncomingTextBox = new GridBagConstraints();
312 		gbc_DualIncomingTextBox.anchor = GridBagConstraints.WEST;
313 		gbc_DualIncomingTextBox.insets = new Insets(0, 0, 0, 5);
314 		gbc_DualIncomingTextBox.gridx = 1;
315 		gbc_DualIncomingTextBox.gridy = 0;
316 		panel.add(myDualIncomingTextBox, gbc_DualIncomingTextBox);
317 		myDualIncomingTextBox.setColumns(10);
318 
319 		JLabel lblOutbound = new JLabel("Outbound");
320 		GridBagConstraints gbc_lblOutbound = new GridBagConstraints();
321 		gbc_lblOutbound.anchor = GridBagConstraints.EAST;
322 		gbc_lblOutbound.insets = new Insets(0, 0, 0, 5);
323 		gbc_lblOutbound.gridx = 2;
324 		gbc_lblOutbound.gridy = 0;
325 		panel.add(lblOutbound, gbc_lblOutbound);
326 
327 		myDualOutgoingTextBox = new JTextField();
328 		myDualOutgoingTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
329 			@Override
330 			public void update(DocumentEvent theE) {
331 				String text = myDualOutgoingTextBox.getText();
332 				text = text.replaceAll("[^0-9]+", "");
333 				if (!StringUtils.equals(myDualOutgoingTextBox.getText(), text)) {
334 					final String newVal = text;
335 					SwingUtilities.invokeLater(new Runnable() {
336 						public void run() {
337 							myDualOutgoingTextBox.setText(newVal);
338 						}
339 					});
340 				}
341 				if (myDualPortRadio.isSelected()) {
342 					if (text.length() > 0) {
343 						myConnection.setOutgoingPort(Integer.parseInt(text));
344 					} else {
345 						myConnection.setOutgoingPort(-1);
346 					}
347 				}
348 			}
349 		});
350 		myDualOutgoingTextBox.setMinimumSize(new Dimension(100, 28));
351 		myDualOutgoingTextBox.setMaximumSize(new Dimension(100, 2147483647));
352 		GridBagConstraints gbc_DualOutgoingTextBox = new GridBagConstraints();
353 		gbc_DualOutgoingTextBox.insets = new Insets(0, 0, 0, 5);
354 		gbc_DualOutgoingTextBox.anchor = GridBagConstraints.WEST;
355 		gbc_DualOutgoingTextBox.gridx = 3;
356 		gbc_DualOutgoingTextBox.gridy = 0;
357 		panel.add(myDualOutgoingTextBox, gbc_DualOutgoingTextBox);
358 		myDualOutgoingTextBox.setColumns(10);
359 
360 		myHl7OverHttpRadioButton = new JRadioButton("HL7 over HTTP");
361 		myHl7OverHttpRadioButton.addActionListener(new ActionListener() {
362 			public void actionPerformed(ActionEvent e) {
363 				updatePortsModel();
364 				updatePortsUi();
365 			}
366 		});
367 		myPortButtonGroup.add(myHl7OverHttpRadioButton);
368 		GridBagConstraints gbc_Hl7OverHttpRadioButton = new GridBagConstraints();
369 		gbc_Hl7OverHttpRadioButton.anchor = GridBagConstraints.WEST;
370 		gbc_Hl7OverHttpRadioButton.insets = new Insets(0, 0, 5, 5);
371 		gbc_Hl7OverHttpRadioButton.gridx = 0;
372 		gbc_Hl7OverHttpRadioButton.gridy = 2;
373 		add(myHl7OverHttpRadioButton, gbc_Hl7OverHttpRadioButton);
374 
375 		mypanel = new JPanel();
376 		mypanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
377 		GridBagConstraints gbc_panel = new GridBagConstraints();
378 		gbc_panel.insets = new Insets(0, 0, 5, 0);
379 		gbc_panel.fill = GridBagConstraints.BOTH;
380 		gbc_panel.gridx = 1;
381 		gbc_panel.gridy = 2;
382 		add(mypanel, gbc_panel);
383 		GridBagLayout gbl_panel2 = new GridBagLayout();
384 		gbl_panel2.columnWidths = new int[] { 0, 0 };
385 		gbl_panel2.rowHeights = new int[] { 0, 0 };
386 		gbl_panel2.columnWeights = new double[] { 0.0, 1.0 };
387 		gbl_panel2.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
388 		mypanel.setLayout(gbl_panel2);
389 
390 		mylabel_1 = new JLabel("URL");
391 		mylabel_1.setHorizontalAlignment(SwingConstants.CENTER);
392 		mylabel_1.setPreferredSize(new Dimension(60, 16));
393 		mylabel_1.setMinimumSize(new Dimension(60, 16));
394 		mylabel_1.setMaximumSize(new Dimension(60, 16));
395 		GridBagConstraints gbc_label_1 = new GridBagConstraints();
396 		gbc_label_1.anchor = GridBagConstraints.EAST;
397 		gbc_label_1.insets = new Insets(0, 0, 0, 5);
398 		gbc_label_1.gridx = 0;
399 		gbc_label_1.gridy = 0;
400 		mypanel.add(mylabel_1, gbc_label_1);
401 
402 		myHoHUrlTextField = new JTextField();
403 		myHoHUrlTextField.getDocument().addDocumentListener(new SimpleDocumentListener() {
404 			@Override
405 			public void update(DocumentEvent theE) {
406 				if (myHohUrlTextFieldUpdating) {
407 					return;
408 				}
409 
410 				String value = myHoHUrlTextField.getText();
411 				try {
412 					URL url = new URL(value);
413 					boolean tls;
414 					if (url.getProtocol().equals("http")) {
415 						tls = false;
416 					} else if (url.getProtocol().equals("https")) {
417 						tls = true;
418 					} else {
419 						ourLog.info("Unknown protocol: {}", url.getProtocol());
420 						myHoHUrlTextField.setBackground(ERROR_BG);
421 						return;
422 					}
423 
424 					myConnection.setTls(tls);
425 					myConnection.setHost(url.getHost());
426 					myConnection.setIncomingOrSinglePort(url.getPort() != -1 ? url.getPort() : url.getDefaultPort());
427 					myConnection.setHttpUriPath(url.getPath());
428 
429 					myHohUrlTextFieldUpdating = true;
430 					updatePortsUi();
431 					myHohUrlTextFieldUpdating = false;
432 
433 					myTlsCheckbox.setSelected(tls);
434 					myHohTlsCheckbox.setSelected(tls);
435 
436 					myHoHUrlTextField.setBackground(Color.white);
437 				} catch (MalformedURLException e) {
438 					myHoHUrlTextField.setBackground(ERROR_BG);
439 				}
440 
441 			}
442 		});
443 		GridBagConstraints gbc_HohUsernameTextbox = new GridBagConstraints();
444 		gbc_HohUsernameTextbox.fill = GridBagConstraints.HORIZONTAL;
445 		gbc_HohUsernameTextbox.gridx = 1;
446 		gbc_HohUsernameTextbox.gridy = 0;
447 		mypanel.add(myHoHUrlTextField, gbc_HohUsernameTextbox);
448 		myHoHUrlTextField.setColumns(10);
449 
450 		JLabel lblEncoding = new JLabel("Encoding");
451 		GridBagConstraints gbc_lblEncoding = new GridBagConstraints();
452 		gbc_lblEncoding.insets = new Insets(0, 0, 5, 5);
453 		gbc_lblEncoding.gridx = 0;
454 		gbc_lblEncoding.gridy = 3;
455 		add(lblEncoding, gbc_lblEncoding);
456 
457 		JPanel encodingPanel = new JPanel();
458 		GridBagConstraints gbc_encodingPanel = new GridBagConstraints();
459 		gbc_encodingPanel.fill = GridBagConstraints.HORIZONTAL;
460 		gbc_encodingPanel.insets = new Insets(0, 0, 5, 0);
461 		gbc_encodingPanel.gridx = 1;
462 		gbc_encodingPanel.gridy = 3;
463 		add(encodingPanel, gbc_encodingPanel);
464 		encodingPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
465 		GridBagLayout gbl_encodingPanel = new GridBagLayout();
466 		gbl_encodingPanel.columnWidths = new int[] { 144, 58, 0 };
467 		gbl_encodingPanel.rowHeights = new int[] { 23, 0 };
468 		gbl_encodingPanel.columnWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
469 		gbl_encodingPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
470 		encodingPanel.setLayout(gbl_encodingPanel);
471 
472 		myXmlRadio = new JRadioButton("XML");
473 		myXmlRadio.addActionListener(new ActionListener() {
474 
475 			public void actionPerformed(ActionEvent theE) {
476 				updateEncodingModel();
477 			}
478 		});
479 
480 		myEr7Radio = new JRadioButton("ER7 (Pipe and hat)");
481 		myEr7Radio.addActionListener(new ActionListener() {
482 			public void actionPerformed(ActionEvent e) {
483 				updateEncodingModel();
484 			}
485 		});
486 		encodingButtonGroup.add(myEr7Radio);
487 		GridBagConstraints gbc_Er7Radio = new GridBagConstraints();
488 		gbc_Er7Radio.anchor = GridBagConstraints.NORTHWEST;
489 		gbc_Er7Radio.insets = new Insets(0, 0, 0, 5);
490 		gbc_Er7Radio.gridx = 0;
491 		gbc_Er7Radio.gridy = 0;
492 		encodingPanel.add(myEr7Radio, gbc_Er7Radio);
493 		encodingButtonGroup.add(myXmlRadio);
494 		GridBagConstraints gbc_XmlRadio = new GridBagConstraints();
495 		gbc_XmlRadio.anchor = GridBagConstraints.NORTHWEST;
496 		gbc_XmlRadio.gridx = 1;
497 		gbc_XmlRadio.gridy = 0;
498 		encodingPanel.add(myXmlRadio, gbc_XmlRadio);
499 
500 		JLabel lblCharset = new JLabel("Charset");
501 		GridBagConstraints gbc_lblCharset = new GridBagConstraints();
502 		gbc_lblCharset.insets = new Insets(0, 0, 5, 5);
503 		gbc_lblCharset.gridx = 0;
504 		gbc_lblCharset.gridy = 4;
505 		add(lblCharset, gbc_lblCharset);
506 
507 		JPanel panel_2 = new JPanel();
508 		GridBagConstraints gbc_panel_2 = new GridBagConstraints();
509 		gbc_panel_2.fill = GridBagConstraints.HORIZONTAL;
510 		gbc_panel_2.insets = new Insets(0, 0, 5, 0);
511 		gbc_panel_2.gridx = 1;
512 		gbc_panel_2.gridy = 4;
513 		add(panel_2, gbc_panel_2);
514 		panel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
515 		GridBagLayout gbl_panel_2 = new GridBagLayout();
516 		gbl_panel_2.columnWidths = new int[] { 28, 198, 0, 0 };
517 		gbl_panel_2.rowHeights = new int[] { 27, 0 };
518 		gbl_panel_2.columnWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
519 		gbl_panel_2.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
520 		panel_2.setLayout(gbl_panel_2);
521 
522 		myCharsetSelectRadio = new JRadioButton("");
523 		myCharsetSelectRadio.addActionListener(new ActionListener() {
524 			public void actionPerformed(ActionEvent e) {
525 				updateCharsetModel();
526 			}
527 		});
528 		charsetButtonGroup.add(myCharsetSelectRadio);
529 		GridBagConstraints gbc_CharsetSelectRadio = new GridBagConstraints();
530 		gbc_CharsetSelectRadio.anchor = GridBagConstraints.WEST;
531 		gbc_CharsetSelectRadio.insets = new Insets(0, 0, 0, 5);
532 		gbc_CharsetSelectRadio.gridx = 0;
533 		gbc_CharsetSelectRadio.gridy = 0;
534 		panel_2.add(myCharsetSelectRadio, gbc_CharsetSelectRadio);
535 
536 		myCharsetCombo = new JComboBox();
537 		myCharsetCombo.addActionListener(new ActionListener() {
538 			public void actionPerformed(ActionEvent e) {
539 				updateCharsetModel();
540 			}
541 		});
542 		GridBagConstraints gbc_CharsetCombo = new GridBagConstraints();
543 		gbc_CharsetCombo.anchor = GridBagConstraints.NORTHWEST;
544 		gbc_CharsetCombo.insets = new Insets(0, 0, 0, 5);
545 		gbc_CharsetCombo.gridx = 1;
546 		gbc_CharsetCombo.gridy = 0;
547 		panel_2.add(myCharsetCombo, gbc_CharsetCombo);
548 
549 		myCharsetDetectRadio = new JRadioButton("Detect in Message (MSH-18)");
550 		myCharsetDetectRadio.addActionListener(new ActionListener() {
551 			public void actionPerformed(ActionEvent e) {
552 				updateCharsetModel();
553 			}
554 		});
555 		charsetButtonGroup.add(myCharsetDetectRadio);
556 		GridBagConstraints gbc_CharsetDetectRadio = new GridBagConstraints();
557 		gbc_CharsetDetectRadio.anchor = GridBagConstraints.NORTH;
558 		gbc_CharsetDetectRadio.gridwidth = 2;
559 		gbc_CharsetDetectRadio.gridx = 2;
560 		gbc_CharsetDetectRadio.gridy = 0;
561 		panel_2.add(myCharsetDetectRadio, gbc_CharsetDetectRadio);
562 
563 		mylabel_5 = new JLabel("Debug");
564 		GridBagConstraints gbc_label_5 = new GridBagConstraints();
565 		gbc_label_5.insets = new Insets(0, 0, 5, 5);
566 		gbc_label_5.gridx = 0;
567 		gbc_label_5.gridy = 5;
568 		add(mylabel_5, gbc_label_5);
569 
570 		mypanel_2 = new JPanel();
571 		mypanel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
572 		GridBagConstraints gbc_panel_75 = new GridBagConstraints();
573 		gbc_panel_75.insets = new Insets(0, 0, 5, 0);
574 		gbc_panel_75.fill = GridBagConstraints.BOTH;
575 		gbc_panel_75.gridx = 1;
576 		gbc_panel_75.gridy = 5;
577 		add(mypanel_2, gbc_panel_75);
578 		GridBagLayout gbl_panel_74 = new GridBagLayout();
579 		gbl_panel_74.columnWidths = new int[] { 0, 0 };
580 		gbl_panel_74.rowHeights = new int[] { 0, 0 };
581 		gbl_panel_74.columnWeights = new double[] { 0.0, Double.MIN_VALUE };
582 		gbl_panel_74.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
583 		mypanel_2.setLayout(gbl_panel_74);
584 
585 		myCaptureByteStreamCheckbox = new JCheckBox("Capture Bytes");
586 		GridBagConstraints gbc_CaptureByteStreamCheckbox = new GridBagConstraints();
587 		gbc_CaptureByteStreamCheckbox.gridx = 0;
588 		gbc_CaptureByteStreamCheckbox.gridy = 0;
589 		mypanel_2.add(myCaptureByteStreamCheckbox, gbc_CaptureByteStreamCheckbox);
590 		myCaptureByteStreamCheckbox.addActionListener(new ActionListener() {
591 			public void actionPerformed(ActionEvent e) {
592 				myConnection.setCaptureBytes(myCaptureByteStreamCheckbox.isSelected());
593 			}
594 		});
595 		myCaptureByteStreamCheckbox.setToolTipText("Check this box to capture the transport level communication");
596 
597 		myInterfaceTypeCardPanel = new JPanel();
598 		myInterfaceTypeCardPanel.setBorder(null);
599 		GridBagConstraints gbc_InterfaceTypeCardPanel = new GridBagConstraints();
600 		gbc_InterfaceTypeCardPanel.gridwidth = 2;
601 		gbc_InterfaceTypeCardPanel.fill = GridBagConstraints.BOTH;
602 		gbc_InterfaceTypeCardPanel.gridx = 0;
603 		gbc_InterfaceTypeCardPanel.gridy = 6;
604 		add(myInterfaceTypeCardPanel, gbc_InterfaceTypeCardPanel);
605 		myInterfaceTypeCardPanel.setLayout(new CardLayout(0, 0));
606 
607 		myMllpCard = new JPanel();
608 		myMllpCard.setBorder(null);
609 		myInterfaceTypeCardPanel.add(myMllpCard, IFACE_TYPE_CARD_MLLP);
610 		GridBagLayout gbl_MllpCard = new GridBagLayout();
611 		gbl_MllpCard.columnWidths = new int[] { 150, 0, 0 };
612 		gbl_MllpCard.rowHeights = new int[] { 0, 0, 0, 0 };
613 		gbl_MllpCard.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
614 		gbl_MllpCard.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
615 		myMllpCard.setLayout(gbl_MllpCard);
616 
617 		JLabel lblHost = new JLabel("Host");
618 		GridBagConstraints gbc_lblHost = new GridBagConstraints();
619 		gbc_lblHost.insets = new Insets(0, 0, 5, 5);
620 		gbc_lblHost.gridx = 0;
621 		gbc_lblHost.gridy = 0;
622 		myMllpCard.add(lblHost, gbc_lblHost);
623 
624 		mypanel_1 = new JPanel();
625 		mypanel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
626 		GridBagConstraints gbc_panel_1 = new GridBagConstraints();
627 		gbc_panel_1.insets = new Insets(0, 0, 5, 0);
628 		gbc_panel_1.fill = GridBagConstraints.BOTH;
629 		gbc_panel_1.gridx = 1;
630 		gbc_panel_1.gridy = 0;
631 		myMllpCard.add(mypanel_1, gbc_panel_1);
632 		GridBagLayout gbl_panel_1 = new GridBagLayout();
633 		gbl_panel_1.columnWidths = new int[] { 134, 0 };
634 		gbl_panel_1.rowHeights = new int[] { 28, 0 };
635 		gbl_panel_1.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
636 		gbl_panel_1.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
637 		mypanel_1.setLayout(gbl_panel_1);
638 
639 		myHostBox = new JTextField();
640 		GridBagConstraints gbc_HostBox = new GridBagConstraints();
641 		gbc_HostBox.fill = GridBagConstraints.HORIZONTAL;
642 		gbc_HostBox.anchor = GridBagConstraints.NORTH;
643 		gbc_HostBox.gridx = 0;
644 		gbc_HostBox.gridy = 0;
645 		mypanel_1.add(myHostBox, gbc_HostBox);
646 		myHostBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
647 			@Override
648 			public void update(DocumentEvent theE) {
649 				myConnection.setHost(myHostBox.getText());
650 			}
651 		});
652 		myHostBox.setColumns(10);
653 
654 		JLabel lblTransport = new JLabel("Transport");
655 		GridBagConstraints gbc_lblTransport = new GridBagConstraints();
656 		gbc_lblTransport.insets = new Insets(0, 0, 5, 5);
657 		gbc_lblTransport.gridx = 0;
658 		gbc_lblTransport.gridy = 1;
659 		myMllpCard.add(lblTransport, gbc_lblTransport);
660 
661 		JPanel panel_3 = new JPanel();
662 		GridBagConstraints gbc_hohAuthPanel = new GridBagConstraints();
663 		gbc_hohAuthPanel.fill = GridBagConstraints.HORIZONTAL;
664 		gbc_hohAuthPanel.insets = new Insets(0, 0, 5, 0);
665 		gbc_hohAuthPanel.gridx = 1;
666 		gbc_hohAuthPanel.gridy = 1;
667 		myMllpCard.add(panel_3, gbc_hohAuthPanel);
668 		panel_3.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
669 		GridBagLayout gbl_hohAuthPanel = new GridBagLayout();
670 		gbl_hohAuthPanel.columnWidths = new int[] { 0, 0, 0 };
671 		gbl_hohAuthPanel.rowHeights = new int[] { 0, 0 };
672 		gbl_hohAuthPanel.columnWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
673 		gbl_hohAuthPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
674 		panel_3.setLayout(gbl_hohAuthPanel);
675 
676 		myTlsCheckbox = new JCheckBox("Use TLS/SSL");
677 		myTlsCheckbox.addActionListener(new ActionListener() {
678 			public void actionPerformed(ActionEvent e) {
679 				myHohTlsCheckbox.setSelected(myTlsCheckbox.isSelected());
680 				myConnection.setTls(myTlsCheckbox.isSelected());
681 			}
682 		});
683 		GridBagConstraints gbc_TlsCheckbox = new GridBagConstraints();
684 		gbc_TlsCheckbox.insets = new Insets(0, 0, 0, 5);
685 		gbc_TlsCheckbox.anchor = GridBagConstraints.WEST;
686 		gbc_TlsCheckbox.gridx = 0;
687 		gbc_TlsCheckbox.gridy = 0;
688 		panel_3.add(myTlsCheckbox, gbc_TlsCheckbox);
689 
690 		myHoHCard = new JPanel();
691 		myInterfaceTypeCardPanel.add(myHoHCard, IFACE_TYPE_CARD_HOH);
692 		GridBagLayout gbl_HoHCard = new GridBagLayout();
693 		gbl_HoHCard.columnWidths = new int[] { 150, 0, 0 };
694 		gbl_HoHCard.rowHeights = new int[] { 0, 0, 0, 0 };
695 		gbl_HoHCard.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
696 		gbl_HoHCard.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
697 		myHoHCard.setLayout(gbl_HoHCard);
698 
699 		mylabel_6 = new JLabel("Authorization");
700 		GridBagConstraints gbc_label_6 = new GridBagConstraints();
701 		gbc_label_6.insets = new Insets(0, 0, 5, 5);
702 		gbc_label_6.gridx = 0;
703 		gbc_label_6.gridy = 0;
704 		myHoHCard.add(mylabel_6, gbc_label_6);
705 
706 		hohAuthPanel = new JPanel();
707 		hohAuthPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
708 		GridBagConstraints gbc_hohAuthPanel2 = new GridBagConstraints();
709 		gbc_hohAuthPanel2.insets = new Insets(0, 0, 5, 0);
710 		gbc_hohAuthPanel2.fill = GridBagConstraints.BOTH;
711 		gbc_hohAuthPanel2.gridx = 1;
712 		gbc_hohAuthPanel2.gridy = 0;
713 		myHoHCard.add(hohAuthPanel, gbc_hohAuthPanel2);
714 		GridBagLayout gbl_hohAuthPanel3 = new GridBagLayout();
715 		gbl_hohAuthPanel3.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0 };
716 		gbl_hohAuthPanel3.rowHeights = new int[] { 0, 0 };
717 		gbl_hohAuthPanel3.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
718 		gbl_hohAuthPanel3.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
719 		hohAuthPanel.setLayout(gbl_hohAuthPanel3);
720 
721 		myHohAuthEnabledCheckbox = new JCheckBox("Enabled");
722 		myHohAuthEnabledCheckbox.addActionListener(new ActionListener() {
723 			public void actionPerformed(ActionEvent theE) {
724 				myConnection.setHohAuthenticationEnabled(myHohAuthEnabledCheckbox.isSelected());
725 			}
726 		});
727 		GridBagConstraints gbc_HohAuthEnabledCheckbox = new GridBagConstraints();
728 		gbc_HohAuthEnabledCheckbox.insets = new Insets(0, 0, 0, 5);
729 		gbc_HohAuthEnabledCheckbox.gridx = 0;
730 		gbc_HohAuthEnabledCheckbox.gridy = 0;
731 		hohAuthPanel.add(myHohAuthEnabledCheckbox, gbc_HohAuthEnabledCheckbox);
732 
733 		mylabel_7 = new JLabel("Username:");
734 		GridBagConstraints gbc_label_7 = new GridBagConstraints();
735 		gbc_label_7.insets = new Insets(0, 0, 0, 5);
736 		gbc_label_7.anchor = GridBagConstraints.EAST;
737 		gbc_label_7.gridx = 1;
738 		gbc_label_7.gridy = 0;
739 		hohAuthPanel.add(mylabel_7, gbc_label_7);
740 
741 		myHohAuthUsernameTextbox = new JTextField();
742 		myHohAuthUsernameTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
743 			@Override
744 			public void update(DocumentEvent theE) {
745 				myConnection.setHohAuthenticationUsername(myHohAuthUsernameTextbox.getText());
746 			}
747 		});
748 		myHohAuthUsernameTextbox.setMaximumSize(new Dimension(200, 2147483647));
749 		myHohAuthUsernameTextbox.setMinimumSize(new Dimension(100, 28));
750 		myHohAuthUsernameTextbox.setPreferredSize(new Dimension(100, 28));
751 		GridBagConstraints gbc_HohUsernameTextbox2 = new GridBagConstraints();
752 		gbc_HohUsernameTextbox2.insets = new Insets(0, 0, 0, 5);
753 		gbc_HohUsernameTextbox2.fill = GridBagConstraints.HORIZONTAL;
754 		gbc_HohUsernameTextbox2.gridx = 2;
755 		gbc_HohUsernameTextbox2.gridy = 0;
756 		hohAuthPanel.add(myHohAuthUsernameTextbox, gbc_HohUsernameTextbox2);
757 		myHohAuthUsernameTextbox.setColumns(10);
758 
759 		mylabel_8 = new JLabel("Password:");
760 		GridBagConstraints gbc_label_8 = new GridBagConstraints();
761 		gbc_label_8.insets = new Insets(0, 0, 0, 5);
762 		gbc_label_8.anchor = GridBagConstraints.EAST;
763 		gbc_label_8.gridx = 3;
764 		gbc_label_8.gridy = 0;
765 		hohAuthPanel.add(mylabel_8, gbc_label_8);
766 
767 		myHohAuthPasswordTextbox = new JTextField();
768 		myHohAuthPasswordTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
769 			@Override
770 			public void update(DocumentEvent theE) {
771 				myConnection.setHohAuthenticationPassword(myHohAuthPasswordTextbox.getText());
772 			}
773 		});
774 		myHohAuthPasswordTextbox.setPreferredSize(new Dimension(100, 28));
775 		myHohAuthPasswordTextbox.setMaximumSize(new Dimension(200, 2147483647));
776 		myHohAuthPasswordTextbox.setMinimumSize(new Dimension(100, 28));
777 		GridBagConstraints gbc_HohSignatureKeystoreTextbox = new GridBagConstraints();
778 		gbc_HohSignatureKeystoreTextbox.insets = new Insets(0, 0, 0, 5);
779 		gbc_HohSignatureKeystoreTextbox.fill = GridBagConstraints.HORIZONTAL;
780 		gbc_HohSignatureKeystoreTextbox.gridx = 4;
781 		gbc_HohSignatureKeystoreTextbox.gridy = 0;
782 		hohAuthPanel.add(myHohAuthPasswordTextbox, gbc_HohSignatureKeystoreTextbox);
783 		myHohAuthPasswordTextbox.setColumns(10);
784 
785 		mylabel_2 = new JLabel("Security Profile");
786 		mylabel_2.setVerticalTextPosition(SwingConstants.TOP);
787 		mylabel_2.setVerticalAlignment(SwingConstants.TOP);
788 		GridBagConstraints gbc_label_2 = new GridBagConstraints();
789 		gbc_label_2.insets = new Insets(0, 0, 5, 5);
790 		gbc_label_2.gridx = 0;
791 		gbc_label_2.gridy = 1;
792 		myHoHCard.add(mylabel_2, gbc_label_2);
793 
794 		// securityProfilePanel = new JPanel();
795 		GridBagConstraints gbc_securityProfilePanel = new GridBagConstraints();
796 		gbc_securityProfilePanel.insets = new Insets(0, 0, 5, 0);
797 		gbc_securityProfilePanel.fill = GridBagConstraints.BOTH;
798 		gbc_securityProfilePanel.gridx = 1;
799 		gbc_securityProfilePanel.gridy = 1;
800 		// myHoHCard.add(securityProfilePanel, gbc_securityProfilePanel);
801 		// securityProfilePanel.setLayout(new BorderLayout(0, 0));
802 
803 		tlsKeystorePanel = new JPanel();
804 		tlsKeystorePanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
805 		// securityProfilePanel.add(tlsKeystorePanel, BorderLayout.CENTER);
806 		myHoHCard.add(tlsKeystorePanel, gbc_securityProfilePanel);
807 		GridBagLayout gbl_tlsKeystorePanel = new GridBagLayout();
808 		gbl_tlsKeystorePanel.columnWidths = new int[] { 0, 58, 107, 77, 0, 0 };
809 		gbl_tlsKeystorePanel.rowHeights = new int[] { 28, 16, 0, 0 };
810 		gbl_tlsKeystorePanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 1.0, 0.0, Double.MIN_VALUE };
811 		gbl_tlsKeystorePanel.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
812 		tlsKeystorePanel.setLayout(gbl_tlsKeystorePanel);
813 
814 		myHohTlsCheckbox = new JCheckBox("TLS Enabled");
815 		GridBagConstraints gbc_HohTlsCheckbox = new GridBagConstraints();
816 		gbc_HohTlsCheckbox.gridheight = 2;
817 		gbc_HohTlsCheckbox.insets = new Insets(0, 0, 5, 5);
818 		gbc_HohTlsCheckbox.gridx = 0;
819 		gbc_HohTlsCheckbox.gridy = 0;
820 		tlsKeystorePanel.add(myHohTlsCheckbox, gbc_HohTlsCheckbox);
821 		myHohTlsCheckbox.addActionListener(new ActionListener() {
822 			public void actionPerformed(ActionEvent e) {
823 				myConnection.setTls(myHohTlsCheckbox.isSelected());
824 				myTlsCheckbox.setSelected(myHohTlsCheckbox.isSelected());
825 				updatePortsUi();
826 			}
827 		});
828 
829 		mylabel_3 = new JLabel("Keystore:");
830 		GridBagConstraints gbc_label_3 = new GridBagConstraints();
831 		gbc_label_3.anchor = GridBagConstraints.WEST;
832 		gbc_label_3.fill = GridBagConstraints.VERTICAL;
833 		gbc_label_3.insets = new Insets(0, 0, 5, 5);
834 		gbc_label_3.gridx = 1;
835 		gbc_label_3.gridy = 0;
836 		tlsKeystorePanel.add(mylabel_3, gbc_label_3);
837 
838 		myHohSecurityKeystoreTextbox = new JTextField();
839 		GridBagConstraints gbc_HohKeystoreTextbox = new GridBagConstraints();
840 		gbc_HohKeystoreTextbox.gridwidth = 2;
841 		gbc_HohKeystoreTextbox.anchor = GridBagConstraints.NORTH;
842 		gbc_HohKeystoreTextbox.fill = GridBagConstraints.HORIZONTAL;
843 		gbc_HohKeystoreTextbox.insets = new Insets(0, 0, 5, 5);
844 		gbc_HohKeystoreTextbox.gridx = 2;
845 		gbc_HohKeystoreTextbox.gridy = 0;
846 		tlsKeystorePanel.add(myHohSecurityKeystoreTextbox, gbc_HohKeystoreTextbox);
847 		myHohSecurityKeystoreTextbox.setColumns(10);
848 		myHohSecurityKeystoreTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
849 			@Override
850 			public void update(DocumentEvent theE) {
851 				String text = myHohSecurityKeystoreTextbox.getText();
852 				myHohSecurityKeyPwTextBox.setEnabled(isNotBlank(text));
853 				myConnection.setTlsKeystoreLocation(text);
854 			}
855 		});
856 
857 		myHohSecurityKeystoreChooseBtn = new JButton("Choose");
858 		myHohSecurityKeystoreChooseBtn.addActionListener(new ActionListener() {
859 			public void actionPerformed(ActionEvent e) {
860 				Hl7ConnectionPanel.chooseKeystore(Hl7ConnectionPanel.this, myHohSecurityKeystoreTextbox);
861 			}
862 		});
863 		myHohSecurityKeystoreChooseBtn.setIcon(new ImageIcon(Hl7ConnectionPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png")));
864 		GridBagConstraints gbc_HohSignatureKeystoreChooseButton = new GridBagConstraints();
865 		gbc_HohSignatureKeystoreChooseButton.insets = new Insets(0, 0, 5, 0);
866 		gbc_HohSignatureKeystoreChooseButton.gridx = 4;
867 		gbc_HohSignatureKeystoreChooseButton.gridy = 0;
868 		tlsKeystorePanel.add(myHohSecurityKeystoreChooseBtn, gbc_HohSignatureKeystoreChooseButton);
869 
870 		mylabel_4 = new JLabel("Store Pass:");
871 		GridBagConstraints gbc_label_4 = new GridBagConstraints();
872 		gbc_label_4.insets = new Insets(0, 0, 0, 5);
873 		gbc_label_4.anchor = GridBagConstraints.EAST;
874 		gbc_label_4.gridx = 1;
875 		gbc_label_4.gridy = 1;
876 		tlsKeystorePanel.add(mylabel_4, gbc_label_4);
877 
878 		myHohSecurityKeyPwTextBox = new JTextField();
879 		myHohSecurityKeyPwTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
880 			@Override
881 			public void update(DocumentEvent theE) {
882 				myConnection.setTlsKeystorePassword(myHohSecurityKeyPwTextBox.getText());
883 			}
884 		});
885 		GridBagConstraints gbc_HohSecurityKeyPwTextBox = new GridBagConstraints();
886 		gbc_HohSecurityKeyPwTextBox.insets = new Insets(0, 0, 0, 5);
887 		gbc_HohSecurityKeyPwTextBox.fill = GridBagConstraints.HORIZONTAL;
888 		gbc_HohSecurityKeyPwTextBox.gridx = 2;
889 		gbc_HohSecurityKeyPwTextBox.gridy = 1;
890 		tlsKeystorePanel.add(myHohSecurityKeyPwTextBox, gbc_HohSecurityKeyPwTextBox);
891 		myHohSecurityKeyPwTextBox.setColumns(10);
892 
893 		myHohSecurityProfileKeystoreStatus = new JLabel("Value goes here");
894 		myHohSecurityProfileKeystoreStatus.setHorizontalAlignment(SwingConstants.CENTER);
895 		GridBagConstraints gbc_HohSecurityProfileKeystoreStatus = new GridBagConstraints();
896 		gbc_HohSecurityProfileKeystoreStatus.anchor = GridBagConstraints.NORTH;
897 		gbc_HohSecurityProfileKeystoreStatus.fill = GridBagConstraints.HORIZONTAL;
898 		gbc_HohSecurityProfileKeystoreStatus.gridwidth = 5;
899 		gbc_HohSecurityProfileKeystoreStatus.gridx = 0;
900 		gbc_HohSecurityProfileKeystoreStatus.gridy = 2;
901 		tlsKeystorePanel.add(myHohSecurityProfileKeystoreStatus, gbc_HohSecurityProfileKeystoreStatus);
902 
903 		mylabel_9 = new JLabel("Signature Profile");
904 		GridBagConstraints gbc_label_9 = new GridBagConstraints();
905 		gbc_label_9.insets = new Insets(0, 0, 0, 5);
906 		gbc_label_9.gridx = 0;
907 		gbc_label_9.gridy = 2;
908 		myHoHCard.add(mylabel_9, gbc_label_9);
909 
910 		mypanel_3 = new JPanel();
911 		mypanel_3.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
912 		GridBagConstraints gbc_panel_3 = new GridBagConstraints();
913 		gbc_panel_3.fill = GridBagConstraints.BOTH;
914 		gbc_panel_3.gridx = 1;
915 		gbc_panel_3.gridy = 2;
916 		myHoHCard.add(mypanel_3, gbc_panel_3);
917 		GridBagLayout gbl_panel_3 = new GridBagLayout();
918 		gbl_panel_3.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 50, 0, 0 };
919 		gbl_panel_3.rowHeights = new int[] { 0, 0, 0, 0 };
920 		gbl_panel_3.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
921 		gbl_panel_3.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
922 		mypanel_3.setLayout(gbl_panel_3);
923 
924 		myHohSignatureEnabled = new JCheckBox("Enabled");
925 		myHohSignatureEnabled.addActionListener(new ActionListener() {
926 			public void actionPerformed(ActionEvent theE) {
927 				myConnection.setHohSignatureEnabled(myHohSignatureEnabled.isSelected());
928 			}
929 		});
930 		GridBagConstraints gbc_HohSignatureEnabled = new GridBagConstraints();
931 		gbc_HohSignatureEnabled.insets = new Insets(0, 0, 5, 5);
932 		gbc_HohSignatureEnabled.gridx = 0;
933 		gbc_HohSignatureEnabled.gridy = 0;
934 		mypanel_3.add(myHohSignatureEnabled, gbc_HohSignatureEnabled);
935 
936 		mylabel_10 = new JLabel("Keystore:");
937 		GridBagConstraints gbc_label_10 = new GridBagConstraints();
938 		gbc_label_10.anchor = GridBagConstraints.EAST;
939 		gbc_label_10.insets = new Insets(0, 0, 5, 5);
940 		gbc_label_10.gridx = 1;
941 		gbc_label_10.gridy = 0;
942 		mypanel_3.add(mylabel_10, gbc_label_10);
943 
944 		myHohSignatureKeystoreTextbox = new JTextField();
945 		myHohSignatureKeystoreTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
946 			@Override
947 			public void update(DocumentEvent theE) {
948 				myConnection.setHohSignatureKeystore(myHohSignatureKeystoreTextbox.getText());
949 			}
950 		});
951 		GridBagConstraints gbc_HohSignatureKeystoreTextbox2 = new GridBagConstraints();
952 		gbc_HohSignatureKeystoreTextbox2.gridwidth = 5;
953 		gbc_HohSignatureKeystoreTextbox2.insets = new Insets(0, 0, 5, 5);
954 		gbc_HohSignatureKeystoreTextbox2.fill = GridBagConstraints.HORIZONTAL;
955 		gbc_HohSignatureKeystoreTextbox2.gridx = 2;
956 		gbc_HohSignatureKeystoreTextbox2.gridy = 0;
957 		mypanel_3.add(myHohSignatureKeystoreTextbox, gbc_HohSignatureKeystoreTextbox2);
958 		myHohSignatureKeystoreTextbox.setColumns(10);
959 
960 		myHohSignatureKeystoreChooseButton = new JButton("Choose");
961 		myHohSignatureKeystoreChooseButton.addActionListener(new ActionListener() {
962 			public void actionPerformed(ActionEvent e) {
963 				Hl7ConnectionPanel.chooseKeystore(Hl7ConnectionPanel.this, myHohSignatureKeystoreTextbox);
964 			}
965 		});
966 		myHohSignatureKeystoreChooseButton.setIcon(new ImageIcon(Hl7ConnectionPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png")));
967 		GridBagConstraints gbc_HohSignatureKeystoreChooseButton2 = new GridBagConstraints();
968 		gbc_HohSignatureKeystoreChooseButton2.insets = new Insets(0, 0, 5, 0);
969 		gbc_HohSignatureKeystoreChooseButton2.gridx = 7;
970 		gbc_HohSignatureKeystoreChooseButton2.gridy = 0;
971 		mypanel_3.add(myHohSignatureKeystoreChooseButton, gbc_HohSignatureKeystoreChooseButton2);
972 
973 		mylabel_11 = new JLabel("Store Pass:");
974 		GridBagConstraints gbc_label_11 = new GridBagConstraints();
975 		gbc_label_11.anchor = GridBagConstraints.EAST;
976 		gbc_label_11.insets = new Insets(0, 0, 5, 5);
977 		gbc_label_11.gridx = 1;
978 		gbc_label_11.gridy = 1;
979 		mypanel_3.add(mylabel_11, gbc_label_11);
980 
981 		myHohSignatureKeystorePasswordTextbox = new JTextField();
982 		myHohSignatureKeystorePasswordTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
983 			@Override
984 			public void update(DocumentEvent theE) {
985 				myConnection.setHohSignatureKeystorePassword(myHohSignatureKeystorePasswordTextbox.getText());
986 			}
987 		});
988 		myHohSignatureKeystorePasswordTextbox.setPreferredSize(new Dimension(100, 28));
989 		myHohSignatureKeystorePasswordTextbox.setMinimumSize(new Dimension(100, 28));
990 		myHohSignatureKeystorePasswordTextbox.setMaximumSize(new Dimension(200, 2147483647));
991 		GridBagConstraints gbc_HohSignatureKeystorePasswordTextbox = new GridBagConstraints();
992 		gbc_HohSignatureKeystorePasswordTextbox.insets = new Insets(0, 0, 5, 5);
993 		gbc_HohSignatureKeystorePasswordTextbox.fill = GridBagConstraints.HORIZONTAL;
994 		gbc_HohSignatureKeystorePasswordTextbox.gridx = 2;
995 		gbc_HohSignatureKeystorePasswordTextbox.gridy = 1;
996 		mypanel_3.add(myHohSignatureKeystorePasswordTextbox, gbc_HohSignatureKeystorePasswordTextbox);
997 		myHohSignatureKeystorePasswordTextbox.setColumns(10);
998 
999 		mylabel_12 = new JLabel("Key:");
1000 		GridBagConstraints gbc_label_12 = new GridBagConstraints();
1001 		gbc_label_12.anchor = GridBagConstraints.EAST;
1002 		gbc_label_12.insets = new Insets(0, 0, 5, 5);
1003 		gbc_label_12.gridx = 3;
1004 		gbc_label_12.gridy = 1;
1005 		mypanel_3.add(mylabel_12, gbc_label_12);
1006 
1007 		myHohSignatureKeyAliasCombo = new JComboBox();
1008 		myHohSignatureKeyAliasCombo.addActionListener(new ActionListener() {
1009 			public void actionPerformed(ActionEvent theE) {
1010 				if (myUpdatingHohSignatureKeyAliasCombo) {
1011 					return;
1012 				}
1013 				String selection = (String) myHohSignatureKeyAliasCombo.getSelectedItem();
1014 				if (selection == HOH_SIGNATURE_KEY_USE_ANY_AVAILABLE) {
1015 					myConnection.setHohSignatureKey(null);
1016 				} else {
1017 					myConnection.setHohSignatureKey(selection.replaceAll(" .*", ""));
1018 				}
1019 			}
1020 		});
1021 		GridBagConstraints gbc_HohSignatureKeyAliasCombo = new GridBagConstraints();
1022 		gbc_HohSignatureKeyAliasCombo.insets = new Insets(0, 0, 5, 5);
1023 		gbc_HohSignatureKeyAliasCombo.fill = GridBagConstraints.HORIZONTAL;
1024 		gbc_HohSignatureKeyAliasCombo.gridx = 4;
1025 		gbc_HohSignatureKeyAliasCombo.gridy = 1;
1026 		mypanel_3.add(myHohSignatureKeyAliasCombo, gbc_HohSignatureKeyAliasCombo);
1027 
1028 		mylabel_13 = new JLabel("Key Pass:");
1029 		GridBagConstraints gbc_label_13 = new GridBagConstraints();
1030 		gbc_label_13.anchor = GridBagConstraints.EAST;
1031 		gbc_label_13.insets = new Insets(0, 0, 5, 5);
1032 		gbc_label_13.gridx = 5;
1033 		gbc_label_13.gridy = 1;
1034 		mypanel_3.add(mylabel_13, gbc_label_13);
1035 
1036 		myHohSignatureKeyPass = new JTextField();
1037 		myHohSignatureKeyPass.getDocument().addDocumentListener(new SimpleDocumentListener() {
1038 			@Override
1039 			public void update(DocumentEvent theE) {
1040 				myConnection.setHohSignatureKeyPassword(myHohSignatureKeyPass.getText());
1041 			}
1042 		});
1043 		myHohSignatureKeyPass.setMinimumSize(new Dimension(50, 28));
1044 		myHohSignatureKeyPass.setMaximumSize(new Dimension(50, 2147483647));
1045 		myHohSignatureKeyPass.setPreferredSize(new Dimension(50, 28));
1046 		GridBagConstraints gbc_HohSignatureKeyPass = new GridBagConstraints();
1047 		gbc_HohSignatureKeyPass.gridwidth = 2;
1048 		gbc_HohSignatureKeyPass.insets = new Insets(0, 0, 5, 0);
1049 		gbc_HohSignatureKeyPass.fill = GridBagConstraints.HORIZONTAL;
1050 		gbc_HohSignatureKeyPass.gridx = 6;
1051 		gbc_HohSignatureKeyPass.gridy = 1;
1052 		mypanel_3.add(myHohSignatureKeyPass, gbc_HohSignatureKeyPass);
1053 		myHohSignatureKeyPass.setColumns(10);
1054 
1055 		myHohSignatureStatusLabel = new JLabel("New label");
1056 		myHohSignatureStatusLabel.setHorizontalAlignment(SwingConstants.CENTER);
1057 		GridBagConstraints gbc_HohSignatureStatusLabel = new GridBagConstraints();
1058 		gbc_HohSignatureStatusLabel.fill = GridBagConstraints.HORIZONTAL;
1059 		gbc_HohSignatureStatusLabel.gridwidth = 8;
1060 		gbc_HohSignatureStatusLabel.insets = new Insets(0, 0, 0, 5);
1061 		gbc_HohSignatureStatusLabel.gridx = 0;
1062 		gbc_HohSignatureStatusLabel.gridy = 2;
1063 		mypanel_3.add(myHohSignatureStatusLabel, gbc_HohSignatureStatusLabel);
1064 
1065 		init();
1066 
1067 	}
1068 
1069 	public void destroy() {
1070 		myConnection.removePropertyChangeListener(OutboundConnection.STATUS_PROPERTY, myStatusPropertyChangeListener);
1071 		myConnection.removePropertyChangeListener(OutboundConnection.STATUS_LINE_PROPERTY, myStatusLinePropertyChangeListener);
1072 		myConnection.removePropertyChangeListener(AbstractConnection.TLS_KEYSTORE_STATUS, myHohSecurityProfileKeystoreStatusListener);
1073 		myConnection.removePropertyChangeListener(AbstractConnection.HOH_SIGNATURE_KEYSTORE_STATUS, myHohSignatureStatusListener);
1074 		myConnection.removePropertyChangeListener(AbstractConnection.HOH_SIGNER_AVAILABLE_ALIASES_PROPERTY, myHohSignerAvailableAliasesListener);
1075 	}
1076 
1077 	private void init() {
1078 		List<String> charSets = new ArrayList<String>(Charset.availableCharsets().keySet());
1079 		Collections.sort(charSets);
1080 		ComboBoxModel charsetModel = new DefaultComboBoxModel(charSets.toArray(new String[0]));
1081 		myCharsetCombo.setModel(charsetModel);
1082 	}
1083 
1084 	private boolean isChangesAllowed() {
1085 		return myConnection.getStatus() == StatusEnum.STOPPED || myConnection.getStatus() == StatusEnum.FAILED;
1086 	}
1087 
1088 	private String portToString(int thePort) {
1089 		if (thePort > 0) {
1090 			return Integer.toString(thePort);
1091 		} else {
1092 			return "";
1093 		}
1094 	}
1095 
1096 	private void updateHohSignatureKeyCombo() {
1097 		myUpdatingHohSignatureKeyAliasCombo = true;
1098 		try {
1099 			myHohSignatureKeyAliasCombo.removeAllItems();
1100 			List<String> aliases = myConnection.getHohSignatureAvailableAliases();
1101 			for (String next : aliases) {
1102 				myHohSignatureKeyAliasCombo.addItem(next);
1103 				if (next.equals(myConnection.getHohSignatureKey())) {
1104 					myHohSignatureKeyAliasCombo.setSelectedIndex(myHohSignatureKeyAliasCombo.getItemCount()-1);
1105 				}
1106 			}
1107 		} finally {
1108 			myUpdatingHohSignatureKeyAliasCombo = false;
1109 		}
1110 	}
1111 
1112 	public void setConnection(AbstractConnection theConnection) {
1113 		myConnection = theConnection;
1114 
1115 		myHohSecurityKeyPwTextBox.setText(myConnection.getTlsKeystorePassword());
1116 		myHohSecurityKeystoreTextbox.setText(myConnection.getTlsKeystoreLocation());
1117 		myHohSecurityProfileKeystoreStatus.setText("");
1118 
1119 		myHohSignatureEnabled.setSelected(myConnection.isHohSignatureEnabled());
1120 		myHohSignatureKeystoreTextbox.setText(myConnection.getHohSignatureKeystore());
1121 		myHohSignatureKeystorePasswordTextbox.setText(myConnection.getHohSignatureKeystorePassword());
1122 		myHohSignatureKeyPass.setText(myConnection.getHohSignatureKeyPassword());
1123 		updateHohSignatureKeyCombo();
1124 		
1125 		myCharsetCombo.setSelectedItem(theConnection.getCharSet());
1126 
1127 		myTlsCheckbox.setSelected(theConnection.isTls());
1128 		myHohTlsCheckbox.setSelected(theConnection.isTls());
1129 		myCaptureByteStreamCheckbox.setSelected(theConnection.isCaptureBytes());
1130 
1131 		myHohAuthEnabledCheckbox.setSelected(myConnection.isHohAuthenticationEnabled());
1132 		myHohAuthUsernameTextbox.setText(myConnection.getHohAuthenticationUsername());
1133 		myHohAuthPasswordTextbox.setText(myConnection.getHohAuthenticationPassword());
1134 
1135 		updateCharset();
1136 
1137 		Hl7V2EncodingTypeEnum encoding = theConnection.getEncoding();
1138 		myEr7Radio.setSelected(encoding == Hl7V2EncodingTypeEnum.ER_7);
1139 		myXmlRadio.setSelected(encoding == Hl7V2EncodingTypeEnum.XML);
1140 		myHostBox.setText(theConnection.getHost());
1141 
1142 		updatePortsUi();
1143 
1144 		myStatusPropertyChangeListener = new PropertyChangeListener() {
1145 
1146 			public void propertyChange(PropertyChangeEvent theEvt) {
1147 				updateStatus();
1148 			}
1149 		};
1150 		myConnection.addPropertyChangeListener(OutboundConnection.STATUS_PROPERTY, myStatusPropertyChangeListener);
1151 
1152 		myStatusLinePropertyChangeListener = new PropertyChangeListener() {
1153 
1154 			public void propertyChange(PropertyChangeEvent theEvt) {
1155 				updateStatus();
1156 			}
1157 		};
1158 		myConnection.addPropertyChangeListener(OutboundConnection.STATUS_LINE_PROPERTY, myStatusLinePropertyChangeListener);
1159 
1160 		myHohSecurityProfileKeystoreStatusListener = new KeystoreStatusListener(myHohSecurityProfileKeystoreStatus);
1161 		myConnection.addPropertyChangeListener(AbstractConnection.TLS_KEYSTORE_STATUS, myHohSecurityProfileKeystoreStatusListener);
1162 
1163 		myHohSignatureStatusListener = new KeystoreStatusListener(myHohSignatureStatusLabel);
1164 		myConnection.addPropertyChangeListener(AbstractConnection.HOH_SIGNATURE_KEYSTORE_STATUS, myHohSignatureStatusListener);
1165 
1166 		myHohSignerAvailableAliasesListener = new PropertyChangeListener() {
1167 			public void propertyChange(PropertyChangeEvent theEvt) {
1168 				updateHohSignatureKeyCombo();
1169 			}
1170 
1171 		};
1172 		myConnection.addPropertyChangeListener(AbstractConnection.HOH_SIGNER_AVAILABLE_ALIASES_PROPERTY, myHohSignerAvailableAliasesListener);
1173 		
1174 		updateStatus();
1175 
1176 	}
1177 
1178 	private void updateCharset() {
1179 		if (myConnection.isDetectCharSetInMessage()) {
1180 			myCharsetDetectRadio.setSelected(true);
1181 			myCharsetSelectRadio.setSelected(false);
1182 			myCharsetCombo.setEnabled(false);
1183 		} else {
1184 			myCharsetDetectRadio.setSelected(false);
1185 			myCharsetSelectRadio.setSelected(true);
1186 			myCharsetCombo.setEnabled(true);
1187 		}
1188 	}
1189 
1190 	private void updateCharsetModel() {
1191 		if (myCharsetDetectRadio.isSelected()) {
1192 			myConnection.setDetectCharSetInMessage(true);
1193 		} else {
1194 			myConnection.setDetectCharSetInMessage(false);
1195 			String charSet = (String) myCharsetCombo.getSelectedItem();
1196 			myConnection.setCharSet(charSet);
1197 			Prefs.getInstance().setMostRecentConnectionCharset(charSet);
1198 		}
1199 	}
1200 
1201 	private void updateEncodingModel() {
1202 		if (myEr7Radio.isSelected()) {
1203 			myConnection.setEncoding(Hl7V2EncodingTypeEnum.ER_7);
1204 		} else {
1205 			myConnection.setEncoding(Hl7V2EncodingTypeEnum.XML);
1206 		}
1207 	}
1208 
1209 	private void updatePortsModel() {
1210 		if (mySinglePortRadio.isSelected()) {
1211 			myConnection.setTransport(TransportStyleEnum.SINGLE_PORT_MLLP);
1212 		} else if (myDualPortRadio.isSelected()) {
1213 			myConnection.setTransport(TransportStyleEnum.DUAL_PORT_MLLP);
1214 		} else {
1215 			myConnection.setTransport(TransportStyleEnum.HL7_OVER_HTTP);
1216 		}
1217 	}
1218 
1219 	private void updatePortsUi() {
1220 		boolean changesAllowed = isChangesAllowed();
1221 		CardLayout cl = (CardLayout) myInterfaceTypeCardPanel.getLayout();
1222 
1223 		switch (myConnection.getTransport()) {
1224 		case DUAL_PORT_MLLP: {
1225 			mySinglePortRadio.setSelected(false);
1226 			myDualPortRadio.setSelected(true);
1227 			myHl7OverHttpRadioButton.setSelected(false);
1228 
1229 			myDualIncomingTextBox.setText(portToString(myConnection.getIncomingOrSinglePort()));
1230 			myDualOutgoingTextBox.setText(portToString(myConnection.getOutgoingPort()));
1231 
1232 			mySinglePortTextBox.setEnabled(false);
1233 			myDualIncomingTextBox.setEnabled(true && changesAllowed);
1234 			myDualOutgoingTextBox.setEnabled(true && changesAllowed);
1235 			myHoHUrlTextField.setEnabled(false);
1236 			mySinglePortTextBox.repaint();
1237 			myDualIncomingTextBox.repaint();
1238 			myDualOutgoingTextBox.repaint();
1239 
1240 			cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanel.IFACE_TYPE_CARD_MLLP);
1241 			break;
1242 		}
1243 		case SINGLE_PORT_MLLP: {
1244 			mySinglePortRadio.setSelected(true);
1245 			myDualPortRadio.setSelected(false);
1246 			myHl7OverHttpRadioButton.setSelected(false);
1247 
1248 			mySinglePortTextBox.setText(portToString(myConnection.getIncomingOrSinglePort()));
1249 
1250 			mySinglePortTextBox.setEnabled(true && changesAllowed);
1251 			myDualIncomingTextBox.setEnabled(false);
1252 			myDualOutgoingTextBox.setEnabled(false);
1253 			myHoHUrlTextField.setEnabled(false);
1254 			mySinglePortTextBox.repaint();
1255 			myDualIncomingTextBox.repaint();
1256 			myDualOutgoingTextBox.repaint();
1257 
1258 			cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanel.IFACE_TYPE_CARD_MLLP);
1259 			break;
1260 		}
1261 		case HL7_OVER_HTTP: {
1262 			mySinglePortTextBox.setEnabled(false);
1263 			myDualIncomingTextBox.setEnabled(false);
1264 			myDualOutgoingTextBox.setEnabled(false);
1265 			mySinglePortRadio.setSelected(false);
1266 			myDualPortRadio.setSelected(false);
1267 			myHl7OverHttpRadioButton.setSelected(true);
1268 
1269 			cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanel.IFACE_TYPE_CARD_HOH);
1270 
1271 			StringBuilder urlBuilder = new StringBuilder();
1272 			urlBuilder.append((myConnection.isTls() ? "https://" : "http://"));
1273 			urlBuilder.append(StringUtils.defaultString(myConnection.getHost(), "localhost"));
1274 			urlBuilder.append(":").append(myConnection.getIncomingOrSinglePort());
1275 			urlBuilder.append(StringUtils.defaultString(myConnection.getHttpUriPath(), "/"));
1276 			String url = urlBuilder.toString();
1277 			if (!myHohUrlTextFieldUpdating) {
1278 				myHohUrlTextFieldUpdating = true;
1279 				myHoHUrlTextField.setText(url);
1280 				myHohUrlTextFieldUpdating = false;
1281 			}
1282 
1283 			myHoHUrlTextField.setEnabled(true && changesAllowed);
1284 
1285 			break;
1286 		}
1287 		}
1288 	}
1289 
1290 	private void updateStatus() {
1291 		boolean changesAllowed = isChangesAllowed();
1292 		myHostBox.setEnabled(changesAllowed);
1293 
1294 		updatePortsUi();
1295 
1296 		mySinglePortRadio.setEnabled(changesAllowed);
1297 		myDualPortRadio.setEnabled(changesAllowed);
1298 		myHl7OverHttpRadioButton.setEnabled(changesAllowed);
1299 		myCharsetCombo.setEnabled(changesAllowed);
1300 		myCharsetDetectRadio.setEnabled(changesAllowed);
1301 		myCharsetSelectRadio.setEnabled(changesAllowed);
1302 		myEr7Radio.setEnabled(changesAllowed);
1303 		myTlsCheckbox.setEnabled(changesAllowed);
1304 		myHohTlsCheckbox.setEnabled(changesAllowed);
1305 		myXmlRadio.setEnabled(changesAllowed);
1306 		myCaptureByteStreamCheckbox.setEnabled(changesAllowed); // TODO: update hoh components enabled status
1307 
1308 	}
1309 
1310 	private static void chooseKeystore(Component theParentController, JTextField theTextbox) {
1311 		String directory = Prefs.getInstance().getInterfaceHohSecurityKeystoreDirectory();
1312 		directory = StringUtils.defaultString(directory, ".");
1313 		JFileChooser chooser = new JFileChooser(directory);
1314 		chooser.setDialogType(JFileChooser.OPEN_DIALOG);
1315 		chooser.setDialogTitle("Select a Java Keystore");
1316 		int result = chooser.showOpenDialog(theParentController);
1317 		if (result == JFileChooser.APPROVE_OPTION) {
1318 			Prefs.getInstance().setInterfaceHohSecurityKeystoreDirectory(chooser.getSelectedFile().getParent());
1319 			theTextbox.setText(chooser.getSelectedFile().getAbsolutePath());
1320 		}
1321 	}
1322 
1323 	private final class KeystoreStatusListener implements PropertyChangeListener {
1324 		private final JLabel myLabel;
1325 
1326 		public KeystoreStatusListener(JLabel theLabel) {
1327 			myLabel = theLabel;
1328 			clear();
1329 		}
1330 
1331 		private void clear() {
1332 			myLabel.setText("");
1333 			myLabel.setIcon(null);
1334 		}
1335 
1336 		public void propertyChange(PropertyChangeEvent theEvt) {
1337 			JLabel label = myLabel;
1338 			WorkingStatusBean newValue = (WorkingStatusBean) theEvt.getNewValue();
1339 			if (newValue == null || isBlank(newValue.getMessage())) {
1340 				clear();
1341 			} else {
1342 				label.setText("<html>" + newValue.getMessage() + "</html>");
1343 				switch (newValue.getStatus()) {
1344 				case ERROR:
1345 					myLabel.setIcon(ICON_INFO_WARNING);
1346 					break;
1347 				case WORKING:
1348 					myLabel.setIcon(ICON_INFO_WORKING);
1349 					break;
1350 				case OK:
1351 					myLabel.setIcon(ICON_INFO_OK);
1352 					break;
1353 				}
1354 			}
1355 		}
1356 	}
1357 
1358 }