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 			@Override
724 			public void actionPerformed(ActionEvent theE) {
725 				myConnection.setHohAuthenticationEnabled(myHohAuthEnabledCheckbox.isSelected());
726 			}
727 		});
728 		GridBagConstraints gbc_HohAuthEnabledCheckbox = new GridBagConstraints();
729 		gbc_HohAuthEnabledCheckbox.insets = new Insets(0, 0, 0, 5);
730 		gbc_HohAuthEnabledCheckbox.gridx = 0;
731 		gbc_HohAuthEnabledCheckbox.gridy = 0;
732 		hohAuthPanel.add(myHohAuthEnabledCheckbox, gbc_HohAuthEnabledCheckbox);
733 
734 		mylabel_7 = new JLabel("Username:");
735 		GridBagConstraints gbc_label_7 = new GridBagConstraints();
736 		gbc_label_7.insets = new Insets(0, 0, 0, 5);
737 		gbc_label_7.anchor = GridBagConstraints.EAST;
738 		gbc_label_7.gridx = 1;
739 		gbc_label_7.gridy = 0;
740 		hohAuthPanel.add(mylabel_7, gbc_label_7);
741 
742 		myHohAuthUsernameTextbox = new JTextField();
743 		myHohAuthUsernameTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
744 			@Override
745 			public void update(DocumentEvent theE) {
746 				myConnection.setHohAuthenticationUsername(myHohAuthUsernameTextbox.getText());
747 			}
748 		});
749 		myHohAuthUsernameTextbox.setMaximumSize(new Dimension(200, 2147483647));
750 		myHohAuthUsernameTextbox.setMinimumSize(new Dimension(100, 28));
751 		myHohAuthUsernameTextbox.setPreferredSize(new Dimension(100, 28));
752 		GridBagConstraints gbc_HohUsernameTextbox2 = new GridBagConstraints();
753 		gbc_HohUsernameTextbox2.insets = new Insets(0, 0, 0, 5);
754 		gbc_HohUsernameTextbox2.fill = GridBagConstraints.HORIZONTAL;
755 		gbc_HohUsernameTextbox2.gridx = 2;
756 		gbc_HohUsernameTextbox2.gridy = 0;
757 		hohAuthPanel.add(myHohAuthUsernameTextbox, gbc_HohUsernameTextbox2);
758 		myHohAuthUsernameTextbox.setColumns(10);
759 
760 		mylabel_8 = new JLabel("Password:");
761 		GridBagConstraints gbc_label_8 = new GridBagConstraints();
762 		gbc_label_8.insets = new Insets(0, 0, 0, 5);
763 		gbc_label_8.anchor = GridBagConstraints.EAST;
764 		gbc_label_8.gridx = 3;
765 		gbc_label_8.gridy = 0;
766 		hohAuthPanel.add(mylabel_8, gbc_label_8);
767 
768 		myHohAuthPasswordTextbox = new JTextField();
769 		myHohAuthPasswordTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
770 			@Override
771 			public void update(DocumentEvent theE) {
772 				myConnection.setHohAuthenticationPassword(myHohAuthPasswordTextbox.getText());
773 			}
774 		});
775 		myHohAuthPasswordTextbox.setPreferredSize(new Dimension(100, 28));
776 		myHohAuthPasswordTextbox.setMaximumSize(new Dimension(200, 2147483647));
777 		myHohAuthPasswordTextbox.setMinimumSize(new Dimension(100, 28));
778 		GridBagConstraints gbc_HohSignatureKeystoreTextbox = new GridBagConstraints();
779 		gbc_HohSignatureKeystoreTextbox.insets = new Insets(0, 0, 0, 5);
780 		gbc_HohSignatureKeystoreTextbox.fill = GridBagConstraints.HORIZONTAL;
781 		gbc_HohSignatureKeystoreTextbox.gridx = 4;
782 		gbc_HohSignatureKeystoreTextbox.gridy = 0;
783 		hohAuthPanel.add(myHohAuthPasswordTextbox, gbc_HohSignatureKeystoreTextbox);
784 		myHohAuthPasswordTextbox.setColumns(10);
785 
786 		mylabel_2 = new JLabel("Security Profile");
787 		mylabel_2.setVerticalTextPosition(SwingConstants.TOP);
788 		mylabel_2.setVerticalAlignment(SwingConstants.TOP);
789 		GridBagConstraints gbc_label_2 = new GridBagConstraints();
790 		gbc_label_2.insets = new Insets(0, 0, 5, 5);
791 		gbc_label_2.gridx = 0;
792 		gbc_label_2.gridy = 1;
793 		myHoHCard.add(mylabel_2, gbc_label_2);
794 
795 		// securityProfilePanel = new JPanel();
796 		GridBagConstraints gbc_securityProfilePanel = new GridBagConstraints();
797 		gbc_securityProfilePanel.insets = new Insets(0, 0, 5, 0);
798 		gbc_securityProfilePanel.fill = GridBagConstraints.BOTH;
799 		gbc_securityProfilePanel.gridx = 1;
800 		gbc_securityProfilePanel.gridy = 1;
801 		// myHoHCard.add(securityProfilePanel, gbc_securityProfilePanel);
802 		// securityProfilePanel.setLayout(new BorderLayout(0, 0));
803 
804 		tlsKeystorePanel = new JPanel();
805 		tlsKeystorePanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
806 		// securityProfilePanel.add(tlsKeystorePanel, BorderLayout.CENTER);
807 		myHoHCard.add(tlsKeystorePanel, gbc_securityProfilePanel);
808 		GridBagLayout gbl_tlsKeystorePanel = new GridBagLayout();
809 		gbl_tlsKeystorePanel.columnWidths = new int[] { 0, 58, 107, 77, 0, 0 };
810 		gbl_tlsKeystorePanel.rowHeights = new int[] { 28, 16, 0, 0 };
811 		gbl_tlsKeystorePanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 1.0, 0.0, Double.MIN_VALUE };
812 		gbl_tlsKeystorePanel.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
813 		tlsKeystorePanel.setLayout(gbl_tlsKeystorePanel);
814 
815 		myHohTlsCheckbox = new JCheckBox("TLS Enabled");
816 		GridBagConstraints gbc_HohTlsCheckbox = new GridBagConstraints();
817 		gbc_HohTlsCheckbox.gridheight = 2;
818 		gbc_HohTlsCheckbox.insets = new Insets(0, 0, 5, 5);
819 		gbc_HohTlsCheckbox.gridx = 0;
820 		gbc_HohTlsCheckbox.gridy = 0;
821 		tlsKeystorePanel.add(myHohTlsCheckbox, gbc_HohTlsCheckbox);
822 		myHohTlsCheckbox.addActionListener(new ActionListener() {
823 			public void actionPerformed(ActionEvent e) {
824 				myConnection.setTls(myHohTlsCheckbox.isSelected());
825 				myTlsCheckbox.setSelected(myHohTlsCheckbox.isSelected());
826 				updatePortsUi();
827 			}
828 		});
829 
830 		mylabel_3 = new JLabel("Keystore:");
831 		GridBagConstraints gbc_label_3 = new GridBagConstraints();
832 		gbc_label_3.anchor = GridBagConstraints.WEST;
833 		gbc_label_3.fill = GridBagConstraints.VERTICAL;
834 		gbc_label_3.insets = new Insets(0, 0, 5, 5);
835 		gbc_label_3.gridx = 1;
836 		gbc_label_3.gridy = 0;
837 		tlsKeystorePanel.add(mylabel_3, gbc_label_3);
838 
839 		myHohSecurityKeystoreTextbox = new JTextField();
840 		GridBagConstraints gbc_HohKeystoreTextbox = new GridBagConstraints();
841 		gbc_HohKeystoreTextbox.gridwidth = 2;
842 		gbc_HohKeystoreTextbox.anchor = GridBagConstraints.NORTH;
843 		gbc_HohKeystoreTextbox.fill = GridBagConstraints.HORIZONTAL;
844 		gbc_HohKeystoreTextbox.insets = new Insets(0, 0, 5, 5);
845 		gbc_HohKeystoreTextbox.gridx = 2;
846 		gbc_HohKeystoreTextbox.gridy = 0;
847 		tlsKeystorePanel.add(myHohSecurityKeystoreTextbox, gbc_HohKeystoreTextbox);
848 		myHohSecurityKeystoreTextbox.setColumns(10);
849 		myHohSecurityKeystoreTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
850 			@Override
851 			public void update(DocumentEvent theE) {
852 				String text = myHohSecurityKeystoreTextbox.getText();
853 				myHohSecurityKeyPwTextBox.setEnabled(isNotBlank(text));
854 				myConnection.setTlsKeystoreLocation(text);
855 			}
856 		});
857 
858 		myHohSecurityKeystoreChooseBtn = new JButton("Choose");
859 		myHohSecurityKeystoreChooseBtn.addActionListener(new ActionListener() {
860 			public void actionPerformed(ActionEvent e) {
861 				Hl7ConnectionPanel.chooseKeystore(Hl7ConnectionPanel.this, myHohSecurityKeystoreTextbox);
862 			}
863 		});
864 		myHohSecurityKeystoreChooseBtn.setIcon(new ImageIcon(Hl7ConnectionPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png")));
865 		GridBagConstraints gbc_HohSignatureKeystoreChooseButton = new GridBagConstraints();
866 		gbc_HohSignatureKeystoreChooseButton.insets = new Insets(0, 0, 5, 0);
867 		gbc_HohSignatureKeystoreChooseButton.gridx = 4;
868 		gbc_HohSignatureKeystoreChooseButton.gridy = 0;
869 		tlsKeystorePanel.add(myHohSecurityKeystoreChooseBtn, gbc_HohSignatureKeystoreChooseButton);
870 
871 		mylabel_4 = new JLabel("Store Pass:");
872 		GridBagConstraints gbc_label_4 = new GridBagConstraints();
873 		gbc_label_4.insets = new Insets(0, 0, 0, 5);
874 		gbc_label_4.anchor = GridBagConstraints.EAST;
875 		gbc_label_4.gridx = 1;
876 		gbc_label_4.gridy = 1;
877 		tlsKeystorePanel.add(mylabel_4, gbc_label_4);
878 
879 		myHohSecurityKeyPwTextBox = new JTextField();
880 		myHohSecurityKeyPwTextBox.getDocument().addDocumentListener(new SimpleDocumentListener() {
881 			@Override
882 			public void update(DocumentEvent theE) {
883 				myConnection.setTlsKeystorePassword(myHohSecurityKeyPwTextBox.getText());
884 			}
885 		});
886 		GridBagConstraints gbc_HohSecurityKeyPwTextBox = new GridBagConstraints();
887 		gbc_HohSecurityKeyPwTextBox.insets = new Insets(0, 0, 0, 5);
888 		gbc_HohSecurityKeyPwTextBox.fill = GridBagConstraints.HORIZONTAL;
889 		gbc_HohSecurityKeyPwTextBox.gridx = 2;
890 		gbc_HohSecurityKeyPwTextBox.gridy = 1;
891 		tlsKeystorePanel.add(myHohSecurityKeyPwTextBox, gbc_HohSecurityKeyPwTextBox);
892 		myHohSecurityKeyPwTextBox.setColumns(10);
893 
894 		myHohSecurityProfileKeystoreStatus = new JLabel("Value goes here");
895 		myHohSecurityProfileKeystoreStatus.setHorizontalAlignment(SwingConstants.CENTER);
896 		GridBagConstraints gbc_HohSecurityProfileKeystoreStatus = new GridBagConstraints();
897 		gbc_HohSecurityProfileKeystoreStatus.anchor = GridBagConstraints.NORTH;
898 		gbc_HohSecurityProfileKeystoreStatus.fill = GridBagConstraints.HORIZONTAL;
899 		gbc_HohSecurityProfileKeystoreStatus.gridwidth = 5;
900 		gbc_HohSecurityProfileKeystoreStatus.gridx = 0;
901 		gbc_HohSecurityProfileKeystoreStatus.gridy = 2;
902 		tlsKeystorePanel.add(myHohSecurityProfileKeystoreStatus, gbc_HohSecurityProfileKeystoreStatus);
903 
904 		mylabel_9 = new JLabel("Signature Profile");
905 		GridBagConstraints gbc_label_9 = new GridBagConstraints();
906 		gbc_label_9.insets = new Insets(0, 0, 0, 5);
907 		gbc_label_9.gridx = 0;
908 		gbc_label_9.gridy = 2;
909 		myHoHCard.add(mylabel_9, gbc_label_9);
910 
911 		mypanel_3 = new JPanel();
912 		mypanel_3.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
913 		GridBagConstraints gbc_panel_3 = new GridBagConstraints();
914 		gbc_panel_3.fill = GridBagConstraints.BOTH;
915 		gbc_panel_3.gridx = 1;
916 		gbc_panel_3.gridy = 2;
917 		myHoHCard.add(mypanel_3, gbc_panel_3);
918 		GridBagLayout gbl_panel_3 = new GridBagLayout();
919 		gbl_panel_3.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 50, 0, 0 };
920 		gbl_panel_3.rowHeights = new int[] { 0, 0, 0, 0 };
921 		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 };
922 		gbl_panel_3.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
923 		mypanel_3.setLayout(gbl_panel_3);
924 
925 		myHohSignatureEnabled = new JCheckBox("Enabled");
926 		myHohSignatureEnabled.addActionListener(new ActionListener() {
927 			@Override
928 			public void actionPerformed(ActionEvent theE) {
929 				myConnection.setHohSignatureEnabled(myHohSignatureEnabled.isSelected());
930 			}
931 		});
932 		GridBagConstraints gbc_HohSignatureEnabled = new GridBagConstraints();
933 		gbc_HohSignatureEnabled.insets = new Insets(0, 0, 5, 5);
934 		gbc_HohSignatureEnabled.gridx = 0;
935 		gbc_HohSignatureEnabled.gridy = 0;
936 		mypanel_3.add(myHohSignatureEnabled, gbc_HohSignatureEnabled);
937 
938 		mylabel_10 = new JLabel("Keystore:");
939 		GridBagConstraints gbc_label_10 = new GridBagConstraints();
940 		gbc_label_10.anchor = GridBagConstraints.EAST;
941 		gbc_label_10.insets = new Insets(0, 0, 5, 5);
942 		gbc_label_10.gridx = 1;
943 		gbc_label_10.gridy = 0;
944 		mypanel_3.add(mylabel_10, gbc_label_10);
945 
946 		myHohSignatureKeystoreTextbox = new JTextField();
947 		myHohSignatureKeystoreTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
948 			@Override
949 			public void update(DocumentEvent theE) {
950 				myConnection.setHohSignatureKeystore(myHohSignatureKeystoreTextbox.getText());
951 			}
952 		});
953 		GridBagConstraints gbc_HohSignatureKeystoreTextbox2 = new GridBagConstraints();
954 		gbc_HohSignatureKeystoreTextbox2.gridwidth = 5;
955 		gbc_HohSignatureKeystoreTextbox2.insets = new Insets(0, 0, 5, 5);
956 		gbc_HohSignatureKeystoreTextbox2.fill = GridBagConstraints.HORIZONTAL;
957 		gbc_HohSignatureKeystoreTextbox2.gridx = 2;
958 		gbc_HohSignatureKeystoreTextbox2.gridy = 0;
959 		mypanel_3.add(myHohSignatureKeystoreTextbox, gbc_HohSignatureKeystoreTextbox2);
960 		myHohSignatureKeystoreTextbox.setColumns(10);
961 
962 		myHohSignatureKeystoreChooseButton = new JButton("Choose");
963 		myHohSignatureKeystoreChooseButton.addActionListener(new ActionListener() {
964 			public void actionPerformed(ActionEvent e) {
965 				Hl7ConnectionPanel.chooseKeystore(Hl7ConnectionPanel.this, myHohSignatureKeystoreTextbox);
966 			}
967 		});
968 		myHohSignatureKeystoreChooseButton.setIcon(new ImageIcon(Hl7ConnectionPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png")));
969 		GridBagConstraints gbc_HohSignatureKeystoreChooseButton2 = new GridBagConstraints();
970 		gbc_HohSignatureKeystoreChooseButton2.insets = new Insets(0, 0, 5, 0);
971 		gbc_HohSignatureKeystoreChooseButton2.gridx = 7;
972 		gbc_HohSignatureKeystoreChooseButton2.gridy = 0;
973 		mypanel_3.add(myHohSignatureKeystoreChooseButton, gbc_HohSignatureKeystoreChooseButton2);
974 
975 		mylabel_11 = new JLabel("Store Pass:");
976 		GridBagConstraints gbc_label_11 = new GridBagConstraints();
977 		gbc_label_11.anchor = GridBagConstraints.EAST;
978 		gbc_label_11.insets = new Insets(0, 0, 5, 5);
979 		gbc_label_11.gridx = 1;
980 		gbc_label_11.gridy = 1;
981 		mypanel_3.add(mylabel_11, gbc_label_11);
982 
983 		myHohSignatureKeystorePasswordTextbox = new JTextField();
984 		myHohSignatureKeystorePasswordTextbox.getDocument().addDocumentListener(new SimpleDocumentListener() {
985 			@Override
986 			public void update(DocumentEvent theE) {
987 				myConnection.setHohSignatureKeystorePassword(myHohSignatureKeystorePasswordTextbox.getText());
988 			}
989 		});
990 		myHohSignatureKeystorePasswordTextbox.setPreferredSize(new Dimension(100, 28));
991 		myHohSignatureKeystorePasswordTextbox.setMinimumSize(new Dimension(100, 28));
992 		myHohSignatureKeystorePasswordTextbox.setMaximumSize(new Dimension(200, 2147483647));
993 		GridBagConstraints gbc_HohSignatureKeystorePasswordTextbox = new GridBagConstraints();
994 		gbc_HohSignatureKeystorePasswordTextbox.insets = new Insets(0, 0, 5, 5);
995 		gbc_HohSignatureKeystorePasswordTextbox.fill = GridBagConstraints.HORIZONTAL;
996 		gbc_HohSignatureKeystorePasswordTextbox.gridx = 2;
997 		gbc_HohSignatureKeystorePasswordTextbox.gridy = 1;
998 		mypanel_3.add(myHohSignatureKeystorePasswordTextbox, gbc_HohSignatureKeystorePasswordTextbox);
999 		myHohSignatureKeystorePasswordTextbox.setColumns(10);
1000 
1001 		mylabel_12 = new JLabel("Key:");
1002 		GridBagConstraints gbc_label_12 = new GridBagConstraints();
1003 		gbc_label_12.anchor = GridBagConstraints.EAST;
1004 		gbc_label_12.insets = new Insets(0, 0, 5, 5);
1005 		gbc_label_12.gridx = 3;
1006 		gbc_label_12.gridy = 1;
1007 		mypanel_3.add(mylabel_12, gbc_label_12);
1008 
1009 		myHohSignatureKeyAliasCombo = new JComboBox();
1010 		myHohSignatureKeyAliasCombo.addActionListener(new ActionListener() {
1011 			@Override
1012 			public void actionPerformed(ActionEvent theE) {
1013 				if (myUpdatingHohSignatureKeyAliasCombo) {
1014 					return;
1015 				}
1016 				String selection = (String) myHohSignatureKeyAliasCombo.getSelectedItem();
1017 				if (selection == HOH_SIGNATURE_KEY_USE_ANY_AVAILABLE) {
1018 					myConnection.setHohSignatureKey(null);
1019 				} else {
1020 					myConnection.setHohSignatureKey(selection.replaceAll(" .*", ""));
1021 				}
1022 			}
1023 		});
1024 		GridBagConstraints gbc_HohSignatureKeyAliasCombo = new GridBagConstraints();
1025 		gbc_HohSignatureKeyAliasCombo.insets = new Insets(0, 0, 5, 5);
1026 		gbc_HohSignatureKeyAliasCombo.fill = GridBagConstraints.HORIZONTAL;
1027 		gbc_HohSignatureKeyAliasCombo.gridx = 4;
1028 		gbc_HohSignatureKeyAliasCombo.gridy = 1;
1029 		mypanel_3.add(myHohSignatureKeyAliasCombo, gbc_HohSignatureKeyAliasCombo);
1030 
1031 		mylabel_13 = new JLabel("Key Pass:");
1032 		GridBagConstraints gbc_label_13 = new GridBagConstraints();
1033 		gbc_label_13.anchor = GridBagConstraints.EAST;
1034 		gbc_label_13.insets = new Insets(0, 0, 5, 5);
1035 		gbc_label_13.gridx = 5;
1036 		gbc_label_13.gridy = 1;
1037 		mypanel_3.add(mylabel_13, gbc_label_13);
1038 
1039 		myHohSignatureKeyPass = new JTextField();
1040 		myHohSignatureKeyPass.getDocument().addDocumentListener(new SimpleDocumentListener() {
1041 			@Override
1042 			public void update(DocumentEvent theE) {
1043 				myConnection.setHohSignatureKeyPassword(myHohSignatureKeyPass.getText());
1044 			}
1045 		});
1046 		myHohSignatureKeyPass.setMinimumSize(new Dimension(50, 28));
1047 		myHohSignatureKeyPass.setMaximumSize(new Dimension(50, 2147483647));
1048 		myHohSignatureKeyPass.setPreferredSize(new Dimension(50, 28));
1049 		GridBagConstraints gbc_HohSignatureKeyPass = new GridBagConstraints();
1050 		gbc_HohSignatureKeyPass.gridwidth = 2;
1051 		gbc_HohSignatureKeyPass.insets = new Insets(0, 0, 5, 0);
1052 		gbc_HohSignatureKeyPass.fill = GridBagConstraints.HORIZONTAL;
1053 		gbc_HohSignatureKeyPass.gridx = 6;
1054 		gbc_HohSignatureKeyPass.gridy = 1;
1055 		mypanel_3.add(myHohSignatureKeyPass, gbc_HohSignatureKeyPass);
1056 		myHohSignatureKeyPass.setColumns(10);
1057 
1058 		myHohSignatureStatusLabel = new JLabel("New label");
1059 		myHohSignatureStatusLabel.setHorizontalAlignment(SwingConstants.CENTER);
1060 		GridBagConstraints gbc_HohSignatureStatusLabel = new GridBagConstraints();
1061 		gbc_HohSignatureStatusLabel.fill = GridBagConstraints.HORIZONTAL;
1062 		gbc_HohSignatureStatusLabel.gridwidth = 8;
1063 		gbc_HohSignatureStatusLabel.insets = new Insets(0, 0, 0, 5);
1064 		gbc_HohSignatureStatusLabel.gridx = 0;
1065 		gbc_HohSignatureStatusLabel.gridy = 2;
1066 		mypanel_3.add(myHohSignatureStatusLabel, gbc_HohSignatureStatusLabel);
1067 
1068 		init();
1069 
1070 	}
1071 
1072 	public void destroy() {
1073 		myConnection.removePropertyChangeListener(OutboundConnection.STATUS_PROPERTY, myStatusPropertyChangeListener);
1074 		myConnection.removePropertyChangeListener(OutboundConnection.STATUS_LINE_PROPERTY, myStatusLinePropertyChangeListener);
1075 		myConnection.removePropertyChangeListener(AbstractConnection.TLS_KEYSTORE_STATUS, myHohSecurityProfileKeystoreStatusListener);
1076 		myConnection.removePropertyChangeListener(AbstractConnection.HOH_SIGNATURE_KEYSTORE_STATUS, myHohSignatureStatusListener);
1077 		myConnection.removePropertyChangeListener(AbstractConnection.HOH_SIGNER_AVAILABLE_ALIASES_PROPERTY, myHohSignerAvailableAliasesListener);
1078 	}
1079 
1080 	private void init() {
1081 		List<String> charSets = new ArrayList<String>(Charset.availableCharsets().keySet());
1082 		Collections.sort(charSets);
1083 		ComboBoxModel charsetModel = new DefaultComboBoxModel(charSets.toArray(new String[0]));
1084 		myCharsetCombo.setModel(charsetModel);
1085 	}
1086 
1087 	private boolean isChangesAllowed() {
1088 		return myConnection.getStatus() == StatusEnum.STOPPED || myConnection.getStatus() == StatusEnum.FAILED;
1089 	}
1090 
1091 	private String portToString(int thePort) {
1092 		if (thePort > 0) {
1093 			return Integer.toString(thePort);
1094 		} else {
1095 			return "";
1096 		}
1097 	}
1098 
1099 	private void updateHohSignatureKeyCombo() {
1100 		myUpdatingHohSignatureKeyAliasCombo = true;
1101 		try {
1102 			myHohSignatureKeyAliasCombo.removeAllItems();
1103 			List<String> aliases = myConnection.getHohSignatureAvailableAliases();
1104 			for (String next : aliases) {
1105 				myHohSignatureKeyAliasCombo.addItem(next);
1106 				if (next.equals(myConnection.getHohSignatureKey())) {
1107 					myHohSignatureKeyAliasCombo.setSelectedIndex(myHohSignatureKeyAliasCombo.getItemCount()-1);
1108 				}
1109 			}
1110 		} finally {
1111 			myUpdatingHohSignatureKeyAliasCombo = false;
1112 		}
1113 	}
1114 
1115 	public void setConnection(AbstractConnection theConnection) {
1116 		myConnection = theConnection;
1117 
1118 		myHohSecurityKeyPwTextBox.setText(myConnection.getTlsKeystorePassword());
1119 		myHohSecurityKeystoreTextbox.setText(myConnection.getTlsKeystoreLocation());
1120 		myHohSecurityProfileKeystoreStatus.setText("");
1121 
1122 		myHohSignatureEnabled.setSelected(myConnection.isHohSignatureEnabled());
1123 		myHohSignatureKeystoreTextbox.setText(myConnection.getHohSignatureKeystore());
1124 		myHohSignatureKeystorePasswordTextbox.setText(myConnection.getHohSignatureKeystorePassword());
1125 		myHohSignatureKeyPass.setText(myConnection.getHohSignatureKeyPassword());
1126 		updateHohSignatureKeyCombo();
1127 		
1128 		myCharsetCombo.setSelectedItem(theConnection.getCharSet());
1129 
1130 		myTlsCheckbox.setSelected(theConnection.isTls());
1131 		myHohTlsCheckbox.setSelected(theConnection.isTls());
1132 		myCaptureByteStreamCheckbox.setSelected(theConnection.isCaptureBytes());
1133 
1134 		myHohAuthEnabledCheckbox.setSelected(myConnection.isHohAuthenticationEnabled());
1135 		myHohAuthUsernameTextbox.setText(myConnection.getHohAuthenticationUsername());
1136 		myHohAuthPasswordTextbox.setText(myConnection.getHohAuthenticationPassword());
1137 
1138 		updateCharset();
1139 
1140 		Hl7V2EncodingTypeEnum encoding = theConnection.getEncoding();
1141 		myEr7Radio.setSelected(encoding == Hl7V2EncodingTypeEnum.ER_7);
1142 		myXmlRadio.setSelected(encoding == Hl7V2EncodingTypeEnum.XML);
1143 		myHostBox.setText(theConnection.getHost());
1144 
1145 		updatePortsUi();
1146 
1147 		myStatusPropertyChangeListener = new PropertyChangeListener() {
1148 
1149 			public void propertyChange(PropertyChangeEvent theEvt) {
1150 				updateStatus();
1151 			}
1152 		};
1153 		myConnection.addPropertyChangeListener(OutboundConnection.STATUS_PROPERTY, myStatusPropertyChangeListener);
1154 
1155 		myStatusLinePropertyChangeListener = new PropertyChangeListener() {
1156 
1157 			public void propertyChange(PropertyChangeEvent theEvt) {
1158 				updateStatus();
1159 			}
1160 		};
1161 		myConnection.addPropertyChangeListener(OutboundConnection.STATUS_LINE_PROPERTY, myStatusLinePropertyChangeListener);
1162 
1163 		myHohSecurityProfileKeystoreStatusListener = new KeystoreStatusListener(myHohSecurityProfileKeystoreStatus);
1164 		myConnection.addPropertyChangeListener(AbstractConnection.TLS_KEYSTORE_STATUS, myHohSecurityProfileKeystoreStatusListener);
1165 
1166 		myHohSignatureStatusListener = new KeystoreStatusListener(myHohSignatureStatusLabel);
1167 		myConnection.addPropertyChangeListener(AbstractConnection.HOH_SIGNATURE_KEYSTORE_STATUS, myHohSignatureStatusListener);
1168 
1169 		myHohSignerAvailableAliasesListener = new PropertyChangeListener() {
1170 			@Override
1171 			public void propertyChange(PropertyChangeEvent theEvt) {
1172 				updateHohSignatureKeyCombo();
1173 			}
1174 
1175 		};
1176 		myConnection.addPropertyChangeListener(AbstractConnection.HOH_SIGNER_AVAILABLE_ALIASES_PROPERTY, myHohSignerAvailableAliasesListener);
1177 		
1178 		updateStatus();
1179 
1180 	}
1181 
1182 	private void updateCharset() {
1183 		if (myConnection.isDetectCharSetInMessage()) {
1184 			myCharsetDetectRadio.setSelected(true);
1185 			myCharsetSelectRadio.setSelected(false);
1186 			myCharsetCombo.setEnabled(false);
1187 		} else {
1188 			myCharsetDetectRadio.setSelected(false);
1189 			myCharsetSelectRadio.setSelected(true);
1190 			myCharsetCombo.setEnabled(true);
1191 		}
1192 	}
1193 
1194 	private void updateCharsetModel() {
1195 		if (myCharsetDetectRadio.isSelected()) {
1196 			myConnection.setDetectCharSetInMessage(true);
1197 		} else {
1198 			myConnection.setDetectCharSetInMessage(false);
1199 			String charSet = (String) myCharsetCombo.getSelectedItem();
1200 			myConnection.setCharSet(charSet);
1201 			Prefs.getInstance().setMostRecentConnectionCharset(charSet);
1202 		}
1203 	}
1204 
1205 	private void updateEncodingModel() {
1206 		if (myEr7Radio.isSelected()) {
1207 			myConnection.setEncoding(Hl7V2EncodingTypeEnum.ER_7);
1208 		} else {
1209 			myConnection.setEncoding(Hl7V2EncodingTypeEnum.XML);
1210 		}
1211 	}
1212 
1213 	private void updatePortsModel() {
1214 		if (mySinglePortRadio.isSelected()) {
1215 			myConnection.setTransport(TransportStyleEnum.SINGLE_PORT_MLLP);
1216 		} else if (myDualPortRadio.isSelected()) {
1217 			myConnection.setTransport(TransportStyleEnum.DUAL_PORT_MLLP);
1218 		} else {
1219 			myConnection.setTransport(TransportStyleEnum.HL7_OVER_HTTP);
1220 		}
1221 	}
1222 
1223 	private void updatePortsUi() {
1224 		boolean changesAllowed = isChangesAllowed();
1225 		CardLayout cl = (CardLayout) myInterfaceTypeCardPanel.getLayout();
1226 
1227 		switch (myConnection.getTransport()) {
1228 		case DUAL_PORT_MLLP: {
1229 			mySinglePortRadio.setSelected(false);
1230 			myDualPortRadio.setSelected(true);
1231 			myHl7OverHttpRadioButton.setSelected(false);
1232 
1233 			myDualIncomingTextBox.setText(portToString(myConnection.getIncomingOrSinglePort()));
1234 			myDualOutgoingTextBox.setText(portToString(myConnection.getOutgoingPort()));
1235 
1236 			mySinglePortTextBox.setEnabled(false);
1237 			myDualIncomingTextBox.setEnabled(true && changesAllowed);
1238 			myDualOutgoingTextBox.setEnabled(true && changesAllowed);
1239 			myHoHUrlTextField.setEnabled(false);
1240 			mySinglePortTextBox.repaint();
1241 			myDualIncomingTextBox.repaint();
1242 			myDualOutgoingTextBox.repaint();
1243 
1244 			cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanel.IFACE_TYPE_CARD_MLLP);
1245 			break;
1246 		}
1247 		case SINGLE_PORT_MLLP: {
1248 			mySinglePortRadio.setSelected(true);
1249 			myDualPortRadio.setSelected(false);
1250 			myHl7OverHttpRadioButton.setSelected(false);
1251 
1252 			mySinglePortTextBox.setText(portToString(myConnection.getIncomingOrSinglePort()));
1253 
1254 			mySinglePortTextBox.setEnabled(true && changesAllowed);
1255 			myDualIncomingTextBox.setEnabled(false);
1256 			myDualOutgoingTextBox.setEnabled(false);
1257 			myHoHUrlTextField.setEnabled(false);
1258 			mySinglePortTextBox.repaint();
1259 			myDualIncomingTextBox.repaint();
1260 			myDualOutgoingTextBox.repaint();
1261 
1262 			cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanel.IFACE_TYPE_CARD_MLLP);
1263 			break;
1264 		}
1265 		case HL7_OVER_HTTP: {
1266 			mySinglePortTextBox.setEnabled(false);
1267 			myDualIncomingTextBox.setEnabled(false);
1268 			myDualOutgoingTextBox.setEnabled(false);
1269 			mySinglePortRadio.setSelected(false);
1270 			myDualPortRadio.setSelected(false);
1271 			myHl7OverHttpRadioButton.setSelected(true);
1272 
1273 			cl.show(myInterfaceTypeCardPanel, Hl7ConnectionPanel.IFACE_TYPE_CARD_HOH);
1274 
1275 			StringBuilder urlBuilder = new StringBuilder();
1276 			urlBuilder.append((myConnection.isTls() ? "https://" : "http://"));
1277 			urlBuilder.append(StringUtils.defaultString(myConnection.getHost(), "localhost"));
1278 			urlBuilder.append(":").append(myConnection.getIncomingOrSinglePort());
1279 			urlBuilder.append(StringUtils.defaultString(myConnection.getHttpUriPath(), "/"));
1280 			String url = urlBuilder.toString();
1281 			if (!myHohUrlTextFieldUpdating) {
1282 				myHohUrlTextFieldUpdating = true;
1283 				myHoHUrlTextField.setText(url);
1284 				myHohUrlTextFieldUpdating = false;
1285 			}
1286 
1287 			myHoHUrlTextField.setEnabled(true && changesAllowed);
1288 
1289 			break;
1290 		}
1291 		}
1292 	}
1293 
1294 	private void updateStatus() {
1295 		boolean changesAllowed = isChangesAllowed();
1296 		myHostBox.setEnabled(changesAllowed);
1297 
1298 		updatePortsUi();
1299 
1300 		mySinglePortRadio.setEnabled(changesAllowed);
1301 		myDualPortRadio.setEnabled(changesAllowed);
1302 		myHl7OverHttpRadioButton.setEnabled(changesAllowed);
1303 		myCharsetCombo.setEnabled(changesAllowed);
1304 		myCharsetDetectRadio.setEnabled(changesAllowed);
1305 		myCharsetSelectRadio.setEnabled(changesAllowed);
1306 		myEr7Radio.setEnabled(changesAllowed);
1307 		myTlsCheckbox.setEnabled(changesAllowed);
1308 		myHohTlsCheckbox.setEnabled(changesAllowed);
1309 		myXmlRadio.setEnabled(changesAllowed);
1310 		myCaptureByteStreamCheckbox.setEnabled(changesAllowed); // TODO: update hoh components enabled status
1311 
1312 	}
1313 
1314 	private static void chooseKeystore(Component theParentController, JTextField theTextbox) {
1315 		String directory = Prefs.getInstance().getInterfaceHohSecurityKeystoreDirectory();
1316 		directory = StringUtils.defaultString(directory, ".");
1317 		JFileChooser chooser = new JFileChooser(directory);
1318 		chooser.setDialogType(JFileChooser.OPEN_DIALOG);
1319 		chooser.setDialogTitle("Select a Java Keystore");
1320 		int result = chooser.showOpenDialog(theParentController);
1321 		if (result == JFileChooser.APPROVE_OPTION) {
1322 			Prefs.getInstance().setInterfaceHohSecurityKeystoreDirectory(chooser.getSelectedFile().getParent());
1323 			theTextbox.setText(chooser.getSelectedFile().getAbsolutePath());
1324 		}
1325 	}
1326 
1327 	private final class KeystoreStatusListener implements PropertyChangeListener {
1328 		private final JLabel myLabel;
1329 
1330 		public KeystoreStatusListener(JLabel theLabel) {
1331 			myLabel = theLabel;
1332 			clear();
1333 		}
1334 
1335 		private void clear() {
1336 			myLabel.setText("");
1337 			myLabel.setIcon(null);
1338 		}
1339 
1340 		@Override
1341 		public void propertyChange(PropertyChangeEvent theEvt) {
1342 			JLabel label = myLabel;
1343 			WorkingStatusBean newValue = (WorkingStatusBean) theEvt.getNewValue();
1344 			if (newValue == null || isBlank(newValue.getMessage())) {
1345 				clear();
1346 			} else {
1347 				label.setText("<html>" + newValue.getMessage() + "</html>");
1348 				switch (newValue.getStatus()) {
1349 				case ERROR:
1350 					myLabel.setIcon(ICON_INFO_WARNING);
1351 					break;
1352 				case WORKING:
1353 					myLabel.setIcon(ICON_INFO_WORKING);
1354 					break;
1355 				case OK:
1356 					myLabel.setIcon(ICON_INFO_OK);
1357 					break;
1358 				}
1359 			}
1360 		}
1361 	}
1362 
1363 }