X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2FAboutScreen.java;h=80a7983418149d97f3cf7fce1e9915cda968dae2;hb=92dad5df664287acb51728e9ea599f150765d34a;hp=0f20ba00778064254a86ddbf2a1d0681f5d1aeb2;hpb=54b9d8bc8f0025ccf97a67d9dd217ef1f9cf082f;p=GpsPrune.git diff --git a/tim/prune/function/AboutScreen.java b/tim/prune/function/AboutScreen.java index 0f20ba0..80a7983 100644 --- a/tim/prune/function/AboutScreen.java +++ b/tim/prune/function/AboutScreen.java @@ -11,7 +11,12 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStream; +import java.util.zip.GZIPInputStream; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -27,7 +32,7 @@ import javax.swing.JTextArea; import tim.prune.App; import tim.prune.ExternalTools; import tim.prune.GenericFunction; -import tim.prune.GpsPruner; +import tim.prune.GpsPrune; import tim.prune.I18nManager; import tim.prune.threedee.WindowFactory; @@ -39,6 +44,7 @@ public class AboutScreen extends GenericFunction private JDialog _dialog = null; private JTabbedPane _tabs = null; private JButton _okButton = null; + private JTextArea _aboutTextArea = null; /** Labels for whether tools installed or not */ private JLabel[] _installedLabels = null; @@ -74,14 +80,14 @@ public class AboutScreen extends GenericFunction JPanel aboutPanel = new JPanel(); aboutPanel.setLayout(new BoxLayout(aboutPanel, BoxLayout.Y_AXIS)); aboutPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - JLabel titleLabel = new JLabel("Prune"); + JLabel titleLabel = new JLabel("GpsPrune"); titleLabel.setFont(new Font("SansSerif", Font.BOLD, 24)); titleLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT); aboutPanel.add(titleLabel); - JLabel versionLabel = new JLabel(I18nManager.getText("dialog.about.version") + ": " + GpsPruner.VERSION_NUMBER); + JLabel versionLabel = new JLabel(I18nManager.getText("dialog.about.version") + ": " + GpsPrune.VERSION_NUMBER); versionLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT); aboutPanel.add(versionLabel); - JLabel buildLabel = new JLabel(I18nManager.getText("dialog.about.build") + ": " + GpsPruner.BUILD_NUMBER); + JLabel buildLabel = new JLabel(I18nManager.getText("dialog.about.build") + ": " + GpsPrune.BUILD_NUMBER); buildLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT); aboutPanel.add(buildLabel); aboutPanel.add(new JLabel(" ")); @@ -90,8 +96,9 @@ public class AboutScreen extends GenericFunction descBuffer.append("

").append(I18nManager.getText("dialog.about.summarytext2")).append("

"); descBuffer.append("

").append(I18nManager.getText("dialog.about.summarytext3")).append("

"); descBuffer.append("

").append(I18nManager.getText("dialog.about.languages")).append(" : ") - .append("deutsch, english, español, français, italiano, polski,
" + - "schwiizerdüütsch, português, bahasa indonesia, română").append("

"); + .append("afrikaans, \u010de\u0161tina, deutsch, english, espa\u00F1ol, fran\u00E7ais, italiano,
" + + " magyar, nederlands, polski, portugu\u00EAs, rom\u00E2n\u0103, suomi, \u0440\u0443\u0441\u0441\u043a\u0438\u0439 (russian),
" + + " \u4e2d\u6587 (chinese), \u65E5\u672C\u8A9E (japanese), \uD55C\uAD6D\uC5B4/\uC870\uC120\uB9D0 (korean), schwiizerd\u00FC\u00FCtsch, ukrainian

"); descBuffer.append("

").append(I18nManager.getText("dialog.about.translatedby")).append("

"); JEditorPane descPane = new JEditorPane("text/html", descBuffer.toString()); descPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); @@ -132,20 +139,18 @@ public class AboutScreen extends GenericFunction 0, 2); addToGridBagPanel(sysInfoPanel, gridBag, constraints, _installedLabels[0], 1, 2); addToGridBagPanel(sysInfoPanel, gridBag, constraints, - new JLabel(I18nManager.getText("dialog.about.systeminfo.povray") + " : "), + new JLabel(I18nManager.getText("dialog.about.systeminfo.exiftool") + " : "), 0, 3); addToGridBagPanel(sysInfoPanel, gridBag, constraints, _installedLabels[1], 1, 3); addToGridBagPanel(sysInfoPanel, gridBag, constraints, - new JLabel(I18nManager.getText("dialog.about.systeminfo.exiftool") + " : "), + new JLabel(I18nManager.getText("dialog.about.systeminfo.gpsbabel") + " : "), 0, 4); addToGridBagPanel(sysInfoPanel, gridBag, constraints, _installedLabels[2], 1, 4); addToGridBagPanel(sysInfoPanel, gridBag, constraints, - new JLabel(I18nManager.getText("dialog.about.systeminfo.gpsbabel") + " : "), + new JLabel(I18nManager.getText("dialog.about.systeminfo.gnuplot") + " : "), 0, 5); addToGridBagPanel(sysInfoPanel, gridBag, constraints, _installedLabels[3], 1, 5); - addToGridBagPanel(sysInfoPanel, gridBag, constraints, - new JLabel(I18nManager.getText("dialog.about.systeminfo.gnuplot") + " : "), - 0, 6); + addToGridBagPanel(sysInfoPanel, gridBag, constraints, new JLabel("Xerces : "), 0, 6); addToGridBagPanel(sysInfoPanel, gridBag, constraints, _installedLabels[4], 1, 6); _tabs.add(I18nManager.getText("dialog.about.systeminfo"), sysInfoPanel); @@ -155,6 +160,7 @@ public class AboutScreen extends GenericFunction creditsPanel.setLayout(gridBag); constraints = new GridBagConstraints(); constraints.weightx = 0.0; constraints.weighty = 0.0; + constraints.ipady = 3; addToGridBagPanel(creditsPanel, gridBag, constraints, new JLabel(I18nManager.getText("dialog.about.credits.code") + " : "), @@ -178,44 +184,59 @@ public class AboutScreen extends GenericFunction new JLabel(I18nManager.getText("dialog.about.credits.translators") + " : "), 0, 3); addToGridBagPanel(creditsPanel, gridBag, constraints, - new JLabel("Ramon, Miguel, Inés, Piotr, Petrovsk, Josatoc, Weehal,"), + new JLabel("Ramon, Miguel, In\u00E9s, Piotr, Petrovsk, Josatoc, Weehal,"), 1, 3); addToGridBagPanel(creditsPanel, gridBag, constraints, - new JLabel(" theYinYeti, Rothermographer"), + new JLabel(" theYinYeti, Rothermographer, Sam, Rudolph, nazotoko,"), 1, 4); + addToGridBagPanel(creditsPanel, gridBag, constraints, + new JLabel(" katpatuka, R\u00E9mi, Marcus, Ali, Javier, Jeroen, prot_d,"), + 1, 5); + addToGridBagPanel(creditsPanel, gridBag, constraints, + new JLabel(" Gy\u00F6rgy, HooAU, Sergey, P\u00E9ter, serhijdubyk, Peter, Cristian,"), + 1, 6); + addToGridBagPanel(creditsPanel, gridBag, constraints, + new JLabel(" Roman, Erkki"), + 1, 7); addToGridBagPanel(creditsPanel, gridBag, constraints, new JLabel(I18nManager.getText("dialog.about.credits.translations") + " : "), - 0, 5); + 0, 8); addToGridBagPanel(creditsPanel, gridBag, constraints, new JLabel("Open Office, Gpsdrive, Babelfish, Leo, Launchpad"), - 1, 5); + 1, 8); addToGridBagPanel(creditsPanel, gridBag, constraints, new JLabel(I18nManager.getText("dialog.about.credits.devtools") + " : "), - 0, 6); + 0, 9); addToGridBagPanel(creditsPanel, gridBag, constraints, - new JLabel("Mandriva Linux, Sun Java, Eclipse, Svn, Gimp"), - 1, 6); + new JLabel("Debian Linux, Sun Java, OpenJDK, Eclipse, Svn, Gimp, Inkscape"), + 1, 9); addToGridBagPanel(creditsPanel, gridBag, constraints, new JLabel(I18nManager.getText("dialog.about.credits.othertools") + " : "), - 0, 7); + 0, 10); addToGridBagPanel(creditsPanel, gridBag, constraints, - new JLabel("Kate, Povray, Exiftool, Inkscape, Google Earth, Gpsbabel, Gnuplot"), - 1, 7); + new JLabel("Openstreetmap, Povray, Exiftool, Gpsbabel, Gnuplot"), + 1, 10); addToGridBagPanel(creditsPanel, gridBag, constraints, new JLabel(I18nManager.getText("dialog.about.credits.thanks") + " : "), - 0, 8); + 0, 11); addToGridBagPanel(creditsPanel, gridBag, constraints, new JLabel("Friends and loved ones, for encouragement and support"), - 1, 8); + 1, 11); _tabs.add(I18nManager.getText("dialog.about.credits"), creditsPanel); // Read me JPanel readmePanel = new JPanel(); readmePanel.setLayout(new BorderLayout()); - JTextArea textArea = new JTextArea(getReadmeText()); - textArea.setEditable(false); - textArea.setLineWrap(true); textArea.setWrapStyleWord(true); - JScrollPane scrollPane = new JScrollPane(textArea); + _aboutTextArea = new JTextArea(I18nManager.getText("details.photo.loading")); + // Set readme text in separate thread so that about screen pops up sooner + new Thread(new Runnable() { + public void run() { + _aboutTextArea.setText(getReadmeText()); + } + }).start(); + _aboutTextArea.setEditable(false); + _aboutTextArea.setLineWrap(true); _aboutTextArea.setWrapStyleWord(true); + JScrollPane scrollPane = new JScrollPane(_aboutTextArea); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setPreferredSize(new Dimension(600, 130)); readmePanel.add(scrollPane, BorderLayout.CENTER); @@ -246,7 +267,7 @@ public class AboutScreen extends GenericFunction } /** - * Helper function to reduce complexity of gui making code + * Helper function to reduce complexity of gui-making code * when adding labels to a GridBagLayout * @param inPanel panel to add to * @param inLayout GridBagLayout object @@ -255,8 +276,8 @@ public class AboutScreen extends GenericFunction * @param inX grid x * @param inY grid y */ - private static void addToGridBagPanel(JPanel inPanel, GridBagLayout inLayout, GridBagConstraints inConstraints, - JLabel inLabel, int inX, int inY) + private static void addToGridBagPanel(JPanel inPanel, GridBagLayout inLayout, + GridBagConstraints inConstraints, JLabel inLabel, int inX, int inY) { // set x and y in constraints inConstraints.gridx = inX; @@ -274,18 +295,60 @@ public class AboutScreen extends GenericFunction */ private String getReadmeText() { + // First, try locally-held readme.txt if available (as it normally should be) + // Readme file can either be in file system or packed in the same jar as code + String errorMessage = null; + String readme = null; + InputStream in = null; try { // For some reason using ../readme.txt doesn't work, so need absolute path - InputStream in = AboutScreen.class.getResourceAsStream("/tim/prune/readme.txt"); + in = AboutScreen.class.getResourceAsStream("/tim/prune/readme.txt"); if (in != null) { byte[] buffer = new byte[in.available()]; in.read(buffer); - return new String(buffer); + in.close(); + readme = new String(buffer); + } + } + catch (IOException e) { + errorMessage = e.getMessage(); + } + finally { + try {in.close();} catch (Exception e) {} + } + if (readme != null) {return readme;} + + // Locally-held file failed, so try to find gz file installed on system (eg Debian) + try + { + File gzFile = new File("/usr/share/doc/gpsprune/readme.txt.gz"); + if (gzFile.exists()) + { + // Copy decompressed bytes from gz file into out + in = new GZIPInputStream(new FileInputStream(gzFile)); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + byte[] buffer = new byte[8 * 1024]; + int count = 0; + do { + out.write(buffer, 0, count); + count = in.read(buffer, 0, buffer.length); + } while (count != -1); + out.close(); + in.close(); + readme = out.toString(); } } - catch (java.io.IOException e) { - System.err.println("Exception trying to get readme : " + e.getMessage()); + catch (IOException e) { + System.err.println("Exception trying to get readme.gz : " + e.getMessage()); + } + finally { + try {in.close();} catch (Exception e) {} + } + if (readme != null) {return readme;} + // Only show first error message if couldn't get readme from gz either + if (errorMessage != null) { + System.err.println("Exception trying to get readme: " + errorMessage); } return I18nManager.getText("error.readme.notfound"); } @@ -315,9 +378,10 @@ public class AboutScreen extends GenericFunction String yesText = I18nManager.getText("dialog.about.yes"); String noText = I18nManager.getText("dialog.about.no"); _installedLabels[0].setText(WindowFactory.isJava3dEnabled()?yesText:noText); - _installedLabels[1].setText(ExternalTools.isPovrayInstalled()?yesText:noText); - _installedLabels[2].setText(ExternalTools.isExiftoolInstalled()?yesText:noText); - _installedLabels[3].setText(ExternalTools.isGpsbabelInstalled()?yesText:noText); - _installedLabels[4].setText(ExternalTools.isGnuplotInstalled()?yesText:noText); + final int[] tools = {ExternalTools.TOOL_EXIFTOOL, ExternalTools.TOOL_GPSBABEL, + ExternalTools.TOOL_GNUPLOT, ExternalTools.TOOL_XERCES}; + for (int i=0; i