From f1c9909bd4e7560cc908e257a94e612ed3970f8c Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 3 Sep 2018 22:46:22 +0200 Subject: Add Angular IDE support in installer, fixes #1830 --- .../eclipse/AngularIDELocationProvider.java | 44 +++++++++++++++++++++ .../eclipse/StandardProductDescriptor.java | 15 ++++++- src/installer/lombok/installer/eclipse/angular.png | Bin 0 -> 1012 bytes 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/installer/lombok/installer/eclipse/AngularIDELocationProvider.java create mode 100644 src/installer/lombok/installer/eclipse/angular.png (limited to 'src') diff --git a/src/installer/lombok/installer/eclipse/AngularIDELocationProvider.java b/src/installer/lombok/installer/eclipse/AngularIDELocationProvider.java new file mode 100644 index 00000000..6d580e13 --- /dev/null +++ b/src/installer/lombok/installer/eclipse/AngularIDELocationProvider.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2018 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.installer.eclipse; + +import java.util.Collections; + +import org.mangosdk.spi.ProviderFor; + +import lombok.installer.IdeLocationProvider; + +@ProviderFor(IdeLocationProvider.class) +public class AngularIDELocationProvider extends EclipseProductLocationProvider { + + private static final EclipseProductDescriptor ANGULAR = new StandardProductDescriptor( + "Angular IDE", + "angularide", + "angular", + AngularIDELocationProvider.class.getResource("angular.png"), + Collections.emptySet() + ); + + public AngularIDELocationProvider() { + super(ANGULAR); + } +} diff --git a/src/installer/lombok/installer/eclipse/StandardProductDescriptor.java b/src/installer/lombok/installer/eclipse/StandardProductDescriptor.java index 47e103aa..9bd3ae94 100644 --- a/src/installer/lombok/installer/eclipse/StandardProductDescriptor.java +++ b/src/installer/lombok/installer/eclipse/StandardProductDescriptor.java @@ -21,6 +21,7 @@ */ package lombok.installer.eclipse; +import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -34,7 +35,7 @@ import lombok.installer.OsUtils; public class StandardProductDescriptor implements EclipseProductDescriptor { private static final String USER_HOME = System.getProperty("user.home", "."); - private static final String[] WINDOWS_ROOTS = {"\\", "\\Program Files", "\\Program Files (x86)", USER_HOME}; + private static final String[] WINDOWS_ROOTS = windowsRoots(); private static final String[] MAC_ROOTS = {"/Applications", USER_HOME}; private static final String[] UNIX_ROOTS = {USER_HOME}; @@ -155,4 +156,16 @@ public class StandardProductDescriptor implements EclipseProductDescriptor { } return base + pathSeparator + alternative.replaceAll("[\\/]", "\\" + pathSeparator); } + + private static String[] windowsRoots() { + String localAppData = windowsLocalAppData(); + if (localAppData == null) return new String[] {"\\", "\\Program Files", "\\Program Files (x86)", USER_HOME}; + return new String[] {"\\", "\\Program Files", "\\Program Files (x86)", USER_HOME, localAppData}; + } + + private static String windowsLocalAppData() { + String localAppData = System.getenv("LOCALAPPDATA"); + File file = localAppData == null ? null : new File(localAppData); + return file != null && file.exists() && file.canRead() && file.isDirectory() ? localAppData : null; + } } diff --git a/src/installer/lombok/installer/eclipse/angular.png b/src/installer/lombok/installer/eclipse/angular.png new file mode 100644 index 00000000..d3204cd7 Binary files /dev/null and b/src/installer/lombok/installer/eclipse/angular.png differ -- cgit