1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package ca.uhn.hl7v2.testpanel.ui;
27
28 import java.awt.BorderLayout;
29 import java.awt.Color;
30 import java.awt.Component;
31 import java.awt.Cursor;
32 import java.awt.Desktop;
33 import java.awt.FlowLayout;
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.awt.event.MouseAdapter;
40 import java.awt.event.MouseEvent;
41 import java.io.IOException;
42 import java.net.URI;
43 import java.net.URISyntaxException;
44
45 import javax.swing.Box;
46 import javax.swing.ImageIcon;
47 import javax.swing.JButton;
48 import javax.swing.JDialog;
49 import javax.swing.JLabel;
50 import javax.swing.JPanel;
51 import javax.swing.SwingConstants;
52 import javax.swing.border.EmptyBorder;
53 import javax.swing.border.LineBorder;
54
55 import org.slf4j.Logger;
56 import org.slf4j.LoggerFactory;
57
58 public class AboutDialog extends JDialog {
59
60 private final JPanel mycontentPanel = new JPanel();
61 private static final Logger ourLog = LoggerFactory.getLogger(AboutDialog.class);
62
63
64
65
66 public static void main(String[] args) {
67 try {
68 AboutDialog dialog = new AboutDialog();
69 dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
70 dialog.setVisible(true);
71 } catch (Exception e) {
72 e.printStackTrace();
73 }
74 }
75
76
77
78
79 public AboutDialog() {
80 setBounds(100, 100, 583, 553);
81 getContentPane().setLayout(new BorderLayout());
82 mycontentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
83 getContentPane().add(mycontentPanel, BorderLayout.CENTER);
84 mycontentPanel.setLayout(new BorderLayout(0, 0));
85 {
86 JPanel panel = new JPanel();
87 panel.setBorder(new LineBorder(Color.GRAY));
88 FlowLayout flowLayout = (FlowLayout) panel.getLayout();
89 flowLayout.setVgap(0);
90 flowLayout.setHgap(0);
91 panel.setBackground(Color.WHITE);
92 mycontentPanel.add(panel, BorderLayout.NORTH);
93 {
94 JLabel label = new JLabel("");
95 label.setIcon(new ImageIcon(AboutDialog.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_logo.png")));
96 panel.add(label);
97 }
98 }
99 {
100 StringBuilder aboutText = new StringBuilder();
101
102 aboutText.append("<html>");
103 aboutText.append("This software is licensed under the terms of the GNU Public License (Version 2) and the Mozilla Public License (Version 1.0).");
104 aboutText.append("</html>");
105 }
106 {
107 JPanel panel = new JPanel();
108 mycontentPanel.add(panel, BorderLayout.CENTER);
109 GridBagLayout gbl_panel = new GridBagLayout();
110 gbl_panel.columnWidths = new int[] { 203, 0, 0 };
111 gbl_panel.rowHeights = new int[] { 16, 0, 0, 0, 0, 0, 0, 0, 0 };
112 gbl_panel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
113 gbl_panel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
114 panel.setLayout(gbl_panel);
115
116 JLabel lblNewLabel = new JLabel("Welcome to the HAPI TestPanel. ");
117 lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
118 GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
119 gbc_lblNewLabel.gridwidth = 2;
120 gbc_lblNewLabel.insets = new Insets(10, 0, 5, 0);
121 gbc_lblNewLabel.fill = GridBagConstraints.HORIZONTAL;
122 gbc_lblNewLabel.anchor = GridBagConstraints.NORTH;
123 gbc_lblNewLabel.gridx = 0;
124 gbc_lblNewLabel.gridy = 0;
125 panel.add(lblNewLabel, gbc_lblNewLabel);
126 {
127 JLabel lblThisSoftwareIs = new JLabel(
128 "<html><center>This is free software, licensed under the terms of the GNU General Public License (Version 2) and the Mozilla Public License (Version 1.0).</center></html>");
129 lblThisSoftwareIs.setHorizontalAlignment(SwingConstants.CENTER);
130 GridBagConstraints gbc_lblThisSoftwareIs = new GridBagConstraints();
131 gbc_lblThisSoftwareIs.gridwidth = 2;
132 gbc_lblThisSoftwareIs.fill = GridBagConstraints.HORIZONTAL;
133 gbc_lblThisSoftwareIs.insets = new Insets(0, 20, 5, 20);
134 gbc_lblThisSoftwareIs.gridx = 0;
135 gbc_lblThisSoftwareIs.gridy = 1;
136 panel.add(lblThisSoftwareIs, gbc_lblThisSoftwareIs);
137 }
138 {
139 JLabel lblLearnMore = new JLabel("Learn More");
140 lblLearnMore.setHorizontalAlignment(SwingConstants.CENTER);
141 lblLearnMore.addMouseListener(new MouseAdapter() {
142 @Override
143 public void mouseClicked(MouseEvent e) {
144 try {
145 open(new URI("http://hl7api.sourceforge.net/newtestpanel.html"));
146 } catch (URISyntaxException e1) {
147 ourLog.error("Failed to create hyperlink", e1);
148 }
149 }
150 });
151 lblLearnMore.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
152 lblLearnMore.setForeground(Color.BLUE);
153 GridBagConstraints gbc_lblLearnMore = new GridBagConstraints();
154 gbc_lblLearnMore.gridwidth = 2;
155 gbc_lblLearnMore.insets = new Insets(10, 0, 5, 0);
156 gbc_lblLearnMore.gridx = 0;
157 gbc_lblLearnMore.gridy = 2;
158 panel.add(lblLearnMore, gbc_lblLearnMore);
159 }
160 {
161 JLabel lblThisSoftwareAlso = new JLabel("This software also makes use of the following great open source projects:");
162 GridBagConstraints gbc_lblThisSoftwareAlso = new GridBagConstraints();
163 gbc_lblThisSoftwareAlso.gridwidth = 2;
164 gbc_lblThisSoftwareAlso.insets = new Insets(10, 0, 5, 0);
165 gbc_lblThisSoftwareAlso.gridx = 0;
166 gbc_lblThisSoftwareAlso.gridy = 3;
167 panel.add(lblThisSoftwareAlso, gbc_lblThisSoftwareAlso);
168 }
169 {
170 JLabel lblJsyntaxpane = new JLabel("JSyntaxPane");
171 GridBagConstraints gbc_lblJsyntaxpane = new GridBagConstraints();
172 gbc_lblJsyntaxpane.insets = new Insets(0, 0, 5, 5);
173 gbc_lblJsyntaxpane.gridx = 0;
174 gbc_lblJsyntaxpane.gridy = 4;
175 panel.add(lblJsyntaxpane, gbc_lblJsyntaxpane);
176 }
177 {
178 JLabel lblNewLabel_1 = new JLabel("NetBeans.org Outline");
179 GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
180 gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 0);
181 gbc_lblNewLabel_1.gridx = 1;
182 gbc_lblNewLabel_1.gridy = 4;
183 panel.add(lblNewLabel_1, gbc_lblNewLabel_1);
184 }
185 {
186 JLabel lblJflex = new JLabel("JFlex");
187 GridBagConstraints gbc_lblJflex = new GridBagConstraints();
188 gbc_lblJflex.insets = new Insets(0, 0, 5, 5);
189 gbc_lblJflex.gridx = 0;
190 gbc_lblJflex.gridy = 5;
191 panel.add(lblJflex, gbc_lblJflex);
192 }
193 {
194 JLabel lblGnuPublicLicense = new JLabel("log4j");
195 GridBagConstraints gbc_lblGnuPublicLicense = new GridBagConstraints();
196 gbc_lblGnuPublicLicense.insets = new Insets(0, 0, 5, 0);
197 gbc_lblGnuPublicLicense.gridx = 1;
198 gbc_lblGnuPublicLicense.gridy = 5;
199 panel.add(lblGnuPublicLicense, gbc_lblGnuPublicLicense);
200 }
201 {
202 Component verticalGlue = Box.createVerticalGlue();
203 GridBagConstraints gbc_verticalGlue = new GridBagConstraints();
204 gbc_verticalGlue.insets = new Insets(0, 0, 5, 5);
205 gbc_verticalGlue.gridx = 0;
206 gbc_verticalGlue.gridy = 6;
207 panel.add(verticalGlue, gbc_verticalGlue);
208 }
209 {
210 JLabel lblNewLabel_2 = new JLabel("");
211 lblNewLabel_2.setIcon(new ImageIcon(AboutDialog.class.getResource("/ca/uhn/hl7v2/testpanel/images/dogs_waiting_175.jpg")));
212 GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
213 gbc_lblNewLabel_2.gridwidth = 2;
214 gbc_lblNewLabel_2.gridx = 0;
215 gbc_lblNewLabel_2.gridy = 7;
216 panel.add(lblNewLabel_2, gbc_lblNewLabel_2);
217 }
218 }
219 {
220 JPanel buttonPane = new JPanel();
221 buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
222 getContentPane().add(buttonPane, BorderLayout.SOUTH);
223 {
224 JButton okButton = new JButton("OK");
225 okButton.setSelected(true);
226 okButton.addActionListener(new ActionListener() {
227 public void actionPerformed(ActionEvent e) {
228 AboutDialog.this.setVisible(false);
229 }
230 });
231 okButton.setActionCommand("OK");
232 buttonPane.add(okButton);
233 getRootPane().setDefaultButton(okButton);
234 }
235 }
236 }
237
238 private static void open(URI uri) {
239 if (Desktop.isDesktopSupported()) {
240 try {
241 Desktop.getDesktop().browse(uri);
242 } catch (IOException e) {
243 ourLog.error("Failed to create hyperlink", e);
244 }
245 } else {
246 ourLog.error("Failed to create hyperlink, no desktop available");
247 }
248 }
249 }