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;
27  
28  import java.awt.Color;
29  import java.awt.Desktop;
30  import java.awt.GridBagConstraints;
31  import java.awt.GridBagLayout;
32  import java.awt.Insets;
33  import java.awt.event.ActionEvent;
34  import java.awt.event.ActionListener;
35  import java.awt.event.MouseAdapter;
36  import java.awt.event.MouseEvent;
37  import java.io.IOException;
38  import java.net.URI;
39  import java.net.URISyntaxException;
40  
41  import javax.swing.ImageIcon;
42  import javax.swing.JButton;
43  import javax.swing.JLabel;
44  import javax.swing.JPanel;
45  import javax.swing.SwingConstants;
46  
47  import ca.uhn.hl7v2.testpanel.controller.Controller;
48  
49  public class NothingSelectedPanel extends BaseMainPanel {
50  
51  	/**
52  	 * Create the panel.
53  	 */
54  	public NothingSelectedPanel(final Controller theController) {
55  		GridBagLayout gridBagLayout = new GridBagLayout();
56  		gridBagLayout.columnWidths = new int[]{0, 0};
57  		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
58  		gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
59  		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
60  		setLayout(gridBagLayout);
61  		
62  		JPanel panel = new JPanel();
63  		panel.setBackground(Color.WHITE);
64  		GridBagConstraints gbc_panel = new GridBagConstraints();
65  		gbc_panel.insets = new Insets(0, 0, 5, 0);
66  		gbc_panel.fill = GridBagConstraints.BOTH;
67  		gbc_panel.gridx = 0;
68  		gbc_panel.gridy = 0;
69  		add(panel, gbc_panel);
70  		
71  		JLabel lblNewLabel_1 = new JLabel("");
72  		lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
73  		lblNewLabel_1.setIcon(new ImageIcon(NothingSelectedPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_logo.png")));
74  		panel.add(lblNewLabel_1);
75  		
76  		JLabel lblNewLabel = new JLabel("<html><center>" +
77  				"Welcome to HAPI TestPanel!<br><br>" +
78  				"This is free software, licensed under the Mozilla Public License. " +
79  				"<br><br>Get Started:" +
80  				"</center></html>");
81  		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
82  		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
83  		gbc_lblNewLabel.insets = new Insets(0, 0, 5, 0);
84  		gbc_lblNewLabel.fill = GridBagConstraints.HORIZONTAL;
85  		gbc_lblNewLabel.gridx = 0;
86  		gbc_lblNewLabel.gridy = 1;
87  		add(lblNewLabel, gbc_lblNewLabel);
88  		
89  		JButton btnCreateHlV = new JButton("Create Samples");
90  		btnCreateHlV.addActionListener(new ActionListener() {
91  			public void actionPerformed(ActionEvent e) {
92  				theController.populateWithSampleMessageAndConnections();
93  			}
94  		});
95  		GridBagConstraints gbc_btnCreateHlV = new GridBagConstraints();
96  		gbc_btnCreateHlV.insets = new Insets(0, 0, 5, 0);
97  		gbc_btnCreateHlV.gridx = 0;
98  		gbc_btnCreateHlV.gridy = 2;
99  		add(btnCreateHlV, gbc_btnCreateHlV);
100 		
101 		JLabel lblNewLabel_2 = new JLabel("<html><center>" +
102 				"<br><br>" +
103 				"Let us know what you think!" +
104 				"</center></html>");
105 		lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
106 		GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
107 		gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 0);
108 		gbc_lblNewLabel_2.fill = GridBagConstraints.HORIZONTAL;
109 		gbc_lblNewLabel_2.gridx = 0;
110 		gbc_lblNewLabel_2.gridy = 3;
111 		add(lblNewLabel_2, gbc_lblNewLabel_2);
112 		
113 		JLabel lblViewLicenseInformation = new JLabel("<html><center>Licensed under the <a href=\"\">Mozilla Public License</a></center></html>");
114 		lblViewLicenseInformation.addMouseListener(new MouseAdapter() {
115 			@Override
116 			public void mouseClicked(MouseEvent e) {
117 				try {
118 					Desktop.getDesktop().browse(new URI("http://hl7api.sourceforge.net/license.html"));
119 				} catch (IOException e1) {
120 					e1.printStackTrace();
121 				} catch (URISyntaxException e1) {
122 					e1.printStackTrace();
123 				}
124 			}
125 		});
126 		lblViewLicenseInformation.setHorizontalAlignment(SwingConstants.CENTER);
127 		lblViewLicenseInformation.setForeground(Color.BLACK);
128 		GridBagConstraints gbc_lblViewLicenseInformation = new GridBagConstraints();
129 		gbc_lblViewLicenseInformation.fill = GridBagConstraints.HORIZONTAL;
130 		gbc_lblViewLicenseInformation.anchor = GridBagConstraints.SOUTH;
131 		gbc_lblViewLicenseInformation.gridx = 0;
132 		gbc_lblViewLicenseInformation.gridy = 4;
133 		add(lblViewLicenseInformation, gbc_lblViewLicenseInformation);
134 
135 	}
136 
137 }