| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -251,9 +251,9 @@ public boolean writePropertiesFile(File propFile) { | |||
| 251 | 251 | sb.deleteCharAt(sb.length() - 1); | |
| 252 | 252 | category = sb.toString(); | |
| 253 | 253 | } | |
| 254 | - | ||
| 254 | + | ||
| 255 | 255 | String specifiedImport = ""; | |
| 256 | - List<String> importsList = parseImports(properties.get("imports")); | ||
| 256 | + List<String> importsList = parseImports(properties.get("imports")); | ||
| 257 | 257 | if (importsList == null || importsList.isEmpty()) { | |
| 258 | 258 | specifiedImport = getImportStr(); | |
| 259 | 259 | } else { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,18 +92,18 @@ protected List<String> getImports() { | |||
| 92 | 92 | ||
| 93 | 93 | ||
| 94 | 94 | protected String getImportStr() { | |
| 95 | - if (specifiedImports == null || specifiedImports.isEmpty()) | ||
| 95 | + if (specifiedImports == null || specifiedImports.isEmpty()) { | ||
| 96 | 96 | return ""; | |
| 97 | + } | ||
| 97 | 98 | StringBuilder sb = new StringBuilder(); | |
| 98 | 99 | for (String importName : specifiedImports) { | |
| 99 | 100 | sb.append(importName); | |
| 100 | 101 | sb.append(','); | |
| 101 | 102 | } | |
| 102 | - sb.deleteCharAt(sb.length()-1); // delete last comma | ||
| 103 | + sb.deleteCharAt(sb.length() - 1); // delete last comma | ||
| 103 | 104 | return sb.toString(); | |
| 104 | 105 | } | |
| 105 | - | ||
| 106 | - | ||
| 106 | + | ||
| 107 | 107 | protected boolean hasImport(String importName) { | |
| 108 | 108 | if (specifiedImports != null && importName != null) { | |
| 109 | 109 | for (String c : specifiedImports) { | |
@@ -267,13 +267,13 @@ static List<String> parseCategories(String categoryStr) { | |||
| 267 | 267 | */ | |
| 268 | 268 | static List<String> parseImports(String importStr) { | |
| 269 | 269 | List<String> outgoing = new ArrayList<String>(); | |
| 270 | - | ||
| 270 | + | ||
| 271 | 271 | if (importStr != null) { | |
| 272 | 272 | String[] importList = PApplet.trim(PApplet.split(importStr, ',')); | |
| 273 | 273 | for (String importName : importList) { | |
| 274 | - outgoing.add(importName); | ||
| 274 | + outgoing.add(importName); | ||
| 275 | 275 | } | |
| 276 | 276 | } | |
| 277 | - return (outgoing.size() > 0) ? outgoing : null; | ||
| 277 | + return (outgoing.size() > 0) ? outgoing : null; | ||
| 278 | 278 | } | |
| 279 | 279 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,7 +120,7 @@ protected void replaceContribution(Contribution oldLib, Contribution newLib) { | |||
| 120 | 120 | } | |
| 121 | 121 | } | |
| 122 | 122 | } | |
| 123 | - | ||
| 123 | + | ||
| 124 | 124 | if (oldLib.getImports() != null) { | |
| 125 | 125 | for (String importName : oldLib.getImports()) { | |
| 126 | 126 | librariesByImportHeader.replace(importName, newLib); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,8 +110,9 @@ static boolean download(URL source, File dest, ProgressMonitor progress) { | |||
| 110 | 110 | // Hiding stack trace. An error has been shown where needed. | |
| 111 | 111 | // ioe.printStackTrace(); | |
| 112 | 112 | } | |
| 113 | - if (progress != null) | ||
| 113 | + if (progress != null) { | ||
| 114 | 114 | progress.finished(); | |
| 115 | + } | ||
| 115 | 116 | return success; | |
| 116 | 117 | } | |
| 117 | 118 | ||
@@ -154,8 +155,9 @@ public void run() { | |||
| 154 | 155 | contribListing.replaceContribution(ad, contribution); | |
| 155 | 156 | if (contribution.getType() == ContributionType.MODE) { | |
| 156 | 157 | ArrayList<ModeContribution> contribModes = editor.getBase().getModeContribs(); | |
| 157 | - if (!contribModes.contains(contribution)) | ||
| 158 | + if (!contribModes.contains(contribution)) { | ||
| 158 | 159 | contribModes.add((ModeContribution) contribution); | |
| 160 | + } | ||
| 159 | 161 | } | |
| 160 | 162 | refreshInstalled(editor); | |
| 161 | 163 | } | |
@@ -232,8 +234,9 @@ public void run() { | |||
| 232 | 234 | contribModes.add((ModeContribution) contribution); | |
| 233 | 235 | } | |
| 234 | 236 | } | |
| 235 | - if (base.getActiveEditor() != null) | ||
| 237 | + if (base.getActiveEditor() != null) { | ||
| 236 | 238 | refreshInstalled(base.getActiveEditor()); | |
| 239 | + } | ||
| 237 | 240 | } | |
| 238 | 241 | ||
| 239 | 242 | contribZip.delete(); | |
@@ -243,13 +246,12 @@ public void run() { | |||
| 243 | 246 | } catch (Exception e) { | |
| 244 | 247 | // Chuck the stack trace. The user might have no idea why it is appearing, or what (s)he did wrong... | |
| 245 | 248 | // e.printStackTrace(); | |
| 246 | - System.out.println("Error during download and install of " | ||
| 247 | - + ad.getName()); | ||
| 249 | + String arg = "contrib.startup.errors.download_install"; | ||
| 250 | + System.err.println(Language.interpolate(arg, ad.getName())); | ||
| 248 | 251 | } | |
| 249 | 252 | } catch (IOException e) { | |
| 250 | - System.err | ||
| 251 | - .println("Could not write to temporary directory during download and install of " | ||
| 252 | - + ad.getName()); | ||
| 253 | + String arg = "contrib.startup.errors.temp_dir"; | ||
| 254 | + System.err.println(Language.interpolate(arg, ad.getName())); | ||
| 253 | 255 | } | |
| 254 | 256 | } | |
| 255 | 257 | }, "Contribution Installer").start(); | |
@@ -288,8 +290,8 @@ public boolean accept(File dir, String file) { | |||
| 288 | 290 | } catch (IOException e) { | |
| 289 | 291 | // Again, forget about the stack trace. The user ain't done wrong | |
| 290 | 292 | // e.printStackTrace(); | |
| 291 | - System.err.println("The unupdated contribution marker seems to not like " | ||
| 292 | - + ac.getName() + ". You may have to install it manually to update..."); | ||
| 293 | + String arg = "contrib.startup.errors.new_marker"; | ||
| 294 | + System.err.println(Language.interpolate(arg, ac.getName())); | ||
| 293 | 295 | } | |
| 294 | 296 | ||
| 295 | 297 | } | |
@@ -311,12 +313,17 @@ public static void downloadAndInstallOnImport(final Base base, | |||
| 311 | 313 | // during pre-processing | |
| 312 | 314 | base.getActiveEditor().getTextArea().setEditable(false); | |
| 313 | 315 | base.getActiveEditor().getConsole().clear(); | |
| 314 | - | ||
| 316 | + | ||
| 315 | 317 | ArrayList<String> installedLibList = new ArrayList<String>(); | |
| 316 | 318 | ||
| 319 | + // boolean variable to check if previous lib was installed successfully, | ||
| 320 | + // to give the user an idea about progress being made. | ||
| 321 | + boolean isPrevDone = false; | ||
| 322 | + | ||
| 317 | 323 | for (AvailableContribution ad : aList) { | |
| 318 | - if (ad.getType() != ContributionType.LIBRARY) | ||
| 324 | + if (ad.getType() != ContributionType.LIBRARY) { | ||
| 319 | 325 | continue; | |
| 326 | + } | ||
| 320 | 327 | try { | |
| 321 | 328 | URL url = new URL(ad.link); | |
| 322 | 329 | String filename = url.getFile(); | |
@@ -332,55 +339,63 @@ public static void downloadAndInstallOnImport(final Base base, | |||
| 332 | 339 | // one install is completed and the next download has begun without | |
| 333 | 340 | // interfereing with occur status messages that may arise in the meanwhile | |
| 334 | 341 | String statusMsg = base.getActiveEditor().getStatusMessage(); | |
| 335 | - if (statusMsg.contains("has been installed")) | ||
| 336 | - base.getActiveEditor().statusNotice(statusMsg + " " | ||
| 337 | - + "Downloading " | ||
| 338 | - + ad.name + "..."); | ||
| 339 | - else | ||
| 340 | - base.getActiveEditor().statusNotice("Downloading " + ad.name | ||
| 341 | - + "..."); | ||
| 342 | + if (isPrevDone) { | ||
| 343 | + String status = statusMsg + " " | ||
| 344 | + + Language.interpolate("contrib.import.progress.download", ad.name); | ||
| 345 | + base.getActiveEditor().statusNotice(status); | ||
| 346 | + } | ||
| 347 | + else { | ||
| 348 | + String arg = "contrib.import.progress.download"; | ||
| 349 | + String status = Language.interpolate(arg, ad.name); | ||
| 350 | + base.getActiveEditor().statusNotice(status); | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + isPrevDone = false; | ||
| 342 | 354 | ||
| 343 | 355 | download(url, contribZip, null); | |
| 344 | 356 | ||
| 345 | - base.getActiveEditor() | ||
| 346 | - .statusNotice("Installing " + ad.name + "..."); | ||
| 357 | + String arg = "contrib.import.progress.install"; | ||
| 358 | + base.getActiveEditor().statusNotice(Language.interpolate(arg,ad.name)); | ||
| 347 | 359 | LocalContribution contribution = ad.install(base, contribZip, | |
| 348 | 360 | false, null); | |
| 349 | 361 | ||
| 350 | 362 | if (contribution != null) { | |
| 351 | 363 | contribListing.replaceContribution(ad, contribution); | |
| 352 | - if (base.getActiveEditor() != null) | ||
| 364 | + if (base.getActiveEditor() != null) { | ||
| 353 | 365 | refreshInstalled(base.getActiveEditor()); | |
| 366 | + } | ||
| 354 | 367 | } | |
| 355 | 368 | ||
| 356 | 369 | contribZip.delete(); | |
| 357 | 370 | ||
| 358 | 371 | installedLibList.add(ad.name); | |
| 359 | - base.getActiveEditor().statusNotice(ad.name | ||
| 360 | - + " has been installed."); | ||
| 372 | + isPrevDone = true; | ||
| 373 | + | ||
| 374 | + arg = "contrib.import.progress.done"; | ||
| 375 | + base.getActiveEditor().statusNotice(Language.interpolate(arg,ad.name)); | ||
| 361 | 376 | ||
| 362 | 377 | } catch (Exception e) { | |
| 363 | - System.out.println("Error during download and install of " | ||
| 364 | - + ad.getName()); | ||
| 378 | + String arg = "contrib.startup.errors.download_install"; | ||
| 379 | + System.err.println(Language.interpolate(arg, ad.getName())); | ||
| 365 | 380 | } | |
| 366 | 381 | } catch (IOException e) { | |
| 367 | - System.err | ||
| 368 | - .println("Could not write to temporary directory during download and install of " | ||
| 369 | - + ad.getName()); | ||
| 382 | + String arg = "contrib.startup.errors.temp_dir"; | ||
| 383 | + System.err.println(Language.interpolate(arg,ad.getName())); | ||
| 370 | 384 | } | |
| 371 | 385 | } catch (MalformedURLException e1) { | |
| 372 | - System.err.println("Error: The library " + ad.getName() | ||
| 373 | - + " has a weird looking download link."); | ||
| 386 | + System.err.println(Language.interpolate("contrib.import.errors.link", | ||
| 387 | + ad.getName())); | ||
| 374 | 388 | } | |
| 375 | 389 | } | |
| 376 | 390 | base.getActiveEditor().getTextArea().setEditable(true); | |
| 377 | 391 | base.getActiveEditor().statusEmpty(); | |
| 378 | - System.out.println("The following libraries have been installed:"); | ||
| 392 | + System.out.println(Language.text("contrib.import.progress.final_list")); | ||
| 379 | 393 | for (String l : installedLibList) { | |
| 380 | - System.out.println(" • " + l); | ||
| 394 | + System.out.println(" * " + l); | ||
| 381 | 395 | } | |
| 382 | 396 | } | |
| 383 | 397 | ||
| 398 | + | ||
| 384 | 399 | static public void refreshInstalled(Editor e) { | |
| 385 | 400 | ||
| 386 | 401 | Iterator<Editor> iter = e.getBase().getEditors().iterator(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -338,8 +338,9 @@ delete.messages.is_read_only.description = Some files are marked \"read-only\", | |||
| 338 | 338 | ||
| 339 | 339 | ||
| 340 | 340 | # --------------------------------------- | |
| 341 | - # Contribution Panel | ||
| 341 | + # Contributions | ||
| 342 | 342 | ||
| 343 | + # Contribution Panel | ||
| 343 | 344 | contrib = Contribution Manager | |
| 344 | 345 | contrib.manager_title.update = Update Manager | |
| 345 | 346 | contrib.manager_title.mode = Mode Manager | |
@@ -384,6 +385,20 @@ contrib.progress.downloading = Downloading | |||
| 384 | 385 | contrib.download_error = An error occured while downloading the contribution. | |
| 385 | 386 | contrib.unsupported_operating_system = Your operating system does not appear to be supported. You should visit the %s\'s library for more info. | |
| 386 | 387 | ||
| 388 | + # Install on Startup | ||
| 389 | + contrib.startup.errors.download_install = Error during download and install of %s | ||
| 390 | + contrib.startup.errors.temp_dir = Could not write to temporary directory during download and install of %s | ||
| 391 | + contrib.startup.errors.new_marker = The unupdated contribution marker seems to not like %s. You may have to install it manually to update... | ||
| 392 | + | ||
| 393 | + # Install on Import | ||
| 394 | + contrib.import.dialog.title = Missing Libraries Available | ||
| 395 | + contrib.import.dialog.primary_text = The following imported libraries are available for download, but have not been installed. | ||
| 396 | + contrib.import.dialog.secondary_text = Would you like to install them now? | ||
| 397 | + contrib.import.progress.download = Downloading %s... | ||
| 398 | + contrib.import.progress.install = Installing %s... | ||
| 399 | + contrib.import.progress.done = %s has been installed. | ||
| 400 | + contrib.import.progress.final_list = The following libraries have been installed: | ||
| 401 | + contrib.import.errors.link = Error: The library %s has a strange looking download link. | ||
| 387 | 402 | ||
| 388 | 403 | # --------------------------------------- | |
| 389 | 404 | # Warnings | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1853,11 +1853,12 @@ public void prepareRun() { | |||
| 1853 | 1853 | super.prepareRun(); | |
| 1854 | 1854 | downloadImports(); | |
| 1855 | 1855 | } | |
| 1856 | - | ||
| 1856 | + | ||
| 1857 | + | ||
| 1857 | 1858 | /** | |
| 1858 | - * Downloads libraries that have been imported, that aren't available as a | ||
| 1859 | - * LocalContribution, but that have an AvailableContribution associated with | ||
| 1860 | - * them. | ||
| 1859 | + * Downloads libraries that have been imported, that aren't available as a | ||
| 1860 | + * LocalContribution, but that have an AvailableContribution associated with | ||
| 1861 | + * them. | ||
| 1861 | 1862 | */ | |
| 1862 | 1863 | protected void downloadImports() { | |
| 1863 | 1864 | String importRegex = errorCheckerService.importRegexp; | |
@@ -1867,7 +1868,7 @@ protected void downloadImports() { | |||
| 1867 | 1868 | tabCode = sc.getProgram(); | |
| 1868 | 1869 | ||
| 1869 | 1870 | String[][] pieces = PApplet.matchAll(tabCode, importRegex); | |
| 1870 | - | ||
| 1871 | + | ||
| 1871 | 1872 | if (pieces != null) { | |
| 1872 | 1873 | ArrayList<String> importHeaders = new ArrayList<String>(); | |
| 1873 | 1874 | for (String[] importStatement : pieces) { | |
@@ -1879,24 +1880,26 @@ protected void downloadImports() { | |||
| 1879 | 1880 | for (AvailableContribution ac : installLibsHeaders) { | |
| 1880 | 1881 | libList.append("\n • " + ac.getName()); | |
| 1881 | 1882 | } | |
| 1882 | - int option = Base | ||
| 1883 | - .showYesNoQuestion(this, "Missing Libraries Available", | ||
| 1884 | - "The following imported libraries are available for download, but have not been installed.", | ||
| 1885 | - libList.toString()); | ||
| 1886 | - | ||
| 1887 | - if (option == JOptionPane.YES_OPTION) { | ||
| 1888 | - ContributionManager.downloadAndInstallOnImport(base, | ||
| 1889 | - installLibsHeaders); | ||
| 1890 | - } | ||
| 1883 | + int option = Base.showYesNoQuestion(this, | ||
| 1884 | + Language.text("contrib.import.dialog.title"), | ||
| 1885 | + Language.text("contrib.import.dialog.primary_text"), | ||
| 1886 | + libList.toString()); | ||
| 1887 | + | ||
| 1888 | + if (option == JOptionPane.YES_OPTION) { | ||
| 1889 | + ContributionManager.downloadAndInstallOnImport(base, | ||
| 1890 | + installLibsHeaders); | ||
| 1891 | + } | ||
| 1891 | 1892 | } | |
| 1892 | 1893 | } | |
| 1893 | 1894 | } | |
| 1894 | 1895 | } | |
| 1895 | 1896 | } | |
| 1896 | - | ||
| 1897 | + | ||
| 1898 | + | ||
| 1897 | 1899 | /** | |
| 1898 | - * Returns a list of AvailableContributions of those libraries that the user wants imported, | ||
| 1899 | - * but that are not installed. | ||
| 1900 | + * Returns a list of AvailableContributions of those libraries that the user | ||
| 1901 | + * wants imported, but that are not installed. | ||
| 1902 | + * | ||
| 1900 | 1903 | * @param importHeaders | |
| 1901 | 1904 | */ | |
| 1902 | 1905 | private ArrayList<AvailableContribution> getNotInstalledAvailableLibs(ArrayList<String> importHeadersList) { | |
@@ -1917,19 +1920,24 @@ private ArrayList<AvailableContribution> getNotInstalledAvailableLibs(ArrayList< | |||
| 1917 | 1920 | library = this.getMode().getLibrary(entry); | |
| 1918 | 1921 | if (library == null) { | |
| 1919 | 1922 | Contribution c = importMap.get(importHeaders); | |
| 1920 | - if (c!=null && c instanceof AvailableContribution) | ||
| 1921 | - libList.add((AvailableContribution)c);//System.out.println(importHeaders + "not found"); | ||
| 1923 | + if (c != null && c instanceof AvailableContribution) { | ||
| 1924 | + libList.add((AvailableContribution) c);// System.out.println(importHeaders | ||
| 1925 | + // + "not found"); | ||
| 1926 | + } | ||
| 1922 | 1927 | } | |
| 1923 | 1928 | } catch (Exception e) { | |
| 1924 | 1929 | // Not gonna happen (hopefully) | |
| 1925 | 1930 | Contribution c = importMap.get(importHeaders); | |
| 1926 | - if (c!=null && c instanceof AvailableContribution) | ||
| 1927 | - libList.add((AvailableContribution)c);//System.out.println(importHeaders + "not found"); | ||
| 1931 | + if (c != null && c instanceof AvailableContribution) { | ||
| 1932 | + libList.add((AvailableContribution) c);// System.out.println(importHeaders | ||
| 1933 | + // + "not found"); | ||
| 1934 | + } | ||
| 1928 | 1935 | } | |
| 1929 | 1936 | } | |
| 1930 | 1937 | return libList; | |
| 1931 | 1938 | } | |
| 1932 | 1939 | ||
| 1940 | + | ||
| 1933 | 1941 | /** | |
| 1934 | 1942 | * Displays a JDialog prompting the user to save when the user hits | |
| 1935 | 1943 | * run/present/etc. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments