]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/gui/AboutScreen.java
1e4f4f5bf5f98f04693f6657d5f460b29999fcc2
[GpsPrune.git] / tim / prune / gui / AboutScreen.java
1 package tim.prune.gui;
2
3 import java.awt.BorderLayout;
4 import java.awt.Component;
5 import java.awt.FlowLayout;
6 import java.awt.Font;
7 import java.awt.GridBagConstraints;
8 import java.awt.GridBagLayout;
9 import java.awt.event.ActionEvent;
10 import java.awt.event.ActionListener;
11 import java.awt.event.KeyEvent;
12 import java.awt.event.KeyListener;
13
14 import javax.swing.BorderFactory;
15 import javax.swing.BoxLayout;
16 import javax.swing.JButton;
17 import javax.swing.JDialog;
18 import javax.swing.JEditorPane;
19 import javax.swing.JFrame;
20 import javax.swing.JLabel;
21 import javax.swing.JPanel;
22 import javax.swing.JTabbedPane;
23
24 import tim.prune.ExternalTools;
25 import tim.prune.GpsPruner;
26 import tim.prune.I18nManager;
27 import tim.prune.threedee.WindowFactory;
28
29 /**
30  * Class to represent the "About" popup window
31  */
32 public class AboutScreen extends JDialog
33 {
34         JButton _okButton = null;
35
36         /**
37          * Constructor
38          */
39         public AboutScreen(JFrame inParent)
40         {
41                 super(inParent, I18nManager.getText("dialog.about.title"));
42                 getContentPane().add(makeContents());
43         }
44
45
46         /**
47          * @return the contents of the window as a Component
48          */
49         private Component makeContents()
50         {
51                 JPanel mainPanel = new JPanel();
52                 mainPanel.setLayout(new BorderLayout());
53
54                 JTabbedPane tabPane = new JTabbedPane();
55                 mainPanel.add(tabPane, BorderLayout.CENTER);
56
57                 JPanel aboutPanel = new JPanel();
58                 aboutPanel.setLayout(new BoxLayout(aboutPanel, BoxLayout.Y_AXIS));
59                 aboutPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
60                 JLabel titleLabel = new JLabel("Prune");
61                 titleLabel.setFont(new Font("SansSerif", Font.BOLD, 24));
62                 titleLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
63                 aboutPanel.add(titleLabel);
64                 JLabel versionLabel = new JLabel(I18nManager.getText("dialog.about.version") + ": " + GpsPruner.VERSION_NUMBER);
65                 versionLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
66                 aboutPanel.add(versionLabel);
67                 JLabel buildLabel = new JLabel(I18nManager.getText("dialog.about.build") + ": " + GpsPruner.BUILD_NUMBER);
68                 buildLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
69                 aboutPanel.add(buildLabel);
70                 aboutPanel.add(new JLabel(" "));
71                 StringBuffer descBuffer = new StringBuffer();
72                 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.summarytext1")).append("</p>");
73                 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.summarytext2")).append("</p>");
74                 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.summarytext3")).append("</p>");
75                 descBuffer.append("<p>").append(I18nManager.getText("dialog.about.translatedby")).append("</p>");
76                 JEditorPane descPane = new JEditorPane("text/html", descBuffer.toString());
77                 descPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
78                 descPane.setEditable(false);
79                 descPane.setOpaque(false);
80                 descPane.setAlignmentX(JEditorPane.CENTER_ALIGNMENT);
81
82                 aboutPanel.add(descPane);
83                 aboutPanel.add(new JLabel(" "));
84                 tabPane.add(I18nManager.getText("dialog.about.title"), aboutPanel);
85
86                 // Second pane for system info
87                 JPanel sysInfoPanel = new JPanel();
88                 GridBagLayout gridBag = new GridBagLayout();
89                 sysInfoPanel.setLayout(gridBag);
90                 GridBagConstraints constraints = new GridBagConstraints();
91                 constraints.weightx = 0.0; constraints.weighty = 0.0;
92                 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
93                         new JLabel(I18nManager.getText("dialog.about.systeminfo.os") + " : "),
94                         0, 0);
95                 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
96                         new JLabel(System.getProperty("os.name")),
97                         1, 0);
98                 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
99                         new JLabel(I18nManager.getText("dialog.about.systeminfo.java") + " : "),
100                         0, 1);
101                 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
102                         new JLabel(System.getProperty("java.runtime.version")),
103                         1, 1);
104                 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
105                         new JLabel(I18nManager.getText("dialog.about.systeminfo.java3d") + " : "),
106                         0, 2);
107                 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
108                         new JLabel(I18nManager.getText(WindowFactory.isJava3dEnabled()?"dialog.about.yes":"dialog.about.no")),
109                         1, 2);
110                 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
111                         new JLabel(I18nManager.getText("dialog.about.systeminfo.povray") + " : "),
112                         0, 3);
113                 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
114                         new JLabel(I18nManager.getText(ExternalTools.isPovrayInstalled()?"dialog.about.yes":"dialog.about.no")),
115                         1, 3);
116                 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
117                         new JLabel(I18nManager.getText("dialog.about.systeminfo.exiftool") + " : "),
118                         0, 4);
119                 addToGridBagPanel(sysInfoPanel, gridBag, constraints,
120                         new JLabel(I18nManager.getText(ExternalTools.isExiftoolInstalled()?"dialog.about.yes":"dialog.about.no")),
121                         1, 4);
122                 tabPane.add(I18nManager.getText("dialog.about.systeminfo"), sysInfoPanel);
123
124                 // Third pane for credits
125                 JPanel creditsPanel = new JPanel();
126                 gridBag = new GridBagLayout();
127                 creditsPanel.setLayout(gridBag);
128                 constraints = new GridBagConstraints();
129                 constraints.weightx = 0.0; constraints.weighty = 0.0;
130
131                 addToGridBagPanel(creditsPanel, gridBag, constraints,
132                         new JLabel(I18nManager.getText("dialog.about.credits.code") + " : "),
133                         0, 0);
134                 addToGridBagPanel(creditsPanel, gridBag, constraints,
135                         new JLabel("activityworkshop.net"),
136                         1, 0);
137                 addToGridBagPanel(creditsPanel, gridBag, constraints,
138                         new JLabel(I18nManager.getText("dialog.about.credits.exifcode") + " : "),
139                         0, 1);
140                 addToGridBagPanel(creditsPanel, gridBag, constraints,
141                         new JLabel("Drew Noakes"),
142                         1, 1);
143                 addToGridBagPanel(creditsPanel, gridBag, constraints,
144                         new JLabel(I18nManager.getText("dialog.about.credits.icons") + " : "),
145                         0, 2);
146                 addToGridBagPanel(creditsPanel, gridBag, constraints,
147                         new JLabel("Eclipse"),
148                         1, 2);
149                 addToGridBagPanel(creditsPanel, gridBag, constraints,
150                         new JLabel(I18nManager.getText("dialog.about.credits.translations") + " : "),
151                         0, 3);
152                 addToGridBagPanel(creditsPanel, gridBag, constraints,
153                         new JLabel("Open Office, Gpsdrive, Babelfish, Leo"),
154                         1, 3);
155                 addToGridBagPanel(creditsPanel, gridBag, constraints,
156                         new JLabel(I18nManager.getText("dialog.about.credits.devtools") + " : "),
157                         0, 4);
158                 addToGridBagPanel(creditsPanel, gridBag, constraints,
159                         new JLabel("Mandriva Linux, Sun Java, Eclipse, Svn, Gimp"),
160                         1, 4);
161                 addToGridBagPanel(creditsPanel, gridBag, constraints,
162                         new JLabel(I18nManager.getText("dialog.about.credits.othertools") + " : "),
163                         0, 5);
164                 addToGridBagPanel(creditsPanel, gridBag, constraints,
165                         new JLabel("Garble, Kate, Povray, Inkscape, Google Earth"),
166                         1, 5);
167                 addToGridBagPanel(creditsPanel, gridBag, constraints,
168                         new JLabel(I18nManager.getText("dialog.about.credits.thanks") + " : "),
169                         0, 6);
170                 addToGridBagPanel(creditsPanel, gridBag, constraints,
171                         new JLabel("Friends and loved ones, for encouragement and support"),
172                         1, 6);
173                 tabPane.add(I18nManager.getText("dialog.about.credits"), creditsPanel);
174
175                 // OK button at the bottom
176                 JPanel okPanel = new JPanel();
177                 okPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
178                 _okButton = new JButton(I18nManager.getText("button.ok"));
179                 _okButton.addActionListener(new ActionListener()
180                 {
181                         public void actionPerformed(ActionEvent e)
182                         {
183                                 dispose();
184                         }
185                 });
186                 _okButton.addKeyListener(new KeyListener() {
187                         public void keyPressed(KeyEvent e)
188                         {
189                                 if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {dispose();}
190                         }
191                         public void keyTyped(KeyEvent e) {}
192                         public void keyReleased(KeyEvent e) {}
193                 });
194                 okPanel.add(_okButton);
195                 mainPanel.add(okPanel, BorderLayout.SOUTH);
196                 return mainPanel;
197         }
198
199         /**
200          * Helper function to reduce complexity of gui making code
201          * when adding labels to a GridBagLayout
202          * @param inPanel panel to add to
203          * @param inLayout GridBagLayout object
204          * @param inConstraints GridBagConstraints object
205          * @param inLabel label to add
206          * @param inX grid x
207          * @param inY grid y
208          */
209         private static void addToGridBagPanel(JPanel inPanel, GridBagLayout inLayout, GridBagConstraints inConstraints,
210                 JLabel inLabel, int inX, int inY)
211         {
212                 // set x and y in constraints
213                 inConstraints.gridx = inX;
214                 inConstraints.gridy = inY;
215                 // set anchor
216                 inConstraints.anchor = (inX == 0?GridBagConstraints.EAST:GridBagConstraints.WEST);
217                 // set constraints to label
218                 inLayout.setConstraints(inLabel, inConstraints);
219                 // add label to panel
220                 inPanel.add(inLabel);
221         }
222
223
224         /**
225          * Show window
226          */
227         public void show()
228         {
229                 pack();
230                 // setSize(300,200);
231                 super.show();
232                 _okButton.requestFocus();
233         }
234 }