From ca2966f735416b62b1906edb22e68bad3963dc5e Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Tue, 7 Feb 2017 14:56:47 +0100 Subject: Display changelog in installer --- src/installer/lombok/installer/InstallerGUI.java | 164 ++++++++++++++++++----- 1 file changed, 132 insertions(+), 32 deletions(-) (limited to 'src/installer') diff --git a/src/installer/lombok/installer/InstallerGUI.java b/src/installer/lombok/installer/InstallerGUI.java index ebdf2035..7a94d595 100644 --- a/src/installer/lombok/installer/InstallerGUI.java +++ b/src/installer/lombok/installer/InstallerGUI.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2016 The Project Lombok Authors. + * Copyright (C) 2009-2017 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,6 +39,8 @@ import java.awt.event.ActionListener; import java.awt.font.TextAttribute; import java.io.File; import java.io.FilenameFilter; +import java.io.InputStream; +import java.io.InputStreamReader; import java.net.URI; import java.util.ArrayList; import java.util.Collections; @@ -65,6 +67,8 @@ import javax.swing.JScrollPane; import javax.swing.Scrollable; import javax.swing.SwingUtilities; import javax.swing.filechooser.FileFilter; +import javax.swing.plaf.basic.BasicHTML; +import javax.swing.text.View; import lombok.core.Version; import lombok.installer.OsUtils.OS; @@ -85,6 +89,7 @@ public class InstallerGUI { private Component ideArea; private Component uninstallArea; private Component howIWorkArea; + private Component successArea; private Box uninstallBox; private JHyperLink uninstallButton; @@ -113,6 +118,8 @@ public class InstallerGUI { uninstallArea.setVisible(false); howIWorkArea = buildHowIWorkArea(); howIWorkArea.setVisible(false); + successArea = buildSuccessArea(); + successArea.setVisible(false); buildChrome(appWindow.getContentPane()); appWindow.pack(); } catch (Throwable t) { @@ -153,6 +160,7 @@ public class InstallerGUI { howIWorkArea.setVisible(false); javacArea.setVisible(true); ideArea.setVisible(true); + successArea.setVisible(false); appWindow.pack(); } }); @@ -160,9 +168,76 @@ public class InstallerGUI { constraints.gridy = 2; container.add(buttonBar, constraints); + container.setPreferredSize(new Dimension(462, 415)); return container; } + private void showSuccess(String installSpecific) { + successExplanation.setText(SUCCESS_EXPLANATION.replace("%%%", installSpecific)); + howIWorkArea.setVisible(false); + javacArea.setVisible(false); + ideArea.setVisible(false); + successArea.setVisible(true); + appWindow.pack(); + } + + private JLabel successExplanation; + + private Component buildSuccessArea() { + JPanel container = new JPanel(); + + container.setLayout(new GridBagLayout()); + GridBagConstraints constraints = new GridBagConstraints(); + constraints.anchor = GridBagConstraints.WEST; + + container.add(new JLabel(SUCCESS_TITLE), constraints); + + constraints.gridy = 1; + constraints.insets = new Insets(8, 0, 0, 16); + container.add(successExplanation = new JLabel(SUCCESS_EXPLANATION), constraints); + + constraints.gridy++; + constraints.fill = GridBagConstraints.BOTH; + + JLabel notes = new JLabel(); + notes.setText(readChangeLog()); + + JScrollPane scroller = new JScrollPane(notes); + container.add(scroller, constraints); + scroller.setPreferredSize(new Dimension(380, 240)); + + View view = (View) notes.getClientProperty(BasicHTML.propertyKey); + view.setSize(380, 0.0f); + float w = view.getPreferredSpan(View.X_AXIS); + float h = view.getPreferredSpan(View.Y_AXIS); + notes.setSize((int) w, (int) h); + + container.setPreferredSize(new Dimension(462, 415)); + return container; + } + + private String readChangeLog() { + InputStream in = Installer.class.getResourceAsStream("/latestchanges.html"); + try { + char[] buff = new char[8192]; + StringBuilder contents = new StringBuilder(); + InputStreamReader reader = new InputStreamReader(in, "UTF-8"); + while (true) { + int read = reader.read(buff); + if (read == -1) break; + contents.append(buff, 0, read); + } + return "" + contents + ""; + } catch (Exception e) { + return "No Changelog available"; + } + finally { + try { + in.close(); + } catch (Exception ignore){ /**/} + } + } + private Component buildUninstallArea() { JPanel container = new JPanel(); @@ -210,6 +285,7 @@ public class InstallerGUI { constraints.gridy = 4; container.add(buttonBar, constraints); + container.setPreferredSize(new Dimension(462, 415)); return container; } @@ -232,6 +308,7 @@ public class InstallerGUI { constraints.gridy = 2; container.add(example, constraints); + container.setPreferredSize(new Dimension(462, 105)); return container; } @@ -419,7 +496,7 @@ public class InstallerGUI { uninstallPlaceholder.setVisible(false); container.add(uninstallPlaceholder, constraints); - + container.setPreferredSize(new Dimension(462, 296)); return container; } @@ -427,6 +504,7 @@ public class InstallerGUI { javacArea.setVisible(false); ideArea.setVisible(false); howIWorkArea.setVisible(true); + successArea.setVisible(false); appWindow.pack(); } @@ -453,6 +531,7 @@ public class InstallerGUI { spinner.setOpaque(true); spinner.setLayout(new FlowLayout()); spinner.add(new JLabel(new ImageIcon(Installer.class.getResource("loading.gif")))); + final Container appWindowContent = appWindow.getContentPane(); appWindow.setContentPane(spinner); final AtomicInteger successes = new AtomicInteger(); @@ -500,20 +579,13 @@ public class InstallerGUI { try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { + appWindow.setContentPane(appWindowContent); + appWindow.pack(); StringBuilder installSpecific = new StringBuilder(); for (String installSpecificMessage : installSpecificMessages) { installSpecific.append("
").append(installSpecificMessage); } - JOptionPane.showMessageDialog(appWindow, - "Lombok has been installed on the selected IDE installations.
" + - "Don't forget to add lombok.jar to your projects, and restart your IDE!" + installSpecific.toString() + "", - "Install successful", - JOptionPane.INFORMATION_MESSAGE); - appWindow.setVisible(false); - synchronized (exitMarker) { - exitMarker.set(0); - exitMarker.notifyAll(); - } + showSuccess(installSpecific.toString()); } }); } catch (Exception e) { @@ -711,6 +783,8 @@ public class InstallerGUI { appWindowContainer.add(howIWorkArea, constraints); + appWindowContainer.add(successArea, constraints); + constraints.gridy++; constraints.gridwidth = 2; constraints.gridx = 0; @@ -719,9 +793,33 @@ public class InstallerGUI { constraints.ipadx = 0; constraints.ipady = 0; constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.anchor = GridBagConstraints.SOUTHEAST; + constraints.anchor = GridBagConstraints.SOUTHWEST; constraints.insets = new Insets(0, 16, 8, 8); + + appWindow.add(buildButtonBar(), constraints); + } + + private Box buildButtonBar() { Box buttonBar = Box.createHorizontalBox(); + + JHyperLink aboutLink = new JHyperLink(Installer.ABOUT_LOMBOK_URL.toString()); + aboutLink.addActionListener(openBrowser(aboutLink, Installer.ABOUT_LOMBOK_URL)); + buttonBar.add(aboutLink); + + buttonBar.add(Box.createRigidArea(new Dimension(16, 1))); + + JLabel versionLabel = new JLabel(); + versionLabel.setText("v" + Version.getVersion()); + + buttonBar.add(versionLabel); + buttonBar.add(Box.createRigidArea(new Dimension(16, 1))); + + JHyperLink changelogLink = new JHyperLink("View full changelog"); + changelogLink.addActionListener(openBrowser(changelogLink, Installer.ABOUT_LOMBOK_URL.resolve("/changelog.html"))); + buttonBar.add(changelogLink); + + buttonBar.add(Box.createHorizontalGlue()); + JButton quitButton = new JButton("Quit Installer"); quitButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -729,14 +827,18 @@ public class InstallerGUI { System.exit(0); } }); - final JHyperLink hyperlink = new JHyperLink(Installer.ABOUT_LOMBOK_URL.toString()); - hyperlink.addActionListener(new ActionListener() { + buttonBar.add(quitButton); + return buttonBar; + } + + private ActionListener openBrowser(final JHyperLink hyperlink, final URI location) { + return new ActionListener() { @Override public void actionPerformed(ActionEvent event) { hyperlink.setForeground(new Color(85, 145, 90)); try { //java.awt.Desktop doesn't exist in 1.5. Object desktop = Class.forName("java.awt.Desktop").getMethod("getDesktop").invoke(null); - Class.forName("java.awt.Desktop").getMethod("browse", URI.class).invoke(desktop, Installer.ABOUT_LOMBOK_URL); + Class.forName("java.awt.Desktop").getMethod("browse", URI.class).invoke(desktop, location); } catch (Exception e) { Runtime rt = Runtime.getRuntime(); try { @@ -746,34 +848,27 @@ public class InstallerGUI { cmd[0] = "cmd.exe"; cmd[1] = "/C"; cmd[2] = "start"; - cmd[3] = Installer.ABOUT_LOMBOK_URL.toString(); + cmd[3] = location.toString(); rt.exec(cmd); break; case MAC_OS_X: - rt.exec("open " + Installer.ABOUT_LOMBOK_URL.toString()); + rt.exec("open " + location.toString()); break; default: case UNIX: - rt.exec("firefox " + Installer.ABOUT_LOMBOK_URL.toString()); + rt.exec("firefox " + location.toString()); break; } } catch (Exception e2) { JOptionPane.showMessageDialog(appWindow, "Well, this is embarrassing. I don't know how to open a webbrowser.\n" + - "I guess you'll have to open it. Browse to:\n" + Installer.ABOUT_LOMBOK_URL + + "I guess you'll have to open it. Browse to:\n" + location + " for more information about Lombok.", "I'm embarrassed", JOptionPane.INFORMATION_MESSAGE); } } } - }); - buttonBar.add(hyperlink); - buttonBar.add(Box.createRigidArea(new Dimension(16, 1))); - buttonBar.add(new JLabel("v" + Version.getVersion() + "")); - - buttonBar.add(Box.createHorizontalGlue()); - buttonBar.add(quitButton); - appWindow.add(buttonBar, constraints); + }; } /** @@ -791,7 +886,7 @@ public class InstallerGUI { } private static final String IDE_TITLE = - "IDEs"; + "IDEs "; private static final String IDE_EXPLANATION = "Lombok can update your Eclipse or eclipse-based IDE to fully support all Lombok features.
" + @@ -801,7 +896,7 @@ public class InstallerGUI { "Scanning your drives for IDE installations..."; private static final String JAVAC_TITLE = - "Javac       (and tools that invoke javac such as ant and maven)"; + "Javac       (and tools that invoke javac such as ant and maven)"; private static final String JAVAC_EXPLANATION = "Lombok works 'out of the box' with javac.
Just make sure the lombok.jar is in your classpath when you compile."; @@ -810,13 +905,13 @@ public class InstallerGUI { "Example: javac -cp lombok.jar MyCode.java"; private static final String UNINSTALL_TITLE = - "Uninstall"; + "Uninstall "; private static final String UNINSTALL_EXPLANATION = "Uninstall Lombok from the following IDE Installations?"; private static final String HOW_I_WORK_TITLE = - "What this installer does"; + "What this installer does "; private static final String HOW_I_WORK_EXPLANATION = "

Eclipse

    " + @@ -826,6 +921,11 @@ public class InstallerGUI { "On Mac OS X, eclipse.ini is hidden in
    " + "Eclipse.app/Contents/MacOS so that's where I place the jar files."; + private static final String SUCCESS_TITLE = "Install successful "; + private static final String SUCCESS_EXPLANATION = "Lombok has been installed on the selected IDE installations.
    " + + "Don't forget to add lombok.jar to your projects, and exit and start your IDE!%%%"; + + private static class JHyperLink extends JButton { private static final long serialVersionUID = 1L; -- cgit From 3127930afa4866ad5e1b45e700045ad656cd2d9e Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Thu, 9 Feb 2017 22:52:25 +0100 Subject: Make it possible to copy from the release notes --- src/installer/lombok/installer/InstallerGUI.java | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/installer') diff --git a/src/installer/lombok/installer/InstallerGUI.java b/src/installer/lombok/installer/InstallerGUI.java index 7a94d595..5c0efcb4 100644 --- a/src/installer/lombok/installer/InstallerGUI.java +++ b/src/installer/lombok/installer/InstallerGUI.java @@ -64,11 +64,12 @@ import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JTextPane; import javax.swing.Scrollable; import javax.swing.SwingUtilities; +import javax.swing.UIManager; import javax.swing.filechooser.FileFilter; -import javax.swing.plaf.basic.BasicHTML; -import javax.swing.text.View; +import javax.swing.text.html.HTMLDocument; import lombok.core.Version; import lombok.installer.OsUtils.OS; @@ -199,19 +200,23 @@ public class InstallerGUI { constraints.gridy++; constraints.fill = GridBagConstraints.BOTH; - JLabel notes = new JLabel(); + JTextPane notes = new JTextPane(); + notes.setContentType("text/html"); notes.setText(readChangeLog()); + notes.setEditable(false); + notes.setOpaque(false); + notes.setBorder(null); + notes.setSelectionStart(0); + notes.setSelectionEnd(0); + + Font font = UIManager.getFont("Label.font"); + String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "pt; }"; + ((HTMLDocument)notes.getDocument()).getStyleSheet().addRule(bodyRule); JScrollPane scroller = new JScrollPane(notes); container.add(scroller, constraints); scroller.setPreferredSize(new Dimension(380, 240)); - View view = (View) notes.getClientProperty(BasicHTML.propertyKey); - view.setSize(380, 0.0f); - float w = view.getPreferredSpan(View.X_AXIS); - float h = view.getPreferredSpan(View.Y_AXIS); - notes.setSize((int) w, (int) h); - container.setPreferredSize(new Dimension(462, 415)); return container; } -- cgit From 4ea6857c7f14babe1c7130a7418f943186979885 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 9 Feb 2017 23:23:29 +0100 Subject: made the installer a little wider; this also fixes bizarre layouting for macosx. --- src/installer/lombok/installer/InstallerGUI.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/installer') diff --git a/src/installer/lombok/installer/InstallerGUI.java b/src/installer/lombok/installer/InstallerGUI.java index 5c0efcb4..ff89df89 100644 --- a/src/installer/lombok/installer/InstallerGUI.java +++ b/src/installer/lombok/installer/InstallerGUI.java @@ -80,6 +80,7 @@ import lombok.installer.OsUtils.OS; * Also offers info on what this installer does in case people want to instrument their IDE manually. */ public class InstallerGUI { + private static final int INSTALLER_WINDOW_WIDTH = 662; static final AtomicReference exitMarker = new AtomicReference(); private JFrame appWindow; @@ -169,7 +170,7 @@ public class InstallerGUI { constraints.gridy = 2; container.add(buttonBar, constraints); - container.setPreferredSize(new Dimension(462, 415)); + container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415)); return container; } @@ -215,9 +216,9 @@ public class InstallerGUI { JScrollPane scroller = new JScrollPane(notes); container.add(scroller, constraints); - scroller.setPreferredSize(new Dimension(380, 240)); + scroller.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 240)); - container.setPreferredSize(new Dimension(462, 415)); + container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415)); return container; } @@ -290,7 +291,7 @@ public class InstallerGUI { constraints.gridy = 4; container.add(buttonBar, constraints); - container.setPreferredSize(new Dimension(462, 415)); + container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415)); return container; } @@ -313,7 +314,7 @@ public class InstallerGUI { constraints.gridy = 2; container.add(example, constraints); - container.setPreferredSize(new Dimension(462, 105)); + container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 105)); return container; } @@ -501,7 +502,7 @@ public class InstallerGUI { uninstallPlaceholder.setVisible(false); container.add(uninstallPlaceholder, constraints); - container.setPreferredSize(new Dimension(462, 296)); + container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 296)); return container; } -- cgit From ad4bd36274d2bfe8dcf74977d921a114739386b1 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 13 Feb 2017 21:47:48 +0100 Subject: Now searches through any subdir of any dir containing the string ‘eclipse’ (or STS or whatnot), to any depth, instead of requiring each subdir to be searched to again contain ‘eclipse’ or some variant thereof. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mac installer installs to /Applications/eclipse/java-neon, for example, by default, so it wasn’t being found. --- .../lombok/installer/eclipse/EclipseProductLocationProvider.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/installer') diff --git a/src/installer/lombok/installer/eclipse/EclipseProductLocationProvider.java b/src/installer/lombok/installer/eclipse/EclipseProductLocationProvider.java index 3710d7d9..b807f02b 100644 --- a/src/installer/lombok/installer/eclipse/EclipseProductLocationProvider.java +++ b/src/installer/lombok/installer/eclipse/EclipseProductLocationProvider.java @@ -288,10 +288,10 @@ public class EclipseProductLocationProvider implements IdeLocationProvider { abstract String findEclipseOnPlatform(File dir); void recurseDirectory(List locations, List problems, File dir) { - recurseDirectory0(locations, problems, dir, 0); + recurseDirectory0(locations, problems, dir, 0, false); } - private void recurseDirectory0(List locations, List problems, File f, int loopCounter) { + private void recurseDirectory0(List locations, List problems, File f, int loopCounter, boolean nameFound) { //Various try/catch/ignore statements are in this for loop. Weird conditions on the disk can cause exceptions, //such as an unformatted drive causing a NullPointerException on listFiles. Best action is almost invariably to just //continue onwards. @@ -301,9 +301,9 @@ public class EclipseProductLocationProvider implements IdeLocationProvider { for (File dir : listFiles) { if (!dir.isDirectory()) continue; try { - if (dir.getName().toLowerCase().contains(descriptor.getDirectoryName())) { + if (nameFound || dir.getName().toLowerCase().contains(descriptor.getDirectoryName())) { findEclipse(locations, problems, dir); - if (loopCounter < 50) recurseDirectory0(locations, problems, dir, loopCounter + 1); + if (loopCounter < 50) recurseDirectory0(locations, problems, dir, loopCounter + 1, true); } } catch (Exception ignore) {} } -- cgit From 627e9dc8a7f381ace59f91c9ee4a023733d4717e Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 13 Feb 2017 21:48:40 +0100 Subject: Updated the text to also mention rebuilding projects. Also fixed various size issues with swing’s… peculiar layouting mechanism. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/installer/lombok/installer/InstallerGUI.java | 28 ++++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/installer') diff --git a/src/installer/lombok/installer/InstallerGUI.java b/src/installer/lombok/installer/InstallerGUI.java index ff89df89..b96fec9c 100644 --- a/src/installer/lombok/installer/InstallerGUI.java +++ b/src/installer/lombok/installer/InstallerGUI.java @@ -192,11 +192,15 @@ public class InstallerGUI { GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; - container.add(new JLabel(SUCCESS_TITLE), constraints); + JLabel title; + container.add(title = new JLabel(SUCCESS_TITLE), constraints); + title.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 20)); constraints.gridy = 1; constraints.insets = new Insets(8, 0, 0, 16); container.add(successExplanation = new JLabel(SUCCESS_EXPLANATION), constraints); + successExplanation.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 175)); + successExplanation.setMinimumSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 175)); constraints.gridy++; constraints.fill = GridBagConstraints.BOTH; @@ -212,13 +216,13 @@ public class InstallerGUI { Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "pt; }"; - ((HTMLDocument)notes.getDocument()).getStyleSheet().addRule(bodyRule); - + ((HTMLDocument) notes.getDocument()).getStyleSheet().addRule(bodyRule); JScrollPane scroller = new JScrollPane(notes); container.add(scroller, constraints); - scroller.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 240)); - + scroller.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 200)); + scroller.setMinimumSize(new Dimension(INSTALLER_WINDOW_WIDTH - 82, 200)); container.setPreferredSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415)); + container.setMinimumSize(new Dimension(INSTALLER_WINDOW_WIDTH, 415)); return container; } @@ -372,11 +376,11 @@ public class InstallerGUI { if (locations.size() + problems.size() == 0) { JOptionPane.showMessageDialog(appWindow, - "I can't find any IDEs on your computer.\n" + - "If you have IDEs installed on this computer, please use the " + - "'Specify Location...' button to manually point out the \n" + - "location of your IDE installation to me. Thanks!", - "Can't find IDE", JOptionPane.INFORMATION_MESSAGE); + "I can't find any IDEs on your computer.\n" + + "If you have IDEs installed on this computer, please use the " + + "'Specify Location...' button to manually point out the \n" + + "location of your IDE installation to me. Thanks!", + "Can't find IDE", JOptionPane.INFORMATION_MESSAGE); } } }); @@ -929,8 +933,8 @@ public class InstallerGUI { private static final String SUCCESS_TITLE = "Install successful "; private static final String SUCCESS_EXPLANATION = "Lombok has been installed on the selected IDE installations.
    " + - "Don't forget to add lombok.jar to your projects, and exit and start your IDE!%%%"; - + "Don't forget to:
    • add lombok.jar to your projects,
    • exit and start your IDE,
    • rebuild all projects!
    %%%"; + private static class JHyperLink extends JButton { private static final long serialVersionUID = 1L; -- cgit