aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/installer
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-10-16 09:32:36 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-10-16 09:32:36 +0200
commitb5c8b725655d2ad8a715cfb1fbbdf25dbdcd4ceb (patch)
tree571d13cd7028a6b7d1ebfe84180a4328a20c42d7 /src/lombok/installer
parent8629a651a66aa5fba9e0ada7df00803528b0e34f (diff)
downloadlombok-b5c8b725655d2ad8a715cfb1fbbdf25dbdcd4ceb.tar.gz
lombok-b5c8b725655d2ad8a715cfb1fbbdf25dbdcd4ceb.tar.bz2
lombok-b5c8b725655d2ad8a715cfb1fbbdf25dbdcd4ceb.zip
Fixed issue #24 by refactoring the AST.Node class - taken it out, and in the process fixed a lot of type annoyance by adding more generics.
Also changed coding style from for/while/if/switch/catch/do ( expr ) {} to for (expr) {}, hence the changes _everywhere_.
Diffstat (limited to 'src/lombok/installer')
-rw-r--r--src/lombok/installer/AppleNativeLook.java2
-rw-r--r--src/lombok/installer/EclipseFinder.java68
-rw-r--r--src/lombok/installer/EclipseLocation.java102
-rw-r--r--src/lombok/installer/Installer.java90
-rw-r--r--src/lombok/installer/WindowsDriveInfo.java10
5 files changed, 136 insertions, 136 deletions
diff --git a/src/lombok/installer/AppleNativeLook.java b/src/lombok/installer/AppleNativeLook.java
index b2c90555..6e64032e 100644
--- a/src/lombok/installer/AppleNativeLook.java
+++ b/src/lombok/installer/AppleNativeLook.java
@@ -36,7 +36,7 @@ class AppleNativeLook {
Object app = appClass.getMethod("getApplication").invoke(null);
appClass.getMethod("removeAboutMenuItem").invoke(app);
appClass.getMethod("removePreferencesMenuItem").invoke(app);
-
+
BufferedImage image = ImageIO.read(AppleNativeLook.class.getResource("lombokIcon.png"));
appClass.getMethod("setDockIconImage", Image.class).invoke(app, image);
}
diff --git a/src/lombok/installer/EclipseFinder.java b/src/lombok/installer/EclipseFinder.java
index b69932e0..57e52065 100644
--- a/src/lombok/installer/EclipseFinder.java
+++ b/src/lombok/installer/EclipseFinder.java
@@ -54,17 +54,17 @@ class EclipseFinder {
URI uri = EclipseFinder.class.getResource("/" + EclipseFinder.class.getName().replace('.', '/') + ".class").toURI();
Pattern p = Pattern.compile("^jar:file:([^\\!]+)\\!.*\\.class$");
Matcher m = p.matcher(uri.toString());
- if ( !m.matches() ) return new File("lombok.jar");
+ if (!m.matches()) return new File("lombok.jar");
String rawUri = m.group(1);
return new File(URLDecoder.decode(rawUri, Charset.defaultCharset().name()));
- } catch ( Exception e ) {
+ } catch (Exception e) {
throw Lombok.sneakyThrow(e);
}
}
private static final AtomicBoolean windowsDriveInfoLibLoaded = new AtomicBoolean(false);
private static void loadWindowsDriveInfoLib() throws IOException {
- if ( !windowsDriveInfoLibLoaded.compareAndSet(false, true) ) return;
+ if (!windowsDriveInfoLibLoaded.compareAndSet(false, true)) return;
final String prefix = "lombok-" + Version.getVersion() + "-";
@@ -75,17 +75,17 @@ class EclipseFinder {
dll1.deleteOnExit();
dll2.deleteOnExit();
try {
- if ( unpackDLL("WindowsDriveInfo-i386.dll", dll1) ) {
+ if (unpackDLL("WindowsDriveInfo-i386.dll", dll1)) {
System.load(dll1.getAbsolutePath());
return;
}
- } catch ( Throwable ignore ) {}
+ } catch (Throwable ignore) {}
try {
- if ( unpackDLL("WindowsDriveInfo-x86_64.dll", dll2) ) {
+ if (unpackDLL("WindowsDriveInfo-x86_64.dll", dll2)) {
System.load(dll2.getAbsolutePath());
}
- } catch ( Throwable ignore ) {}
+ } catch (Throwable ignore) {}
}
private static boolean unpackDLL(String dllName, File target) throws IOException {
@@ -95,15 +95,15 @@ class EclipseFinder {
FileOutputStream out = new FileOutputStream(target);
try {
byte[] b = new byte[32000];
- while ( true ) {
+ while (true) {
int r = in.read(b);
- if ( r == -1 ) break;
+ if (r == -1) break;
out.write(b, 0, r);
}
} finally {
out.close();
}
- } catch ( IOException e ) {
+ } catch (IOException e) {
//Fall through - if there is a file named lombok-WindowsDriveInfo-arch.dll, we'll try it.
return target.exists() && target.canRead();
}
@@ -125,8 +125,8 @@ class EclipseFinder {
List<String> drives = new ArrayList<String>();
WindowsDriveInfo info = new WindowsDriveInfo();
- for ( String drive : info.getLogicalDrives() ) {
- if ( info.isFixedDisk(drive) ) drives.add(drive);
+ for (String drive : info.getLogicalDrives()) {
+ if (info.isFixedDisk(drive)) drives.add(drive);
}
return drives;
@@ -149,24 +149,24 @@ class EclipseFinder {
List<String> driveLetters = asList("C");
try {
driveLetters = getDrivesOnWindows();
- } catch ( Throwable ignore ) {
+ } catch (Throwable ignore) {
ignore.printStackTrace();
}
- for ( String letter : driveLetters ) {
+ for (String letter : driveLetters) {
File f = new File(letter + ":\\");
- for ( File dir : f.listFiles() ) {
- if ( !dir.isDirectory() ) continue;
- if ( dir.getName().toLowerCase().contains("eclipse") ) {
+ for (File dir : f.listFiles()) {
+ if (!dir.isDirectory()) continue;
+ if (dir.getName().toLowerCase().contains("eclipse")) {
String eclipseLocation = findEclipseOnWindows1(dir);
- if ( eclipseLocation != null ) eclipses.add(eclipseLocation);
+ if (eclipseLocation != null) eclipses.add(eclipseLocation);
}
- if ( dir.getName().toLowerCase().contains("program files") ) {
- for ( File dir2 : dir.listFiles() ) {
- if ( !dir2.isDirectory() ) continue;
- if ( dir.getName().toLowerCase().contains("eclipse") ) {
+ if (dir.getName().toLowerCase().contains("program files")) {
+ for (File dir2 : dir.listFiles()) {
+ if (!dir2.isDirectory()) continue;
+ if (dir.getName().toLowerCase().contains("eclipse")) {
String eclipseLocation = findEclipseOnWindows1(dir);
- if ( eclipseLocation != null ) eclipses.add(eclipseLocation);
+ if (eclipseLocation != null) eclipses.add(eclipseLocation);
}
}
}
@@ -178,7 +178,7 @@ class EclipseFinder {
/** Checks if the provided directory contains 'eclipse.exe', and if so, returns the directory, otherwise null. */
private static String findEclipseOnWindows1(File dir) {
- if ( new File(dir, "eclipse.exe").isFile() ) return dir.getAbsolutePath();
+ if (new File(dir, "eclipse.exe").isFile()) return dir.getAbsolutePath();
return null;
}
@@ -189,7 +189,7 @@ class EclipseFinder {
* @return List of directories that contain the Eclipse executable.
*/
static List<String> findEclipses() {
- switch ( getOS() ) {
+ switch (getOS()) {
case WINDOWS:
return findEclipseOnWindows();
case MAC_OS_X:
@@ -206,9 +206,9 @@ class EclipseFinder {
static OS getOS() {
String prop = System.getProperty("os.name", "").toLowerCase();
- if ( prop.matches("^.*\\bmac\\b.*$") ) return OS.MAC_OS_X;
- if ( prop.matches("^.*\\bdarwin\\b.*$") ) return OS.MAC_OS_X;
- if ( prop.matches("^.*\\bwin(dows)\\b.*$") ) return OS.WINDOWS;
+ if (prop.matches("^.*\\bmac\\b.*$")) return OS.MAC_OS_X;
+ if (prop.matches("^.*\\bdarwin\\b.*$")) return OS.MAC_OS_X;
+ if (prop.matches("^.*\\bwin(dows)\\b.*$")) return OS.WINDOWS;
return OS.UNIX;
}
@@ -219,7 +219,7 @@ class EclipseFinder {
* @return 'Eclipse.app' on OS X, 'eclipse.exe' on Windows, and 'eclipse' on other OSes.
*/
static String getEclipseExecutableName() {
- switch ( getOS() ) {
+ switch (getOS()) {
case WINDOWS:
return "eclipse.exe";
case MAC_OS_X:
@@ -235,15 +235,15 @@ class EclipseFinder {
*/
static List<String> findEclipseOnMac() {
List<String> eclipses = new ArrayList<String>();
- for ( File dir : new File("/Applications").listFiles() ) {
- if ( !dir.isDirectory() ) continue;
- if ( dir.getName().toLowerCase().equals("eclipse.app") ) {
+ for (File dir : new File("/Applications").listFiles()) {
+ if (!dir.isDirectory()) continue;
+ if (dir.getName().toLowerCase().equals("eclipse.app")) {
//This would be kind of an unorthodox Eclipse installation, but if Eclipse ever
//moves to this more maclike installation concept, our installer can still handle it.
eclipses.add("/Applications");
}
- if ( dir.getName().toLowerCase().contains("eclipse") ) {
- if ( new File(dir, "Eclipse.app").exists() ) eclipses.add(dir.toString());
+ if (dir.getName().toLowerCase().contains("eclipse")) {
+ if (new File(dir, "Eclipse.app").exists()) eclipses.add(dir.toString());
}
}
return eclipses;
diff --git a/src/lombok/installer/EclipseLocation.java b/src/lombok/installer/EclipseLocation.java
index 2b7e021d..85ed0f79 100644
--- a/src/lombok/installer/EclipseLocation.java
+++ b/src/lombok/installer/EclipseLocation.java
@@ -48,8 +48,8 @@ final class EclipseLocation {
static {
String os = System.getProperty("os.name", "");
- if ( "Mac OS".equals(os) ) OS_NEWLINE = "\r";
- else if ( os.toLowerCase().contains("windows") ) OS_NEWLINE = "\r\n";
+ if ("Mac OS".equals(os)) OS_NEWLINE = "\r";
+ else if (os.toLowerCase().contains("windows")) OS_NEWLINE = "\r\n";
else OS_NEWLINE = "\n";
}
@@ -84,28 +84,28 @@ final class EclipseLocation {
* @throws NotAnEclipseException If this isn't an Eclipse executable or a directory with an Eclipse executable.
*/
EclipseLocation(String path) throws NotAnEclipseException {
- if ( path == null ) throw new NullPointerException("path");
+ if (path == null) throw new NullPointerException("path");
File p = new File(path);
- if ( !p.exists() ) throw new NotAnEclipseException("File does not exist: " + path, null);
+ if (!p.exists()) throw new NotAnEclipseException("File does not exist: " + path, null);
final String execName = EclipseFinder.getEclipseExecutableName();
- if ( p.isDirectory() ) {
- for ( File f : p.listFiles() ) {
- if ( f.getName().equalsIgnoreCase(execName) ) {
+ if (p.isDirectory()) {
+ for (File f : p.listFiles()) {
+ if (f.getName().equalsIgnoreCase(execName)) {
p = f;
break;
}
}
}
- if ( !p.exists() || !p.getName().equalsIgnoreCase(execName) ) {
+ if (!p.exists() || !p.getName().equalsIgnoreCase(execName)) {
throw new NotAnEclipseException("This path does not appear to contain an Eclipse installation: " + p, null);
}
this.path = p;
try {
this.hasLombok = checkForLombok();
- } catch ( IOException e ) {
+ } catch (IOException e) {
throw new NotAnEclipseException(
"I can't read the configuration file of the Eclipse installed at " + this.path.getAbsolutePath() + "\n" +
"You may need to run this installer with root privileges if you want to modify that Eclipse.", e);
@@ -117,7 +117,7 @@ final class EclipseLocation {
}
@Override public boolean equals(Object o) {
- if ( !(o instanceof EclipseLocation) ) return false;
+ if (!(o instanceof EclipseLocation)) return false;
return ((EclipseLocation)o).path.equals(path);
}
@@ -146,8 +146,8 @@ final class EclipseLocation {
}
private boolean checkForLombok() throws IOException {
- for ( File targetDir : getTargetDirs() ) {
- if ( checkForLombok0(targetDir) ) return true;
+ for (File targetDir : getTargetDirs()) {
+ if (checkForLombok0(targetDir)) return true;
}
return false;
@@ -161,13 +161,13 @@ final class EclipseLocation {
private boolean checkForLombok0(File dir) throws IOException {
File iniFile = new File(dir, "eclipse.ini");
- if ( !iniFile.exists() ) return false;
+ if (!iniFile.exists()) return false;
FileInputStream fis = new FileInputStream(iniFile);
try {
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
String line;
- while ( (line = br.readLine()) != null ) {
- if ( JAVA_AGENT_LINE_MATCHER.matcher(line.trim()).matches() ) return true;
+ while ((line = br.readLine()) != null) {
+ if (JAVA_AGENT_LINE_MATCHER.matcher(line.trim()).matches()) return true;
}
return false;
@@ -194,10 +194,10 @@ final class EclipseLocation {
* bugs in the uninstall code will probably throw other exceptions; this is intentional.
*/
void uninstall() throws UninstallException {
- for ( File dir : getTargetDirs() ) {
+ for (File dir : getTargetDirs()) {
File lombokJar = new File(dir, "lombok.jar");
- if ( lombokJar.exists() ) {
- if ( !lombokJar.delete() ) throw new UninstallException(
+ if (lombokJar.exists()) {
+ if (!lombokJar.delete()) throw new UninstallException(
"Can't delete " + lombokJar.getAbsolutePath() +
" - perhaps the installer does not have the access rights to do so.",
null);
@@ -206,8 +206,8 @@ final class EclipseLocation {
/* legacy code - lombok at one point used to have a separate jar for the eclipse agent.
* Leave this code in to delete it for those upgrading from an old version. */ {
File agentJar = new File(dir, "lombok.eclipse.agent.jar");
- if ( agentJar.exists() ) {
- if ( !agentJar.delete() ) throw new UninstallException(
+ if (agentJar.exists()) {
+ if (!agentJar.delete()) throw new UninstallException(
"Can't delete " + agentJar.getAbsolutePath() +
" - perhaps the installer does not have the access rights to do so.",
null);
@@ -216,29 +216,29 @@ final class EclipseLocation {
File iniFile = new File(dir, "eclipse.ini");
StringBuilder newContents = new StringBuilder();
- if ( iniFile.exists() ) {
+ if (iniFile.exists()) {
try {
FileInputStream fis = new FileInputStream(iniFile);
try {
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
String line;
- while ( (line = br.readLine()) != null ) {
- if ( JAVA_AGENT_LINE_MATCHER.matcher(line).matches() ) continue;
+ while ((line = br.readLine()) != null) {
+ if (JAVA_AGENT_LINE_MATCHER.matcher(line).matches()) continue;
Matcher m = BOOTCLASSPATH_LINE_MATCHER.matcher(line);
- if ( m.matches() ) {
+ if (m.matches()) {
StringBuilder elemBuilder = new StringBuilder();
elemBuilder.append("-Xbootclasspath/a:");
boolean first = true;
- for ( String elem : m.group(1).split(Pattern.quote(File.pathSeparator)) ) {
- if ( elem.toLowerCase().endsWith("lombok.jar") ) continue;
+ for (String elem : m.group(1).split(Pattern.quote(File.pathSeparator))) {
+ if (elem.toLowerCase().endsWith("lombok.jar")) continue;
/* legacy code -see previous comment that starts with 'legacy' */ {
- if ( elem.toLowerCase().endsWith("lombok.eclipse.agent.jar") ) continue;
+ if (elem.toLowerCase().endsWith("lombok.eclipse.agent.jar")) continue;
}
- if ( first ) first = false;
+ if (first) first = false;
else elemBuilder.append(File.pathSeparator);
elemBuilder.append(elem);
}
- if ( !first ) newContents.append(elemBuilder.toString()).append(OS_NEWLINE);
+ if (!first) newContents.append(elemBuilder.toString()).append(OS_NEWLINE);
continue;
}
@@ -255,7 +255,7 @@ final class EclipseLocation {
} finally {
fos.close();
}
- } catch ( IOException e ) {
+ } catch (IOException e) {
throw new UninstallException("Cannot uninstall lombok from " + path.getAbsolutePath() +
" probably because this installer does not have the access rights to do so.", e);
}
@@ -289,10 +289,10 @@ final class EclipseLocation {
boolean fullPathRequired = EclipseFinder.getOS() == EclipseFinder.OS.UNIX;
boolean installSucceeded = false;
- for ( File dir : getTargetDirs() ) {
+ for (File dir : getTargetDirs()) {
File iniFile = new File(dir, "eclipse.ini");
StringBuilder newContents = new StringBuilder();
- if ( !iniFile.exists() ) failedDirs.add(dir);
+ if (!iniFile.exists()) failedDirs.add(dir);
else {
//If 'installSucceeded' is true here, something very weird is going on, but instrumenting all of them
//is no less bad than aborting, and this situation should be rare to the point of non-existence.
@@ -306,19 +306,19 @@ final class EclipseLocation {
FileOutputStream out = new FileOutputStream(lombokJar);
InputStream in = new FileInputStream(ourJar);
try {
- while ( true ) {
+ while (true) {
int r = in.read(b);
- if ( r == -1 ) break;
+ if (r == -1) break;
out.write(b, 0, r);
}
} finally {
out.close();
}
- } catch ( IOException e ) {
+ } catch (IOException e) {
try {
lombokJar.delete();
- } catch ( Throwable ignore ) {}
- if ( !readSucceeded ) throw new InstallException("I can't read my own jar file. I think you've found a bug in this installer! I suggest you restart it " +
+ } catch (Throwable ignore) {}
+ if (!readSucceeded) throw new InstallException("I can't read my own jar file. I think you've found a bug in this installer! I suggest you restart it " +
"and use the 'what do I do' link, to manually install lombok. And tell us about this. Thanks!", e);
throw new InstallException("I can't write to your Eclipse directory, probably because this installer does not have the access rights.", e);
}
@@ -332,23 +332,23 @@ final class EclipseLocation {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
String line;
- while ( (line = br.readLine()) != null ) {
- if ( JAVA_AGENT_LINE_MATCHER.matcher(line).matches() ) continue;
+ while ((line = br.readLine()) != null) {
+ if (JAVA_AGENT_LINE_MATCHER.matcher(line).matches()) continue;
Matcher m = BOOTCLASSPATH_LINE_MATCHER.matcher(line);
- if ( m.matches() ) {
+ if (m.matches()) {
StringBuilder elemBuilder = new StringBuilder();
elemBuilder.append("-Xbootclasspath/a:");
boolean first = true;
- for ( String elem : m.group(1).split(Pattern.quote(File.pathSeparator)) ) {
- if ( elem.toLowerCase().endsWith("lombok.jar") ) continue;
+ for (String elem : m.group(1).split(Pattern.quote(File.pathSeparator))) {
+ if (elem.toLowerCase().endsWith("lombok.jar")) continue;
/* legacy code -see previous comment that starts with 'legacy' */ {
- if ( elem.toLowerCase().endsWith("lombok.eclipse.agent.jar") ) continue;
+ if (elem.toLowerCase().endsWith("lombok.eclipse.agent.jar")) continue;
}
- if ( first ) first = false;
+ if (first) first = false;
else elemBuilder.append(File.pathSeparator);
elemBuilder.append(elem);
}
- if ( !first ) newContents.append(elemBuilder.toString()).append(OS_NEWLINE);
+ if (!first) newContents.append(elemBuilder.toString()).append(OS_NEWLINE);
continue;
}
@@ -373,27 +373,27 @@ final class EclipseLocation {
fos.close();
}
installSucceeded = true;
- } catch ( IOException e ) {
+ } catch (IOException e) {
throw new InstallException("Cannot install lombok at " + path.getAbsolutePath() +
" probably because this installer does not have the access rights to do so.", e);
} finally {
- if ( !installSucceeded ) try {
+ if (!installSucceeded) try {
lombokJar.delete();
- } catch ( Throwable ignore ) {}
+ } catch (Throwable ignore) {}
}
}
}
- if ( !installSucceeded ) {
+ if (!installSucceeded) {
throw new InstallException("I can't find the eclipse.ini file. Is this a real Eclipse installation?", null);
}
- for ( File dir : failedDirs ) {
+ for (File dir : failedDirs) {
/* Legacy code - lombok's installer used to install in other places. To keep the user's eclipse dir clean, we'll delete these. */ {
try {
new File(dir, "lombok.jar").delete();
new File(dir, "lombok.eclipse.agent.jar").delete();
- } catch ( Throwable ignore ) {}
+ } catch (Throwable ignore) {}
}
}
}
diff --git a/src/lombok/installer/Installer.java b/src/lombok/installer/Installer.java
index 695de4b7..07830964 100644
--- a/src/lombok/installer/Installer.java
+++ b/src/lombok/installer/Installer.java
@@ -96,7 +96,7 @@ public class Installer {
private JButton installButton;
public static void main(String[] args) {
- if ( EclipseFinder.getOS() == OS.MAC_OS_X ) {
+ if (EclipseFinder.getOS() == OS.MAC_OS_X) {
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Lombok Installer");
System.setProperty("com.apple.macos.use-file-dialog-packages", "true");
}
@@ -107,15 +107,15 @@ public class Installer {
try {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch ( Exception ignore ) {}
+ } catch (Exception ignore) {}
new Installer().show();
- } catch ( HeadlessException e ) {
+ } catch (HeadlessException e) {
printHeadlessInfo();
}
}
});
- } catch ( HeadlessException e ) {
+ } catch (HeadlessException e) {
printHeadlessInfo();
}
}
@@ -156,7 +156,7 @@ public class Installer {
howIWorkArea.setVisible(false);
buildChrome(appWindow.getContentPane());
appWindow.pack();
- } catch ( Throwable t ) {
+ } catch (Throwable t) {
handleException(t);
}
}
@@ -312,31 +312,31 @@ public class Installer {
final List<EclipseLocation> locations = new ArrayList<EclipseLocation>();
final List<NotAnEclipseException> problems = new ArrayList<NotAnEclipseException>();
- if ( eclipses != null ) {
- for ( String eclipse : eclipses ) try {
+ if (eclipses != null) {
+ for (String eclipse : eclipses) try {
locations.add(new EclipseLocation(eclipse));
- } catch ( NotAnEclipseException e ) {
+ } catch (NotAnEclipseException e) {
problems.add(e);
}
}
SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
- for ( EclipseLocation location : locations ) {
+ for (EclipseLocation location : locations) {
try {
eclipsesList.addEclipse(location);
- } catch ( Throwable t ) {
+ } catch (Throwable t) {
handleException(t);
}
}
- for ( NotAnEclipseException problem : problems ) {
+ for (NotAnEclipseException problem : problems) {
problem.showDialog(appWindow);
}
loadingExpl.setVisible(false);
- if ( eclipses == null ) {
+ if (eclipses == null) {
JOptionPane.showMessageDialog(appWindow,
"I don't know how to automatically find Eclipse installations on this platform.\n" +
"Please use the 'Specify Eclipse Location...' button to manually point out the\n" +
@@ -344,7 +344,7 @@ public class Installer {
}
}
});
- } catch ( Throwable t ) {
+ } catch (Throwable t) {
handleException(t);
}
}
@@ -360,13 +360,13 @@ public class Installer {
final String name = EclipseFinder.getEclipseExecutableName();
String file = null;
- if ( EclipseFinder.getOS() == OS.MAC_OS_X ) {
+ if (EclipseFinder.getOS() == OS.MAC_OS_X) {
FileDialog chooser = new FileDialog(appWindow);
chooser.setMode(FileDialog.LOAD);
chooser.setFilenameFilter(new FilenameFilter() {
@Override public boolean accept(File dir, String name) {
- if ( name.equalsIgnoreCase(name) ) return true;
- if ( new File(dir, name).isDirectory() ) return true;
+ if (name.equalsIgnoreCase(name)) return true;
+ if (new File(dir, name).isDirectory()) return true;
return false;
}
@@ -381,8 +381,8 @@ public class Installer {
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
chooser.setFileFilter(new FileFilter() {
@Override public boolean accept(File f) {
- if ( f.getName().equalsIgnoreCase(name) ) return true;
- if ( f.isDirectory() ) return true;
+ if (f.getName().equalsIgnoreCase(name)) return true;
+ if (f.isDirectory()) return true;
return false;
}
@@ -392,18 +392,18 @@ public class Installer {
}
});
- switch ( chooser.showDialog(appWindow, "Select") ) {
+ switch (chooser.showDialog(appWindow, "Select")) {
case JFileChooser.APPROVE_OPTION:
file = chooser.getSelectedFile().getAbsolutePath();
}
}
- if ( file != null ) {
+ if (file != null) {
try {
eclipsesList.addEclipse(new EclipseLocation(file));
- } catch ( NotAnEclipseException e ) {
+ } catch (NotAnEclipseException e) {
e.showDialog(appWindow);
- } catch ( Throwable t ) {
+ } catch (Throwable t) {
handleException(t);
}
}
@@ -417,7 +417,7 @@ public class Installer {
installButton.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
List<EclipseLocation> locationsToInstall = new ArrayList<EclipseLocation>(eclipsesList.getSelectedEclipses());
- if ( locationsToInstall.isEmpty() ) {
+ if (locationsToInstall.isEmpty()) {
JOptionPane.showMessageDialog(appWindow, "You haven't selected any Eclipse installations!.", "No Selection", JOptionPane.WARNING_MESSAGE);
return;
}
@@ -446,11 +446,11 @@ public class Installer {
uninstallButton.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
List<EclipseLocation> locationsToUninstall = new ArrayList<EclipseLocation>();
- for ( EclipseLocation location : eclipsesList.getSelectedEclipses() ) {
- if ( location.hasLombok() ) locationsToUninstall.add(location);
+ for (EclipseLocation location : eclipsesList.getSelectedEclipses()) {
+ if (location.hasLombok()) locationsToUninstall.add(location);
}
- if ( locationsToUninstall.isEmpty() ) {
+ if (locationsToUninstall.isEmpty()) {
JOptionPane.showMessageDialog(appWindow, "You haven't selected any Eclipse installations that have been lombok-enabled.", "No Selection", JOptionPane.WARNING_MESSAGE);
return;
}
@@ -480,7 +480,7 @@ public class Installer {
uninstallBox.removeAll();
uninstallBox.add(Box.createRigidArea(new Dimension(1, 16)));
- for ( EclipseLocation location : locations ) {
+ for (EclipseLocation location : locations) {
JLabel label = new JLabel(location.getPath());
label.setFont(label.getFont().deriveFont(Font.BOLD));
uninstallBox.add(label);
@@ -503,10 +503,10 @@ public class Installer {
new Thread() {
@Override public void run() {
- for ( EclipseLocation loc : toInstall ) {
+ for (EclipseLocation loc : toInstall) {
try {
loc.install();
- } catch ( final InstallException e ) {
+ } catch (final InstallException e) {
success.set(false);
try {
SwingUtilities.invokeAndWait(new Runnable() {
@@ -515,14 +515,14 @@ public class Installer {
e.getMessage(), "Install Problem", JOptionPane.ERROR_MESSAGE);
}
});
- } catch ( Exception e2 ) {
+ } catch (Exception e2) {
//Shouldn't happen.
throw new RuntimeException(e2);
}
}
}
- if ( success.get() ) SwingUtilities.invokeLater(new Runnable() {
+ if (success.get()) SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
JOptionPane.showMessageDialog(appWindow, "<html>Lombok has been installed on the selected Eclipse installations.<br>Don't forget to add <code>lombok.jar</code> to your projects, and restart your eclipse!</html>", "Install successful", JOptionPane.INFORMATION_MESSAGE);
appWindow.setVisible(false);
@@ -544,10 +544,10 @@ public class Installer {
final AtomicReference<Boolean> success = new AtomicReference<Boolean>(true);
new Thread() {
@Override public void run() {
- for ( EclipseLocation loc : toUninstall ) {
+ for (EclipseLocation loc : toUninstall) {
try {
loc.uninstall();
- } catch ( final UninstallException e ) {
+ } catch (final UninstallException e) {
success.set(false);
try {
SwingUtilities.invokeAndWait(new Runnable() {
@@ -556,14 +556,14 @@ public class Installer {
e.getMessage(), "Uninstall Problem", JOptionPane.ERROR_MESSAGE);
}
});
- } catch ( Exception e2 ) {
+ } catch (Exception e2) {
//Shouldn't happen.
throw new RuntimeException(e2);
}
}
}
- if ( success.get() ) SwingUtilities.invokeLater(new Runnable() {
+ if (success.get()) SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
JOptionPane.showMessageDialog(appWindow, "Lombok has been removed from the selected Eclipse installations.", "Uninstall successful", JOptionPane.INFORMATION_MESSAGE);
appWindow.setVisible(false);
@@ -594,8 +594,8 @@ public class Installer {
void selectedLomboksChanged(List<EclipseLocation> selectedEclipses) {
boolean uninstallAvailable = false;
boolean installAvailable = false;
- for ( EclipseLocation loc : selectedEclipses ) {
- if ( loc.hasLombok() ) uninstallAvailable = true;
+ for (EclipseLocation loc : selectedEclipses) {
+ if (loc.hasLombok()) uninstallAvailable = true;
installAvailable = true;
}
@@ -616,7 +616,7 @@ public class Installer {
List<EclipseLocation> getSelectedEclipses() {
List<EclipseLocation> list = new ArrayList<EclipseLocation>();
- for ( EclipseLocation loc : locations ) if ( loc.selected ) list.add(loc);
+ for (EclipseLocation loc : locations) if (loc.selected) list.add(loc);
return list;
}
@@ -625,7 +625,7 @@ public class Installer {
}
void addEclipse(final EclipseLocation location) {
- if ( locations.contains(location) ) return;
+ if (locations.contains(location)) return;
Box box = Box.createHorizontalBox();
box.setBackground(Color.WHITE);
final JCheckBox checkbox = new JCheckBox(location.getPath());
@@ -639,7 +639,7 @@ public class Installer {
}
});
- if ( location.hasLombok() ) {
+ if (location.hasLombok()) {
box.add(new JLabel(new ImageIcon(Installer.class.getResource("/lombok/installer/lombokIcon.png"))));
}
box.add(Box.createHorizontalGlue());
@@ -726,10 +726,10 @@ public class Installer {
//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, ABOUT_LOMBOK_URL);
- } catch ( Exception e ) {
+ } catch (Exception e) {
Runtime rt = Runtime.getRuntime();
try {
- switch ( EclipseFinder.getOS() ) {
+ switch (EclipseFinder.getOS()) {
case WINDOWS:
String[] cmd = new String[4];
cmd[0] = "cmd.exe";
@@ -746,7 +746,7 @@ public class Installer {
rt.exec("firefox " + ABOUT_LOMBOK_URL.toString());
break;
}
- } catch ( Exception e2 ) {
+ } 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" +
@@ -770,10 +770,10 @@ public class Installer {
*/
public void show() {
appWindow.setVisible(true);
- if ( EclipseFinder.getOS() == OS.MAC_OS_X ) {
+ if (EclipseFinder.getOS() == OS.MAC_OS_X) {
try {
AppleNativeLook.go();
- } catch ( Throwable ignore ) {
+ } catch (Throwable ignore) {
//We're just prettying up the app. If it fails, meh.
}
}
diff --git a/src/lombok/installer/WindowsDriveInfo.java b/src/lombok/installer/WindowsDriveInfo.java
index fd16ee6e..41a6b17e 100644
--- a/src/lombok/installer/WindowsDriveInfo.java
+++ b/src/lombok/installer/WindowsDriveInfo.java
@@ -77,8 +77,8 @@ public class WindowsDriveInfo {
int flags = getLogicalDrives0();
List<String> letters = new ArrayList<String>();
- for ( int i = 0 ; i < 26 ; i++ ) {
- if ( (flags & (1 << i)) != 0 ) letters.add(Character.toString((char)('A' + i)));
+ for (int i = 0; i < 26; i++) {
+ if ((flags & (1 << i)) != 0) letters.add(Character.toString((char)('A' + i)));
}
return letters;
@@ -94,9 +94,9 @@ public class WindowsDriveInfo {
* Feed it a drive letter (such as 'A') to see if it is a fixed disk.
*/
public boolean isFixedDisk(String letter) {
- if ( letter.length() != 1 ) throw new IllegalArgumentException("Supply 1 letter, not: " + letter);
+ if (letter.length() != 1) throw new IllegalArgumentException("Supply 1 letter, not: " + letter);
char drive = Character.toUpperCase(letter.charAt(0));
- if ( drive < 'A' || drive > 'Z' ) throw new IllegalArgumentException(
+ if (drive < 'A' || drive > 'Z') throw new IllegalArgumentException(
"A drive is indicated by a letter, so A-Z inclusive. Not " + drive);
return getDriveType(drive + ":\\") == 3L;
}
@@ -119,7 +119,7 @@ public class WindowsDriveInfo {
System.loadLibrary("WindowsDriveInfo");
WindowsDriveInfo info = new WindowsDriveInfo();
- for ( String letter : info.getLogicalDrives() ) {
+ for (String letter : info.getLogicalDrives()) {
System.out.printf("Drive %s: - %s\n", letter,
info.isFixedDisk(letter) ? "Fixed Disk" : "Not Fixed Disk");
}