diff --git a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCell.java b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCell.java index 15c03c06d..2cfe711f7 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCell.java +++ b/app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCell.java @@ -344,9 +344,9 @@ public class ContributedLibraryTableCell extends InstallerTableCell { String desc = ""; // Library name... - desc += format("{0} ", name); + desc += format("{0}", name); if (installed != null && installed.isReadOnly()) { - desc += "Built-In "; + desc += " Built-In "; } // ...author... diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCell.java b/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCell.java index 0cb2d1796..e4690354f 100644 --- a/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCell.java +++ b/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCell.java @@ -348,8 +348,11 @@ public class ContributedPlatformTableCell extends InstallerTableCell { String desc = ""; desc += "" + selected.getName() + ""; + if (installed != null && installed.isReadOnly()) { + desc += " Built-In "; + } + String author = selected.getParentPackage().getMaintainer(); - String url = selected.getParentPackage().getWebsiteURL(); if (author != null && !author.isEmpty()) { desc += " " + format("by {0}", author); } @@ -364,6 +367,7 @@ public class ContributedPlatformTableCell extends InstallerTableCell { } desc = desc.substring(0, desc.lastIndexOf(',')) + ".
"; + String url = selected.getParentPackage().getWebsiteURL(); if (url != null && !url.isEmpty()) { desc += " " + format("More info", url); } diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java b/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java index e003a7a19..9201669f1 100644 --- a/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java +++ b/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java @@ -40,6 +40,8 @@ import processing.app.I18n; import javax.swing.*; import java.awt.*; import java.util.Collection; +import java.util.LinkedList; +import java.util.List; import static processing.app.I18n._; @@ -158,17 +160,21 @@ public class ContributionManagerUI extends InstallerJDialog { installerThread = new Thread(new Runnable() { @Override public void run() { + List errors = new LinkedList(); try { setProgressVisible(true, _("Installing...")); - installer.install(platformToInstall); + errors.addAll(installer.install(platformToInstall)); if (platformToRemove != null && !platformToRemove.isReadOnly()) { - installer.remove(platformToRemove); + errors.addAll(installer.remove(platformToRemove)); } onIndexesUpdated(); } catch (Exception e) { throw new RuntimeException(e); } finally { setProgressVisible(false, ""); + if (!errors.isEmpty()) { + setErrorMessage(errors.get(0)); + } } } }); diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java b/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java index 17b7dacbf..e13cec4ae 100644 --- a/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java +++ b/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java @@ -79,7 +79,8 @@ public class ContributionInstaller { }; } - public void install(ContributedPlatform platform) throws Exception { + public List install(ContributedPlatform platform) throws Exception { + List errors = new LinkedList(); if (platform.isInstalled()) { throw new Exception("Platform is already installed!"); } @@ -117,7 +118,7 @@ public class ContributionInstaller { } } catch (InterruptedException e) { // Download interrupted... just exit - return; + return errors; } ContributedPackage pack = platform.getParentPackage(); @@ -140,7 +141,11 @@ public class ContributionInstaller { destFolder.mkdirs(); assert toolContrib.getDownloadedFile() != null; new ArchiveExtractor(BaseNoGui.getPlatform()).extract(toolContrib.getDownloadedFile(), destFolder, 1); - executePostInstallScriptIfAny(destFolder); + try { + executePostInstallScriptIfAny(destFolder); + } catch (IOException e) { + errors.add(_("Error running post install script")); + } toolContrib.setInstalled(true); toolContrib.setInstalledFolder(destFolder); progress.stepDone(); @@ -159,6 +164,8 @@ public class ContributionInstaller { progress.setStatus(_("Installation completed!")); onProgress(progress); + + return errors; } private void executePostInstallScriptIfAny(File folder) throws IOException { @@ -184,14 +191,15 @@ public class ContributionInstaller { ByteArrayOutputStream stdout = new ByteArrayOutputStream(); ByteArrayOutputStream stderr = new ByteArrayOutputStream(); Executor executor = new CollectStdOutStdErrExecutor(stdout, stderr); - + executor.setWorkingDirectory(folder); executor.execute(new CommandLine(postInstallScript)); System.out.write(stdout.toByteArray()); System.err.write(stderr.toByteArray()); } - public void remove(ContributedPlatform platform) { + public List remove(ContributedPlatform platform) { + List errors = new LinkedList(); FileUtils.recursiveDelete(platform.getInstalledFolder()); platform.setInstalled(false); platform.setInstalledFolder(null); @@ -217,11 +225,14 @@ public class ContributionInstaller { // ignore } } + + return errors; } - public void updateIndex() throws Exception { - final MultiStepProgress progress = new MultiStepProgress(1); - final String statusText = _("Downloading platforms index..."); + public List updateIndex() throws Exception { + List errors = new LinkedList(); + MultiStepProgress progress = new MultiStepProgress(1); + String statusText = _("Downloading platforms index..."); URL url = new URL(PACKAGE_INDEX_URL); File outputFile = indexer.getIndexFile(); @@ -232,10 +243,13 @@ public class ContributionInstaller { // TODO: Check downloaded index // Replace old index with the updated one - if (outputFile.exists()) + if (outputFile.exists()) { outputFile.delete(); - if (!tmpFile.renameTo(outputFile)) + } + if (!tmpFile.renameTo(outputFile)) { throw new Exception("An error occurred while updating platforms index!"); + } + return errors; } protected void onProgress(Progress progress) {