From 9402ef4a0bab0b31294bb9c2dade8aaf15955bc7 Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Sat, 26 Jul 2014 00:48:18 +0200 Subject: [PATCH 001/134] Corrected a typo in Tessellator#addQuadraticVertex() Fixes #2648 - corrected a typo in a5cbb0e2 --- core/src/processing/opengl/PGraphicsOpenGL.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index c2bf327e9..541f1981c 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -11579,7 +11579,7 @@ public class PGraphicsOpenGL extends PGraphics { void addQuadraticVertex(int i) { pg.curveVertexCount = 0; pg.bezierInitCheck(); - pg.bezierVertexCheck(pg.shape, i); + pg.bezierVertexCheck(POLYGON, i); PMatrix3D draw = pg.bezierDrawMatrix; From 406d38d51e3cde39ab8d70bbc5bd9c0c7debffd5 Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Sat, 26 Jul 2014 02:00:26 +0200 Subject: [PATCH 002/134] Fixed error reporting for bez/quad/curve vertices When user calls bezierVertex()/quadraticVertex()/curveVertex() and does not call beginShape()/beginShape(POLYGON) before or forgets to specify first vertex(), proper error message is shown. --- core/src/processing/core/PGraphics.java | 2 +- core/src/processing/opengl/PGraphicsOpenGL.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 7d950eecc..c8776a2e1 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -1867,7 +1867,7 @@ public class PGraphics extends PImage implements PConstants { "must be used before bezierVertex() or quadraticVertex()"); } if (vertexCount == 0) { - throw new RuntimeException("vertex() must be used at least once" + + throw new RuntimeException("vertex() must be used at least once " + "before bezierVertex() or quadraticVertex()"); } } diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index 541f1981c..c6ae59cb9 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -3056,6 +3056,7 @@ public class PGraphicsOpenGL extends PGraphics { protected void bezierVertexImpl(float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4) { + bezierVertexCheck(shape, inGeo.vertexCount); inGeo.setMaterial(fillColor, strokeColor, strokeWeight, ambientColor, specularColor, emissiveColor, shininess); inGeo.setNormal(normalX, normalY, normalZ); @@ -3083,6 +3084,7 @@ public class PGraphicsOpenGL extends PGraphics { protected void quadraticVertexImpl(float cx, float cy, float cz, float x3, float y3, float z3) { + bezierVertexCheck(shape, inGeo.vertexCount); inGeo.setMaterial(fillColor, strokeColor, strokeWeight, ambientColor, specularColor, emissiveColor, shininess); inGeo.setNormal(normalX, normalY, normalZ); @@ -3109,6 +3111,7 @@ public class PGraphicsOpenGL extends PGraphics { protected void curveVertexImpl(float x, float y, float z) { + curveVertexCheck(shape); inGeo.setMaterial(fillColor, strokeColor, strokeWeight, ambientColor, specularColor, emissiveColor, shininess); inGeo.setNormal(normalX, normalY, normalZ); From 4a5d9494cb1cc79dc3cf17b646995828940b0aca Mon Sep 17 00:00:00 2001 From: ArthurYidi Date: Wed, 30 Jul 2014 18:27:19 -0400 Subject: [PATCH 003/134] fix firstline when modifying lines above it (fixes #2654) --- app/src/processing/app/syntax/JEditTextArea.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index 221218d46..a6a1b4136 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -414,6 +414,11 @@ public class JEditTextArea extends JComponent * updating the scroll bars. */ public void setFirstLine(int firstLine) { + if(firstLine < 0 || firstLine > getLineCount()) { + throw new IllegalArgumentException("First line out of range: " + + firstLine + " [0, " + getLineCount() + "]"); + } + if (firstLine == this.firstLine) return; this.firstLine = firstLine; @@ -2086,7 +2091,7 @@ public class JEditTextArea extends JComponent // do magic stuff else if(line < firstLine) { - setFirstLine(firstLine + count); + setFirstLine(line); } // end of magic stuff else From b129b80448b72b39f40037fe206ae330caf308e6 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Thu, 31 Jul 2014 20:44:44 +0530 Subject: [PATCH 004/134] error bar, old offset removed --- pdex/src/processing/mode/experimental/ErrorBar.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pdex/src/processing/mode/experimental/ErrorBar.java b/pdex/src/processing/mode/experimental/ErrorBar.java index b858dcdbb..037f98d83 100755 --- a/pdex/src/processing/mode/experimental/ErrorBar.java +++ b/pdex/src/processing/mode/experimental/ErrorBar.java @@ -149,7 +149,8 @@ public class ErrorBar extends JPanel { // NOTE TO SELF: ErrorMarkers are calculated for the present tab only // Error Marker index in the arraylist is LOCALIZED for current tab. - // Also, need to do the update in the UI thread to prevent concurrency issues. + // Also, need to do the update in the UI thread via SwingWorker to prevent + // concurrency issues. final int fheight = this.getHeight(); SwingWorker worker = new SwingWorker() { @@ -178,7 +179,7 @@ public class ErrorBar extends JPanel { for (Problem problem : problems) { if (problem.getTabIndex() == currentTab) { // Ratio of error line to total lines - float y = (problem.getLineNumber() - errorCheckerService.defaultImportsOffset) + float y = (problem.getLineNumber() + 1) / ((float) totalLines); // Ratio multiplied by height of the error bar y *= fheight - 15; // -15 is just a vertical offset From 10fedecd155cbb6a8d156b977de9c413d1a3dea8 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Thu, 31 Jul 2014 20:45:42 +0530 Subject: [PATCH 005/134] ECS, 3 secs feels like a decent compromise --- pdex/src/processing/mode/experimental/ErrorCheckerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdex/src/processing/mode/experimental/ErrorCheckerService.java b/pdex/src/processing/mode/experimental/ErrorCheckerService.java index 2f63a752a..fad2a2dd7 100644 --- a/pdex/src/processing/mode/experimental/ErrorCheckerService.java +++ b/pdex/src/processing/mode/experimental/ErrorCheckerService.java @@ -68,7 +68,7 @@ public class ErrorCheckerService implements Runnable{ /** * Error check happens every sleepTime milliseconds */ - public static final int sleepTime = 4000; + public static final int sleepTime = 3000; /** * The amazing eclipse ast parser From ada4423aa9f12761613c239910adbe1d593cf441 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Thu, 31 Jul 2014 21:18:46 -0400 Subject: [PATCH 006/134] deal with some warnings and other notes --- .../com/oracle/appbundler/BundleDocument.java | 2 +- core/todo.txt | 1 + .../glw/src/processing/glw/PNEWT.java | 2 +- .../pdf/src/processing/pdf/PGraphicsPDF.java | 6 +++-- .../mode/experimental/ASTGenerator.java | 4 +-- .../mode/experimental/Debugger.java | 2 +- .../processing/mode/experimental/Utils.java | 2 +- .../mode/experimental/VariableInspector.java | 4 +-- .../mode/experimental/VariableNode.java | 2 +- todo.txt | 25 +++++++++++-------- 10 files changed, 29 insertions(+), 21 deletions(-) diff --git a/build/macosx/appbundler/src/com/oracle/appbundler/BundleDocument.java b/build/macosx/appbundler/src/com/oracle/appbundler/BundleDocument.java index 2f0a01fdf..94fdde05e 100644 --- a/build/macosx/appbundler/src/com/oracle/appbundler/BundleDocument.java +++ b/build/macosx/appbundler/src/com/oracle/appbundler/BundleDocument.java @@ -38,7 +38,7 @@ public class BundleDocument { private String[] extensions; private boolean isPackage = false; - private String capitalizeFirst(String string) { + static private String capitalizeFirst(String string) { char[] stringArray = string.toCharArray(); stringArray[0] = Character.toUpperCase(stringArray[0]); return new String(stringArray); diff --git a/core/todo.txt b/core/todo.txt index 290d32746..9edc000c9 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -92,6 +92,7 @@ _ no high-dpi support for core on Windows _ https://github.com/processing/processing/issues/2411 _ retina sketches slow to start _ https://github.com/processing/processing/issues/2357 +_ glw? lwjgl? retina jogl? cantfix diff --git a/java/libraries/glw/src/processing/glw/PNEWT.java b/java/libraries/glw/src/processing/glw/PNEWT.java index 08d3de581..c633bac47 100644 --- a/java/libraries/glw/src/processing/glw/PNEWT.java +++ b/java/libraries/glw/src/processing/glw/PNEWT.java @@ -174,7 +174,7 @@ public class PNEWT extends PJOGL { } - private void displayWindows() { + static private void displayWindows() { int totalCount = 0; int realizedCount = 0; for (GLWindow win: GLW.windows.values()) { diff --git a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java index 69e02d1f8..9de7ec65e 100644 --- a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java +++ b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java @@ -647,8 +647,10 @@ public class PGraphicsPDF extends PGraphicsJava2D { // fontList = new String[entries.size()]; fontList = new String[map.size()]; int count = 0; - for (Object entry : map.entrySet()) { - fontList[count++] = (String) ((Map.Entry) entry).getKey(); + for (Object key : map.keySet()) { +// for (Object entry : map.entrySet()) { +// fontList[count++] = (String) ((Map.Entry) entry).getKey(); + fontList[count++] = (String) key; } // Iterator it = entries.iterator(); // int count = 0; diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index ea47a91d3..1fdf69e0b 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -561,7 +561,7 @@ public class ASTGenerator { } else { // or in a predefined class? - Class tehClass = findClassIfExists(((SimpleName) astNode).toString()); + Class tehClass = findClassIfExists(((SimpleName) astNode).toString()); if (tehClass != null) { return new ClassMember(tehClass); } @@ -587,7 +587,7 @@ public class ASTGenerator { /*The type wasn't found in local code, so it might be something like * log(), or maybe belonging to super class, etc. */ - Class tehClass = findClassIfExists(((SimpleName)fa.getExpression()).toString()); + Class tehClass = findClassIfExists(((SimpleName)fa.getExpression()).toString()); if (tehClass != null) { // Method Expression is a simple name and wasn't located locally, but found in a class // so look for method in this class. diff --git a/pdex/src/processing/mode/experimental/Debugger.java b/pdex/src/processing/mode/experimental/Debugger.java index 7f19d0622..908fa73f7 100755 --- a/pdex/src/processing/mode/experimental/Debugger.java +++ b/pdex/src/processing/mode/experimental/Debugger.java @@ -1116,7 +1116,7 @@ public class Debugger implements VMEventListener { for (Field f : type.visibleFields()) { System.out.println(f.typeName() + " " + f.name() + " = " + thisObject.getValue(f)); } - } else { + } else { // TODO [this is not reachable - fry] System.out.println("can't get this (in native or static method)"); } } diff --git a/pdex/src/processing/mode/experimental/Utils.java b/pdex/src/processing/mode/experimental/Utils.java index 7992676dc..d1bcced2f 100644 --- a/pdex/src/processing/mode/experimental/Utils.java +++ b/pdex/src/processing/mode/experimental/Utils.java @@ -213,7 +213,7 @@ public class Utils { } public void minDistInGrid(int g[][], int i, int j, int fi, int fj, - char s1[], char s2[], ArrayList set) { + char s1[], char s2[], ArrayList set) { // if(i < s1.length)System.out.print(s1[i] + " <->"); // if(j < s2.length)System.out.print(s2[j]); if (i < s1.length && j < s2.length) { diff --git a/pdex/src/processing/mode/experimental/VariableInspector.java b/pdex/src/processing/mode/experimental/VariableInspector.java index e80f9e579..f17ef30d3 100755 --- a/pdex/src/processing/mode/experimental/VariableInspector.java +++ b/pdex/src/processing/mode/experimental/VariableInspector.java @@ -74,7 +74,7 @@ public class VariableInspector extends javax.swing.JFrame { protected List declaredThisFields; // declared i.e. non-inherited fields of this protected DebugEditor editor; // the editor protected Debugger dbg; // the debugger - protected List expandedNodes = new ArrayList(); // list of expanded tree paths. (using list to maintain the order of expansion) + protected List expandedNodes = new ArrayList<>(); // list of expanded tree paths. (using list to maintain the order of expansion) protected boolean p5mode = true; // processing / "advanced" mode flag (currently not used /** @@ -515,7 +515,7 @@ public class VariableInspector extends javax.swing.JFrame { // first remove all children of collapsed path // this makes sure children do not appear before parents in the list. // (children can't be expanded before their parents) - List removalList = new ArrayList(); + List removalList = new ArrayList<>(); for (TreePath path : expandedNodes) { if (path.getParentPath().equals(tee.getPath())) { removalList.add(path); diff --git a/pdex/src/processing/mode/experimental/VariableNode.java b/pdex/src/processing/mode/experimental/VariableNode.java index 66b0575d7..42944cdc3 100755 --- a/pdex/src/processing/mode/experimental/VariableNode.java +++ b/pdex/src/processing/mode/experimental/VariableNode.java @@ -53,7 +53,7 @@ public class VariableNode implements MutableTreeNode { protected String type; protected String name; protected Value value; - protected List children = new ArrayList(); + protected List children = new ArrayList<>(); protected MutableTreeNode parent; /** diff --git a/todo.txt b/todo.txt index bf095a65b..ce2cda767 100644 --- a/todo.txt +++ b/todo.txt @@ -1,5 +1,11 @@ 0230 pde (3.0a3) +earlier +X repo cleanup +X remove non-web stuff from web +X remove non-android stuff from android +X remove web and android from the main repo + pulls X Add polling to detect file system changes X https://github.com/processing/processing/issues/1939 @@ -9,18 +15,24 @@ X https://github.com/processing/processing/issues/632 X https://github.com/processing/processing/pull/2084 X http://code.google.com/p/processing/issues/detail?id=593 _ need to make sure the .properties files are read properly as UTF-8 +X Indent breaks when hitting enter before spaces +X https://github.com/processing/processing/issues/2004 +X https://github.com/processing/processing/pull/2690 +X support for Japanese +X https://github.com/processing/processing/pull/2688 pending _ look at the sound library https://github.com/wirsing/ProcessingSound _ sound is not yet supported on Windows -_ glw? lwjgl? retina jogl? _ make reference build process part of dist _ https://github.com/processing/processing-docs/issues/85 _ separate ant target, but only require them for dist _ as separate targets, folks can build explicitly if they'd like _ processing-docs/java_generate/ReferenceGenerator/processingrefBuild.sh _ remove reference.zip from main repo +_ clean out the repo +_ https://github.com/processing/processing/issues/1898 gsoc/help me @@ -59,12 +71,6 @@ _ display "1" is not correct in 2.1.2 _ https://github.com/processing/processing/issues/2502 _ re/move things from Google Code downloads _ https://code.google.com/p/support/wiki/DownloadsFAQ -_ clean out the repo -_ https://github.com/processing/processing/issues/1898 -_ requires re-forking, so still a ton of work -_ remove non-web stuff from web -_ remove non-android stuff from android -_ remove web and android from the main repo _ add font fixes to the rest of the API _ https://github.com/processing/processing/commit/eaff673d173b2d27f276cf5c59e3abf6c0fab86b _ g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, @@ -96,9 +102,6 @@ _ add documentation for how to run mode development from Eclipse _ implementation/changes from JDF _ modes are being loaded multiple times, which can cause trouble _ add minimum version required (or max version?) to libraries/modes/etc -_ no high-res display support for the PDE -_ PDE and sketches are 2x smaller on high-res Windows 8 machines -_ https://github.com/processing/processing/issues/2411 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -802,6 +805,8 @@ _ avoid some confusion for when describing the libraries folder to users DIST / Windows +_ PDE and sketches are 2x smaller on high-res Windows 8 machines +_ https://github.com/processing/processing/issues/2411 _ processing-java output as UTF-8 makes Windows unhappy _ https://github.com/processing/processing/issues/1633 _ does launching p5 from inside the .zip folder cause it to quit immediately? From 2749e12b682ca2442b80078cee7288bb1b5a6293 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Thu, 31 Jul 2014 21:32:12 -0400 Subject: [PATCH 007/134] remove settings that used source version 1.6 --- pdex/.settings/org.eclipse.jdt.core.prefs | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 pdex/.settings/org.eclipse.jdt.core.prefs diff --git a/pdex/.settings/org.eclipse.jdt.core.prefs b/pdex/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8000cd6ca..000000000 --- a/pdex/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 From afe7ddf90ecfbb021f08be23929c77a763a6dd80 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Fri, 1 Aug 2014 01:16:12 -0300 Subject: [PATCH 008/134] Add Spanish language --- app/src/processing/app/Language.java | 2 + .../app/languages/PDE_es.properties | 214 ++++++++++++++++++ 2 files changed, 216 insertions(+) create mode 100644 app/src/processing/app/languages/PDE_es.properties diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index d98d2eaa4..27524575a 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -44,6 +44,8 @@ public class Language { this.languages.put(Locale.GERMAN.getLanguage(), Locale.GERMAN.getDisplayLanguage(Locale.GERMAN)); // ja, Japanese this.languages.put(Locale.JAPANESE.getLanguage(), Locale.JAPANESE.getDisplayLanguage(Locale.JAPANESE)); + // es, Spanish + this.languages.put("es", Locale.forLanguageTag("es").getDisplayLanguage(Locale.forLanguageTag("es"))); // Set default language if (!this.languages.containsKey(this.language)) { diff --git a/app/src/processing/app/languages/PDE_es.properties b/app/src/processing/app/languages/PDE_es.properties new file mode 100644 index 000000000..fdafe3f6e --- /dev/null +++ b/app/src/processing/app/languages/PDE_es.properties @@ -0,0 +1,214 @@ + + +# --------------------------------------- +# Language: Spanish (es) +# --------------------------------------- + + +# --------------------------------------- +# Menu + +# | File | Edit | Sketch | Library | Tools | Help | +# | File | +menu.file = Archivo +menu.file.new = Nuevo +menu.file.open = Abrir... +menu.file.sketchbook = Sketchbook +menu.file.recent = Recientes +menu.file.examples = Ejemplos... +menu.file.close = Cerrar +menu.file.save = Guardar +menu.file.save_as = Guardar como... +menu.file.export_application = Exportar Aplicación... +menu.file.page_setup = Configurar página +menu.file.print = Imprimir... +menu.file.preferences = Preferencias... +menu.file.quit = Salir + +# | File | Edit | Sketch | Library | Tools | Help | +# | Edit | +menu.edit = Editar +menu.edit.undo = Deshacer +menu.edit.redo = Rehacer +menu.edit.cut = Cortar +menu.edit.copy = Copiar +menu.edit.copy_as_html = Copar como HTML +menu.edit.paste = Pegar +menu.edit.select_all = Seleccionar todo +menu.edit.auto_format = Autoformato +menu.edit.comment_uncomment = Comentar/Descomentar +menu.edit.increase_indent = \u2192 Aumentar indentación +menu.edit.decrease_indent = \u2190 Reducir indentación +menu.edit.find = Buscar... +menu.edit.find_next = Buscar siguiente +menu.edit.find_previous = Buscar anterior +menu.edit.use_selection_for_find = Usar selección para buscar + +# | File | Edit | Sketch | Library | Tools | Help | +# | Sketch | +menu.sketch = Sketch +menu.sketch.show_sketch_folder = Mostrar carpeta de sketches +menu.sketch.add_file = Añadir archivo + +# | File | Edit | Sketch | Library | Tools | Help | +# | Library | +menu.library = Importar biblioteca... +menu.library.add_library = Añadir biblioteca... +menu.library.contributed = Contribuidas +menu.library.no_core_libraries = el modo no tiene bibliotecas incluidas + +# | File | Edit | Sketch | Library | Tools | Help | +# | Tools | +menu.tools = Herramientas +menu.tools.color_selector = Selector de colores... +menu.tools.create_font = Crear fuente... +menu.tools.archive_sketch = Archivar sketch +menu.tools.fix_the_serial_lbrary = Corregir la biblioteca de serie +menu.tools.install_processing_java = Instalar "processing-java" +menu.tools.add_tool = Añadir herramienta... + +# | File | Edit | Sketch | Library | Tools | Help | +# | Help | +menu.help = Ayuda +menu.help.about = Acerca de Processing +menu.help.environment = Entorno +menu.help.reference = Referencia +menu.help.find_in_reference = Buscar en la referencia +menu.help.online = Online +menu.help.getting_started = Primeros Pasos +menu.help.getting_started.url = http://processing.org/learning/gettingstarted/ +menu.help.troubleshooting = Resolución de problemas +menu.help.troubleshooting.url = http://wiki.processing.org/w/Troubleshooting +menu.help.faq = Preguntas Frecuentes +menu.help.faq.url = http://wiki.processing.org/w/FAQ +menu.help.foundation = The Processing Foundation +menu.help.foundation.url = http://processing.org/foundation/ +menu.help.visit = Visitar Processing.org +menu.help.visit.url = http://processing.org/ + + +# --------------------------------------- +# Basics + +# Buttons +prompt.yes = Sí +prompt.no = No +prompt.cancel = Cancelar +prompt.ok = Aceptar +prompt.browse = Buscar +prompt.export = Exportar + + +# --------------------------------------- +# Frames + +# Open (Frame) +open = Abrir un sketch de Processing... + +# Save (Frame) +save = Guardar directorio de sketches... +save.title = Deseas guardar cambios a este sketch
antes de cerrar? +save.hint = Si no los guardas, tus cambios se perderán. +save.btn.save = Guardar +save.btn.dont_save = No guardar + +# Preferences (Frame) +preferences = Preferencias +preferences.button.width = 80 +preferences.requires_restart = requiere reiniciar Processing +preferences.sketchbook_location = Ubicación del sketchbook +preferences.language = Idioma +preferences.editor_and_console_font = Fuenta de la consola y el editor +preferences.editor_font_size = Tamaño de letra del editor +preferences.console_font_size = Tamaño de letra de la consola +preferences.background_color = Color de fondo en modo presentación +preferences.use_smooth_text = Usar texto suavizado en la ventana del editor +preferences.enable_complex_text_input = Habilitar el ingreso de caracteres complejos +preferences.enable_complex_text_input_example = ej. Japonés +preferences.continuously_check = Comprobar errores de forma continua +preferences.show_warnings = Mostrar advertencias +preferences.code_completion = Autocompletado de código +preferences.trigger_with = Activar con +preferences.cmd_space = espacio +preferences.increase_max_memory = Aumentar memoria máxima disponible a +preferences.delete_previous_folder_on_export = Eliminar directorio anterior al exportar +preferences.hide_toolbar_background_image = Ocultar imagen de fondo de la barra de herramientas +preferences.check_for_updates_on_startup = Comprobar actualizaciones al iniciar +preferences.run_sketches_on_display = Ejecutar sketches en la pantalla +preferences.run_sketches_on_display.tip = \ +Configura la pantalla donde los sketches se abren inicialmente.
\ +Como es habitual, si la ventana del sketch se mueve, se volverá a abrir
\ +en la misma ubicación. Sin embargo, al ejecutar en modo presentación
\ +(pantalla completa), esta pantalla será utilizada siempre. +preferences.automatically_associate_pde_files = Asociar automáticamente archivos .pde con Processing +preferences.launch_programs_in = Ejecutar programs en +preferences.launch_programs_in.mode = modo +preferences.file = Puedes editar otras preferencias modificando directamente el archivo +preferences.file.hint = asegúrate de que Processing está cerrado antes de editar este archivo + +# Sketchbook Location (Frame) +sketchbook_location = Select new sketchbook location + +# Export (Frame) +export = Opciones de exportación +export.platforms = Plataformas +export.options = Opciones +export.options.fullscreen = Pantalla completa (Modo Presentación) +export.options.show_stop_button = Mostrar un botón de Detener +export.description.line1 = Exportar a Aplicación crea aplicaciones ejecutables, +export.description.line2 = independientes para las plataformas seleccionadas. + +# Find (Frame) +find = Buscar +find.find = Buscar: +find.replace_with = Reemplazar con: +find.ignore_case = Ignorar mayúsculas +find.all_tabs = Todas las pestañas +find.wrap_around = Continuar buscando +find.btn.replace_all = Reemplazar todo +find.btn.replace = Reemplazar +find.btn.find_and_replace = Buscar y reemplazar +find.btn.previous = Anterior +find.btn.find = Buscar + +# Find in reference (Frame) +find_in_reference = Buscar en el manual de referencia + +# Library Manager (Frame) +library.category = Categoría: +library.filter_your_search = Filtrar tu búsqueda... + +# File (Frame) +file = Selecciona una imagen u otro archivo de datos para copiar a tu sketch + +# Create Font (Frame) +create_font = Crear fuente + +# Color Selector (Frame) +color_selector = Selector de colores + +# Archive Sketch (Frame) +archive_sketch = Archivar sketch como... + + +# --------------------------------------- +# Toolbar + +# [Run/Present] [Stop] [New] [Open] [Save] +toolbar.run = Ejecutar +toolbar.present = Presentar +toolbar.stop = Detener +toolbar.new = Nuevo +toolbar.open = Abrir +toolbar.save = Guardar +toolbar.export_application = Exportar Aplicación +toolbar.add_mode = Añadir modo... + +# [Tab1] [Tab2] [v] +editor.header.new_tab = Nueva pestaña +editor.header.rename = Renombrar +editor.header.delete = Eliminar +editor.header.previous_tab = Pestaña anterior +editor.header.next_tab = Pestaña siguiente +editor.header.delete.warning.title = No +editor.header.delete.warning.text = No puedes eliminar la última pestaña del último sketch abierto From 0da39458ce7670dc3c04dc06e6c383eb7d58ec42 Mon Sep 17 00:00:00 2001 From: AmnonOwed Date: Fri, 1 Aug 2014 11:52:45 +0200 Subject: [PATCH 009/134] Fix typo "platforms" in PDE.properties --- app/src/processing/app/languages/PDE.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/processing/app/languages/PDE.properties b/app/src/processing/app/languages/PDE.properties index cf133b207..ff8c6acd3 100644 --- a/app/src/processing/app/languages/PDE.properties +++ b/app/src/processing/app/languages/PDE.properties @@ -156,7 +156,7 @@ export.options = Options export.options.fullscreen = Full Screen (Present mode) export.options.show_stop_button = Show a Stop button export.description.line1 = Export to Application creates double-clickable, -export.description.line2 = standalone applications for the selected plaforms. +export.description.line2 = standalone applications for the selected platforms. # Find (Frame) find = Find From 57d6b214e5cf03e2b3c3be0757b7fbcc39fd8eb8 Mon Sep 17 00:00:00 2001 From: AmnonOwed Date: Fri, 1 Aug 2014 12:59:12 +0200 Subject: [PATCH 010/134] Add Dutch language --- app/src/processing/app/Language.java | 2 + .../app/languages/PDE_nl.properties | 214 ++++++++++++++++++ 2 files changed, 216 insertions(+) create mode 100644 app/src/processing/app/languages/PDE_nl.properties diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 27524575a..f32dedf45 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -46,6 +46,8 @@ public class Language { this.languages.put(Locale.JAPANESE.getLanguage(), Locale.JAPANESE.getDisplayLanguage(Locale.JAPANESE)); // es, Spanish this.languages.put("es", Locale.forLanguageTag("es").getDisplayLanguage(Locale.forLanguageTag("es"))); + // nl, Dutch, Nederlands + this.languages.put("nl", Locale.forLanguageTag("nl").getDisplayLanguage(Locale.forLanguageTag("nl"))); // Set default language if (!this.languages.containsKey(this.language)) { diff --git a/app/src/processing/app/languages/PDE_nl.properties b/app/src/processing/app/languages/PDE_nl.properties new file mode 100644 index 000000000..05932c99b --- /dev/null +++ b/app/src/processing/app/languages/PDE_nl.properties @@ -0,0 +1,214 @@ + + +# --------------------------------------- +# Language: Dutch (Nederlands) (nl) +# --------------------------------------- + + +# --------------------------------------- +# Menu + +# | File | Edit | Sketch | Library | Tools | Help | +# | File | +menu.file = Bestand +menu.file.new = Nieuw +menu.file.open = Openen... +menu.file.sketchbook = Schetsboek +menu.file.recent = Recent +menu.file.examples = Voorbeelden... +menu.file.close = Sluiten +menu.file.save = Opslaan +menu.file.save_as = Opslaan Als... +menu.file.export_application = Exporteren Applicatie... +menu.file.page_setup = Pagina Instelling +menu.file.print = Afdrukken... +menu.file.preferences = Instellingen... +menu.file.quit = Afsluiten + +# | File | Edit | Sketch | Library | Tools | Help | +# | Edit | +menu.edit = Bewerken +menu.edit.undo = Ongedaan Maken +menu.edit.redo = Opnieuw Uitvoeren +menu.edit.cut = Knippen +menu.edit.copy = Kopiëren +menu.edit.copy_as_html = Kopiëren als HTML +menu.edit.paste = Plakken +menu.edit.select_all = Alles Selecteren +menu.edit.auto_format = Automatische Opmaak +menu.edit.comment_uncomment = Commentaar Aan/Uit +menu.edit.increase_indent = \u2192 Inspringen Vergroten +menu.edit.decrease_indent = \u2190 Inspringen Verkleinen +menu.edit.find = Zoeken... +menu.edit.find_next = Volgende Zoeken +menu.edit.find_previous = Vorige Zoeken +menu.edit.use_selection_for_find = Gebruik Selectie voor Zoeken + +# | File | Edit | Sketch | Library | Tools | Help | +# | Sketch | +menu.sketch = Schets +menu.sketch.show_sketch_folder = Toon Schets Map +menu.sketch.add_file = Bestand Toevoegen... + +# | File | Edit | Sketch | Library | Tools | Help | +# | Library | +menu.library = Bibliotheek Importeren... +menu.library.add_library = Bibliotheek Toevoegen... +menu.library.contributed = Bijgedragen +menu.library.no_core_libraries = Modus heeft geen standaard bibliotheken + +# | File | Edit | Sketch | Library | Tools | Help | +# | Tools | +menu.tools = Tools +menu.tools.color_selector = Kleur Selecteren... +menu.tools.create_font = Lettertype Maken... +menu.tools.archive_sketch = Schets Archiveren +menu.tools.fix_the_serial_lbrary = Seriële Bibliotheek Herstellen +menu.tools.install_processing_java = Installeren "processing-java" +menu.tools.add_tool = Tool Toevoegen... + +# | File | Edit | Sketch | Library | Tools | Help | +# | Help | +menu.help = Help +menu.help.about = Over Processing +menu.help.environment = Programmeeromgeving +menu.help.reference = Handleiding +menu.help.find_in_reference = Zoeken in Handleiding +menu.help.online = Online +menu.help.getting_started = Om te beginnen +menu.help.getting_started.url = http://processing.org/learning/gettingstarted/ +menu.help.troubleshooting = Bekende Problemen +menu.help.troubleshooting.url = http://wiki.processing.org/w/Troubleshooting +menu.help.faq = Veelgestelde Vragen +menu.help.faq.url = http://wiki.processing.org/w/FAQ +menu.help.foundation = The Processing Foundation +menu.help.foundation.url = http://processing.org/foundation/ +menu.help.visit = Ga naar Processing.org +menu.help.visit.url = http://processing.org/ + + +# --------------------------------------- +# Basics + +# Buttons +prompt.yes = Ja +prompt.no = Nee +prompt.cancel = Annuleren +prompt.ok = OK +prompt.browse = Verkennen +prompt.export = Exporteren + + +# --------------------------------------- +# Frames + +# Open (Frame) +open = Een Processing schets openen... + +# Save (Frame) +save = Schets map opslaan als... +save.title = Wilt u wijzigingen die zijn aangebracht in deze schets
opslaan voor het sluiten? +save.hint = Als u niet opslaat, zullen uw wijzigingen verloren gaan. +save.btn.save = Opslaan +save.btn.dont_save = Niet Opslaan + +# Preferences (Frame) +preferences = Instellingen +preferences.button.width = 80 +preferences.requires_restart = herstart van Processing vereist +preferences.sketchbook_location = Sketsboek locatie +preferences.language = Taal +preferences.editor_and_console_font = Editor en Console lettertype +preferences.editor_font_size = Editor lettergrootte +preferences.console_font_size = Console lettergrootte +preferences.background_color = Achtergrond kleur bij Presenteren +preferences.use_smooth_text = Gebruik smooth text in editor window +preferences.enable_complex_text_input = Complexe tekstkarakters mogelijk maken +preferences.enable_complex_text_input_example = i.e. Japans +preferences.continuously_check = Continu controleren op fouten +preferences.show_warnings = Toon Waarschuwingen +preferences.code_completion = Automatische aanvulling +preferences.trigger_with = Activeren met +preferences.cmd_space = Spatie +preferences.increase_max_memory = Verhogen maximaal beschikbare geheugen naar +preferences.delete_previous_folder_on_export = Vorige map verwijderen bij exporteren +preferences.hide_toolbar_background_image = Verbergen tab/toolbar achtergrond +preferences.check_for_updates_on_startup = Controleren op updates bij het opstarten +preferences.run_sketches_on_display = Uitvoeren schetsen op beeld +preferences.run_sketches_on_display.tip = \ +Stelt het beeld in waarop schetsen aanvankelijk te zien zijn.
\ +Zoals gebruikelijk, als het schets venster wordt verplaatst, zal het heropenen
\ +op dezelfde locatie, echter wanneer gebruik wordt gemaakt van de Presenteer
\ +(volledig scherm) modus, zal dit beeld altijd worden gebruikt. +preferences.automatically_associate_pde_files = Automatisch associëren .pde bestanden met Processing +preferences.launch_programs_in = Programma's starten in +preferences.launch_programs_in.mode = modus +preferences.file = Meer instellingen kunnen direct worden aangepast in het bestand +preferences.file.hint = alleen aanpassen wanneer Processing niet actief is + +# Sketchbook Location (Frame) +sketchbook_location = Selecteer nieuwe schetsboek locatie + +# Export (Frame) +export = Exporteer Opties +export.platforms = Platforms +export.options = Opties +export.options.fullscreen = Volledig Scherm (Presenteer modus) +export.options.show_stop_button = Tonen Stop knop +export.description.line1 = Exporteren naar Applicatie creëert dubbel-klikbare, +export.description.line2 = zelfstandige applicaties voor de geselecteerde platforms. + +# Find (Frame) +find = Zoeken +find.find = Zoeken naar: +find.replace_with = Vervangen door: +find.ignore_case = Hoofdletter/kleine letters negeren +find.all_tabs = Alle Tabbladen +find.wrap_around = Rondgaan +find.btn.replace_all = Alles Vervangen +find.btn.replace = Vervangen +find.btn.find_and_replace = Zoeken & Vervangen +find.btn.previous = Vorige +find.btn.find = Zoeken + +# Find in reference (Frame) +find_in_reference = Zoeken in Handleiding + +# Library Manager (Frame) +library.category = Categorie: +library.filter_your_search = Filter zoekresultaten... + +# File (Frame) +file = Selecteer een bestand om te kopiëren naar uw schets + +# Create Font (Frame) +create_font = Lettertype Maken + +# Color Selector (Frame) +color_selector = Kleur Selecteren + +# Archive Sketch (Frame) +archive_sketch = Schets archiveren als... + + +# --------------------------------------- +# Toolbar + +# [Run/Present] [Stop] [New] [Open] [Save] +toolbar.run = Uitvoeren +toolbar.present = Presenteren +toolbar.stop = Stoppen +toolbar.new = Nieuw +toolbar.open = Openen +toolbar.save = Opslaan +toolbar.export_application = Exporteren Applicatie +toolbar.add_mode = Modus toevoegen... + +# [Tab1] [Tab2] [v] +editor.header.new_tab = Nieuw Tabblad +editor.header.rename = Naam wijzigen +editor.header.delete = Verwijderen +editor.header.previous_tab = Vorige Tabblad +editor.header.next_tab = Volgende Tabblad +editor.header.delete.warning.title = Ja, nee. +editor.header.delete.warning.text = U kunt het laatste tabblad van de laatst geopende schets niet verwijderen From f6981f386a1a7a39602689c22b15fb2505e93f89 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 07:13:06 -0400 Subject: [PATCH 011/134] fix indents and cleanups --- app/src/processing/app/Language.java | 274 ++++++++++++------------ app/src/processing/app/Preferences.java | 8 +- todo.txt | 4 + 3 files changed, 144 insertions(+), 142 deletions(-) diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 27524575a..9b1616a42 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -1,165 +1,163 @@ +/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + Part of the Processing project - http://processing.org + + Copyright (c) 2014 The Processing Foundation + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + package processing.app; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.io.*; import java.net.URL; import java.net.URLConnection; -import java.util.HashMap; -import java.util.Locale; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; +import java.util.*; import processing.core.PApplet; + /** * Internationalization (i18n) - * * @author Darius Morawiec */ public class Language { + static private Language instance = null; + private String language; + private HashMap languages; + private ResourceBundle bundle; + static private final String FILE = "processing.app.languages.PDE"; - private static Language instance = null; - private String language; - private HashMap languages; - private ResourceBundle bundle; - private static final String FILE = "processing.app.languages.PDE"; - private Language() { + private Language() { + // Get system language + this.language = Locale.getDefault().getLanguage(); - // Get system language - this.language = Locale.getDefault().getLanguage(); + // Set available languages + this.languages = new HashMap(); - // Set available languages - this.languages = new HashMap(); + // Language code: + // http://en.wikipedia.org/wiki/ISO_639-1 + // http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes - // Language code: - // http://en.wikipedia.org/wiki/ISO_639-1 - // http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes + // en, English, English + this.languages.put(Locale.ENGLISH.getLanguage(), Locale.ENGLISH.getDisplayLanguage(Locale.ENGLISH)); + // de, German, Deutsch + this.languages.put(Locale.GERMAN.getLanguage(), Locale.GERMAN.getDisplayLanguage(Locale.GERMAN)); + // ja, Japanese + this.languages.put(Locale.JAPANESE.getLanguage(), Locale.JAPANESE.getDisplayLanguage(Locale.JAPANESE)); + // es, Spanish + this.languages.put("es", Locale.forLanguageTag("es").getDisplayLanguage(Locale.forLanguageTag("es"))); - // en, English, English - this.languages.put(Locale.ENGLISH.getLanguage(), Locale.ENGLISH.getDisplayLanguage(Locale.ENGLISH)); - // de, German, Deutsch - this.languages.put(Locale.GERMAN.getLanguage(), Locale.GERMAN.getDisplayLanguage(Locale.GERMAN)); - // ja, Japanese - this.languages.put(Locale.JAPANESE.getLanguage(), Locale.JAPANESE.getDisplayLanguage(Locale.JAPANESE)); - // es, Spanish - this.languages.put("es", Locale.forLanguageTag("es").getDisplayLanguage(Locale.forLanguageTag("es"))); + // Set default language + if (!this.languages.containsKey(this.language)) { + this.language = "en"; + } - // Set default language - if (!this.languages.containsKey(this.language)) { - this.language = "en"; - } + // Get saved language + try { + File file = Base.getContentFile("lib/language.txt"); + if (file.exists()) { + String language = PApplet.loadStrings(file)[0]; + language = language.trim().toLowerCase(); + if (!language.equals("")) { + this.language = language; + } else { + Base.saveFile(this.language, file); + } + } + } catch (Exception e) { + e.printStackTrace(); + } - // Get saved language - try { - File file = Base.getContentFile("lib/language.txt"); - if (file.exists()) { - String language = PApplet.loadStrings(file)[0]; - language = language.trim().toLowerCase(); - if (!language.equals("")) { - this.language = language; - } else { - Base.saveFile(this.language, file); - } - } - } catch (Exception e) { - e.printStackTrace(); - } + // Get bundle with translations (processing.app.language.PDE) + this.bundle = ResourceBundle.getBundle(Language.FILE, new Locale(this.language), new UTF8Control()); + } - // Get bundle with translations (processing.app.language.PDE) - this.bundle = ResourceBundle.getBundle(Language.FILE, new Locale(this.language), new UTF8Control()); - } - /** - * Singleton constructor - * - * @return - */ - public static synchronized Language init() { - if (instance == null) { - instance = new Language(); - } - return instance; - } + /** Singleton constructor */ + static public synchronized Language init() { + if (instance == null) { + instance = new Language(); + } + return instance; + } - /** - * Get translation from bundles. - * - * @param text - * @return - */ - public static String text(String text) { - return init().bundle.getString(text); - } - /** - * Get all available languages - * - * @return - */ - public static HashMap getLanguages() { - return init().languages; - } + /** Get translation from bundles. */ + static public String text(String text) { + return init().bundle.getString(text); + } - /** - * Get current language - * - * @return - */ - public static String getLanguage() { - return init().language; - } - /** - * Set new language - * - * @param language - */ - public static void setLanguage(String language) { - try { - File file = Base.getContentFile("lib/language.txt"); - Base.saveFile(language, file); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Custom Control class for consitent encoding. - * http://stackoverflow.com/questions/4659929/how-to-use-utf-8-in-resource-properties-with-resourcebundle - */ - public class UTF8Control extends ResourceBundle.Control { - public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException,IOException { - // The below is a copy of the default implementation. - String bundleName = toBundleName(baseName, locale); - String resourceName = toResourceName(bundleName, "properties"); - ResourceBundle bundle = null; - InputStream stream = null; - if (reload) { - URL url = loader.getResource(resourceName); - if (url != null) { - URLConnection connection = url.openConnection(); - if (connection != null) { - connection.setUseCaches(false); - stream = connection.getInputStream(); - } - } - } else { - stream = loader.getResourceAsStream(resourceName); - } - if (stream != null) { - try { - // Only this line is changed to make it to read properties - // files as UTF-8. - bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8")); - } finally { - stream.close(); - } - } - return bundle; - } - } + /** Get all available languages */ + static public Map getLanguages() { + return init().languages; + } -} \ No newline at end of file + + /** Get current language */ + static public String getLanguage() { + return init().language; + } + + + /** Set new language */ + static public void setLanguage(String language) { + try { + File file = Base.getContentFile("lib/language.txt"); + Base.saveFile(language, file); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + /** + * Custom Control class for consitent encoding. + * http://stackoverflow.com/questions/4659929/how-to-use-utf-8-in-resource-properties-with-resourcebundle + */ + class UTF8Control extends ResourceBundle.Control { + public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException,IOException { + // The below is a copy of the default implementation. + String bundleName = toBundleName(baseName, locale); + String resourceName = toResourceName(bundleName, "properties"); + ResourceBundle bundle = null; + InputStream stream = null; + if (reload) { + URL url = loader.getResource(resourceName); + if (url != null) { + URLConnection connection = url.openConnection(); + if (connection != null) { + connection.setUseCaches(false); + stream = connection.getInputStream(); + } + } + } else { + stream = loader.getResourceAsStream(resourceName); + } + if (stream != null) { + try { + // Only this line is changed to make it to read properties + // files as UTF-8. + bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8")); + } finally { + stream.close(); + } + } + return bundle; + } + } +} diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 3b5f2a826..3c2a73aa1 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -293,7 +293,7 @@ public class Preferences { languageBox.add(languageLabel); languageSelectionBox = new JComboBox(); - HashMap languages = Language.getLanguages(); + Map languages = Language.getLanguages(); String[] languageSelection = new String[languages.size()]; languageSelection[0] = languages.get(Language.getLanguage()); int i = 1; @@ -807,15 +807,15 @@ public class Preferences { setBoolean("update.check", checkUpdatesBox.isSelected()); //$NON-NLS-1$ // Save Language - HashMap languages = Language.getLanguages(); + Map languages = Language.getLanguages(); String language = ""; for (Map.Entry lang : languages.entrySet()) { - if( lang.getValue().equals( String.valueOf(languageSelectionBox.getSelectedItem()) ) ){ + if (lang.getValue().equals( String.valueOf(languageSelectionBox.getSelectedItem()))) { language = lang.getKey().trim().toLowerCase(); break; } } - if(!language.equals(Language.getLanguage()) && !language.equals("")){ + if (!language.equals(Language.getLanguage()) && !language.equals("")) { Language.setLanguage(language); } diff --git a/todo.txt b/todo.txt index ce2cda767..0d3465c77 100644 --- a/todo.txt +++ b/todo.txt @@ -20,6 +20,10 @@ X https://github.com/processing/processing/issues/2004 X https://github.com/processing/processing/pull/2690 X support for Japanese X https://github.com/processing/processing/pull/2688 +X support for Spanish +X https://github.com/processing/processing/pull/2691 +X support for Dutch +X https://github.com/processing/processing/pull/2694 pending From 818e22db1bf594ff96e44aae7d9314674f4f4928 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 07:24:03 -0400 Subject: [PATCH 012/134] slightly more automatic means of adding languages --- app/src/processing/app/Language.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 3b0f3df9e..b8ac0f7dd 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -51,7 +51,21 @@ public class Language { // Language code: // http://en.wikipedia.org/wiki/ISO_639-1 // http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes - + + // List of languages in alphabetical order. New additions go here. + final String[] SUPPORTED = { + "de", // de, German, Deutsch + "en", // en, English, English + "es", // es, Spanish + "ja", // ja, Japanese + "nl", // nl, Dutch, Nederlands + }; + + for (String code : SUPPORTED) { + languages.put(code, Locale.forLanguageTag(code).getDisplayLanguage(Locale.forLanguageTag(code))); + } + + /* // en, English, English this.languages.put(Locale.ENGLISH.getLanguage(), Locale.ENGLISH.getDisplayLanguage(Locale.ENGLISH)); // de, German, Deutsch @@ -62,6 +76,7 @@ public class Language { this.languages.put("es", Locale.forLanguageTag("es").getDisplayLanguage(Locale.forLanguageTag("es"))); // nl, Dutch, Nederlands this.languages.put("nl", Locale.forLanguageTag("nl").getDisplayLanguage(Locale.forLanguageTag("nl"))); + */ // Set default language if (!this.languages.containsKey(this.language)) { From 964c535b03f033575dfd3884f7db6909a682ddf7 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 08:14:25 -0400 Subject: [PATCH 013/134] add French support (pull #2965) --- app/src/processing/app/Language.java | 1 + todo.txt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index b8ac0f7dd..99fa17e1a 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -57,6 +57,7 @@ public class Language { "de", // de, German, Deutsch "en", // en, English, English "es", // es, Spanish + "fr", // fr, French, Français, Langue française "ja", // ja, Japanese "nl", // nl, Dutch, Nederlands }; diff --git a/todo.txt b/todo.txt index 0d3465c77..31df72ed2 100644 --- a/todo.txt +++ b/todo.txt @@ -24,6 +24,8 @@ X support for Spanish X https://github.com/processing/processing/pull/2691 X support for Dutch X https://github.com/processing/processing/pull/2694 +X support for French +X https://github.com/processing/processing/pull/2695 pending From b58d55dea424999912a5aab111ddb96a1f717686 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 08:15:17 -0400 Subject: [PATCH 014/134] add French support (pull #2965) --- .../app/languages/PDE_fr.properties | 204 ++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 app/src/processing/app/languages/PDE_fr.properties diff --git a/app/src/processing/app/languages/PDE_fr.properties b/app/src/processing/app/languages/PDE_fr.properties new file mode 100644 index 000000000..96087da85 --- /dev/null +++ b/app/src/processing/app/languages/PDE_fr.properties @@ -0,0 +1,204 @@ + + +# --------------------------------------- +# Language: Français (French) (fr) +# --------------------------------------- + + +# --------------------------------------- +# Menu + +# | File | Edit | Sketch | Library | Tools | Help | +# | File | +menu.file = Fichier +menu.file.new = Nouveau +menu.file.open = Ouvrir... +menu.file.sketchbook = Sketchbook +menu.file.recent = Ouvrir récent +menu.file.examples = Exemples... +menu.file.close = Fermer +menu.file.save = Enregistrer +menu.file.save_as = Enregistrer sous... +menu.file.export_application = Exporter +menu.file.page_setup = Aperçu avant impression +menu.file.print = Imprimer... +menu.file.preferences = Préférences... +menu.file.quit = Quitter + +# | File | Edit | Sketch | Library | Tools | Help | +# | Edit | +menu.edit = Modifier +menu.edit.undo = Annuler +menu.edit.redo = Refaire +menu.edit.cut = Couper +menu.edit.copy = Copier +menu.edit.copy_as_html = Copier comme HTML +menu.edit.paste = Coller +menu.edit.select_all = Selectionner tout +menu.edit.auto_format = Mise en forme automatique +menu.edit.comment_uncomment = Commenter/Décommenter +menu.edit.increase_indent = Augmenter l'indentation +menu.edit.decrease_indent = Diminuer l'indentation +menu.edit.find = Rechercher... +menu.edit.find_next = Rechercher suivant +menu.edit.find_previous = Rechercher précédent +menu.edit.use_selection_for_find = Rechercher dans la sélection + +# | File | Edit | Sketch | Library | Tools | Help | +# | Sketch | +menu.sketch = Sketch +menu.sketch.show_sketch_folder = Afficher le dossier +menu.sketch.add_file = Ajouter un fichier... + +# | File | Edit | Sketch | Library | Tools | Help | +# | Library | +menu.library = Importer une librairie... +menu.library.add_library = Ajouter une librairie... +menu.library.contributed = Contribuées +menu.library.no_core_libraries = Ce mode n'a pas de librairies de base + +# | File | Edit | Sketch | Library | Tools | Help | +# | Tools | +menu.tools = Outils +menu.tools.color_selector = Sélecteur de couleurs... +menu.tools.create_font = Générer la police... +menu.tools.archive_sketch = Archiver le sketch... +menu.tools.fix_the_serial_lbrary = Réparer la "Serial Library"... +menu.tools.install_processing_java = Installer "processing-java"... +menu.tools.add_tool = Ajouter un outil... + +# | File | Edit | Sketch | Library | Tools | Help | +# | Help | +menu.help = Aide +menu.help.about = À propos de Processing (en) +menu.help.environment = Environement (en) +menu.help.reference = Documentation (en) +menu.help.find_in_reference = Chercher dans la documentation (en) +menu.help.online = En ligne +menu.help.getting_started = Premiers pas (en) +menu.help.troubleshooting = Dépannage (en) +menu.help.faq = Foire aux questions (en) +menu.help.foundation = "The Processing Foundation" (en) +menu.help.visit = Visiter Processing.org (en) + + +# --------------------------------------- +# Basics + +# Buttons +prompt.yes = Oui +prompt.no = Non +prompt.cancel = Annuler +prompt.ok = Ok +prompt.browse = Naviguer +prompt.export = Exporter + + +# --------------------------------------- +# Frames + +# Open (Frame) +open = Ouvrir un sketch Processing... + +# Save (Frame) +save = Enregistrer le dossier de sketch sous... +save.title = Voulez-vous enregistrer les modifications
avant de quitter? +save.hint = Si vous ne sauvegardez pas, vos modifications seront supprimées. +save.btn.save = Enregistrer +save.btn.dont_save = Ne pas enregistrer + +# Preferences (Frame) +preferences = Préférences +preferences.button.width = 110 +preferences.requires_restart = Nécessite de redémarrer Processing +preferences.sketchbook_location = Emplacement du sketchbook +preferences.language = Langue +preferences.editor_and_console_font = Police de l'éditeur et de la console +preferences.editor_font_size = Taille de police de l'éditeur +preferences.console_font_size = Taille de police de la console +preferences.background_color = Couleur d'arrière plan en mode présentation +preferences.use_smooth_text = Lissage des polices dans l'éditeur +preferences.enable_complex_text_input = Autoriser la saisie de caractères non-latins +preferences.enable_complex_text_input_example = ex.: Japonais +preferences.continuously_check = Détecter les erreurs en continu +preferences.show_warnings = Afficher les avertissements +preferences.code_completion = Autocomplétion du code +preferences.trigger_with = Forcer l'autocomplétion avec +preferences.cmd_space = Espace +preferences.increase_max_memory = Augmenter la mémoire vive disponible +preferences.delete_previous_folder_on_export = Effacer le dossier précédent lors de l'export +preferences.hide_toolbar_background_image = Masquer l'image d'arrière-plan de la barre d'outils +preferences.check_for_updates_on_startup = Vérifier les mises à jour au démarrage +preferences.run_sketches_on_display = Exécuter les sketch sur le moniteur +preferences.automatically_associate_pde_files = Ouvrir les fichiers .pde avec Processing par défaut +preferences.launch_programs_in = Lancer les programmes en +preferences.launch_programs_in.mode = mode +preferences.file = Plus de préférences peuvent être éditées dirrectement dans le fichier suivant +preferences.file.hint = fermez toutes les instances de Processing avant d'éditer les préférences + +# Sketchbook Location (Frame) +sketchbook_location = Sélectionnez l'emplacement du sketchbook + +# Export (Frame) +export = Options d'export +export.platforms = Plateformes +export.options = Options +export.options.fullscreen = Plein écran (Mode présentation) +export.options.show_stop_button = Afficher un bouton stop +export.description.line1 = “Exporter l’application” crée un exécutable +export.description.line2 = autonome pour chaque plateforme sélectionnée. + +# Find (Frame) +find = Rechercher +find.find = Rechercher: +find.replace_with = Remplacer par: +find.ignore_case = Ignorer la casse +find.all_tabs = Tous les onglets +find.wrap_around = Reprendre au début +find.btn.replace_all = Remplacer tout +find.btn.replace = Remplacer +find.btn.find_and_replace = Remplacer & rechercher +find.btn.previous = Précédent +find.btn.find = Rechercher + +# Find in reference (Frame) +find_in_reference = Chercher dans la doc (en) + +# Library Manager (Frame) +library.category = Catégorie: +library.filter_your_search = Filter la recherche... + +# File (Frame) +file = Selectionner une image ou fichier de données à ajouter au sketch + +# Create Font (Frame) +create_font = Créer la police + +# Color Selector (Frame) +color_selector = Sélecteur de couleurs + +# Archive Sketch (Frame) +archive_sketch = Archiver le sketch sous... + + +# --------------------------------------- +# Toolbar + +# [Run/Present] [Stop] [New] [Open] [Save] +toolbar.run = Exécuter +toolbar.present = Présenter +toolbar.stop = Stop +toolbar.new = Nouveau +toolbar.open = Ouvrir +toolbar.save = Enregistrer +toolbar.export_application = Exporter +toolbar.add_mode = Ajouter un mode... + +# [Tab1] [Tab2] [v] +editor.header.new_tab = Nouvel onglet +editor.header.rename = Renommer +editor.header.delete = Supprimer +editor.header.previous_tab = Onglet précédent +editor.header.next_tab = Onglet suivant +editor.header.delete.warning.title = Ouais, mais non. +editor.header.delete.warning.text = Impossible de supprimer le dernier onglet du sketch. From 359a5f3c47a156670449c14f83ba0bb9abddbccc Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Fri, 1 Aug 2014 02:32:01 -0300 Subject: [PATCH 015/134] Localize status messages and contributions panel --- app/src/processing/app/Editor.java | 32 +++++++++---------- .../app/contrib/ContributionManager.java | 3 +- .../app/contrib/ContributionPanel.java | 19 ++++++----- .../processing/app/languages/PDE.properties | 27 +++++++++++++++- 4 files changed, 53 insertions(+), 28 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 18aa9f26f..f2f2fc2b5 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -360,13 +360,13 @@ public abstract class Editor extends JFrame implements RunnerListener { } if (successful == 0) { - statusError("No files were added to the sketch."); + statusError(Language.text("editor.status.drag_and_drop.no_files_added")); } else if (successful == 1) { - statusNotice("One file added to the sketch."); + statusNotice(Language.text("editor.status.drag_and_drop.one_file_added")); } else { - statusNotice(successful + " files added to the sketch."); + statusNotice(String.format(Language.text("editor.status.drag_and_drop.n_files_added"), successful)); } return true; } @@ -1852,7 +1852,7 @@ public abstract class Editor extends JFrame implements RunnerListener { } if (formattedText.equals(source)) { - statusNotice("No changes necessary for Auto Format."); + statusNotice(Language.text("editor.status.autoformat.no_changes")); } else { // replace with new bootiful text // selectionEnd hopefully at least in the neighborhood @@ -1876,7 +1876,7 @@ public abstract class Editor extends JFrame implements RunnerListener { } getSketch().setModified(true); // mark as finished - statusNotice("Auto Format finished."); + statusNotice(Language.text("editor.status.autoformat.finished")); } } catch (final Exception e) { @@ -2090,9 +2090,9 @@ public abstract class Editor extends JFrame implements RunnerListener { } else { String text = textarea.getSelectedText().trim(); if (text.length() == 0) { - statusNotice("First select a word to find in the reference."); + statusNotice(Language.text("editor.status.find_reference.select_word_first")); } else { - statusNotice("No reference available for \"" + text + "\""); + statusNotice(String.format(Language.text("editor.status.find_reference.not_available"), text)); } } } @@ -2525,10 +2525,10 @@ public abstract class Editor extends JFrame implements RunnerListener { protected void handleSaveImpl() { - statusNotice("Saving..."); + statusNotice(Language.text("editor.status.saving")); try { if (sketch.save()) { - statusNotice("Done Saving."); + statusNotice(Language.text("editor.status.saving.done")); } else { statusEmpty(); } @@ -2546,7 +2546,7 @@ public abstract class Editor extends JFrame implements RunnerListener { public boolean handleSaveAs() { - statusNotice("Saving..."); + statusNotice(Language.text("editor.status.saving")); try { if (sketch.saveAs()) { // statusNotice("Done Saving."); @@ -2558,7 +2558,7 @@ public abstract class Editor extends JFrame implements RunnerListener { // only one who knows whether something was renamed. //sketchbook.rebuildMenusAsync(); } else { - statusNotice("Save Canceled."); + statusNotice(Language.text("editor.status.saving.canceled")); return false; } } catch (Exception e) { @@ -2589,7 +2589,7 @@ public abstract class Editor extends JFrame implements RunnerListener { * Handler for File → Print. */ public void handlePrint() { - statusNotice("Printing..."); + statusNotice(Language.text("editor.status.printing")); //printerJob = null; if (printerJob == null) { printerJob = PrinterJob.getPrinterJob(); @@ -2606,14 +2606,14 @@ public abstract class Editor extends JFrame implements RunnerListener { if (printerJob.printDialog()) { try { printerJob.print(); - statusNotice("Done printing."); + statusNotice(Language.text("editor.status.printing.done")); } catch (PrinterException pe) { - statusError("Error while printing."); + statusError(Language.text("editor.status.printing.error")); pe.printStackTrace(); } } else { - statusNotice("Printing canceled."); + statusNotice(Language.text("editor.status.printing.canceled")); } //printerJob = null; // clear this out? } @@ -2906,4 +2906,4 @@ public abstract class Editor extends JFrame implements RunnerListener { super.show(component, x, y); } } -} \ No newline at end of file +} diff --git a/app/src/processing/app/contrib/ContributionManager.java b/app/src/processing/app/contrib/ContributionManager.java index 262b09573..f39d04606 100644 --- a/app/src/processing/app/contrib/ContributionManager.java +++ b/app/src/processing/app/contrib/ContributionManager.java @@ -26,6 +26,7 @@ import java.net.*; import processing.app.Base; import processing.app.Editor; +import processing.app.Language; public class ContributionManager { @@ -64,7 +65,7 @@ public class ContributionManager { // TODO this is often -1, may need to set progress to indeterminate int fileSize = conn.getContentLength(); // System.out.println("file size is " + fileSize); - progress.startTask("Downloading", fileSize); + progress.startTask(Language.text("contributions.progress.downloading"), fileSize); InputStream in = conn.getInputStream(); FileOutputStream out = new FileOutputStream(dest); diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index c4a2763b5..07f76e472 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -40,6 +40,7 @@ import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.StyleSheet; import processing.app.Base; +import processing.app.Language; /** @@ -433,14 +434,14 @@ class ContributionPanel extends JPanel { if (contrib.isDeletionFlagged()) { installRemoveButton.addActionListener(undoActionListener); - installRemoveButton.setText("Undo"); + installRemoveButton.setText(Language.text("contributions.undo")); } else if (contrib.isInstalled()) { installRemoveButton.addActionListener(removeActionListener); - installRemoveButton.setText("Remove"); + installRemoveButton.setText(Language.text("contributions.remove")); installRemoveButton.setVisible(true); } else { installRemoveButton.addActionListener(installActionListener); - installRemoveButton.setText("Install"); + installRemoveButton.setText(Language.text("contributions.install")); } contextMenu.removeAll(); @@ -456,9 +457,7 @@ class ContributionPanel extends JPanel { private void installContribution(AvailableContribution info) { if (info.link == null) { - listPanel.contribManager.status.setErrorMessage("Your operating system " - + "doesn't appear to be supported. You should visit the " - + info.getType() + "'s library for more info."); + listPanel.contribManager.status.setErrorMessage(String.format(Language.text("contributions.unsupported_operating_system"), info.getType())); } else { installContribution(info, info.link); } @@ -485,7 +484,7 @@ class ContributionPanel extends JPanel { installRemoveButton.setEnabled(true); if (isError()) { - listPanel.contribManager.status.setErrorMessage("An error occured while downloading the contribution."); + listPanel.contribManager.status.setErrorMessage(Language.text("contributions.download_error")); } } }; @@ -520,7 +519,7 @@ class ContributionPanel extends JPanel { protected void resetInstallProgressBarState() { - installProgressBar.setString("Starting"); + installProgressBar.setString(Language.text("contributions.progress.starting")); installProgressBar.setIndeterminate(false); installProgressBar.setValue(0); installProgressBar.setVisible(false); @@ -540,7 +539,7 @@ class ContributionPanel extends JPanel { if (contrib != null && !contrib.getType().requiresRestart()) { updateButton.setVisible(isSelected() && contribListing.hasUpdates(contrib)); } - installRemoveButton.setVisible(isSelected() || installRemoveButton.getText().equals("Remove")); + installRemoveButton.setVisible(isSelected() || installRemoveButton.getText().equals(Language.text("contributions.remove"))); // for (JTextPane textPane : headerPaneSet) { { @@ -694,4 +693,4 @@ class ContributionPanel extends JPanel { } } } -} \ No newline at end of file +} diff --git a/app/src/processing/app/languages/PDE.properties b/app/src/processing/app/languages/PDE.properties index cf133b207..661feb2f0 100644 --- a/app/src/processing/app/languages/PDE.properties +++ b/app/src/processing/app/languages/PDE.properties @@ -211,4 +211,29 @@ editor.header.delete = Delete editor.header.previous_tab = Previous Tab editor.header.next_tab = Next Tab editor.header.delete.warning.title = Yeah, no. -editor.header.delete.warning.text = You can't delete the last tab of the last open sketch. \ No newline at end of file +editor.header.delete.warning.text = You can't delete the last tab of the last open sketch. + +editor.status.autoformat.no_changes = No changes necessary for Auto Format. +editor.status.autoformat.finished = Auto Format finished. +editor.status.find_reference.select_word_first = First select a word to find in the reference. +editor.status.find_reference.not_available = No reference available for "%s". +editor.status.drag_and_drop.no_files_added = No files were added to the sketch. +editor.status.drag_and_drop.one_file_added = One file added to the sketch. +editor.status.drag_and_drop.n_files_added = %d files added to the sketch. +editor.status.saving = Saving... +editor.status.saving.done = Done saving. +editor.status.saving.canceled = Save canceled. +editor.status.printing = Printing... +editor.status.printing.done = Done printing. +editor.status.printing.error = Error while printing. +editor.status.printing.canceled = Printing canceled. + +# --------------------------------------- +# Contribution Panel +contributions.undo = Undo +contributions.remove = Remove +contributions.install = Install +contributions.progress.starting = Starting +contributions.progress.downloading = Downloading +contributions.download_error = An error occured while downloading the contribution. +contributions.unsupported_operating_system = Your operating system doesn't appear to be supported. You should visit the %s's library for more info. From 0e127e69eaca3a908809aaef0f717edb02f0c8db Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Fri, 1 Aug 2014 09:27:24 -0300 Subject: [PATCH 016/134] Disable file drag & drop for read-only sketches --- app/src/processing/app/Editor.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 18aa9f26f..9ca7d79e9 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -313,15 +313,20 @@ public abstract class Editor extends JFrame implements RunnerListener { * "Sketch → Add File" for each file. */ class FileDropHandler extends TransferHandler { - public boolean canImport(JComponent dest, DataFlavor[] flavors) { - return true; + public boolean canImport(TransferHandler.TransferSupport support) { + return !sketch.isReadOnly(); } @SuppressWarnings("unchecked") - public boolean importData(JComponent src, Transferable transferable) { + public boolean importData(TransferHandler.TransferSupport support) { int successful = 0; + if (!canImport(support)) { + return false; + } + try { + Transferable transferable = support.getTransferable(); DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String"); @@ -2906,4 +2911,4 @@ public abstract class Editor extends JFrame implements RunnerListener { super.show(component, x, y); } } -} \ No newline at end of file +} From f3bfe45d7188ea0dd771324ce13c4f777b6ce450 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 09:37:36 -0400 Subject: [PATCH 017/134] add notes for pull requests that have been integrated --- done.txt | 2 ++ todo.txt | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/done.txt b/done.txt index ba69845aa..5d1633ed1 100644 --- a/done.txt +++ b/done.txt @@ -85,6 +85,8 @@ o add spaces to the end of the text? X seems to have fixed itself in newer Java releases X implement Windows menu in the PDE X https://github.com/processing/processing/issues/584 +X Auto Format: Switch block cases not indented +X https://github.com/processing/processing/issues/1042 0228 pde (3.0a1) diff --git a/todo.txt b/todo.txt index 31df72ed2..8407725b8 100644 --- a/todo.txt +++ b/todo.txt @@ -26,7 +26,11 @@ X support for Dutch X https://github.com/processing/processing/pull/2694 X support for French X https://github.com/processing/processing/pull/2695 - +X Localize status messages and contributions panel +X https://github.com/processing/processing/pull/2696 +X prevent adding files to read-only sketches +X https://github.com/processing/processing/issues/2459 +X https://github.com/processing/processing/pull/2697 pending _ look at the sound library https://github.com/wirsing/ProcessingSound From 7122fd7405ccdb9ad702134f75fd14259c57b6d8 Mon Sep 17 00:00:00 2001 From: bgc Date: Fri, 1 Aug 2014 16:01:24 +0100 Subject: [PATCH 018/134] Create PDE_pt.properties Initial translation. not yet finished. --- .../app/languages/PDE_pt.properties | 239 ++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 app/src/processing/app/languages/PDE_pt.properties diff --git a/app/src/processing/app/languages/PDE_pt.properties b/app/src/processing/app/languages/PDE_pt.properties new file mode 100644 index 000000000..3532fdd03 --- /dev/null +++ b/app/src/processing/app/languages/PDE_pt.properties @@ -0,0 +1,239 @@ + + +# --------------------------------------- +# Language: English (en) (default) +# --------------------------------------- + + +# --------------------------------------- +# Menu + +# | File | Edit | Sketch | Library | Tools | Help | +# | File | +menu.file = Arquivo +menu.file.new = Novo +menu.file.open = Abrir... +menu.file.sketchbook = Sketchbook +menu.file.recent = Recentes +menu.file.examples = Exemplos... +menu.file.close = Fechar +menu.file.save = Guardar +menu.file.save_as = Guardar Como... +menu.file.export_application = Exportar Applicação... +menu.file.page_setup = Configurar Página +menu.file.print = Imprimir... +menu.file.preferences = Preferências... +menu.file.quit = Sair + +# | File | Edit | Sketch | Library | Tools | Help | +# | Edit | +menu.edit = Editar +menu.edit.undo = Undo +menu.edit.redo = Redo +menu.edit.cut = Cortar +menu.edit.copy = Copiar +menu.edit.copy_as_html = Copiar como HTML +menu.edit.paste = Colar +menu.edit.select_all = Seleccionar Tudo +menu.edit.auto_format = Auto Formatar +menu.edit.comment_uncomment = Comentar/Descomentar +menu.edit.increase_indent = \u2192 Aumentar Indentação +menu.edit.decrease_indent = \u2190 Diminuir Indentação +menu.edit.find = Procurar... +menu.edit.find_next = Procurar Seguinte +menu.edit.find_previous = Procurar Anterior +menu.edit.use_selection_for_find = Usar Selecção para Procurar + +# | File | Edit | Sketch | Library | Tools | Help | +# | Sketch | +menu.sketch = Sketch +menu.sketch.show_sketch_folder = Ver Pasta de Sketch +menu.sketch.add_file = Adicionar Ficheiro... + +# | File | Edit | Sketch | Library | Tools | Help | +# | Library | +menu.library = Importar Biblioteca... +menu.library.add_library = Adicionar Biblioteca... +menu.library.contributed = Contribuidas +menu.library.no_core_libraries = O modo não tem bibliotecas incluídas + +# | File | Edit | Sketch | Library | Tools | Help | +# | Tools | +menu.tools = Ferramentas +menu.tools.color_selector = Selector de Côr... +menu.tools.create_font = Criar Fonte... +menu.tools.archive_sketch = Arquivar Sketch +menu.tools.fix_the_serial_lbrary = Corrijir a Biblioteca Serial +menu.tools.install_processing_java = Instalar "processing-java" +menu.tools.add_tool = Adicionar Ferramenta... + +# | File | Edit | Sketch | Library | Tools | Help | +# | Help | +menu.help = Ajuda +menu.help.about = Acerca do Processing +menu.help.environment = Ambiente +menu.help.reference = Referência +menu.help.find_in_reference = Procurar na Referencia +menu.help.online = Online +menu.help.getting_started = Primeiros Passos +menu.help.getting_started.url = http://processing.org/learning/gettingstarted/ +menu.help.troubleshooting = Resolução de Problemas +menu.help.troubleshooting.url = http://wiki.processing.org/w/Troubleshooting +menu.help.faq = Perguntas Mais Frequentes +menu.help.faq.url = http://wiki.processing.org/w/FAQ +menu.help.foundation = A Processing Foundation +menu.help.foundation.url = http://processing.org/foundation/ +menu.help.visit = Visitar Processing.org +menu.help.visit.url = http://processing.org/ + + +# --------------------------------------- +# Basics + +# Buttons +prompt.yes = Sim +prompt.no = Não +prompt.cancel = Cancelar +prompt.ok = OK +prompt.browse = Procurar +prompt.export = Exportar + + +# --------------------------------------- +# Frames + +# Open (Frame) +open = Abrir um sketch de Processing... + +# Save (Frame) +save = Guardar pasta do sketch como... +save.title = Deseja guardar as alterções a este sketch
antes de fechar? +save.hint = Se não guardar as suas alterações serão perdidas. +save.btn.save = Guardar +save.btn.dont_save = Não Guardar + +# Preferences (Frame) +preferences = Preferencias +preferences.button.width = 80 +preferences.requires_restart = requer reiniciar o Processing +preferences.sketchbook_location = Localização do Sketchook +preferences.language = Língua +preferences.editor_and_console_font = Fonte do Editor e da Consola +preferences.editor_font_size = Tamanho da fonte do Editor +preferences.console_font_size = Tamanho da fonte da Consola +preferences.background_color = Cor de fundo em modo de Apresentação +preferences.use_smooth_text = Utilizar texto suavizado na janela do editor +preferences.enable_complex_text_input = Activar inserção de caracteres complexos +preferences.enable_complex_text_input_example = ex. Japonês +preferences.continuously_check = Verificação contínua de erros +preferences.show_warnings = Mostrar avisos +preferences.code_completion = Auto-completar de código +preferences.trigger_with = Activar com +preferences.cmd_space = espaço +preferences.increase_max_memory = Aumentar tamanho máximo de memória para +preferences.delete_previous_folder_on_export = Apagar pasta anterior ao exportar +preferences.hide_toolbar_background_image = Esconder imagem de fundo da Aba/Aba de ferramentas +preferences.check_for_updates_on_startup = Verificar por actualizações ao iniciar +preferences.run_sketches_on_display = Executar sketches na janela +preferences.run_sketches_on_display.tip = \ +Sets the display where sketches are initially placed.
\ +As usual, if the sketch window is moved, it will re-open
\ +at the same location, however when running in present
\ +(full screen) mode, this display will always be used. +preferences.automatically_associate_pde_files = Automatically associate .pde files with Processing +preferences.launch_programs_in = Launch programs in +preferences.launch_programs_in.mode = mode +preferences.file = More preferences can be edited directly in the file +preferences.file.hint = edit only when Processing is not running + +# Sketchbook Location (Frame) +sketchbook_location = Select new sketchbook location + +# Export (Frame) +export = Export Options +export.platforms = Platforms +export.options = Options +export.options.fullscreen = Full Screen (Present mode) +export.options.show_stop_button = Show a Stop button +export.description.line1 = Export to Application creates double-clickable, +export.description.line2 = standalone applications for the selected platforms. + +# Find (Frame) +find = Find +find.find = Find: +find.replace_with = Replace with: +find.ignore_case = Ignore Case +find.all_tabs = All Tabs +find.wrap_around = Wrap Around +find.btn.replace_all = Replace All +find.btn.replace = Replace +find.btn.find_and_replace = Find & Replace +find.btn.previous = Previous +find.btn.find = Find + +# Find in reference (Frame) +find_in_reference = Find in Reference + +# Library Manager (Frame) +library.category = Category: +library.filter_your_search = Filter your search... + +# File (Frame) +file = Select an image or other data file to copy to your sketch + +# Create Font (Frame) +create_font = Create Font + +# Color Selector (Frame) +color_selector = Color Selector + +# Archive Sketch (Frame) +archive_sketch = Archive sketch as... + + +# --------------------------------------- +# Toolbar + +# [Run/Present] [Stop] [New] [Open] [Save] +toolbar.run = Run +toolbar.present = Present +toolbar.stop = Stop +toolbar.new = New +toolbar.open = Open +toolbar.save = Save +toolbar.export_application = Export Application +toolbar.add_mode = Add mode... + +# [Tab1] [Tab2] [v] +editor.header.new_tab = New Tab +editor.header.rename = Rename +editor.header.delete = Delete +editor.header.previous_tab = Previous Tab +editor.header.next_tab = Next Tab +editor.header.delete.warning.title = Yeah, no. +editor.header.delete.warning.text = You can't delete the last tab of the last open sketch. + +editor.status.autoformat.no_changes = No changes necessary for Auto Format. +editor.status.autoformat.finished = Auto Format finished. +editor.status.find_reference.select_word_first = First select a word to find in the reference. +editor.status.find_reference.not_available = No reference available for "%s". +editor.status.drag_and_drop.no_files_added = No files were added to the sketch. +editor.status.drag_and_drop.one_file_added = One file added to the sketch. +editor.status.drag_and_drop.n_files_added = %d files added to the sketch. +editor.status.saving = Saving... +editor.status.saving.done = Done saving. +editor.status.saving.canceled = Save canceled. +editor.status.printing = Printing... +editor.status.printing.done = Done printing. +editor.status.printing.error = Error while printing. +editor.status.printing.canceled = Printing canceled. + +# --------------------------------------- +# Contribution Panel +contributions.undo = Undo +contributions.remove = Remove +contributions.install = Install +contributions.progress.starting = Starting +contributions.progress.downloading = Downloading +contributions.download_error = An error occured while downloading the contribution. +contributions.unsupported_operating_system = Your operating system doesn't appear to be supported. You should visit the %s's library for more info. From f62bf0c2ef413fd042211ffb92f97fc92bd5a09d Mon Sep 17 00:00:00 2001 From: bgc Date: Fri, 1 Aug 2014 16:22:49 +0100 Subject: [PATCH 019/134] Update PDE_pt.properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completada a tradução. Falta revisão. --- .../app/languages/PDE_pt.properties | 140 +++++++++--------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/app/src/processing/app/languages/PDE_pt.properties b/app/src/processing/app/languages/PDE_pt.properties index 3532fdd03..7cae63af3 100644 --- a/app/src/processing/app/languages/PDE_pt.properties +++ b/app/src/processing/app/languages/PDE_pt.properties @@ -134,106 +134,106 @@ preferences.increase_max_memory = Aumentar tamanho máximo de memória para preferences.delete_previous_folder_on_export = Apagar pasta anterior ao exportar preferences.hide_toolbar_background_image = Esconder imagem de fundo da Aba/Aba de ferramentas preferences.check_for_updates_on_startup = Verificar por actualizações ao iniciar -preferences.run_sketches_on_display = Executar sketches na janela +preferences.run_sketches_on_display = Executar sketches no ecrã preferences.run_sketches_on_display.tip = \ -Sets the display where sketches are initially placed.
\ -As usual, if the sketch window is moved, it will re-open
\ -at the same location, however when running in present
\ -(full screen) mode, this display will always be used. -preferences.automatically_associate_pde_files = Automatically associate .pde files with Processing -preferences.launch_programs_in = Launch programs in -preferences.launch_programs_in.mode = mode -preferences.file = More preferences can be edited directly in the file -preferences.file.hint = edit only when Processing is not running +Configura o ecrã onde os sketches se abrem inicialmente.
\ +Como habitual, ao mover a janela do sketch, esta volta a abrir
\ +na mesma localização. No entanto, quando em modo de apresentação
\ +(ecrã inteiro), este ecrã será sempre utilizado. +preferences.automatically_associate_pde_files = Automaticamente associar ficheiros .pde com o Processing +preferences.launch_programs_in = Executar aplicações em +preferences.launch_programs_in.mode = modo +preferences.file = Mais preferências podem ser configuradas directamente no ficheiro +preferences.file.hint = editar apenas quando o Processing não está a ser executado # Sketchbook Location (Frame) -sketchbook_location = Select new sketchbook location +sketchbook_location = Escolha a nova loclização do sketchbook # Export (Frame) -export = Export Options -export.platforms = Platforms -export.options = Options -export.options.fullscreen = Full Screen (Present mode) -export.options.show_stop_button = Show a Stop button -export.description.line1 = Export to Application creates double-clickable, -export.description.line2 = standalone applications for the selected platforms. +export = Opções de Exportação +export.platforms = Plataformas +export.options = Opções +export.options.fullscreen = Ecrã Inteiro (Modo de Apresentação) +export.options.show_stop_button = Mostrar botão de Parar +export.description.line1 = Exportar para Aplicação cria uma aplicação executavél, +export.description.line2 = para as plataformas seleccionadas. # Find (Frame) -find = Find -find.find = Find: -find.replace_with = Replace with: -find.ignore_case = Ignore Case -find.all_tabs = All Tabs -find.wrap_around = Wrap Around -find.btn.replace_all = Replace All -find.btn.replace = Replace -find.btn.find_and_replace = Find & Replace -find.btn.previous = Previous -find.btn.find = Find +find = Procurar +find.find = Procurar: +find.replace_with = Substituir por: +find.ignore_case = Ignorar Caixa +find.all_tabs = Todas as Abas +find.wrap_around = Continuar desde início +find.btn.replace_all = Substituir Todas +find.btn.replace = Substituir +find.btn.find_and_replace = Procurar e Substituir +find.btn.previous = Anterior +find.btn.find = Seguinte # Find in reference (Frame) -find_in_reference = Find in Reference +find_in_reference = Procurar na Referência # Library Manager (Frame) -library.category = Category: -library.filter_your_search = Filter your search... +library.category = Categoria: +library.filter_your_search = Filtrar a sua procura... # File (Frame) -file = Select an image or other data file to copy to your sketch +file = Seleccionar uma imagem ou outro ficheiro de dados para copiar para o sketch # Create Font (Frame) -create_font = Create Font +create_font = Criar Fonte # Color Selector (Frame) -color_selector = Color Selector +color_selector = Selector de Côr # Archive Sketch (Frame) -archive_sketch = Archive sketch as... +archive_sketch = Arquivar sketch como... # --------------------------------------- # Toolbar # [Run/Present] [Stop] [New] [Open] [Save] -toolbar.run = Run -toolbar.present = Present -toolbar.stop = Stop -toolbar.new = New -toolbar.open = Open -toolbar.save = Save -toolbar.export_application = Export Application -toolbar.add_mode = Add mode... +toolbar.run = Executar +toolbar.present = Apresentar +toolbar.stop = Parar +toolbar.new = Novo +toolbar.open = Abrir +toolbar.save = Guardr +toolbar.export_application = Exportar Aplicação +toolbar.add_mode = Adicionar modo... # [Tab1] [Tab2] [v] -editor.header.new_tab = New Tab -editor.header.rename = Rename -editor.header.delete = Delete -editor.header.previous_tab = Previous Tab -editor.header.next_tab = Next Tab -editor.header.delete.warning.title = Yeah, no. -editor.header.delete.warning.text = You can't delete the last tab of the last open sketch. +editor.header.new_tab = Nova Aba +editor.header.rename = Renomear +editor.header.delete = Apagar +editor.header.previous_tab = Aba Anterior +editor.header.next_tab = Aba Seguinte +editor.header.delete.warning.title = Yah, não. +editor.header.delete.warning.text = Não pode apagar a última aba do último sketch aberto. -editor.status.autoformat.no_changes = No changes necessary for Auto Format. -editor.status.autoformat.finished = Auto Format finished. -editor.status.find_reference.select_word_first = First select a word to find in the reference. -editor.status.find_reference.not_available = No reference available for "%s". -editor.status.drag_and_drop.no_files_added = No files were added to the sketch. -editor.status.drag_and_drop.one_file_added = One file added to the sketch. -editor.status.drag_and_drop.n_files_added = %d files added to the sketch. -editor.status.saving = Saving... -editor.status.saving.done = Done saving. -editor.status.saving.canceled = Save canceled. -editor.status.printing = Printing... -editor.status.printing.done = Done printing. -editor.status.printing.error = Error while printing. -editor.status.printing.canceled = Printing canceled. +editor.status.autoformat.no_changes = Não foram necessárias alterações para a Auto Formatação. +editor.status.autoformat.finished = Auto Formatação completa. +editor.status.find_reference.select_word_first = Primeiro escolha uma palavra para procurar na referência. +editor.status.find_reference.not_available = Não existe refrência disponivel para "%s". +editor.status.drag_and_drop.no_files_added = Nenhuns ficheiros foram adicionados ao sketch. +editor.status.drag_and_drop.one_file_added = Um ficheiro adicionado ao sketch. +editor.status.drag_and_drop.n_files_added = %d ficheiros adicionados ao sketch. +editor.status.saving = A Guardar... +editor.status.saving.done = Guardado com sucesso. +editor.status.saving.canceled = Guardar cancelado. +editor.status.printing = A imprimir... +editor.status.printing.done = Impresso com sucesso. +editor.status.printing.error = Erro a imprimir. +editor.status.printing.canceled = Impressão cancelada. # --------------------------------------- # Contribution Panel contributions.undo = Undo contributions.remove = Remove -contributions.install = Install -contributions.progress.starting = Starting -contributions.progress.downloading = Downloading -contributions.download_error = An error occured while downloading the contribution. -contributions.unsupported_operating_system = Your operating system doesn't appear to be supported. You should visit the %s's library for more info. +contributions.install = Instalar +contributions.progress.starting = A iniciar +contributions.progress.downloading = A descarregar +contributions.download_error = Ocorreu um erro a descarregar a contribuição. +contributions.unsupported_operating_system = O seu sistema operativo não parece ser suportado. Deve visitar a biblioteca %s para mais informação. From 583856d9488da88ae2b35afc53319b8543d7a448 Mon Sep 17 00:00:00 2001 From: Raphael de Courville Date: Fri, 1 Aug 2014 17:28:44 +0200 Subject: [PATCH 020/134] Fixed typo --- app/src/processing/app/languages/PDE_fr.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/processing/app/languages/PDE_fr.properties b/app/src/processing/app/languages/PDE_fr.properties index 96087da85..13c051890 100644 --- a/app/src/processing/app/languages/PDE_fr.properties +++ b/app/src/processing/app/languages/PDE_fr.properties @@ -166,7 +166,7 @@ find_in_reference = Chercher dans la doc (en) # Library Manager (Frame) library.category = Catégorie: -library.filter_your_search = Filter la recherche... +library.filter_your_search = Filtrer la recherche... # File (Frame) file = Selectionner une image ou fichier de données à ajouter au sketch From abbd0172fbfa59785ff9238a97d0c08b9f707705 Mon Sep 17 00:00:00 2001 From: bgc Date: Fri, 1 Aug 2014 16:41:20 +0100 Subject: [PATCH 021/134] Update PDE_pt.properties Undo/Redo translated. Final verification needed --- app/src/processing/app/languages/PDE_pt.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/languages/PDE_pt.properties b/app/src/processing/app/languages/PDE_pt.properties index 7cae63af3..92be82135 100644 --- a/app/src/processing/app/languages/PDE_pt.properties +++ b/app/src/processing/app/languages/PDE_pt.properties @@ -28,8 +28,8 @@ menu.file.quit = Sair # | File | Edit | Sketch | Library | Tools | Help | # | Edit | menu.edit = Editar -menu.edit.undo = Undo -menu.edit.redo = Redo +menu.edit.undo = Desfazer +menu.edit.redo = Refazer menu.edit.cut = Cortar menu.edit.copy = Copiar menu.edit.copy_as_html = Copiar como HTML @@ -230,8 +230,8 @@ editor.status.printing.canceled = Impressão cancelada. # --------------------------------------- # Contribution Panel -contributions.undo = Undo -contributions.remove = Remove +contributions.undo = Desfazer +contributions.remove = Refazer contributions.install = Instalar contributions.progress.starting = A iniciar contributions.progress.downloading = A descarregar From b11d8117fc4cdf9309b09b12d8a53105b5a278d6 Mon Sep 17 00:00:00 2001 From: bgc Date: Fri, 1 Aug 2014 16:42:04 +0100 Subject: [PATCH 022/134] Update PDE_pt.properties --- app/src/processing/app/languages/PDE_pt.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/processing/app/languages/PDE_pt.properties b/app/src/processing/app/languages/PDE_pt.properties index 92be82135..f4723de9d 100644 --- a/app/src/processing/app/languages/PDE_pt.properties +++ b/app/src/processing/app/languages/PDE_pt.properties @@ -1,7 +1,7 @@ # --------------------------------------- -# Language: English (en) (default) +# Language: Portuguese (pt) # --------------------------------------- From f78234ba5b7bbb733e25b7c4a31e6f5fc9573b4a Mon Sep 17 00:00:00 2001 From: bgc Date: Fri, 1 Aug 2014 16:45:06 +0100 Subject: [PATCH 023/134] Update Language.java --- app/src/processing/app/Language.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 99fa17e1a..15ae9b685 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -60,6 +60,7 @@ public class Language { "fr", // fr, French, Français, Langue française "ja", // ja, Japanese "nl", // nl, Dutch, Nederlands + "pt", //pt, Portuguese }; for (String code : SUPPORTED) { @@ -77,6 +78,9 @@ public class Language { this.languages.put("es", Locale.forLanguageTag("es").getDisplayLanguage(Locale.forLanguageTag("es"))); // nl, Dutch, Nederlands this.languages.put("nl", Locale.forLanguageTag("nl").getDisplayLanguage(Locale.forLanguageTag("nl"))); + // pt, Portuguese + this.languages.put("pt", Locale.forLanguageTag("pt").getDisplayLanguage(Locale.forLanguageTag("pt"))); + */ // Set default language From 0b5319104aa29d887a011fcf81ae1c50a95b1b3d Mon Sep 17 00:00:00 2001 From: bgc Date: Fri, 1 Aug 2014 16:51:36 +0100 Subject: [PATCH 024/134] Update PDE_pt.properties Fixed typos. --- app/src/processing/app/languages/PDE_pt.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/languages/PDE_pt.properties b/app/src/processing/app/languages/PDE_pt.properties index f4723de9d..20932a81c 100644 --- a/app/src/processing/app/languages/PDE_pt.properties +++ b/app/src/processing/app/languages/PDE_pt.properties @@ -73,7 +73,7 @@ menu.help = Ajuda menu.help.about = Acerca do Processing menu.help.environment = Ambiente menu.help.reference = Referência -menu.help.find_in_reference = Procurar na Referencia +menu.help.find_in_reference = Procurar na Referência menu.help.online = Online menu.help.getting_started = Primeiros Passos menu.help.getting_started.url = http://processing.org/learning/gettingstarted/ @@ -113,7 +113,7 @@ save.btn.save = Guardar save.btn.dont_save = Não Guardar # Preferences (Frame) -preferences = Preferencias +preferences = Preferências preferences.button.width = 80 preferences.requires_restart = requer reiniciar o Processing preferences.sketchbook_location = Localização do Sketchook @@ -121,7 +121,7 @@ preferences.language = Língua preferences.editor_and_console_font = Fonte do Editor e da Consola preferences.editor_font_size = Tamanho da fonte do Editor preferences.console_font_size = Tamanho da fonte da Consola -preferences.background_color = Cor de fundo em modo de Apresentação +preferences.background_color = Côr de fundo em modo de Apresentação preferences.use_smooth_text = Utilizar texto suavizado na janela do editor preferences.enable_complex_text_input = Activar inserção de caracteres complexos preferences.enable_complex_text_input_example = ex. Japonês From 2b334c8b91d46ea18dadb50bb59aef476f9095cf Mon Sep 17 00:00:00 2001 From: Joel Moniz Date: Thu, 19 Jun 2014 14:10:10 +0530 Subject: [PATCH 025/134] Modes now can be removed without restart --- app/src/processing/app/Mode.java | 1 + .../app/contrib/LocalContribution.java | 33 +++++++++++---- .../app/contrib/ModeContribution.java | 40 ++++++++++++++++++- 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index 666ec7f0d..931483650 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -162,6 +162,7 @@ public abstract class Mode { } } } + reader.close(); } diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 57ac2ffc9..74df31a32 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -329,14 +329,12 @@ public abstract class LocalContribution extends Contribution { } - void remove(final Editor editor, - final ProgressMonitor pm, - final StatusPanel status, - final ContributionListing contribListing) { + void remove(final Editor editor, final ProgressMonitor pm, + final StatusPanel status, final ContributionListing contribListing) { pm.startTask("Removing", ProgressMonitor.UNKNOWN); boolean doBackup = Preferences.getBoolean("contribution.backup.on_remove"); - if (getType().requiresRestart()) { + if (getType().requiresRestart() && getType() != ContributionType.MODE) { if (!doBackup || (doBackup && backup(editor, false, status))) { if (setDeletionFlag(true)) { contribListing.replaceContribution(this, this); @@ -344,6 +342,27 @@ public abstract class LocalContribution extends Contribution { } } else { boolean success = false; + if (getType() == ContributionType.MODE) { + boolean isModeActive = false; + ModeContribution m = (ModeContribution) this; + for (Editor e : editor.getBase().getEditors()) + if (e.getMode().equals(m.getMode())) { + isModeActive = true; + break; + } + if (!isModeActive) + m.clearClassLoader(editor.getBase()); + else { + if (!doBackup || (doBackup && backup(editor, false, status))) { + if (setDeletionFlag(true)) { + contribListing.replaceContribution(this, this); + } + } + ContributionManager.refreshInstalled(editor); + pm.finished(); + return; + } + } if (doBackup) { success = backup(editor, true, status); } else { @@ -352,8 +371,8 @@ public abstract class LocalContribution extends Contribution { } if (success) { - Contribution advertisedVersion = - contribListing.getAvailableContribution(this); + Contribution advertisedVersion = contribListing + .getAvailableContribution(this); if (advertisedVersion == null) { contribListing.removeContribution(this); diff --git a/app/src/processing/app/contrib/ModeContribution.java b/app/src/processing/app/contrib/ModeContribution.java index 052628e7b..7c4dfeb01 100644 --- a/app/src/processing/app/contrib/ModeContribution.java +++ b/app/src/processing/app/contrib/ModeContribution.java @@ -21,11 +21,19 @@ */ package processing.app.contrib; +import java.awt.Component; import java.io.File; +import java.io.IOException; import java.lang.reflect.Constructor; -import java.util.*; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.swing.JRadioButtonMenuItem; import processing.app.Base; +import processing.app.Editor; import processing.app.Mode; @@ -71,7 +79,6 @@ public class ModeContribution extends LocalContribution { private ModeContribution(Base base, File folder, String className) throws Exception { super(folder); - className = initLoader(className); if (className != null) { Class modeClass = loader.loadClass(className); @@ -84,6 +91,35 @@ public class ModeContribution extends LocalContribution { } } + /** + * Method to close the ClassLoader so that the archives are no longer "locked" and + * a mode can be removed without restart. + */ + public void clearClassLoader(Base base) { + ArrayList contribModes = base.getModeContribs(); + contribModes.remove(contribModes.indexOf(this)); + List editorList = base.getEditors(); + for (Editor editor : editorList) { + Component[] j = editor.getModeMenu().getPopupMenu().getComponents(); + for (Component component : j) { + JRadioButtonMenuItem cbmi = null; + if (component instanceof JRadioButtonMenuItem) { + cbmi = (JRadioButtonMenuItem) component; + if (cbmi.getText().equals(mode.toString())) + editor.getModeMenu().getPopupMenu().remove(component); + } + } + } + try { + ((URLClassLoader) loader).close(); + // The typecast should be safe, since the only case when loader is not of + // type URLClassLoader is when no archives were found in the first + // place... + } catch (IOException e) { + e.printStackTrace(); + } + } + static public void loadMissing(Base base) { File modesFolder = Base.getSketchbookModesFolder(); From db8853a1d11b892b0517ae90ca40b4b3b9d2320f Mon Sep 17 00:00:00 2001 From: Joel Moniz Date: Sun, 22 Jun 2014 19:05:12 +0530 Subject: [PATCH 026/134] Install works without restart for modes --- app/src/processing/app/Editor.java | 28 ++++++++++ .../app/contrib/AvailableContribution.java | 3 ++ .../app/contrib/ContributionManager.java | 18 +++++-- .../app/contrib/ContributionPanel.java | 51 +++++++++++++------ .../app/contrib/ModeContribution.java | 40 ++++++++------- 5 files changed, 102 insertions(+), 38 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index d27d52ffb..28456f19d 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -435,6 +435,34 @@ public abstract class Editor extends JFrame implements RunnerListener { } + public void rebuildModeMenu() { + modeMenu = new JMenu(); + ButtonGroup modeGroup = new ButtonGroup(); + for (final Mode m : base.getModeList()) { + JRadioButtonMenuItem item = new JRadioButtonMenuItem(m.getTitle()); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + base.changeMode(m); + } + }); + modeMenu.add(item); + modeGroup.add(item); + if (mode == m) { + item.setSelected(true); + } + } + + modeMenu.addSeparator(); + JMenuItem addLib = new JMenuItem("Add Mode..."); + addLib.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + base.handleOpenModeManager(); + } + }); + modeMenu.add(addLib); + } + + public JMenu getModeMenu() { return modeMenu; } diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java index 44ed86888..39c2940e1 100644 --- a/app/src/processing/app/contrib/AvailableContribution.java +++ b/app/src/processing/app/contrib/AvailableContribution.java @@ -143,6 +143,9 @@ class AvailableContribution extends Contribution { installedContrib.setRestartFlag(); //status.setMessage("Restart Processing to finish the installation."); } +// else if (type == ContributionType.MODE) { +// +// } // 3. Delete the newContrib, do a garbage collection, hope and pray // that Java will unlock the temp folder on Windows now diff --git a/app/src/processing/app/contrib/ContributionManager.java b/app/src/processing/app/contrib/ContributionManager.java index f39d04606..1c4204880 100644 --- a/app/src/processing/app/contrib/ContributionManager.java +++ b/app/src/processing/app/contrib/ContributionManager.java @@ -23,6 +23,8 @@ package processing.app.contrib; import java.io.*; import java.net.*; +import java.util.List; +import java.util.ArrayList; import processing.app.Base; import processing.app.Editor; @@ -130,6 +132,10 @@ public class ContributionManager { if (contribution != null) { contribListing.replaceContribution(ad, contribution); + if (contribution.getType() == ContributionType.MODE) { + ArrayList contribModes = editor.getBase().getModeContribs(); + contribModes.add((ModeContribution)contribution); + } refreshInstalled(editor); } installProgress.finished(); @@ -148,10 +154,14 @@ public class ContributionManager { } - static public void refreshInstalled(Editor editor) { - editor.getMode().rebuildImportMenu(); - editor.getMode().resetExamples(); - editor.rebuildToolMenu(); + static public void refreshInstalled(Editor e) { + List editor = e.getBase().getEditors(); + for (Editor ed : editor) { + ed.getMode().rebuildImportMenu(); + ed.getMode().resetExamples(); + ed.rebuildToolMenu(); + ed.rebuildModeMenu(); + } } diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 07f76e472..57b7e7e80 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -208,23 +208,44 @@ class ContributionPanel extends JPanel { notificationBlock.setFont(new Font("Verdana", Font.ITALIC, 10)); // stripTextSelectionListeners(notificationBlock); - updateButton = new JButton("Update"); - updateButton.setInheritsPopupMenu(true); - Dimension updateButtonDimensions = updateButton.getPreferredSize(); - updateButtonDimensions.width = BUTTON_WIDTH; - updateButton.setMinimumSize(updateButtonDimensions); - updateButton.setPreferredSize(updateButtonDimensions); - updateButton.setOpaque(false); - updateButton.setVisible(false); - updateButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - listPanel.contribManager.status.clear(); + updateButton = new JButton("Update"); + updateButton.setInheritsPopupMenu(true); + Dimension updateButtonDimensions = updateButton.getPreferredSize(); + updateButtonDimensions.width = BUTTON_WIDTH; + updateButton.setMinimumSize(updateButtonDimensions); + updateButton.setPreferredSize(updateButtonDimensions); + updateButton.setOpaque(false); + updateButton.setVisible(false); + updateButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + listPanel.contribManager.status.clear(); + if (contrib.getType() == ContributionType.MODE) { + installRemoveButton.setEnabled(false); + installProgressBar.setVisible(true); + installProgressBar.setIndeterminate(true); + + ((LocalContribution) contrib) + .removeContribution(listPanel.contribManager.editor, + new JProgressMonitor(installProgressBar) { + public void finishedAction() { + // Finished uninstalling the library + resetInstallProgressBarState(); + updateButton.setEnabled(false); + AvailableContribution ad = contribListing + .getAvailableContribution(contrib); + String url = ad.link; + installContribution(ad, url); + } + }, listPanel.contribManager.status); + } else { updateButton.setEnabled(false); - AvailableContribution ad = contribListing.getAvailableContribution(contrib); + AvailableContribution ad = contribListing + .getAvailableContribution(contrib); String url = ad.link; installContribution(ad, url); } - }); + } + }); // add(updateButton, c); // } updateBox.add(updateButton); @@ -424,7 +445,7 @@ class ContributionPanel extends JPanel { } updateButton.setEnabled(true); - if (contrib != null && !contrib.getType().requiresRestart()) { + if (contrib != null && contrib.getType() != ContributionType.TOOL) { updateButton.setVisible(isSelected() && contribListing.hasUpdates(contrib)); } @@ -536,7 +557,7 @@ class ContributionPanel extends JPanel { // now a hyperlink, it will be opened as the mouse is released. enableHyperlinks = alreadySelected; - if (contrib != null && !contrib.getType().requiresRestart()) { + if (contrib != null && contrib.getType() != ContributionType.TOOL) { updateButton.setVisible(isSelected() && contribListing.hasUpdates(contrib)); } installRemoveButton.setVisible(isSelected() || installRemoveButton.getText().equals(Language.text("contributions.remove"))); diff --git a/app/src/processing/app/contrib/ModeContribution.java b/app/src/processing/app/contrib/ModeContribution.java index 7c4dfeb01..4be3184a4 100644 --- a/app/src/processing/app/contrib/ModeContribution.java +++ b/app/src/processing/app/contrib/ModeContribution.java @@ -97,30 +97,32 @@ public class ModeContribution extends LocalContribution { */ public void clearClassLoader(Base base) { ArrayList contribModes = base.getModeContribs(); - contribModes.remove(contribModes.indexOf(this)); - List editorList = base.getEditors(); - for (Editor editor : editorList) { - Component[] j = editor.getModeMenu().getPopupMenu().getComponents(); - for (Component component : j) { - JRadioButtonMenuItem cbmi = null; - if (component instanceof JRadioButtonMenuItem) { - cbmi = (JRadioButtonMenuItem) component; - if (cbmi.getText().equals(mode.toString())) - editor.getModeMenu().getPopupMenu().remove(component); + int botherToRemove = contribModes.indexOf(this); + if (botherToRemove != -1) { // The poor thing isn't even loaded, and we're trying to remove it... + contribModes.remove(botherToRemove); + /* List editorList = base.getEditors(); + for (Editor editor : editorList) { + Component[] j = editor.getModeMenu().getPopupMenu().getComponents(); + for (Component component : j) { + JRadioButtonMenuItem cbmi = null; + if (component instanceof JRadioButtonMenuItem) { + cbmi = (JRadioButtonMenuItem) component; + if (cbmi.getText().equals(mode.toString())) + editor.getModeMenu().getPopupMenu().remove(component); + } } + } */ + try { + ((URLClassLoader) loader).close(); + // The typecast should be safe, since the only case when loader is not of + // type URLClassLoader is when no archives were found in the first + // place... + } catch (IOException e) { + e.printStackTrace(); } } - try { - ((URLClassLoader) loader).close(); - // The typecast should be safe, since the only case when loader is not of - // type URLClassLoader is when no archives were found in the first - // place... - } catch (IOException e) { - e.printStackTrace(); - } } - static public void loadMissing(Base base) { File modesFolder = Base.getSketchbookModesFolder(); ArrayList contribModes = base.getModeContribs(); From 3a1cbefddf595d7f2061c4ff80c4d394dcb8f64c Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Fri, 27 Jun 2014 14:29:11 +0530 Subject: [PATCH 027/134] Display dialog to prevent user from changing an active mode And a few clean ups --- app/src/processing/app/Editor.java | 25 +----------------- .../app/contrib/AvailableContribution.java | 9 +++---- .../app/contrib/ContributionPanel.java | 18 +++++++++++-- .../app/contrib/LocalContribution.java | 26 +++++++++++-------- .../app/contrib/ModeContribution.java | 4 +-- 5 files changed, 36 insertions(+), 46 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 28456f19d..f18d7fd76 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -436,30 +436,7 @@ public abstract class Editor extends JFrame implements RunnerListener { public void rebuildModeMenu() { - modeMenu = new JMenu(); - ButtonGroup modeGroup = new ButtonGroup(); - for (final Mode m : base.getModeList()) { - JRadioButtonMenuItem item = new JRadioButtonMenuItem(m.getTitle()); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - base.changeMode(m); - } - }); - modeMenu.add(item); - modeGroup.add(item); - if (mode == m) { - item.setSelected(true); - } - } - - modeMenu.addSeparator(); - JMenuItem addLib = new JMenuItem("Add Mode..."); - addLib.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - base.handleOpenModeManager(); - } - }); - modeMenu.add(addLib); + initModeMenu(); } diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java index 39c2940e1..9311a5ef9 100644 --- a/app/src/processing/app/contrib/AvailableContribution.java +++ b/app/src/processing/app/contrib/AvailableContribution.java @@ -139,13 +139,10 @@ class AvailableContribution extends Contribution { // backup old if needed, then move things into place and reload. installedContrib = newContrib.copyAndLoad(editor, confirmReplace, status); - if (newContrib != null && type.requiresRestart()) { + if (newContrib != null && type.requiresRestart() && type != ContributionType.MODE) { installedContrib.setRestartFlag(); //status.setMessage("Restart Processing to finish the installation."); } -// else if (type == ContributionType.MODE) { -// -// } // 3. Delete the newContrib, do a garbage collection, hope and pray // that Java will unlock the temp folder on Windows now @@ -154,10 +151,10 @@ class AvailableContribution extends Contribution { if (Base.isWindows()) { - // we'll even give it a second to finish up ... because file ops are + // we'll even give it 2 seconds to finish up ... because file ops are // just that flaky on Windows. try { - Thread.sleep(1000); + Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 57b7e7e80..b31c4c9ae 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -137,6 +137,13 @@ class ContributionPanel extends JPanel { resetInstallProgressBarState(); installRemoveButton.setEnabled(true); } + + public void cancel() { + super.cancel(); + resetInstallProgressBarState(); + updateButton.setEnabled(true); + installRemoveButton.setEnabled(true); + } }, listPanel.contribManager.status); } @@ -236,11 +243,18 @@ class ContributionPanel extends JPanel { String url = ad.link; installContribution(ad, url); } + + @Override + public void cancel() { + super.cancel(); + resetInstallProgressBarState(); + installRemoveButton.setEnabled(true); + } + }, listPanel.contribManager.status); } else { updateButton.setEnabled(false); - AvailableContribution ad = contribListing - .getAvailableContribution(contrib); + AvailableContribution ad = contribListing.getAvailableContribution(contrib); String url = ad.link; installContribution(ad, url); } diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 74df31a32..d64db6f3d 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -329,8 +329,10 @@ public abstract class LocalContribution extends Contribution { } - void remove(final Editor editor, final ProgressMonitor pm, - final StatusPanel status, final ContributionListing contribListing) { + void remove(final Editor editor, + final ProgressMonitor pm, + final StatusPanel status, + final ContributionListing contribListing) { pm.startTask("Removing", ProgressMonitor.UNKNOWN); boolean doBackup = Preferences.getBoolean("contribution.backup.on_remove"); @@ -353,13 +355,15 @@ public abstract class LocalContribution extends Contribution { if (!isModeActive) m.clearClassLoader(editor.getBase()); else { - if (!doBackup || (doBackup && backup(editor, false, status))) { - if (setDeletionFlag(true)) { - contribListing.replaceContribution(this, this); - } - } - ContributionManager.refreshInstalled(editor); - pm.finished(); +// if (!doBackup || (doBackup && backup(editor, false, status))) { +// if (setDeletionFlag(true)) { +// contribListing.replaceContribution(this, this); +// } +// } + pm.cancel(); + Base.showMessage("Mode Manager", "Please save your Sketch and change the Mode of all Editor\nwindows that have " + + this.name + " as the active Mode."); +// ContributionManager.refreshInstalled(editor); return; } } @@ -371,8 +375,8 @@ public abstract class LocalContribution extends Contribution { } if (success) { - Contribution advertisedVersion = contribListing - .getAvailableContribution(this); + Contribution advertisedVersion = + contribListing.getAvailableContribution(this); if (advertisedVersion == null) { contribListing.removeContribution(this); diff --git a/app/src/processing/app/contrib/ModeContribution.java b/app/src/processing/app/contrib/ModeContribution.java index 4be3184a4..7312b5309 100644 --- a/app/src/processing/app/contrib/ModeContribution.java +++ b/app/src/processing/app/contrib/ModeContribution.java @@ -26,9 +26,7 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.Constructor; import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; +import java.util.*; import javax.swing.JRadioButtonMenuItem; From 29dcaaf1e9484e022cca9ca9b44f3a7ec2b9aab8 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Fri, 27 Jun 2014 16:26:20 +0530 Subject: [PATCH 028/134] Remove works for Tools without restart --- app/src/processing/app/Editor.java | 32 +++++++++++++++++++ .../app/contrib/LocalContribution.java | 25 ++++++++++----- .../app/contrib/ToolContribution.java | 29 +++++++++++++++++ 3 files changed, 78 insertions(+), 8 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index f18d7fd76..02f039d02 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -1032,6 +1032,38 @@ public abstract class Editor extends JFrame implements RunnerListener { } + public void clearToolMenu() { + toolsMenu.removeAll(); + System.gc(); + } + + + public void removeTool(ToolContribution tool) { +// Component[] menuBarItems = this.getJMenuBar().getComponents(); +// for (Component menuBarComponent : menuBarItems) { +// if (menuBarComponent instanceof JMenu) { +// if (((JMenu)menuBarComponent).getText().equals("Tools")) { +// System.out.println("Found tools!"); +// Component[] toolMenuItems = ((JMenu)menuBarComponent).getMenuComponents(); +// System.out.println(toolMenuItems.length); +// for (Component toolMenuComponent : toolMenuItems) { +// System.out.println(toolMenuComponent.toString()); +// if (toolMenuComponent instanceof JMenuItem) { +// System.out.println("Found tools: " + ((JMenuItem)toolMenuComponent).getText()); +// if (((JMenuItem)toolMenuComponent).getText().equals(tool.getMenuTitle())) { +// ((JMenu)menuBarComponent).remove(toolMenuComponent); +// break; +// } +// } +// } +// break; +// } +// } +// } + rebuildToolMenu(); + } + + // /** // * Attempt to init or run a Tool from the safety of a try/catch block that // * will report errors to the user. diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index d64db6f3d..d892a5869 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -336,13 +336,13 @@ public abstract class LocalContribution extends Contribution { pm.startTask("Removing", ProgressMonitor.UNKNOWN); boolean doBackup = Preferences.getBoolean("contribution.backup.on_remove"); - if (getType().requiresRestart() && getType() != ContributionType.MODE) { - if (!doBackup || (doBackup && backup(editor, false, status))) { - if (setDeletionFlag(true)) { - contribListing.replaceContribution(this, this); - } - } - } else { +// if (getType().requiresRestart() && getType() != ContributionType.MODE) { +// if (!doBackup || (doBackup && backup(editor, false, status))) { +// if (setDeletionFlag(true)) { +// contribListing.replaceContribution(this, this); +// } +// } +// } else { boolean success = false; if (getType() == ContributionType.MODE) { boolean isModeActive = false; @@ -367,6 +367,11 @@ public abstract class LocalContribution extends Contribution { return; } } + if (getType() == ContributionType.TOOL) { + ToolContribution t = (ToolContribution) this; + editor.clearToolMenu(); + t.clearClassLoader(editor.getBase()); + } if (doBackup) { success = backup(editor, true, status); } else { @@ -375,6 +380,10 @@ public abstract class LocalContribution extends Contribution { } if (success) { + if (getType() == ContributionType.TOOL) { + editor.removeTool((ToolContribution) this); + } + Contribution advertisedVersion = contribListing.getAvailableContribution(this); @@ -389,7 +398,7 @@ public abstract class LocalContribution extends Contribution { status.setErrorMessage("Could not delete the contribution's files"); } } - } +// } ContributionManager.refreshInstalled(editor); pm.finished(); } diff --git a/app/src/processing/app/contrib/ToolContribution.java b/app/src/processing/app/contrib/ToolContribution.java index bccbda1bb..cb8c017b5 100644 --- a/app/src/processing/app/contrib/ToolContribution.java +++ b/app/src/processing/app/contrib/ToolContribution.java @@ -22,6 +22,7 @@ package processing.app.contrib; import java.io.*; +import java.net.URLClassLoader; //import java.net.*; import java.util.*; @@ -61,6 +62,34 @@ public class ToolContribution extends LocalContribution implements Tool { } + /** + * Method to close the ClassLoader so that the archives are no longer "locked" and + * a tool can be removed without restart. + */ + public void clearClassLoader(Base base) { +// ArrayList contribTools = base.getActiveEditor().contribTools; +// int botherToRemove = contribTools.indexOf(this); +// if (botherToRemove != -1) { // The poor thing doesn't even exist, and we're trying to remove it... +// contribTools.remove(botherToRemove); + ArrayList contribTools = base.getActiveEditor().contribTools; + for (ToolContribution toolContrib : contribTools) + if (toolContrib.getName().equals(this.name)) { + try { + System.out.println("Here " + name); + ((URLClassLoader) this.loader).close(); + ((URLClassLoader) toolContrib.loader).close(); + // The typecast should be safe, since the only case when loader is not of + // type URLClassLoader is when no archives were found in the first + // place... + } catch (IOException e) { + e.printStackTrace(); + } +// base.getActiveEditor().rebuildToolMenu(); + } +// } + } + + // static protected List discover(File folder) { // File[] folders = listCandidates(folder, "tool"); // if (folders == null) { From 40652baeef76e8eaad9d5dbf5026d5f3a8323332 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Sun, 29 Jun 2014 13:10:46 +0530 Subject: [PATCH 029/134] Remove works across multiple open editors --- .../app/contrib/LocalContribution.java | 3 +- .../app/contrib/ToolContribution.java | 36 +++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index d892a5869..7c17c4d04 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -369,7 +369,8 @@ public abstract class LocalContribution extends Contribution { } if (getType() == ContributionType.TOOL) { ToolContribution t = (ToolContribution) this; - editor.clearToolMenu(); + for (Editor ed : editor.getBase().getEditors()) + ed.clearToolMenu(); t.clearClassLoader(editor.getBase()); } if (doBackup) { diff --git a/app/src/processing/app/contrib/ToolContribution.java b/app/src/processing/app/contrib/ToolContribution.java index cb8c017b5..cf7ecab6e 100644 --- a/app/src/processing/app/contrib/ToolContribution.java +++ b/app/src/processing/app/contrib/ToolContribution.java @@ -71,21 +71,29 @@ public class ToolContribution extends LocalContribution implements Tool { // int botherToRemove = contribTools.indexOf(this); // if (botherToRemove != -1) { // The poor thing doesn't even exist, and we're trying to remove it... // contribTools.remove(botherToRemove); - ArrayList contribTools = base.getActiveEditor().contribTools; - for (ToolContribution toolContrib : contribTools) - if (toolContrib.getName().equals(this.name)) { - try { - System.out.println("Here " + name); - ((URLClassLoader) this.loader).close(); - ((URLClassLoader) toolContrib.loader).close(); - // The typecast should be safe, since the only case when loader is not of - // type URLClassLoader is when no archives were found in the first - // place... - } catch (IOException e) { - e.printStackTrace(); - } + try { + ((URLClassLoader) this.loader).close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + List editors = base.getEditors(); + for (Editor editor : editors) { + ArrayList contribTools = editor.contribTools; + for (ToolContribution toolContrib : contribTools) + if (toolContrib.getName().equals(this.name)) { + try { + System.out.println("Here " + name); + ((URLClassLoader) toolContrib.loader).close(); + System.out.println(contribTools.size()); + editor.contribTools.remove(toolContrib); + System.out.println(contribTools.size()); + break; + } catch (IOException e) { + e.printStackTrace(); + } // base.getActiveEditor().rebuildToolMenu(); - } + } + } // } } From 98ab001d2c7069ada6ec1bcfaa459006be5ee1d2 Mon Sep 17 00:00:00 2001 From: Joel Moniz Date: Tue, 1 Jul 2014 10:24:14 +0530 Subject: [PATCH 030/134] Old remove methd used if remove without restart fails --- .../app/contrib/LocalContribution.java | 106 +++++++++--------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 7c17c4d04..08df73a5d 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -47,6 +47,8 @@ public abstract class LocalContribution extends Contribution { protected HashMap properties; protected ClassLoader loader; + boolean isRemoveOnRestart = false; + public LocalContribution(File folder) { this.folder = folder; @@ -328,11 +330,8 @@ public abstract class LocalContribution extends Contribution { }).start(); } - - void remove(final Editor editor, - final ProgressMonitor pm, - final StatusPanel status, - final ContributionListing contribListing) { + void remove(final Editor editor, final ProgressMonitor pm, + final StatusPanel status, final ContributionListing contribListing) { pm.startTask("Removing", ProgressMonitor.UNKNOWN); boolean doBackup = Preferences.getBoolean("contribution.backup.on_remove"); @@ -343,62 +342,65 @@ public abstract class LocalContribution extends Contribution { // } // } // } else { - boolean success = false; - if (getType() == ContributionType.MODE) { - boolean isModeActive = false; - ModeContribution m = (ModeContribution) this; - for (Editor e : editor.getBase().getEditors()) - if (e.getMode().equals(m.getMode())) { - isModeActive = true; - break; - } - if (!isModeActive) - m.clearClassLoader(editor.getBase()); - else { -// if (!doBackup || (doBackup && backup(editor, false, status))) { -// if (setDeletionFlag(true)) { -// contribListing.replaceContribution(this, this); -// } -// } - pm.cancel(); - Base.showMessage("Mode Manager", "Please save your Sketch and change the Mode of all Editor\nwindows that have " - + this.name + " as the active Mode."); + boolean success = false; + if (getType() == ContributionType.MODE) { + boolean isModeActive = false; + ModeContribution m = (ModeContribution) this; + for (Editor e : editor.getBase().getEditors()) + if (e.getMode().equals(m.getMode())) { + isModeActive = true; + break; + } + if (!isModeActive) + m.clearClassLoader(editor.getBase()); + else { + pm.cancel(); + Base.showMessage("Mode Manager", + "Please save your Sketch and change the Mode of all Editor\nwindows that have " + + this.name + " as the active Mode."); // ContributionManager.refreshInstalled(editor); - return; - } + return; } + } + if (getType() == ContributionType.TOOL) { + ToolContribution t = (ToolContribution) this; + for (Editor ed : editor.getBase().getEditors()) + ed.clearToolMenu(); + t.clearClassLoader(editor.getBase()); + } + if (doBackup) { + success = backup(editor, true, status); + } else { + Base.removeDir(getFolder()); + success = !getFolder().exists(); + } + + if (success) { if (getType() == ContributionType.TOOL) { - ToolContribution t = (ToolContribution) this; - for (Editor ed : editor.getBase().getEditors()) - ed.clearToolMenu(); - t.clearClassLoader(editor.getBase()); - } - if (doBackup) { - success = backup(editor, true, status); - } else { - Base.removeDir(getFolder()); - success = !getFolder().exists(); + editor.removeTool((ToolContribution) this); } - if (success) { - if (getType() == ContributionType.TOOL) { - editor.removeTool((ToolContribution) this); - } - - Contribution advertisedVersion = - contribListing.getAvailableContribution(this); + Contribution advertisedVersion = contribListing + .getAvailableContribution(this); - if (advertisedVersion == null) { - contribListing.removeContribution(this); - } else { - contribListing.replaceContribution(this, advertisedVersion); - } + if (advertisedVersion == null) { + contribListing.removeContribution(this); } else { - // There was a failure backing up the folder - if (!doBackup) { + contribListing.replaceContribution(this, advertisedVersion); + } + } else { + // There was a failure backing up the folder + if (getType().requiresRestart()) { + if (!doBackup || (doBackup && backup(editor, false, status))) { + if (setDeletionFlag(true)) { + contribListing.replaceContribution(this, this); + } + isRemoveOnRestart = true; + } + else status.setErrorMessage("Could not delete the contribution's files"); - } } + } // } ContributionManager.refreshInstalled(editor); pm.finished(); From 26796b45cb075020c55d4930f2a33cb87fc9c26f Mon Sep 17 00:00:00 2001 From: Joel Moniz Date: Tue, 1 Jul 2014 18:09:12 +0530 Subject: [PATCH 031/134] No restart needed to Install Tools And some work on restartless update and a few cleanups --- app/src/processing/app/Editor.java | 23 +------------------ .../app/contrib/AvailableContribution.java | 10 ++++---- .../app/contrib/ContributionPanel.java | 4 ++-- .../app/contrib/LocalContribution.java | 2 +- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 02f039d02..126152f4c 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -1038,28 +1038,7 @@ public abstract class Editor extends JFrame implements RunnerListener { } - public void removeTool(ToolContribution tool) { -// Component[] menuBarItems = this.getJMenuBar().getComponents(); -// for (Component menuBarComponent : menuBarItems) { -// if (menuBarComponent instanceof JMenu) { -// if (((JMenu)menuBarComponent).getText().equals("Tools")) { -// System.out.println("Found tools!"); -// Component[] toolMenuItems = ((JMenu)menuBarComponent).getMenuComponents(); -// System.out.println(toolMenuItems.length); -// for (Component toolMenuComponent : toolMenuItems) { -// System.out.println(toolMenuComponent.toString()); -// if (toolMenuComponent instanceof JMenuItem) { -// System.out.println("Found tools: " + ((JMenuItem)toolMenuComponent).getText()); -// if (((JMenuItem)toolMenuComponent).getText().equals(tool.getMenuTitle())) { -// ((JMenu)menuBarComponent).remove(toolMenuComponent); -// break; -// } -// } -// } -// break; -// } -// } -// } + public void removeTool() { rebuildToolMenu(); } diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java index 9311a5ef9..d1338fd78 100644 --- a/app/src/processing/app/contrib/AvailableContribution.java +++ b/app/src/processing/app/contrib/AvailableContribution.java @@ -139,10 +139,12 @@ class AvailableContribution extends Contribution { // backup old if needed, then move things into place and reload. installedContrib = newContrib.copyAndLoad(editor, confirmReplace, status); - if (newContrib != null && type.requiresRestart() && type != ContributionType.MODE) { - installedContrib.setRestartFlag(); - //status.setMessage("Restart Processing to finish the installation."); - } + + // Restart no longer needed. Yay! +// if (newContrib != null && type.requiresRestart()) { +// installedContrib.setRestartFlag(); +// //status.setMessage("Restart Processing to finish the installation."); +// } // 3. Delete the newContrib, do a garbage collection, hope and pray // that Java will unlock the temp folder on Windows now diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index b31c4c9ae..79d44c01d 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -459,7 +459,7 @@ class ContributionPanel extends JPanel { } updateButton.setEnabled(true); - if (contrib != null && contrib.getType() != ContributionType.TOOL) { + if (contrib != null) { updateButton.setVisible(isSelected() && contribListing.hasUpdates(contrib)); } @@ -571,7 +571,7 @@ class ContributionPanel extends JPanel { // now a hyperlink, it will be opened as the mouse is released. enableHyperlinks = alreadySelected; - if (contrib != null && contrib.getType() != ContributionType.TOOL) { + if (contrib != null) { updateButton.setVisible(isSelected() && contribListing.hasUpdates(contrib)); } installRemoveButton.setVisible(isSelected() || installRemoveButton.getText().equals(Language.text("contributions.remove"))); diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 08df73a5d..424fc0ca2 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -377,7 +377,7 @@ public abstract class LocalContribution extends Contribution { if (success) { if (getType() == ContributionType.TOOL) { - editor.removeTool((ToolContribution) this); + editor.removeTool(); } Contribution advertisedVersion = contribListing From 1bdbf25fc0c36b652892b3f91565e328099f24ca Mon Sep 17 00:00:00 2001 From: Joel Moniz Date: Sat, 5 Jul 2014 11:45:02 +0530 Subject: [PATCH 032/134] Restart is no longer need for Updating contribs --- app/src/processing/app/Base.java | 2 +- .../app/contrib/AvailableContribution.java | 84 +++++++++ .../processing/app/contrib/Contribution.java | 5 + .../app/contrib/ContributionManager.java | 161 +++++++++++++++++- .../app/contrib/ContributionPanel.java | 39 +++-- .../app/contrib/LocalContribution.java | 69 +++++++- .../app/contrib/ToolContribution.java | 3 - 7 files changed, 339 insertions(+), 24 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 233178ac0..061c44705 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -353,7 +353,7 @@ public class Base { // removeDir(contrib.getFolder()); // } // } - ContributionManager.cleanup(); + ContributionManager.cleanup(this); buildCoreModes(); rebuildContribModes(); diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java index d1338fd78..acd6b8dbc 100644 --- a/app/src/processing/app/contrib/AvailableContribution.java +++ b/app/src/processing/app/contrib/AvailableContribution.java @@ -178,6 +178,90 @@ class AvailableContribution extends Contribution { } + /** + * @param contribArchive + * a zip file containing the library to install + * @return + */ + public LocalContribution installOnStartup(Base base, File contribArchive, StatusPanel status) { + // Unzip the file into the modes, tools, or libraries folder inside the + // sketchbook. Unzipping to /tmp is problematic because it may be on + // another file system, so move/rename operations will break. + + File tempFolder = null; + + try { + tempFolder = type.createTempFolder(); + } catch (IOException e) { + status.setErrorMessage("Could not create a temporary folder to install."); + return null; + } + Base.unzip(contribArchive, tempFolder); + + // Now go looking for a legit contrib inside what's been unpacked. + File contribFolder = null; + + // Sometimes contrib authors place all their folders in the base directory + // of the .zip file instead of in single folder as the guidelines suggest. + if (type.isCandidate(tempFolder)) { + status.setErrorMessage(getName() + " needs to be repackaged according to the " + type.getTitle() + " guidelines."); + return null; + } + + contribFolder = type.findCandidate(tempFolder); + LocalContribution installedContrib = null; + + if (contribFolder == null) { + status.setErrorMessage("Could not find a " + type + " in the downloaded file."); + + } else { + File propFile = new File(contribFolder, type + ".properties"); + if (writePropertiesFile(propFile)) { + // 1. contribFolder now has a legit contribution, load it to get info. + LocalContribution newContrib = + type.load(base, contribFolder); + + // 1.1. get info we need to delete the newContrib folder later + File newContribFolder = newContrib.getFolder(); + + // 2. Check to make sure nothing has the same name already, + // backup old if needed, then move things into place and reload. + installedContrib = + newContrib.copyAndLoadOnStartup(base, status); + + // 3. Delete the newContrib, do a garbage collection, hope and pray + // that Java will unlock the temp folder on Windows now + newContrib = null; + System.gc(); + + + if (Base.isWindows()) { + // we'll even give it 2 seconds to finish up ... because file ops are + // just that flaky on Windows. + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + // 4. Okay, now actually delete that temp folder + Base.removeDir(newContribFolder); + + } else { + status.setErrorMessage("Error overwriting .properties file."); + } + } + + // Remove any remaining ickies + if (tempFolder.exists()) { + Base.removeDir(tempFolder); + } + return installedContrib; + } + + + public boolean isInstalled() { return false; } diff --git a/app/src/processing/app/contrib/Contribution.java b/app/src/processing/app/contrib/Contribution.java index 9fc73c851..fedec1543 100644 --- a/app/src/processing/app/contrib/Contribution.java +++ b/app/src/processing/app/contrib/Contribution.java @@ -158,6 +158,11 @@ abstract public class Contribution { return false; } + + boolean isUpdateFlagged() { + return false; + } + /** * @return a single element list with "Unknown" as the category. diff --git a/app/src/processing/app/contrib/ContributionManager.java b/app/src/processing/app/contrib/ContributionManager.java index 1c4204880..2fe22b84e 100644 --- a/app/src/processing/app/contrib/ContributionManager.java +++ b/app/src/processing/app/contrib/ContributionManager.java @@ -23,9 +23,12 @@ package processing.app.contrib; import java.io.*; import java.net.*; +import java.util.LinkedList; import java.util.List; import java.util.ArrayList; +import javax.swing.JProgressBar; + import processing.app.Base; import processing.app.Editor; import processing.app.Language; @@ -95,7 +98,52 @@ public class ContributionManager { return success; } + + /** + * Blocks until the file is downloaded or an error occurs. + * Returns true if the file was successfully downloaded, false otherwise. + * Used at startup for automatically downloading and installing. + * + * @param source + * the URL of the file to download + * @param dest + * the file on the local system where the file will be written. This + * must be a file (not a directory), and must already exist. + */ + static boolean download(URL source, File dest) { + boolean success = false; + try { +// System.out.println("downloading file " + source); +// URLConnection conn = source.openConnection(); + HttpURLConnection conn = (HttpURLConnection) source.openConnection(); + HttpURLConnection.setFollowRedirects(true); + conn.setConnectTimeout(15 * 1000); + conn.setReadTimeout(60 * 1000); + conn.setRequestMethod("GET"); + conn.connect(); + InputStream in = conn.getInputStream(); + FileOutputStream out = new FileOutputStream(dest); + + byte[] b = new byte[8192]; + int amount; + while ((amount = in.read(b)) != -1) { + out.write(b, 0, amount); + } + out.flush(); + out.close(); + success = true; + + } catch (SocketTimeoutException ste) { + // When there's no internet... + // TODO: Will have to find a way to download later + } catch (IOException ioe) { + ioe.printStackTrace(); + } + return success; + } + + /** * Non-blocking call to download and install a contribution in a new thread. * @@ -154,6 +202,67 @@ public class ContributionManager { } + + /** + * Non-blocking call to download and install a contribution in a new thread. + * + * @param url + * Direct link to the contribution. + * @param ad + * The AvailableContribution to be downloaded and installed. + */ + static void downloadAndInstallOnStartup(final Base base, final URL url, + final AvailableContribution ad) { + + new Thread(new Runnable() { + public void run() { + String filename = url.getFile(); + filename = filename.substring(filename.lastIndexOf('/') + 1); + try { + File contribZip = File.createTempFile("download", filename); + contribZip.setWritable(true); // necessary? + + try { + download(url, contribZip); + + StatusPanel status = new StatusPanel(); + LocalContribution contribution = ad.installOnStartup(base, + contribZip, + status); + + if (contribution != null) { + contribListing.replaceContribution(ad, contribution); + if (contribution.getType() == ContributionType.MODE) { + ArrayList contribModes = base + .getModeContribs(); + if (contribModes != null) + contribModes.add((ModeContribution) contribution); + } + if (base.getActiveEditor() != null) + refreshInstalled(base.getActiveEditor()); + } + + System.out.println(status.getText()); +// if (contribution != null) { +// contribListing.replaceContribution(ad, contribution); +// } + contribZip.delete(); + + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Error during download and install of " + + ad.getName()); + } + } catch (IOException e) { + System.err + .println("Could not write to temporary directory during download and install of " + + ad.getName()); + } + } + }).start(); + } + + static public void refreshInstalled(Editor e) { List editor = e.getBase().getEditors(); for (Editor ed : editor) { @@ -219,12 +328,17 @@ public class ContributionManager { /** * Called by Base to clean up entries previously marked for deletion * and remove any "requires restart" flags. + * Also updates all entries previously marked for update. */ - static public void cleanup() throws Exception { + static public void cleanup(Base base) throws Exception { deleteFlagged(Base.getSketchbookLibrariesFolder()); deleteFlagged(Base.getSketchbookModesFolder()); deleteFlagged(Base.getSketchbookToolsFolder()); + updateFlagged(base, Base.getSketchbookLibrariesFolder()); + updateFlagged(base, Base.getSketchbookModesFolder()); + updateFlagged(base, Base.getSketchbookToolsFolder()); + clearRestartFlags(Base.getSketchbookModesFolder()); clearRestartFlags(Base.getSketchbookToolsFolder()); } @@ -243,6 +357,51 @@ public class ContributionManager { } + static private void updateFlagged(Base base, File root) throws Exception { + File[] markedForUpdate = root.listFiles(new FileFilter() { + public boolean accept(File folder) { + return (folder.isDirectory() && + LocalContribution.isUpdateFlagged(folder)); + } + }); + ArrayList updateContribsNames = new ArrayList(); + LinkedList updateContribsList = new LinkedList(); + for (File folder : markedForUpdate) { + updateContribsNames.add(folder.getName()); + Base.removeDir(folder); + } + for (AvailableContribution availableContribs : contribListing.advertisedContributions) { + if(updateContribsNames.contains(availableContribs.getName())) { + updateContribsList.add(availableContribs); + } + } + for (AvailableContribution contribToUpdate : updateContribsList) { + installOnStartUp(base, contribToUpdate); + contribListing.replaceContribution(contribToUpdate, contribToUpdate); + } + } + + + static private void installOnStartUp(final Base base, final AvailableContribution availableContrib) { + if (availableContrib.link == null) { + Base.showWarning("Update on Restart of " + availableContrib.getName() + "failed", + "Your operating system " + + "doesn't appear to be supported. You should visit the " + + availableContrib.getType() + "'s library for more info."); + return; + } + try { + URL downloadUrl = new URL(availableContrib.link); + + ContributionManager.downloadAndInstallOnStartup(base, downloadUrl, availableContrib); + + } catch (MalformedURLException e) { + Base.showWarning("Update on Restart of " + availableContrib.getName() + "failed", + ContributionListPanel.MALFORMED_URL_MESSAGE, e); + } + } + + static private void clearRestartFlags(File root) throws Exception { File[] folderList = root.listFiles(new FileFilter() { public boolean accept(File folder) { diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 79d44c01d..d2612dafb 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -52,6 +52,9 @@ class ContributionPanel extends JPanel { static public final String INSTALL_RESTART_MESSAGE = "Please restart Processing to finish installing this item."; + + static public final String UPDATE_RESTART_MESSAGE = + "Please restart Processing to finish updating this item."; private final ContributionListPanel listPanel; private final ContributionListing contribListing = ContributionListing.getInstance(); @@ -141,7 +144,6 @@ class ContributionPanel extends JPanel { public void cancel() { super.cancel(); resetInstallProgressBarState(); - updateButton.setEnabled(true); installRemoveButton.setEnabled(true); } }, @@ -225,9 +227,7 @@ class ContributionPanel extends JPanel { updateButton.setVisible(false); updateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - listPanel.contribManager.status.clear(); - if (contrib.getType() == ContributionType.MODE) { - installRemoveButton.setEnabled(false); + listPanel.contribManager.status.clear(); if (contrib.getType().requiresRestart()) { installRemoveButton.setEnabled(false); installProgressBar.setVisible(true); installProgressBar.setIndeterminate(true); @@ -249,6 +249,12 @@ class ContributionPanel extends JPanel { super.cancel(); resetInstallProgressBarState(); installRemoveButton.setEnabled(true); + if (contrib.isDeletionFlagged()) { + ((LocalContribution)contrib).setUpdateFlag(true); + ((LocalContribution)contrib).setDeletionFlag(false); + contribListing.replaceContribution(contrib,contrib); + updateButton.setVisible(false); + } } }, listPanel.contribManager.status); @@ -394,7 +400,11 @@ class ContributionPanel extends JPanel { description.append(REMOVE_RESTART_MESSAGE); } else if (contrib.isRestartFlagged()) { description.append(INSTALL_RESTART_MESSAGE); - } else { + } + else if (contrib.isUpdateFlagged()) { + description.append(UPDATE_RESTART_MESSAGE); + } + else { String sentence = contrib.getSentence(); if (sentence == null || sentence.isEmpty()) { sentence = "Description unavailable."; @@ -435,20 +445,21 @@ class ContributionPanel extends JPanel { if (contribListing.hasUpdates(contrib)) { StringBuilder versionText = new StringBuilder(); versionText.append(""); - if (contrib.isDeletionFlagged()) { + if (contrib.isUpdateFlagged()) { // Already marked for deletion, see requiresRestart() notes below. - versionText.append("To finish an update, reinstall this contribution after restarting."); + // versionText.append("To finish an update, reinstall this contribution after restarting."); + ; } else { String latestVersion = contribListing.getLatestVersion(contrib); if (latestVersion != null) versionText.append("New version (" + latestVersion + ") available!"); else versionText.append("New version available!"); - if (contrib.getType().requiresRestart()) { - // If a contribution can't be reinstalled in-place, the user may need - // to remove the current version, restart Processing, then install. - versionText.append(" To update, first remove the current version."); - } +// if (contrib.getType().requiresRestart()) { +// // If a contribution can't be reinstalled in-place, the user may need +// // to remove the current version, restart Processing, then install. +// versionText.append(" To update, first remove the current version."); +// } } versionText.append(""); notificationBlock.setText(versionText.toString()); @@ -460,7 +471,7 @@ class ContributionPanel extends JPanel { updateButton.setEnabled(true); if (contrib != null) { - updateButton.setVisible(isSelected() && contribListing.hasUpdates(contrib)); + updateButton.setVisible(isSelected() && contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged()); } installRemoveButton.removeActionListener(installActionListener); @@ -572,7 +583,7 @@ class ContributionPanel extends JPanel { enableHyperlinks = alreadySelected; if (contrib != null) { - updateButton.setVisible(isSelected() && contribListing.hasUpdates(contrib)); + updateButton.setVisible(isSelected() && contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged()); } installRemoveButton.setVisible(isSelected() || installRemoveButton.getText().equals(Language.text("contributions.remove"))); diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 424fc0ca2..494e68828 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -39,6 +39,7 @@ import processing.app.*; */ public abstract class LocalContribution extends Contribution { static public final String DELETION_FLAG = "marked_for_deletion"; + static public final String UPDATE_FLAGGED = "marked_for_update"; static public final String RESTART_FLAG = "requires_restart"; protected String id; // 1 (unique id for this library) @@ -47,8 +48,6 @@ public abstract class LocalContribution extends Contribution { protected HashMap properties; protected ClassLoader loader; - boolean isRemoveOnRestart = false; - public LocalContribution(File folder) { this.folder = folder; @@ -281,6 +280,44 @@ public abstract class LocalContribution extends Contribution { } + LocalContribution copyAndLoadOnStartup(Base base, StatusPanel status) { + + String contribFolderName = getFolder().getName(); + + File contribTypeFolder = getType().getSketchbookFolder(); + File contribFolder = new File(contribTypeFolder, contribFolderName); + + // This if should ideally never happen, since this function is to be called only when restarting on update + if (contribFolder.exists()) { + Base.removeDir(contribFolder); + } + + + File oldFolder = getFolder(); + + try { + Base.copyDir(oldFolder, contribFolder); + } catch (IOException e) { + status.setErrorMessage("Could not copy " + getTypeName() + + " \"" + getName() + "\" to the sketchbook."); + e.printStackTrace(); + return null; + } + + + /* + if (!getFolder().renameTo(contribFolder)) { + status.setErrorMessage("Could not move " + getTypeName() + + " \"" + getName() + "\" to the sketchbook."); + return null; + } + */ + + return getType().load(base, contribFolder); + } + + + /** * Moves the given contribution to a backup folder. * @param deleteOriginal @@ -388,14 +425,15 @@ public abstract class LocalContribution extends Contribution { } else { contribListing.replaceContribution(this, advertisedVersion); } - } else { + } + else { // There was a failure backing up the folder if (getType().requiresRestart()) { if (!doBackup || (doBackup && backup(editor, false, status))) { + status.setMessage(""); if (setDeletionFlag(true)) { contribListing.replaceContribution(this, this); } - isRemoveOnRestart = true; } else status.setErrorMessage("Could not delete the contribution's files"); @@ -403,7 +441,10 @@ public abstract class LocalContribution extends Contribution { } // } ContributionManager.refreshInstalled(editor); - pm.finished(); + if (success) + pm.finished(); + else + pm.cancel(); } @@ -506,6 +547,24 @@ public abstract class LocalContribution extends Contribution { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + boolean setUpdateFlag(boolean flag) { + return setFlag(UPDATE_FLAGGED, flag); + } + + + boolean isUpdateFlagged() { + return isUpdateFlagged(getFolder()); + } + + + static boolean isUpdateFlagged(File folder) { + return isFlagged(folder, UPDATE_FLAGGED); + } + + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + boolean setRestartFlag() { //System.out.println("setting restart flag for " + folder); return setFlag(RESTART_FLAG, true); diff --git a/app/src/processing/app/contrib/ToolContribution.java b/app/src/processing/app/contrib/ToolContribution.java index cf7ecab6e..85befb838 100644 --- a/app/src/processing/app/contrib/ToolContribution.java +++ b/app/src/processing/app/contrib/ToolContribution.java @@ -82,11 +82,8 @@ public class ToolContribution extends LocalContribution implements Tool { for (ToolContribution toolContrib : contribTools) if (toolContrib.getName().equals(this.name)) { try { - System.out.println("Here " + name); ((URLClassLoader) toolContrib.loader).close(); - System.out.println(contribTools.size()); editor.contribTools.remove(toolContrib); - System.out.println(contribTools.size()); break; } catch (IOException e) { e.printStackTrace(); From 269af683e91dd77ab6837c3f843954c109b3bdbe Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Sat, 19 Jul 2014 02:35:39 +0400 Subject: [PATCH 033/134] The Contribution Managers' GUIs just recieved a makeover --- .../contrib/ContributionManagerDialog.java | 17 +- .../app/contrib/ContributionPanel.java | 157 ++++++++++++++++-- .../app/contrib/LocalContribution.java | 1 - 3 files changed, 158 insertions(+), 17 deletions(-) diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index a4a4e4f70..22133b374 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -48,6 +48,7 @@ public class ContributionManagerDialog { ContributionListPanel contributionListPanel; StatusPanel status; FilterField filterField; + JButton restartButton; // the calling editor, so updates can be applied Editor editor; @@ -84,6 +85,8 @@ public class ContributionManagerDialog { if (dialog == null) { dialog = new JFrame(title); + restartButton = new JButton("Restart Processing"); + Toolkit.setIcon(dialog); createComponents(); registerDisposeListeners(); @@ -204,8 +207,18 @@ public class ContributionManagerDialog { pane.add(Box.createHorizontalStrut(10), BorderLayout.EAST); status = new StatusPanel(); - status.setBorder(new EmptyBorder(7, 7, 7, 7)); - pane.add(status, BorderLayout.SOUTH); +// status.setBorder(new EmptyBorder(7, 7, 7, 7)); + + JPanel statusRestartPane = new JPanel(); + statusRestartPane.setLayout(new BorderLayout()); + + statusRestartPane.setBorder(new EmptyBorder(7, 7, 7, 7)); + statusRestartPane.setOpaque(false); + + statusRestartPane.add(status, BorderLayout.WEST); + statusRestartPane.add(restartButton, BorderLayout.EAST); + + pane.add(statusRestartPane, BorderLayout.SOUTH); // status = new StatusPanel(); diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index d2612dafb..280919d7a 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -56,6 +56,10 @@ class ContributionPanel extends JPanel { static public final String UPDATE_RESTART_MESSAGE = "Please restart Processing to finish updating this item."; + static public final String PROGRESS_BAR_CONSTRAINT = "Install/Remove Progress Bar Panel"; + + static public final String BUTTON_CONSTRAINT = "Install/Remvoe Button Panel"; + private final ContributionListPanel listPanel; private final ContributionListing contribListing = ContributionListing.getInstance(); @@ -78,15 +82,21 @@ class ContributionPanel extends JPanel { private JButton installRemoveButton; private JPopupMenu contextMenu; private JMenuItem openFolder; + private JPanel barButtonCardPane; // private HashSet headerPaneSet; private ActionListener removeActionListener; private ActionListener installActionListener; private ActionListener undoActionListener; + + private boolean isUpdateInProgress; + private boolean isInstallInProgress; + private boolean isRemoveInProgress; ContributionPanel(ContributionListPanel contributionListPanel) { listPanel = contributionListPanel; + barButtonCardPane = new JPanel(); // headerPaneSet = new HashSet(); enableHyperlinks = false; @@ -106,6 +116,8 @@ class ContributionPanel extends JPanel { installActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { listPanel.contribManager.status.clear(); + isInstallInProgress = true; + ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, PROGRESS_BAR_CONSTRAINT); if (contrib instanceof AvailableContribution) { installContribution((AvailableContribution) contrib); contribListing.replaceContribution(contrib, contrib); @@ -128,6 +140,8 @@ class ContributionPanel extends JPanel { public void actionPerformed(ActionEvent arg) { listPanel.contribManager.status.clear(); if (contrib.isInstalled() && contrib instanceof LocalContribution) { + isRemoveInProgress = true; + ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, PROGRESS_BAR_CONSTRAINT); updateButton.setEnabled(false); installRemoveButton.setEnabled(false); installProgressBar.setVisible(true); @@ -138,13 +152,21 @@ class ContributionPanel extends JPanel { public void finishedAction() { // Finished uninstalling the library resetInstallProgressBarState(); + isRemoveInProgress = false; installRemoveButton.setEnabled(true); +// ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); + reorganizePaneComponents(); + setSelected(true); // Needed for smooth working. Dunno why, though... } public void cancel() { super.cancel(); resetInstallProgressBarState(); + isRemoveInProgress = false; installRemoveButton.setEnabled(true); +// ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); + reorganizePaneComponents(); + setSelected(true); } }, listPanel.contribManager.status); @@ -204,7 +226,8 @@ class ContributionPanel extends JPanel { descriptionBlock.setHighlighter(null); add(descriptionBlock, BorderLayout.CENTER); - Box updateBox = Box.createHorizontalBox(); //new BoxLayout(filterPanel, BoxLayout.X_AXIS) + JPanel updateBox = new JPanel(); //new BoxLayout(filterPanel, BoxLayout.X_AXIS) + updateBox.setLayout(new BorderLayout()); notificationBlock = new JLabel(); notificationBlock.setInheritsPopupMenu(true); @@ -227,7 +250,10 @@ class ContributionPanel extends JPanel { updateButton.setVisible(false); updateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - listPanel.contribManager.status.clear(); if (contrib.getType().requiresRestart()) { installRemoveButton.setEnabled(false); + listPanel.contribManager.status.clear(); + isUpdateInProgress = true; + if (contrib.getType().requiresRestart()) { + installRemoveButton.setEnabled(false); installProgressBar.setVisible(true); installProgressBar.setIndeterminate(true); @@ -248,13 +274,15 @@ class ContributionPanel extends JPanel { public void cancel() { super.cancel(); resetInstallProgressBarState(); + isUpdateInProgress = false; installRemoveButton.setEnabled(true); if (contrib.isDeletionFlagged()) { ((LocalContribution)contrib).setUpdateFlag(true); ((LocalContribution)contrib).setDeletionFlag(false); contribListing.replaceContribution(contrib,contrib); - updateButton.setVisible(false); +// updateButton.setVisible(false); } + listPanel.contribManager.status.setMessage(""); } }, listPanel.contribManager.status); @@ -268,9 +296,10 @@ class ContributionPanel extends JPanel { }); // add(updateButton, c); // } - updateBox.add(updateButton); - updateBox.add(notificationBlock); + updateBox.add(updateButton, BorderLayout.EAST); + updateBox.add(notificationBlock, BorderLayout.WEST); updateBox.setBorder(new EmptyBorder(4, 7, 7, 7)); + updateBox.setOpaque(false); add(updateBox, BorderLayout.SOUTH); // } @@ -294,6 +323,11 @@ class ContributionPanel extends JPanel { // add(rightPane, c); // statusBox.add(rightPane); add(rightPane, BorderLayout.EAST); + + barButtonCardPane.setLayout(new CardLayout()); + barButtonCardPane.setInheritsPopupMenu(true); + barButtonCardPane.setOpaque(false); + barButtonCardPane.setMinimumSize(new Dimension(ContributionPanel.BUTTON_WIDTH, 1)); installProgressBar = new JProgressBar(); installProgressBar.setInheritsPopupMenu(true); @@ -305,9 +339,7 @@ class ContributionPanel extends JPanel { installProgressBar.setMaximumSize(d); installProgressBar.setMinimumSize(d); installProgressBar.setOpaque(false); - rightPane.add(installProgressBar); installProgressBar.setAlignmentX(CENTER_ALIGNMENT); - rightPane.add(Box.createVerticalGlue()); installRemoveButton = new JButton(" "); installRemoveButton.setInheritsPopupMenu(true); @@ -318,20 +350,106 @@ class ContributionPanel extends JPanel { installRemoveButton.setMaximumSize(installButtonDimensions); installRemoveButton.setMinimumSize(installButtonDimensions); installRemoveButton.setOpaque(false); - rightPane.add(installRemoveButton); installRemoveButton.setAlignmentX(CENTER_ALIGNMENT); + + JPanel barPane = new JPanel(); + barPane.setOpaque(false); + barPane.add(installProgressBar); + + JPanel buttonPane = new JPanel(); + buttonPane.setOpaque(false); + buttonPane.add(installRemoveButton); + + barButtonCardPane.add(buttonPane, BUTTON_CONSTRAINT); + barButtonCardPane.add(barPane, PROGRESS_BAR_CONSTRAINT); + + ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); + + rightPane.add(barButtonCardPane); // Set the minimum size of this pane to be the sum of the height of the // progress bar and install button d = installProgressBar.getPreferredSize(); Dimension d2 = installRemoveButton.getPreferredSize(); d.width = ContributionPanel.BUTTON_WIDTH; - d.height = d.height+d2.height; + d.height = d2.height;//d.height+d2.height; rightPane.setMinimumSize(d); rightPane.setPreferredSize(d); } + private void reorganizePaneComponents() { + BorderLayout layout = (BorderLayout) this.getLayout(); + remove(layout.getLayoutComponent(BorderLayout.SOUTH)); + remove(layout.getLayoutComponent(BorderLayout.EAST)); + + JPanel updateBox = new JPanel(); + updateBox.setLayout(new BorderLayout()); + updateBox.add(notificationBlock, BorderLayout.WEST); + updateBox.setBorder(new EmptyBorder(4, 7, 7, 7)); + updateBox.setOpaque(false); + add(updateBox, BorderLayout.SOUTH); + + JPanel rightPane = new JPanel(); + rightPane.setInheritsPopupMenu(true); + rightPane.setOpaque(false); + rightPane.setLayout(new BoxLayout(rightPane, BoxLayout.Y_AXIS)); + rightPane.setMinimumSize(new Dimension(ContributionPanel.BUTTON_WIDTH, 1)); + add(rightPane, BorderLayout.EAST); + + + if (updateButton.isVisible() && !isRemoveInProgress && !contrib.isDeletionFlagged()) {//installRemoveButton.getText().equals("Remove") && + JPanel updateRemovePanel = new JPanel(); + updateRemovePanel.setLayout(new FlowLayout()); + updateRemovePanel.setOpaque(false); + updateRemovePanel.add(updateButton); + updateRemovePanel.add(installRemoveButton); + updateBox.add(updateRemovePanel, BorderLayout.EAST); + + JPanel barPane = new JPanel(); + barPane.setOpaque(false); + barPane.add(installProgressBar); + rightPane.add(barPane); + + if (isUpdateInProgress) + ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, PROGRESS_BAR_CONSTRAINT); + +// barButtonCardPane.removeAll(); +// barButtonCardPane.add(barPane, PROGRESS_BAR_CONSTRAINT); +// ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, PROGRESS_BAR_CONSTRAINT); +// rightPane.add(barButtonCardPane); + } + else { + updateBox.add(updateButton, BorderLayout.EAST); + barButtonCardPane.removeAll(); + + JPanel barPane = new JPanel(); + barPane.setOpaque(false); + barPane.add(installProgressBar); + + JPanel buttonPane = new JPanel(); + buttonPane.setOpaque(false); + buttonPane.add(installRemoveButton); + + barButtonCardPane.add(buttonPane, BUTTON_CONSTRAINT); + barButtonCardPane.add(barPane, PROGRESS_BAR_CONSTRAINT); + if (isInstallInProgress || isRemoveInProgress || isUpdateInProgress) + ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, PROGRESS_BAR_CONSTRAINT); + else + ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); + + rightPane.add(barButtonCardPane); + } + + Dimension d = installProgressBar.getPreferredSize(); + Dimension d2 = installRemoveButton.getPreferredSize(); + d.width = ContributionPanel.BUTTON_WIDTH; + d.height = Math.max(d.height,d2.height); + rightPane.setMinimumSize(d); + rightPane.setPreferredSize(d); + } + + private void setExpandListener(Component component, MouseAdapter expandPanelMouseListener) { component.addMouseListener(expandPanelMouseListener); @@ -445,7 +563,7 @@ class ContributionPanel extends JPanel { if (contribListing.hasUpdates(contrib)) { StringBuilder versionText = new StringBuilder(); versionText.append(""); - if (contrib.isUpdateFlagged()) { + if (contrib.isUpdateFlagged() || contrib.isDeletionFlagged()) { // Already marked for deletion, see requiresRestart() notes below. // versionText.append("To finish an update, reinstall this contribution after restarting."); ; @@ -471,7 +589,7 @@ class ContributionPanel extends JPanel { updateButton.setEnabled(true); if (contrib != null) { - updateButton.setVisible(isSelected() && contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged()); + updateButton.setVisible((contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged() && !contrib.isDeletionFlagged()) || isUpdateInProgress); } installRemoveButton.removeActionListener(installActionListener); @@ -485,11 +603,15 @@ class ContributionPanel extends JPanel { installRemoveButton.addActionListener(removeActionListener); installRemoveButton.setText(Language.text("contributions.remove")); installRemoveButton.setVisible(true); + installRemoveButton.setEnabled(!contrib.isUpdateFlagged()); + reorganizePaneComponents(); } else { installRemoveButton.addActionListener(installActionListener); installRemoveButton.setText(Language.text("contributions.install")); } +// reorganizePaneComponents(); + contextMenu.removeAll(); if (contrib.isInstalled()) { @@ -527,11 +649,17 @@ class ContributionPanel extends JPanel { public void finishedAction() { // Finished installing library resetInstallProgressBarState(); - installRemoveButton.setEnabled(true); + installRemoveButton.setEnabled(!contrib.isUpdateFlagged()); if (isError()) { listPanel.contribManager.status.setErrorMessage(Language.text("contributions.download_error")); } + ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); + isInstallInProgress = false; + if(isUpdateInProgress) + isUpdateInProgress = !isUpdateInProgress; + updateButton.setVisible(contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged()); + setSelected(true); } }; @@ -583,9 +711,10 @@ class ContributionPanel extends JPanel { enableHyperlinks = alreadySelected; if (contrib != null) { - updateButton.setVisible(isSelected() && contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged()); + updateButton.setVisible((contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged() && !contrib.isDeletionFlagged()) || isUpdateInProgress); } - installRemoveButton.setVisible(isSelected() || installRemoveButton.getText().equals(Language.text("contributions.remove"))); + installRemoveButton.setVisible(isSelected() || installRemoveButton.getText().equals(Language.text("contributions.remove")) || isUpdateInProgress); + reorganizePaneComponents(); // for (JTextPane textPane : headerPaneSet) { { diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 494e68828..3a3e5528d 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -430,7 +430,6 @@ public abstract class LocalContribution extends Contribution { // There was a failure backing up the folder if (getType().requiresRestart()) { if (!doBackup || (doBackup && backup(editor, false, status))) { - status.setMessage(""); if (setDeletionFlag(true)) { contribListing.replaceContribution(this, this); } From 599054fc92976eacf580e0773a227551479b66e4 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Fri, 1 Aug 2014 13:10:04 -0300 Subject: [PATCH 034/134] Fix build errors --- pdex/src/processing/mode/experimental/VariableInspector.java | 4 ++-- pdex/src/processing/mode/experimental/VariableNode.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pdex/src/processing/mode/experimental/VariableInspector.java b/pdex/src/processing/mode/experimental/VariableInspector.java index f17ef30d3..80e74f5c9 100755 --- a/pdex/src/processing/mode/experimental/VariableInspector.java +++ b/pdex/src/processing/mode/experimental/VariableInspector.java @@ -74,7 +74,7 @@ public class VariableInspector extends javax.swing.JFrame { protected List declaredThisFields; // declared i.e. non-inherited fields of this protected DebugEditor editor; // the editor protected Debugger dbg; // the debugger - protected List expandedNodes = new ArrayList<>(); // list of expanded tree paths. (using list to maintain the order of expansion) + protected List expandedNodes = new ArrayList(); // list of expanded tree paths. (using list to maintain the order of expansion) protected boolean p5mode = true; // processing / "advanced" mode flag (currently not used /** @@ -515,7 +515,7 @@ public class VariableInspector extends javax.swing.JFrame { // first remove all children of collapsed path // this makes sure children do not appear before parents in the list. // (children can't be expanded before their parents) - List removalList = new ArrayList<>(); + List removalList = new ArrayList(); for (TreePath path : expandedNodes) { if (path.getParentPath().equals(tee.getPath())) { removalList.add(path); diff --git a/pdex/src/processing/mode/experimental/VariableNode.java b/pdex/src/processing/mode/experimental/VariableNode.java index 42944cdc3..958923c66 100755 --- a/pdex/src/processing/mode/experimental/VariableNode.java +++ b/pdex/src/processing/mode/experimental/VariableNode.java @@ -53,7 +53,7 @@ public class VariableNode implements MutableTreeNode { protected String type; protected String name; protected Value value; - protected List children = new ArrayList<>(); + protected List children = new ArrayList(); protected MutableTreeNode parent; /** From 362e79a5d41af7bd2132062239989c70d09d8ae1 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 12:31:06 -0400 Subject: [PATCH 035/134] fix source/target level in pdex, remove tabs from build.xml --- pdex/build.xml | 184 +++++++++--------- .../mode/experimental/ASTNodeWrapper.java | 9 +- 2 files changed, 96 insertions(+), 97 deletions(-) diff --git a/pdex/build.xml b/pdex/build.xml index a839c9160..13b900fdc 100644 --- a/pdex/build.xml +++ b/pdex/build.xml @@ -1,125 +1,125 @@ - + - - - - + + + + - - - + + + - - - - - - - - + + + + + + + + - - - - + + + + - - - + + + - - - + + + - - - - - + + + + + - - - - - + + + + + - + - - - - - + + + + - - - + + + - - - - - - + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - - - - + + + + + + + + + - - - - - - + + + + + + diff --git a/pdex/src/processing/mode/experimental/ASTNodeWrapper.java b/pdex/src/processing/mode/experimental/ASTNodeWrapper.java index e3d26c271..f198c51f7 100644 --- a/pdex/src/processing/mode/experimental/ASTNodeWrapper.java +++ b/pdex/src/processing/mode/experimental/ASTNodeWrapper.java @@ -157,15 +157,14 @@ public class ASTNodeWrapper { if (jd == null) { log("Visiting children of node " + getNodeAsString(thisNode)); - Iterator it = - (Iterator) thisNode - .structuralPropertiesForType().iterator(); + Iterator it = (Iterator) + thisNode.structuralPropertiesForType().iterator(); boolean flag = true; while (it.hasNext()) { StructuralPropertyDescriptor prop = it.next(); if (prop.isChildListProperty()) { - List nodelist = (List) thisNode - .getStructuralProperty(prop); + List nodelist = (List) + thisNode.getStructuralProperty(prop); log("prop " + prop); for (ASTNode cnode : nodelist) { log("Visiting node " + getNodeAsString(cnode)); From aa44a9b9a7e7cf4b249cbf54dede65b5358cd99c Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 12:31:21 -0400 Subject: [PATCH 036/134] add getFolder() method to Mode --- app/src/processing/app/Mode.java | 9 +++++++++ todo.txt | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index 666ec7f0d..b7f8b4224 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -274,6 +274,15 @@ public abstract class Mode { //abstract public Editor createEditor(Base base, String path, int[] location); + /** + * Get the folder where this mode is stored. + * @since 3.0a3 + */ + public File getFolder() { + return folder; + } + + public File getExamplesFolder() { return examplesFolder; } diff --git a/todo.txt b/todo.txt index 8407725b8..aea14aca6 100644 --- a/todo.txt +++ b/todo.txt @@ -32,6 +32,12 @@ X prevent adding files to read-only sketches X https://github.com/processing/processing/issues/2459 X https://github.com/processing/processing/pull/2697 + +high +_ export application ubuntu -> windows not working (2.2.1) +_ https://github.com/processing/processing/issues/2698 + + pending _ look at the sound library https://github.com/wirsing/ProcessingSound _ sound is not yet supported on Windows From e7f6d44ad3f27ed9b4962ee7e9b25cafa48705eb Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 12:33:40 -0400 Subject: [PATCH 037/134] clean up with pt language --- todo.txt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/todo.txt b/todo.txt index aea14aca6..4432341a8 100644 --- a/todo.txt +++ b/todo.txt @@ -18,20 +18,19 @@ _ need to make sure the .properties files are read properly as UTF-8 X Indent breaks when hitting enter before spaces X https://github.com/processing/processing/issues/2004 X https://github.com/processing/processing/pull/2690 -X support for Japanese -X https://github.com/processing/processing/pull/2688 -X support for Spanish -X https://github.com/processing/processing/pull/2691 -X support for Dutch -X https://github.com/processing/processing/pull/2694 -X support for French -X https://github.com/processing/processing/pull/2695 X Localize status messages and contributions panel X https://github.com/processing/processing/pull/2696 X prevent adding files to read-only sketches X https://github.com/processing/processing/issues/2459 X https://github.com/processing/processing/pull/2697 +languages +X Japanese https://github.com/processing/processing/pull/2688 +X Spanish https://github.com/processing/processing/pull/2691 +X Dutch https://github.com/processing/processing/pull/2694 +X French https://github.com/processing/processing/pull/2695 +X Portugese https://github.com/processing/processing/pull/2701 + high _ export application ubuntu -> windows not working (2.2.1) From 9df2bcfa3439880315a617e4a3d15b7f4139f079 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Fri, 1 Aug 2014 14:01:12 -0300 Subject: [PATCH 038/134] Add some helper methods to Language --- app/src/processing/app/Editor.java | 11 ++--------- app/src/processing/app/Language.java | 14 ++++++++++++++ app/src/processing/app/languages/PDE.properties | 6 +++--- app/src/processing/app/languages/PDE_pt.properties | 6 +++--- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index d27d52ffb..0e81c8c17 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -364,15 +364,8 @@ public abstract class Editor extends JFrame implements RunnerListener { return false; } - if (successful == 0) { - statusError(Language.text("editor.status.drag_and_drop.no_files_added")); + statusNotice(Language.pluralize("editor.status.drag_and_drop.files_added", successful)); - } else if (successful == 1) { - statusNotice(Language.text("editor.status.drag_and_drop.one_file_added")); - - } else { - statusNotice(String.format(Language.text("editor.status.drag_and_drop.n_files_added"), successful)); - } return true; } } @@ -2097,7 +2090,7 @@ public abstract class Editor extends JFrame implements RunnerListener { if (text.length() == 0) { statusNotice(Language.text("editor.status.find_reference.select_word_first")); } else { - statusNotice(String.format(Language.text("editor.status.find_reference.not_available"), text)); + statusNotice(Language.interpolate("editor.status.find_reference.not_available", text)); } } } diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 15ae9b685..050c57821 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -123,6 +123,20 @@ public class Language { return init().bundle.getString(text); } + static public String interpolate(String text, Object... arguments) { + return String.format(init().bundle.getString(text), arguments); + } + + static public String pluralize(String text, int count) { + ResourceBundle bundle = init().bundle; + + String fmt = text + ".%s"; + + if (bundle.containsKey(String.format(fmt, count))) { + return interpolate(String.format(fmt, count), count); + } + return interpolate(String.format(fmt, "n"), count); + } /** Get all available languages */ static public Map getLanguages() { diff --git a/app/src/processing/app/languages/PDE.properties b/app/src/processing/app/languages/PDE.properties index 1aa1acbde..c399b965a 100644 --- a/app/src/processing/app/languages/PDE.properties +++ b/app/src/processing/app/languages/PDE.properties @@ -217,9 +217,9 @@ editor.status.autoformat.no_changes = No changes necessary for Auto Format. editor.status.autoformat.finished = Auto Format finished. editor.status.find_reference.select_word_first = First select a word to find in the reference. editor.status.find_reference.not_available = No reference available for "%s". -editor.status.drag_and_drop.no_files_added = No files were added to the sketch. -editor.status.drag_and_drop.one_file_added = One file added to the sketch. -editor.status.drag_and_drop.n_files_added = %d files added to the sketch. +editor.status.drag_and_drop.files_added.0 = No files were added to the sketch. +editor.status.drag_and_drop.files_added.1 = One file added to the sketch. +editor.status.drag_and_drop.files_added.n = %d files added to the sketch. editor.status.saving = Saving... editor.status.saving.done = Done saving. editor.status.saving.canceled = Save canceled. diff --git a/app/src/processing/app/languages/PDE_pt.properties b/app/src/processing/app/languages/PDE_pt.properties index 20932a81c..b69607e26 100644 --- a/app/src/processing/app/languages/PDE_pt.properties +++ b/app/src/processing/app/languages/PDE_pt.properties @@ -217,9 +217,9 @@ editor.status.autoformat.no_changes = Não foram necessárias alterações para editor.status.autoformat.finished = Auto Formatação completa. editor.status.find_reference.select_word_first = Primeiro escolha uma palavra para procurar na referência. editor.status.find_reference.not_available = Não existe refrência disponivel para "%s". -editor.status.drag_and_drop.no_files_added = Nenhuns ficheiros foram adicionados ao sketch. -editor.status.drag_and_drop.one_file_added = Um ficheiro adicionado ao sketch. -editor.status.drag_and_drop.n_files_added = %d ficheiros adicionados ao sketch. +editor.status.drag_and_drop.files_added.0 = Nenhuns ficheiros foram adicionados ao sketch. +editor.status.drag_and_drop.files_added.1 = Um ficheiro adicionado ao sketch. +editor.status.drag_and_drop.files_added.n = %d ficheiros adicionados ao sketch. editor.status.saving = A Guardar... editor.status.saving.done = Guardado com sucesso. editor.status.saving.canceled = Guardar cancelado. From 3d0a9b88a3db8e6a0ca7843ff814e1c0e1003ee7 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Sun, 20 Jul 2014 19:33:19 +0400 Subject: [PATCH 039/134] Added a restart button in case restarless update/removal fails --- .../contrib/ContributionManagerDialog.java | 47 ++++++++++++++++++- .../app/contrib/ContributionPanel.java | 16 ++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index 22133b374..46e70598a 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -27,6 +27,9 @@ import java.awt.Container; import java.awt.Dimension; import java.awt.Font; import java.awt.event.*; +import java.io.File; +import java.io.IOException; +import java.lang.management.ManagementFactory; import java.net.SocketTimeoutException; import java.util.*; @@ -79,13 +82,55 @@ public class ContributionManagerDialog { return contribListing.hasUpdates(base); } - public void showFrame(Editor editor) { + public void showFrame(final Editor editor) { this.editor = editor; if (dialog == null) { dialog = new JFrame(title); restartButton = new JButton("Restart Processing"); + restartButton.setVisible(false); + restartButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + + for (Editor ed : editor.getBase().getEditors()) + if (ed.getSketch().isModified() || ed.getSketch().isUntitled()) { + int option = Base + .showYesNoQuestion(editor, title, + "Unsaved changes have been found", + "Are you sure you want to restart Processing without saving first?"); + + if (option == JOptionPane.NO_OPTION) + return; + else + break; + } + + // Thanks to http://stackoverflow.com/a/4160543 + StringBuilder cmd = new StringBuilder(); + cmd.append(System.getProperty("java.home") + File.separator + "bin" + + File.separator + "java "); + for (String jvmArg : ManagementFactory.getRuntimeMXBean() + .getInputArguments()) { + cmd.append(jvmArg + " "); + } + cmd.append("-cp ") + .append(ManagementFactory.getRuntimeMXBean().getClassPath()) + .append(" "); + cmd.append(Base.class.getName()); + + try { + Runtime.getRuntime().exec(cmd.toString()); + System.exit(0); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + }); Toolkit.setIcon(dialog); createComponents(); diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 280919d7a..f393066f4 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -26,6 +26,7 @@ import java.awt.event.*; import java.io.File; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.Date; @@ -132,6 +133,17 @@ class ContributionPanel extends JPanel { LocalContribution installed = (LocalContribution) contrib; installed.setDeletionFlag(false); contribListing.replaceContribution(contrib, contrib); // ?? + ArrayList contribsList = contribListing.allContributions; + boolean toBeRestarted = false; + for(Contribution contribElement : contribsList) + if (contrib.getType().equals(contribElement.getType())) { + if (contribElement.isDeletionFlagged() || contribElement.isUpdateFlagged()) + { + toBeRestarted = !toBeRestarted; + break; + } + } + listPanel.contribManager.restartButton.setVisible(toBeRestarted); } } }; @@ -162,6 +174,7 @@ class ContributionPanel extends JPanel { public void cancel() { super.cancel(); resetInstallProgressBarState(); + listPanel.contribManager.restartButton.setVisible(true); isRemoveInProgress = false; installRemoveButton.setEnabled(true); // ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); @@ -274,6 +287,7 @@ class ContributionPanel extends JPanel { public void cancel() { super.cancel(); resetInstallProgressBarState(); + listPanel.contribManager.status.setMessage(""); isUpdateInProgress = false; installRemoveButton.setEnabled(true); if (contrib.isDeletionFlagged()) { @@ -282,7 +296,7 @@ class ContributionPanel extends JPanel { contribListing.replaceContribution(contrib,contrib); // updateButton.setVisible(false); } - listPanel.contribManager.status.setMessage(""); + listPanel.contribManager.restartButton.setVisible(true); } }, listPanel.contribManager.status); From 819f9eae7bb1628006224e94d15addc2fe2d8709 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Mon, 21 Jul 2014 11:37:20 +0400 Subject: [PATCH 040/134] tmp folders delete much better --- .../app/contrib/AvailableContribution.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java index acd6b8dbc..de8add146 100644 --- a/app/src/processing/app/contrib/AvailableContribution.java +++ b/app/src/processing/app/contrib/AvailableContribution.java @@ -146,17 +146,27 @@ class AvailableContribution extends Contribution { // //status.setMessage("Restart Processing to finish the installation."); // } - // 3. Delete the newContrib, do a garbage collection, hope and pray + // 3.1 Unlock all the jars if it is a mode or tool + if (newContrib.getType() == ContributionType.MODE) { + ((ModeContribution)newContrib).clearClassLoader(editor.getBase()); + System.out.println("ismode"); + } + else if (newContrib.getType() == ContributionType.TOOL) { + ((ToolContribution)newContrib).clearClassLoader(editor.getBase()); + System.out.println("istool"); + } + + // 3.2 Delete the newContrib, do a garbage collection, hope and pray // that Java will unlock the temp folder on Windows now newContrib = null; System.gc(); if (Base.isWindows()) { - // we'll even give it 2 seconds to finish up ... because file ops are + // we'll even give it a second to finish up ... because file ops are // just that flaky on Windows. try { - Thread.sleep(2000); + Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } From 8322a29fd1ba124c9e97ce843085f7d5cb2eacf6 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Mon, 21 Jul 2014 13:40:20 +0400 Subject: [PATCH 041/134] Left over tmp folders now removed on restart --- .../app/contrib/ContributionManager.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/src/processing/app/contrib/ContributionManager.java b/app/src/processing/app/contrib/ContributionManager.java index 2fe22b84e..bb9c65b0a 100644 --- a/app/src/processing/app/contrib/ContributionManager.java +++ b/app/src/processing/app/contrib/ContributionManager.java @@ -23,6 +23,7 @@ package processing.app.contrib; import java.io.*; import java.net.*; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.ArrayList; @@ -331,6 +332,9 @@ public class ContributionManager { * Also updates all entries previously marked for update. */ static public void cleanup(Base base) throws Exception { + deleteTemp(Base.getSketchbookModesFolder()); + deleteTemp(Base.getSketchbookToolsFolder()); + deleteFlagged(Base.getSketchbookLibrariesFolder()); deleteFlagged(Base.getSketchbookModesFolder()); deleteFlagged(Base.getSketchbookToolsFolder()); @@ -343,6 +347,22 @@ public class ContributionManager { clearRestartFlags(Base.getSketchbookToolsFolder()); } + + static private void deleteTemp(File root) { + + LinkedList deleteList = new LinkedList(); + + for (File f : root.listFiles()) + if (f.getName().matches(root.getName().substring(0, 4) + "\\d*" + "tmp")) + deleteList.add(f); + + Iterator folderIter = deleteList.iterator(); + + while(folderIter.hasNext()) { + Base.removeDir(folderIter.next()); + } + } + static private void deleteFlagged(File root) throws Exception { File[] markedForDeletion = root.listFiles(new FileFilter() { From 2665a6f50c11042dbbd321c13841ead20edceab6 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Tue, 22 Jul 2014 01:43:34 +0400 Subject: [PATCH 042/134] A few bug fixes * Correcting a bug that prevents some contribs from auto-update on restart * Mode installed during auto-update on restart now displays in mode menu --- .../app/contrib/ContributionManager.java | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/app/src/processing/app/contrib/ContributionManager.java b/app/src/processing/app/contrib/ContributionManager.java index bb9c65b0a..8e6c33c8a 100644 --- a/app/src/processing/app/contrib/ContributionManager.java +++ b/app/src/processing/app/contrib/ContributionManager.java @@ -23,13 +23,12 @@ package processing.app.contrib; import java.io.*; import java.net.*; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.ArrayList; -import javax.swing.JProgressBar; - import processing.app.Base; import processing.app.Editor; import processing.app.Language; @@ -183,7 +182,8 @@ public class ContributionManager { contribListing.replaceContribution(ad, contribution); if (contribution.getType() == ContributionType.MODE) { ArrayList contribModes = editor.getBase().getModeContribs(); - contribModes.add((ModeContribution)contribution); + if (!contribModes.contains(contribution)) + contribModes.add((ModeContribution) contribution); } refreshInstalled(editor); } @@ -236,8 +236,16 @@ public class ContributionManager { if (contribution.getType() == ContributionType.MODE) { ArrayList contribModes = base .getModeContribs(); - if (contribModes != null) + if (contribModes != null) { contribModes.add((ModeContribution) contribution); + if (contribution.getType() == ContributionType.MODE + && base.getActiveEditor() != null) { + ArrayList contribModesList = base + .getModeContribs(); + if (!contribModesList.contains(contribution)) + contribModesList.add((ModeContribution) contribution); + } + } } if (base.getActiveEditor() != null) refreshInstalled(base.getActiveEditor()); @@ -384,10 +392,23 @@ public class ContributionManager { LocalContribution.isUpdateFlagged(folder)); } }); + ArrayList updateContribsNames = new ArrayList(); LinkedList updateContribsList = new LinkedList(); + + String type = root.getName().substring(root.getName().lastIndexOf('/') + 1); + String propFileName = null; + + if (type.equalsIgnoreCase("tools")) + propFileName = "tool.properties"; + else if (type.equalsIgnoreCase("modes")) + propFileName = "mode.properties"; + else if (type.equalsIgnoreCase("libraries")) //putting this here, just in case + propFileName = "libraries.properties"; + for (File folder : markedForUpdate) { - updateContribsNames.add(folder.getName()); + HashMap properties = Base.readSettings(new File(folder, propFileName)); + updateContribsNames.add(properties.get("name")); Base.removeDir(folder); } for (AvailableContribution availableContribs : contribListing.advertisedContributions) { From 251acc60673173eca4b738ee81c2f67b72edaa8d Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Tue, 22 Jul 2014 14:38:28 +0400 Subject: [PATCH 043/134] Update on next restart if net isnt available during auto-update on restart And some Spring Cleaning * Changed for-each to iterator * Removed a few redundant functions --- .../app/contrib/AvailableContribution.java | 112 ++------ .../app/contrib/ContributionManager.java | 243 ++++++++++-------- .../contrib/ContributionManagerDialog.java | 5 +- .../app/contrib/ContributionPanel.java | 23 +- .../app/contrib/LocalContribution.java | 164 ++++++------ .../app/contrib/ModeContribution.java | 23 +- .../app/contrib/ToolContribution.java | 5 +- 7 files changed, 259 insertions(+), 316 deletions(-) diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java index de8add146..0eb741e76 100644 --- a/app/src/processing/app/contrib/AvailableContribution.java +++ b/app/src/processing/app/contrib/AvailableContribution.java @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.List; import processing.app.Base; -import processing.app.Editor; import processing.core.PApplet; @@ -70,9 +69,12 @@ class AvailableContribution extends Contribution { * @param confirmReplace * true to open a dialog asking the user to confirm removing/moving * the library when a library by the same name already exists + * @param status + * the StatusPanel. Pass null if this function is called for an + * install-on-startup * @return */ - public LocalContribution install(Editor editor, File contribArchive, + public LocalContribution install(Base base, File contribArchive, boolean confirmReplace, StatusPanel status) { // Unzip the file into the modes, tools, or libraries folder inside the // sketchbook. Unzipping to /tmp is problematic because it may be on @@ -83,7 +85,8 @@ class AvailableContribution extends Contribution { try { tempFolder = type.createTempFolder(); } catch (IOException e) { - status.setErrorMessage("Could not create a temporary folder to install."); + if (status != null) + status.setErrorMessage("Could not create a temporary folder to install."); return null; } Base.unzip(contribArchive, tempFolder); @@ -111,7 +114,8 @@ class AvailableContribution extends Contribution { tempFolder.renameTo(contribFolder); tempFolder = enclosingFolder; */ - status.setErrorMessage(getName() + " needs to be repackaged according to the " + type.getTitle() + " guidelines."); + if (status != null) + status.setErrorMessage(getName() + " needs to be repackaged according to the " + type.getTitle() + " guidelines."); //status.setErrorMessage("This " + type + " needs to be repackaged according to the guidelines."); return null; } @@ -123,14 +127,15 @@ class AvailableContribution extends Contribution { LocalContribution installedContrib = null; if (contribFolder == null) { - status.setErrorMessage("Could not find a " + type + " in the downloaded file."); + if (status != null) + status.setErrorMessage("Could not find a " + type + " in the downloaded file."); } else { File propFile = new File(contribFolder, type + ".properties"); if (writePropertiesFile(propFile)) { // 1. contribFolder now has a legit contribution, load it to get info. LocalContribution newContrib = - type.load(editor.getBase(), contribFolder); + type.load(base, contribFolder); // 1.1. get info we need to delete the newContrib folder later File newContribFolder = newContrib.getFolder(); @@ -138,7 +143,7 @@ class AvailableContribution extends Contribution { // 2. Check to make sure nothing has the same name already, // backup old if needed, then move things into place and reload. installedContrib = - newContrib.copyAndLoad(editor, confirmReplace, status); + newContrib.copyAndLoad(base, confirmReplace, status); // Restart no longer needed. Yay! // if (newContrib != null && type.requiresRestart()) { @@ -148,12 +153,10 @@ class AvailableContribution extends Contribution { // 3.1 Unlock all the jars if it is a mode or tool if (newContrib.getType() == ContributionType.MODE) { - ((ModeContribution)newContrib).clearClassLoader(editor.getBase()); - System.out.println("ismode"); + ((ModeContribution)newContrib).clearClassLoader(base); } else if (newContrib.getType() == ContributionType.TOOL) { - ((ToolContribution)newContrib).clearClassLoader(editor.getBase()); - System.out.println("istool"); + ((ToolContribution)newContrib).clearClassLoader(base); } // 3.2 Delete the newContrib, do a garbage collection, hope and pray @@ -176,7 +179,8 @@ class AvailableContribution extends Contribution { Base.removeDir(newContribFolder); } else { - status.setErrorMessage("Error overwriting .properties file."); + if (status != null) + status.setErrorMessage("Error overwriting .properties file."); } } @@ -188,90 +192,6 @@ class AvailableContribution extends Contribution { } - /** - * @param contribArchive - * a zip file containing the library to install - * @return - */ - public LocalContribution installOnStartup(Base base, File contribArchive, StatusPanel status) { - // Unzip the file into the modes, tools, or libraries folder inside the - // sketchbook. Unzipping to /tmp is problematic because it may be on - // another file system, so move/rename operations will break. - - File tempFolder = null; - - try { - tempFolder = type.createTempFolder(); - } catch (IOException e) { - status.setErrorMessage("Could not create a temporary folder to install."); - return null; - } - Base.unzip(contribArchive, tempFolder); - - // Now go looking for a legit contrib inside what's been unpacked. - File contribFolder = null; - - // Sometimes contrib authors place all their folders in the base directory - // of the .zip file instead of in single folder as the guidelines suggest. - if (type.isCandidate(tempFolder)) { - status.setErrorMessage(getName() + " needs to be repackaged according to the " + type.getTitle() + " guidelines."); - return null; - } - - contribFolder = type.findCandidate(tempFolder); - LocalContribution installedContrib = null; - - if (contribFolder == null) { - status.setErrorMessage("Could not find a " + type + " in the downloaded file."); - - } else { - File propFile = new File(contribFolder, type + ".properties"); - if (writePropertiesFile(propFile)) { - // 1. contribFolder now has a legit contribution, load it to get info. - LocalContribution newContrib = - type.load(base, contribFolder); - - // 1.1. get info we need to delete the newContrib folder later - File newContribFolder = newContrib.getFolder(); - - // 2. Check to make sure nothing has the same name already, - // backup old if needed, then move things into place and reload. - installedContrib = - newContrib.copyAndLoadOnStartup(base, status); - - // 3. Delete the newContrib, do a garbage collection, hope and pray - // that Java will unlock the temp folder on Windows now - newContrib = null; - System.gc(); - - - if (Base.isWindows()) { - // we'll even give it 2 seconds to finish up ... because file ops are - // just that flaky on Windows. - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - // 4. Okay, now actually delete that temp folder - Base.removeDir(newContribFolder); - - } else { - status.setErrorMessage("Error overwriting .properties file."); - } - } - - // Remove any remaining ickies - if (tempFolder.exists()) { - Base.removeDir(tempFolder); - } - return installedContrib; - } - - - public boolean isInstalled() { return false; } diff --git a/app/src/processing/app/contrib/ContributionManager.java b/app/src/processing/app/contrib/ContributionManager.java index 8e6c33c8a..ec1c799cd 100644 --- a/app/src/processing/app/contrib/ContributionManager.java +++ b/app/src/processing/app/contrib/ContributionManager.java @@ -23,11 +23,7 @@ package processing.app.contrib; import java.io.*; import java.net.*; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.ArrayList; +import java.util.*; import processing.app.Base; import processing.app.Editor; @@ -43,8 +39,8 @@ public class ContributionManager { /** - * Blocks until the file is downloaded or an error occurs. - * Returns true if the file was successfully downloaded, false otherwise. + * Blocks until the file is downloaded or an error occurs. Returns true if the + * file was successfully downloaded, false otherwise. * * @param source * the URL of the file to download @@ -52,6 +48,9 @@ public class ContributionManager { * the file on the local system where the file will be written. This * must be a file (not a directory), and must already exist. * @param progress + * null if progress is irrelevant, such as when downloading for an + * install during startup, when the ProgressMonitor is useless since + * UI isn't setup yet. * @throws FileNotFoundException * if an error occurred downloading the file */ @@ -67,83 +66,48 @@ public class ContributionManager { conn.setRequestMethod("GET"); conn.connect(); - // TODO this is often -1, may need to set progress to indeterminate - int fileSize = conn.getContentLength(); + if (progress != null) { + // TODO this is often -1, may need to set progress to indeterminate + int fileSize = conn.getContentLength(); // System.out.println("file size is " + fileSize); - progress.startTask(Language.text("contributions.progress.downloading"), fileSize); + progress.startTask(Language.text("contributions.progress.downloading"), fileSize); + } InputStream in = conn.getInputStream(); FileOutputStream out = new FileOutputStream(dest); byte[] b = new byte[8192]; int amount; - int total = 0; - while (!progress.isCanceled() && (amount = in.read(b)) != -1) { - out.write(b, 0, amount); - total += amount; - progress.setProgress(total); + if (progress != null) { + int total = 0; + while (!progress.isCanceled() && (amount = in.read(b)) != -1) { + out.write(b, 0, amount); + total += amount; + progress.setProgress(total); + } + } else { + while ((amount = in.read(b)) != -1) { + out.write(b, 0, amount); + } } out.flush(); out.close(); success = true; } catch (SocketTimeoutException ste) { - progress.error(ste); - + if (progress != null) + progress.error(ste); } catch (IOException ioe) { - progress.error(ioe); + if (progress != null) + progress.error(ioe); ioe.printStackTrace(); } - progress.finished(); + if (progress != null) + progress.finished(); return success; } - - /** - * Blocks until the file is downloaded or an error occurs. - * Returns true if the file was successfully downloaded, false otherwise. - * Used at startup for automatically downloading and installing. - * - * @param source - * the URL of the file to download - * @param dest - * the file on the local system where the file will be written. This - * must be a file (not a directory), and must already exist. - */ - static boolean download(URL source, File dest) { - boolean success = false; - try { -// System.out.println("downloading file " + source); -// URLConnection conn = source.openConnection(); - HttpURLConnection conn = (HttpURLConnection) source.openConnection(); - HttpURLConnection.setFollowRedirects(true); - conn.setConnectTimeout(15 * 1000); - conn.setReadTimeout(60 * 1000); - conn.setRequestMethod("GET"); - conn.connect(); - InputStream in = conn.getInputStream(); - FileOutputStream out = new FileOutputStream(dest); - - byte[] b = new byte[8192]; - int amount; - while ((amount = in.read(b)) != -1) { - out.write(b, 0, amount); - } - out.flush(); - out.close(); - success = true; - - } catch (SocketTimeoutException ste) { - // When there's no internet... - // TODO: Will have to find a way to download later - } catch (IOException ioe) { - ioe.printStackTrace(); - } - return success; - } - - /** * Non-blocking call to download and install a contribution in a new thread. * @@ -176,7 +140,7 @@ public class ContributionManager { if (!downloadProgress.isCanceled() && !downloadProgress.isError()) { installProgress.startTask("Installing...", ProgressMonitor.UNKNOWN); LocalContribution contribution = - ad.install(editor, contribZip, false, status); + ad.install(editor.getBase(), contribZip, false, status); if (contribution != null) { contribListing.replaceContribution(ad, contribution); @@ -224,38 +188,27 @@ public class ContributionManager { contribZip.setWritable(true); // necessary? try { - download(url, contribZip); + download(url, contribZip, null); - StatusPanel status = new StatusPanel(); - LocalContribution contribution = ad.installOnStartup(base, - contribZip, - status); + LocalContribution contribution = ad.install(base, contribZip, + false, null); if (contribution != null) { contribListing.replaceContribution(ad, contribution); if (contribution.getType() == ContributionType.MODE) { ArrayList contribModes = base .getModeContribs(); - if (contribModes != null) { + if (contribModes != null && !contribModes.contains(contribution)) { contribModes.add((ModeContribution) contribution); - if (contribution.getType() == ContributionType.MODE - && base.getActiveEditor() != null) { - ArrayList contribModesList = base - .getModeContribs(); - if (!contribModesList.contains(contribution)) - contribModesList.add((ModeContribution) contribution); - } } } if (base.getActiveEditor() != null) refreshInstalled(base.getActiveEditor()); } - System.out.println(status.getText()); -// if (contribution != null) { -// contribListing.replaceContribution(ad, contribution); -// } contribZip.delete(); + + handleUpdateFailedMarkers(ad, filename.substring(0, filename.lastIndexOf('.'))); } catch (Exception e) { e.printStackTrace(); @@ -272,9 +225,34 @@ public class ContributionManager { } +/** + * After install, this function checks whether everything went properly or not. + * If not, it adds a marker file so that the next time Processing is started, installPreviouslyFailed() + * can install the contribution. + * @param ac + * The contribution just installed. + * @param filename + * The name of the folder in which the contribution is supposed to be stored. + */ + static private void handleUpdateFailedMarkers(final AvailableContribution ac, String filename) { + + File contribLocn = ac.getType().getSketchbookFolder(); + + try { + new File(contribLocn, ac.getName()).createNewFile(); + } catch (IOException e) { + // File already exists... + //e.printStackTrace(); + } + + } + + static public void refreshInstalled(Editor e) { - List editor = e.getBase().getEditors(); - for (Editor ed : editor) { + + Iterator iter = e.getBase().getEditors().iterator(); + while (iter.hasNext()) { + Editor ed = iter.next(); ed.getMode().rebuildImportMenu(); ed.getMode().resetExamples(); ed.rebuildToolMenu(); @@ -340,6 +318,7 @@ public class ContributionManager { * Also updates all entries previously marked for update. */ static public void cleanup(Base base) throws Exception { + deleteTemp(Base.getSketchbookModesFolder()); deleteTemp(Base.getSketchbookToolsFolder()); @@ -347,7 +326,9 @@ public class ContributionManager { deleteFlagged(Base.getSketchbookModesFolder()); deleteFlagged(Base.getSketchbookToolsFolder()); - updateFlagged(base, Base.getSketchbookLibrariesFolder()); + installPreviouslyFailed(base, Base.getSketchbookModesFolder()); + installPreviouslyFailed(base, Base.getSketchbookToolsFolder()); + updateFlagged(base, Base.getSketchbookModesFolder()); updateFlagged(base, Base.getSketchbookToolsFolder()); @@ -356,27 +337,40 @@ public class ContributionManager { } + /** + * Deletes the icky tmp folders that were left over from installs and updates + * in the previous run of Processing. Needed to be called only on the tools + * and modes sketchbook folders. + * + * @param root + */ static private void deleteTemp(File root) { - + LinkedList deleteList = new LinkedList(); - + for (File f : root.listFiles()) if (f.getName().matches(root.getName().substring(0, 4) + "\\d*" + "tmp")) deleteList.add(f); - + Iterator folderIter = deleteList.iterator(); - - while(folderIter.hasNext()) { + + while (folderIter.hasNext()) { Base.removeDir(folderIter.next()); } } - + + /** + * Deletes all the modes/tools/libs that are flagged for removal. + * + * @param root + * @throws Exception + */ static private void deleteFlagged(File root) throws Exception { File[] markedForDeletion = root.listFiles(new FileFilter() { public boolean accept(File folder) { - return (folder.isDirectory() && - LocalContribution.isDeletionFlagged(folder)); + return (folder.isDirectory() && LocalContribution + .isDeletionFlagged(folder)); } }); for (File folder : markedForDeletion) { @@ -385,38 +379,81 @@ public class ContributionManager { } + /** + * Installs all the modes/tools whose installation failed during an + * auto-update the previous time Processing was started up. + * + * @param base + * @param root + * @throws Exception + */ + static private void installPreviouslyFailed(Base base, File root) throws Exception { + File[] installList = root.listFiles(new FileFilter() { + public boolean accept(File folder) { + return (folder.isFile()); + } + }); + + for (File file : installList) { + Iterator iter = contribListing.advertisedContributions.iterator(); + while (iter.hasNext()) { + AvailableContribution availableContrib = iter.next(); + if (file.getName().equals(availableContrib.getName())) { + installOnStartUp(base, availableContrib); + contribListing + .replaceContribution(availableContrib, availableContrib); + } + } + } + } + + + /** + * Updates all the flagged modes/tools. + * + * @param base + * @param root + * @throws Exception + */ static private void updateFlagged(Base base, File root) throws Exception { File[] markedForUpdate = root.listFiles(new FileFilter() { public boolean accept(File folder) { - return (folder.isDirectory() && - LocalContribution.isUpdateFlagged(folder)); + return (folder.isDirectory() && LocalContribution + .isUpdateFlagged(folder)); } }); - + ArrayList updateContribsNames = new ArrayList(); LinkedList updateContribsList = new LinkedList(); - + String type = root.getName().substring(root.getName().lastIndexOf('/') + 1); String propFileName = null; - + if (type.equalsIgnoreCase("tools")) propFileName = "tool.properties"; else if (type.equalsIgnoreCase("modes")) propFileName = "mode.properties"; else if (type.equalsIgnoreCase("libraries")) //putting this here, just in case propFileName = "libraries.properties"; - + for (File folder : markedForUpdate) { - HashMap properties = Base.readSettings(new File(folder, propFileName)); + HashMap properties = Base + .readSettings(new File(folder, propFileName)); updateContribsNames.add(properties.get("name")); Base.removeDir(folder); } - for (AvailableContribution availableContribs : contribListing.advertisedContributions) { - if(updateContribsNames.contains(availableContribs.getName())) { + + Iterator iter = contribListing.advertisedContributions.iterator(); + while (iter.hasNext()) { + AvailableContribution availableContribs = iter.next(); + if (updateContribsNames.contains(availableContribs.getName())) { updateContribsList.add(availableContribs); } } - for (AvailableContribution contribToUpdate : updateContribsList) { + + Iterator iter2 = updateContribsList.iterator(); + while (iter2.hasNext()) { + AvailableContribution contribToUpdate = iter2.next(); installOnStartUp(base, contribToUpdate); contribListing.replaceContribution(contribToUpdate, contribToUpdate); } diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index 46e70598a..189c0152a 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -95,7 +95,9 @@ public class ContributionManagerDialog { @Override public void actionPerformed(ActionEvent arg0) { - for (Editor ed : editor.getBase().getEditors()) + Iterator iter = editor.getBase().getEditors().iterator(); + while (iter.hasNext()) { + Editor ed = iter.next(); if (ed.getSketch().isModified() || ed.getSketch().isUntitled()) { int option = Base .showYesNoQuestion(editor, title, @@ -107,6 +109,7 @@ public class ContributionManagerDialog { else break; } + } // Thanks to http://stackoverflow.com/a/4160543 StringBuilder cmd = new StringBuilder(); diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index f393066f4..3fbb79c6d 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -26,7 +26,7 @@ import java.awt.event.*; import java.io.File; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; +import java.util.Iterator; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.Date; @@ -133,9 +133,10 @@ class ContributionPanel extends JPanel { LocalContribution installed = (LocalContribution) contrib; installed.setDeletionFlag(false); contribListing.replaceContribution(contrib, contrib); // ?? - ArrayList contribsList = contribListing.allContributions; + Iterator contribsListIter = contribListing.allContributions.iterator(); boolean toBeRestarted = false; - for(Contribution contribElement : contribsList) + while (contribsListIter.hasNext()) { + Contribution contribElement = contribsListIter.next(); if (contrib.getType().equals(contribElement.getType())) { if (contribElement.isDeletionFlagged() || contribElement.isUpdateFlagged()) { @@ -143,6 +144,7 @@ class ContributionPanel extends JPanel { break; } } + } listPanel.contribManager.restartButton.setVisible(toBeRestarted); } } @@ -399,6 +401,7 @@ class ContributionPanel extends JPanel { JPanel updateBox = new JPanel(); updateBox.setLayout(new BorderLayout()); + updateBox.setInheritsPopupMenu(true); updateBox.add(notificationBlock, BorderLayout.WEST); updateBox.setBorder(new EmptyBorder(4, 7, 7, 7)); updateBox.setOpaque(false); @@ -412,26 +415,24 @@ class ContributionPanel extends JPanel { add(rightPane, BorderLayout.EAST); - if (updateButton.isVisible() && !isRemoveInProgress && !contrib.isDeletionFlagged()) {//installRemoveButton.getText().equals("Remove") && + if (updateButton.isVisible() && !isRemoveInProgress && !contrib.isDeletionFlagged()) { JPanel updateRemovePanel = new JPanel(); updateRemovePanel.setLayout(new FlowLayout()); updateRemovePanel.setOpaque(false); updateRemovePanel.add(updateButton); + updateRemovePanel.setInheritsPopupMenu(true); updateRemovePanel.add(installRemoveButton); updateBox.add(updateRemovePanel, BorderLayout.EAST); JPanel barPane = new JPanel(); barPane.setOpaque(false); + barPane.setInheritsPopupMenu(true); barPane.add(installProgressBar); rightPane.add(barPane); if (isUpdateInProgress) ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, PROGRESS_BAR_CONSTRAINT); - -// barButtonCardPane.removeAll(); -// barButtonCardPane.add(barPane, PROGRESS_BAR_CONSTRAINT); -// ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, PROGRESS_BAR_CONSTRAINT); -// rightPane.add(barButtonCardPane); + } else { updateBox.add(updateButton, BorderLayout.EAST); @@ -439,10 +440,12 @@ class ContributionPanel extends JPanel { JPanel barPane = new JPanel(); barPane.setOpaque(false); + barPane.setInheritsPopupMenu(true); barPane.add(installProgressBar); JPanel buttonPane = new JPanel(); buttonPane.setOpaque(false); + buttonPane.setInheritsPopupMenu(true); buttonPane.add(installRemoveButton); barButtonCardPane.add(buttonPane, BUTTON_CONSTRAINT); @@ -624,8 +627,6 @@ class ContributionPanel extends JPanel { installRemoveButton.setText(Language.text("contributions.install")); } -// reorganizePaneComponents(); - contextMenu.removeAll(); if (contrib.isInstalled()) { diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 3a3e5528d..70dce887d 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -195,104 +195,90 @@ public abstract class LocalContribution extends Contribution { // } - LocalContribution copyAndLoad(Editor editor, + LocalContribution copyAndLoad(Base base, boolean confirmReplace, StatusPanel status) { - ArrayList oldContribs = - getType().listContributions(editor); +// NOTE: null status => function is called on startup when Editor objects, et al. aren't ready String contribFolderName = getFolder().getName(); File contribTypeFolder = getType().getSketchbookFolder(); File contribFolder = new File(contribTypeFolder, contribFolderName); + + if (status != null) { // when status != null, install is not occurring on startup + + Editor editor = base.getActiveEditor(); + + ArrayList oldContribs = + getType().listContributions(editor); + + // In case an update marker exists, and the user wants to install, delete the update marker + if (contribFolder.exists() && !contribFolder.isDirectory()) { + contribFolder.delete(); + contribFolder = new File(contribTypeFolder, contribFolderName); + } - for (LocalContribution oldContrib : oldContribs) { - if ((oldContrib.getFolder().exists() && oldContrib.getFolder().equals(contribFolder)) || - (oldContrib.getId() != null && oldContrib.getId().equals(getId()))) { + for (LocalContribution oldContrib : oldContribs) { + if ((oldContrib.getFolder().exists() && oldContrib.getFolder().equals(contribFolder)) || + (oldContrib.getId() != null && oldContrib.getId().equals(getId()))) { - if (oldContrib.getType().requiresRestart()) { - // XXX: We can't replace stuff, soooooo.... do something different - if (!oldContrib.backup(editor, false, status)) { - return null; - } - } else { - int result = 0; - boolean doBackup = Preferences.getBoolean("contribution.backup.on_install"); - if (confirmReplace) { - if (doBackup) { - result = Base.showYesNoQuestion(editor, "Replace", - "Replace pre-existing \"" + oldContrib.getName() + "\" library?", - "A pre-existing copy of the \"" + oldContrib.getName() + "\" library
"+ - "has been found in your sketchbook. Clicking “Yes”
"+ - "will move the existing library to a backup folder
" + - "in libraries/old before replacing it."); - if (result != JOptionPane.YES_OPTION || !oldContrib.backup(editor, true, status)) { - return null; - } - } else { - result = Base.showYesNoQuestion(editor, "Replace", - "Replace pre-existing \"" + oldContrib.getName() + "\" library?", - "A pre-existing copy of the \"" + oldContrib.getName() + "\" library
"+ - "has been found in your sketchbook. Clicking “Yes”
"+ - "will permanently delete this library and all of its contents
"+ - "before replacing it."); - if (result != JOptionPane.YES_OPTION || !oldContrib.getFolder().delete()) { - return null; - } + if (oldContrib.getType().requiresRestart()) { + // XXX: We can't replace stuff, soooooo.... do something different + if (!oldContrib.backup(editor, false, status)) { + return null; } } else { - if ((doBackup && !oldContrib.backup(editor, true, status)) || - (!doBackup && !oldContrib.getFolder().delete())) { - return null; + int result = 0; + boolean doBackup = Preferences.getBoolean("contribution.backup.on_install"); + if (confirmReplace) { + if (doBackup) { + result = Base.showYesNoQuestion(editor, "Replace", + "Replace pre-existing \"" + oldContrib.getName() + "\" library?", + "A pre-existing copy of the \"" + oldContrib.getName() + "\" library
"+ + "has been found in your sketchbook. Clicking “Yes”
"+ + "will move the existing library to a backup folder
" + + "in libraries/old before replacing it."); + if (result != JOptionPane.YES_OPTION || !oldContrib.backup(editor, true, status)) { + return null; + } + } else { + result = Base.showYesNoQuestion(editor, "Replace", + "Replace pre-existing \"" + oldContrib.getName() + "\" library?", + "A pre-existing copy of the \"" + oldContrib.getName() + "\" library
"+ + "has been found in your sketchbook. Clicking “Yes”
"+ + "will permanently delete this library and all of its contents
"+ + "before replacing it."); + if (result != JOptionPane.YES_OPTION || !oldContrib.getFolder().delete()) { + return null; + } + } + } else { + if ((doBackup && !oldContrib.backup(editor, true, status)) || + (!doBackup && !oldContrib.getFolder().delete())) { + return null; + } } } } } - } - // At this point it should be safe to replace this fella - if (contribFolder.exists()) { - Base.removeDir(contribFolder); + // At this point it should be safe to replace this fella + if (contribFolder.exists()) { + Base.removeDir(contribFolder); + } + + } + else { + // This if should ideally never happen, since this function is to be called only when restarting on update + if (contribFolder.exists() && contribFolder.isDirectory()) { + Base.removeDir(contribFolder); + } + else if (contribFolder.exists()) { + contribFolder.delete(); + contribFolder = new File(contribTypeFolder, contribFolderName); + } } - - File oldFolder = getFolder(); - - try { - Base.copyDir(oldFolder, contribFolder); - } catch (IOException e) { - status.setErrorMessage("Could not copy " + getTypeName() + - " \"" + getName() + "\" to the sketchbook."); - e.printStackTrace(); - return null; - } - - - /* - if (!getFolder().renameTo(contribFolder)) { - status.setErrorMessage("Could not move " + getTypeName() + - " \"" + getName() + "\" to the sketchbook."); - return null; - } - */ - - return getType().load(editor.getBase(), contribFolder); - } - - - LocalContribution copyAndLoadOnStartup(Base base, StatusPanel status) { - - String contribFolderName = getFolder().getName(); - - File contribTypeFolder = getType().getSketchbookFolder(); - File contribFolder = new File(contribTypeFolder, contribFolderName); - - // This if should ideally never happen, since this function is to be called only when restarting on update - if (contribFolder.exists()) { - Base.removeDir(contribFolder); - } - - File oldFolder = getFolder(); try { @@ -317,7 +303,6 @@ public abstract class LocalContribution extends Contribution { } - /** * Moves the given contribution to a backup folder. * @param deleteOriginal @@ -367,8 +352,11 @@ public abstract class LocalContribution extends Contribution { }).start(); } - void remove(final Editor editor, final ProgressMonitor pm, - final StatusPanel status, final ContributionListing contribListing) { + + void remove(final Editor editor, + final ProgressMonitor pm, + final StatusPanel status, + final ContributionListing contribListing) { pm.startTask("Removing", ProgressMonitor.UNKNOWN); boolean doBackup = Preferences.getBoolean("contribution.backup.on_remove"); @@ -383,11 +371,14 @@ public abstract class LocalContribution extends Contribution { if (getType() == ContributionType.MODE) { boolean isModeActive = false; ModeContribution m = (ModeContribution) this; - for (Editor e : editor.getBase().getEditors()) + Iterator iter = editor.getBase().getEditors().iterator(); + while (iter.hasNext()) { + Editor e = iter.next(); if (e.getMode().equals(m.getMode())) { isModeActive = true; break; } + } if (!isModeActive) m.clearClassLoader(editor.getBase()); else { @@ -401,8 +392,11 @@ public abstract class LocalContribution extends Contribution { } if (getType() == ContributionType.TOOL) { ToolContribution t = (ToolContribution) this; - for (Editor ed : editor.getBase().getEditors()) + Iterator iter = editor.getBase().getEditors().iterator(); + while (iter.hasNext()) { + Editor ed = iter.next(); ed.clearToolMenu(); + } t.clearClassLoader(editor.getBase()); } if (doBackup) { diff --git a/app/src/processing/app/contrib/ModeContribution.java b/app/src/processing/app/contrib/ModeContribution.java index 7312b5309..d80c074a0 100644 --- a/app/src/processing/app/contrib/ModeContribution.java +++ b/app/src/processing/app/contrib/ModeContribution.java @@ -21,17 +21,13 @@ */ package processing.app.contrib; -import java.awt.Component; import java.io.File; import java.io.IOException; import java.lang.reflect.Constructor; import java.net.URLClassLoader; import java.util.*; -import javax.swing.JRadioButtonMenuItem; - import processing.app.Base; -import processing.app.Editor; import processing.app.Mode; @@ -77,6 +73,7 @@ public class ModeContribution extends LocalContribution { private ModeContribution(Base base, File folder, String className) throws Exception { super(folder); + className = initLoader(className); if (className != null) { Class modeClass = loader.loadClass(className); @@ -90,26 +87,16 @@ public class ModeContribution extends LocalContribution { } /** - * Method to close the ClassLoader so that the archives are no longer "locked" and - * a mode can be removed without restart. + * Method to close the ClassLoader so that the archives are no longer "locked" + * and a mode can be removed without restart. */ public void clearClassLoader(Base base) { + ArrayList contribModes = base.getModeContribs(); int botherToRemove = contribModes.indexOf(this); if (botherToRemove != -1) { // The poor thing isn't even loaded, and we're trying to remove it... contribModes.remove(botherToRemove); - /* List editorList = base.getEditors(); - for (Editor editor : editorList) { - Component[] j = editor.getModeMenu().getPopupMenu().getComponents(); - for (Component component : j) { - JRadioButtonMenuItem cbmi = null; - if (component instanceof JRadioButtonMenuItem) { - cbmi = (JRadioButtonMenuItem) component; - if (cbmi.getText().equals(mode.toString())) - editor.getModeMenu().getPopupMenu().remove(component); - } - } - } */ + try { ((URLClassLoader) loader).close(); // The typecast should be safe, since the only case when loader is not of diff --git a/app/src/processing/app/contrib/ToolContribution.java b/app/src/processing/app/contrib/ToolContribution.java index 85befb838..2769bf820 100644 --- a/app/src/processing/app/contrib/ToolContribution.java +++ b/app/src/processing/app/contrib/ToolContribution.java @@ -76,8 +76,9 @@ public class ToolContribution extends LocalContribution implements Tool { } catch (IOException e1) { e1.printStackTrace(); } - List editors = base.getEditors(); - for (Editor editor : editors) { + Iterator editorIter = base.getEditors().iterator(); + while (editorIter.hasNext()) { + Editor editor = editorIter.next(); ArrayList contribTools = editor.contribTools; for (ToolContribution toolContrib : contribTools) if (toolContrib.getName().equals(this.name)) { From ef23935c96eb465c5cf88a24d2e6543f5502ba57 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Wed, 23 Jul 2014 15:49:53 +0400 Subject: [PATCH 044/134] Done revamping Contribution Manager Lots of Bug Squashin' * Fixed the bug that appeared when trying to remove the present mode * Minor bug fix in working of Lib Manager * Minor GUI Changes * Solves ConcurModifExcept that randomly pops up * Fix bug that appears when multiple modes are to be updated on restart * Fixed bug affecting failedupdate for modes * Solved bug that involved auto-update on startup * Removed pointless commented out code --- .../app/contrib/ContributionListing.java | 4 +- .../app/contrib/ContributionManager.java | 60 +++++++++++++++---- .../contrib/ContributionManagerDialog.java | 2 +- .../app/contrib/ContributionPanel.java | 45 ++++++++++++-- .../app/contrib/LocalContribution.java | 7 +-- .../app/contrib/ToolContribution.java | 5 -- 6 files changed, 95 insertions(+), 28 deletions(-) diff --git a/app/src/processing/app/contrib/ContributionListing.java b/app/src/processing/app/contrib/ContributionListing.java index 65c16048f..8ad8df331 100644 --- a/app/src/processing/app/contrib/ContributionListing.java +++ b/app/src/processing/app/contrib/ContributionListing.java @@ -166,7 +166,9 @@ public class ContributionListing { protected AvailableContribution getAvailableContribution(Contribution info) { - for (AvailableContribution advertised : advertisedContributions) { + Iterator iter = advertisedContributions.iterator(); + while(iter.hasNext()) { + AvailableContribution advertised = iter.next(); if (advertised.getType() == info.getType() && advertised.getName().equals(info.getName())) { return advertised; diff --git a/app/src/processing/app/contrib/ContributionManager.java b/app/src/processing/app/contrib/ContributionManager.java index ec1c799cd..83ed5285c 100644 --- a/app/src/processing/app/contrib/ContributionManager.java +++ b/app/src/processing/app/contrib/ContributionManager.java @@ -25,6 +25,8 @@ import java.io.*; import java.net.*; import java.util.*; +import javax.swing.SwingWorker; + import processing.app.Base; import processing.app.Editor; import processing.app.Language; @@ -189,7 +191,7 @@ public class ContributionManager { try { download(url, contribZip, null); - + LocalContribution contribution = ad.install(base, contribZip, false, null); @@ -211,7 +213,8 @@ public class ContributionManager { handleUpdateFailedMarkers(ad, filename.substring(0, filename.lastIndexOf('.'))); } catch (Exception e) { - e.printStackTrace(); +// Chuck the stack trace. The user might have no idea why it is appearing, or what (s)he did wrong... +// e.printStackTrace(); System.out.println("Error during download and install of " + ad.getName()); } @@ -235,16 +238,32 @@ public class ContributionManager { * The name of the folder in which the contribution is supposed to be stored. */ static private void handleUpdateFailedMarkers(final AvailableContribution ac, String filename) { - + File contribLocn = ac.getType().getSketchbookFolder(); - try { - new File(contribLocn, ac.getName()).createNewFile(); - } catch (IOException e) { - // File already exists... - //e.printStackTrace(); + for (File contribDir : contribLocn.listFiles()) + if (contribDir.isDirectory()) { + File[] contents = contribDir.listFiles(new FilenameFilter() { + + @Override + public boolean accept(File dir, String file) { + return file.equals(ac.getType() + ".properties"); + } + }); + if (contents.length > 0 && Base.readSettings(contents[0]).get("name").equals(ac.getName())) { + return; + } } - + + try { + new File(contribLocn, ac.getName()).createNewFile(); + } catch (IOException e) { +// Again, forget about the stack trace. The user ain't done wrong +// e.printStackTrace(); + System.err.println("The unupdated contribution marker seems to not like " + + ac.getName() + ". You may have to install it manually to update..."); + } + } @@ -317,7 +336,7 @@ public class ContributionManager { * and remove any "requires restart" flags. * Also updates all entries previously marked for update. */ - static public void cleanup(Base base) throws Exception { + static public void cleanup(final Base base) throws Exception { deleteTemp(Base.getSketchbookModesFolder()); deleteTemp(Base.getSketchbookToolsFolder()); @@ -327,11 +346,27 @@ public class ContributionManager { deleteFlagged(Base.getSketchbookToolsFolder()); installPreviouslyFailed(base, Base.getSketchbookModesFolder()); - installPreviouslyFailed(base, Base.getSketchbookToolsFolder()); - updateFlagged(base, Base.getSketchbookModesFolder()); + updateFlagged(base, Base.getSketchbookToolsFolder()); + SwingWorker s = new SwingWorker() { + + @Override + protected Void doInBackground() throws Exception { + try { + Thread.sleep(1 * 1000); + installPreviouslyFailed(base, Base.getSketchbookToolsFolder()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + return null; + } + }; + s.execute(); + + + clearRestartFlags(Base.getSketchbookModesFolder()); clearRestartFlags(Base.getSketchbookToolsFolder()); } @@ -399,6 +434,7 @@ public class ContributionManager { while (iter.hasNext()) { AvailableContribution availableContrib = iter.next(); if (file.getName().equals(availableContrib.getName())) { + file.delete(); installOnStartUp(base, availableContrib); contribListing .replaceContribution(availableContrib, availableContrib); diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index 189c0152a..b37b2c6bc 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -98,7 +98,7 @@ public class ContributionManagerDialog { Iterator iter = editor.getBase().getEditors().iterator(); while (iter.hasNext()) { Editor ed = iter.next(); - if (ed.getSketch().isModified() || ed.getSketch().isUntitled()) { + if (ed.getSketch().isModified()) { int option = Base .showYesNoQuestion(editor, title, "Unsaved changes have been found", diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 3fbb79c6d..69ba5382a 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -41,6 +41,7 @@ import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.StyleSheet; import processing.app.Base; +import processing.app.Editor; import processing.app.Language; @@ -168,7 +169,7 @@ class ContributionPanel extends JPanel { resetInstallProgressBarState(); isRemoveInProgress = false; installRemoveButton.setEnabled(true); -// ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); + reorganizePaneComponents(); setSelected(true); // Needed for smooth working. Dunno why, though... } @@ -176,12 +177,29 @@ class ContributionPanel extends JPanel { public void cancel() { super.cancel(); resetInstallProgressBarState(); - listPanel.contribManager.restartButton.setVisible(true); isRemoveInProgress = false; installRemoveButton.setEnabled(true); -// ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); + reorganizePaneComponents(); setSelected(true); + + boolean isModeActive = false; + if (contrib.getType() == ContributionType.MODE) { + ModeContribution m = (ModeContribution) contrib; + Iterator iter = listPanel.contribManager.editor.getBase().getEditors().iterator(); + + while (iter.hasNext()) { + Editor e = iter.next(); + if (e.getMode().equals(m.getMode())) { + isModeActive = true; + break; + } + } + } + if(!isModeActive) + listPanel.contribManager.restartButton.setVisible(true); + else + updateButton.setEnabled(true); } }, listPanel.contribManager.status); @@ -296,14 +314,31 @@ class ContributionPanel extends JPanel { ((LocalContribution)contrib).setUpdateFlag(true); ((LocalContribution)contrib).setDeletionFlag(false); contribListing.replaceContribution(contrib,contrib); -// updateButton.setVisible(false); } - listPanel.contribManager.restartButton.setVisible(true); + + boolean isModeActive = false; + if (contrib.getType() == ContributionType.MODE) { + ModeContribution m = (ModeContribution) contrib; + Iterator iter = listPanel.contribManager.editor.getBase().getEditors().iterator(); + + while (iter.hasNext()) { + Editor e = iter.next(); + if (e.getMode().equals(m.getMode())) { + isModeActive = true; + break; + } + } + } + if(!isModeActive) + listPanel.contribManager.restartButton.setVisible(true); + else + updateButton.setEnabled(true); } }, listPanel.contribManager.status); } else { updateButton.setEnabled(false); + installRemoveButton.setEnabled(false); AvailableContribution ad = contribListing.getAvailableContribution(contrib); String url = ad.link; installContribution(ad, url); diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 70dce887d..143adb44f 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -360,7 +360,7 @@ public abstract class LocalContribution extends Contribution { pm.startTask("Removing", ProgressMonitor.UNKNOWN); boolean doBackup = Preferences.getBoolean("contribution.backup.on_remove"); -// if (getType().requiresRestart() && getType() != ContributionType.MODE) { +// if (getType().requiresRestart()) { // if (!doBackup || (doBackup && backup(editor, false, status))) { // if (setDeletionFlag(true)) { // contribListing.replaceContribution(this, this); @@ -386,10 +386,10 @@ public abstract class LocalContribution extends Contribution { Base.showMessage("Mode Manager", "Please save your Sketch and change the Mode of all Editor\nwindows that have " + this.name + " as the active Mode."); -// ContributionManager.refreshInstalled(editor); return; } } + if (getType() == ContributionType.TOOL) { ToolContribution t = (ToolContribution) this; Iterator iter = editor.getBase().getEditors().iterator(); @@ -399,6 +399,7 @@ public abstract class LocalContribution extends Contribution { } t.clearClassLoader(editor.getBase()); } + if (doBackup) { success = backup(editor, true, status); } else { @@ -422,7 +423,6 @@ public abstract class LocalContribution extends Contribution { } else { // There was a failure backing up the folder - if (getType().requiresRestart()) { if (!doBackup || (doBackup && backup(editor, false, status))) { if (setDeletionFlag(true)) { contribListing.replaceContribution(this, this); @@ -430,7 +430,6 @@ public abstract class LocalContribution extends Contribution { } else status.setErrorMessage("Could not delete the contribution's files"); - } } // } ContributionManager.refreshInstalled(editor); diff --git a/app/src/processing/app/contrib/ToolContribution.java b/app/src/processing/app/contrib/ToolContribution.java index 2769bf820..b84dbd89c 100644 --- a/app/src/processing/app/contrib/ToolContribution.java +++ b/app/src/processing/app/contrib/ToolContribution.java @@ -67,10 +67,6 @@ public class ToolContribution extends LocalContribution implements Tool { * a tool can be removed without restart. */ public void clearClassLoader(Base base) { -// ArrayList contribTools = base.getActiveEditor().contribTools; -// int botherToRemove = contribTools.indexOf(this); -// if (botherToRemove != -1) { // The poor thing doesn't even exist, and we're trying to remove it... -// contribTools.remove(botherToRemove); try { ((URLClassLoader) this.loader).close(); } catch (IOException e1) { @@ -92,7 +88,6 @@ public class ToolContribution extends LocalContribution implements Tool { // base.getActiveEditor().rebuildToolMenu(); } } -// } } From 1c0ee3ca95e9200e9cbb01e75798f8a7283c0e4b Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Fri, 1 Aug 2014 14:18:35 -0300 Subject: [PATCH 045/134] Use interpolate in ContributionPanel status --- app/src/processing/app/contrib/ContributionPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 07f76e472..a85fa7e2f 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -457,7 +457,7 @@ class ContributionPanel extends JPanel { private void installContribution(AvailableContribution info) { if (info.link == null) { - listPanel.contribManager.status.setErrorMessage(String.format(Language.text("contributions.unsupported_operating_system"), info.getType())); + listPanel.contribManager.status.setErrorMessage(Language.interpolate("contributions.unsupported_operating_system", info.getType())); } else { installContribution(info, info.link); } From 58e7fb979ac5c86290e8190607487fa706b0d015 Mon Sep 17 00:00:00 2001 From: AmnonOwed Date: Fri, 1 Aug 2014 21:29:54 +0200 Subject: [PATCH 046/134] Several improvements to the Dutch language file --- .../app/languages/PDE_nl.properties | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/src/processing/app/languages/PDE_nl.properties b/app/src/processing/app/languages/PDE_nl.properties index 05932c99b..aa32ff702 100644 --- a/app/src/processing/app/languages/PDE_nl.properties +++ b/app/src/processing/app/languages/PDE_nl.properties @@ -20,7 +20,7 @@ menu.file.close = Sluiten menu.file.save = Opslaan menu.file.save_as = Opslaan Als... menu.file.export_application = Exporteren Applicatie... -menu.file.page_setup = Pagina Instelling +menu.file.page_setup = Pagina-instelling menu.file.print = Afdrukken... menu.file.preferences = Instellingen... menu.file.quit = Afsluiten @@ -81,7 +81,7 @@ menu.help.troubleshooting = Bekende Problemen menu.help.troubleshooting.url = http://wiki.processing.org/w/Troubleshooting menu.help.faq = Veelgestelde Vragen menu.help.faq.url = http://wiki.processing.org/w/FAQ -menu.help.foundation = The Processing Foundation +menu.help.foundation = Over The Processing Foundation menu.help.foundation.url = http://processing.org/foundation/ menu.help.visit = Ga naar Processing.org menu.help.visit.url = http://processing.org/ @@ -95,7 +95,7 @@ prompt.yes = Ja prompt.no = Nee prompt.cancel = Annuleren prompt.ok = OK -prompt.browse = Verkennen +prompt.browse = Bladeren prompt.export = Exporteren @@ -114,32 +114,32 @@ save.btn.dont_save = Niet Opslaan # Preferences (Frame) preferences = Instellingen -preferences.button.width = 80 -preferences.requires_restart = herstart van Processing vereist -preferences.sketchbook_location = Sketsboek locatie +preferences.button.width = 90 +preferences.requires_restart = herstart van Processing vereist +preferences.sketchbook_location = Schetsboek locatie preferences.language = Taal preferences.editor_and_console_font = Editor en Console lettertype preferences.editor_font_size = Editor lettergrootte preferences.console_font_size = Console lettergrootte -preferences.background_color = Achtergrond kleur bij Presenteren -preferences.use_smooth_text = Gebruik smooth text in editor window +preferences.background_color = Achtergrond kleur in Presenteer modus +preferences.use_smooth_text = Gebruik duidelijke tekst in Editor venster preferences.enable_complex_text_input = Complexe tekstkarakters mogelijk maken preferences.enable_complex_text_input_example = i.e. Japans preferences.continuously_check = Continu controleren op fouten -preferences.show_warnings = Toon Waarschuwingen +preferences.show_warnings = Toon waarschuwingen preferences.code_completion = Automatische aanvulling preferences.trigger_with = Activeren met preferences.cmd_space = Spatie preferences.increase_max_memory = Verhogen maximaal beschikbare geheugen naar preferences.delete_previous_folder_on_export = Vorige map verwijderen bij exporteren -preferences.hide_toolbar_background_image = Verbergen tab/toolbar achtergrond +preferences.hide_toolbar_background_image = Achtergrond van toolbar verbergen preferences.check_for_updates_on_startup = Controleren op updates bij het opstarten preferences.run_sketches_on_display = Uitvoeren schetsen op beeld preferences.run_sketches_on_display.tip = \ Stelt het beeld in waarop schetsen aanvankelijk te zien zijn.
\ -Zoals gebruikelijk, als het schets venster wordt verplaatst, zal het heropenen
\ -op dezelfde locatie, echter wanneer gebruik wordt gemaakt van de Presenteer
\ -(volledig scherm) modus, zal dit beeld altijd worden gebruikt. +Zoals gebruikelijk, als het venster wordt verplaatst, zal het heropenen
\ +op die locatie. Wanneer echter gebruik wordt gemaakt van de Presenteer
\ +modus (volledig scherm), zal altijd het gekozen beeld worden gebruikt. preferences.automatically_associate_pde_files = Automatisch associëren .pde bestanden met Processing preferences.launch_programs_in = Programma's starten in preferences.launch_programs_in.mode = modus @@ -162,7 +162,7 @@ export.description.line2 = zelfstandige applicaties voor de geselecteerde platfo find = Zoeken find.find = Zoeken naar: find.replace_with = Vervangen door: -find.ignore_case = Hoofdletter/kleine letters negeren +find.ignore_case = Case negeren find.all_tabs = Alle Tabbladen find.wrap_around = Rondgaan find.btn.replace_all = Alles Vervangen @@ -210,5 +210,5 @@ editor.header.rename = Naam wijzigen editor.header.delete = Verwijderen editor.header.previous_tab = Vorige Tabblad editor.header.next_tab = Volgende Tabblad -editor.header.delete.warning.title = Ja, nee. -editor.header.delete.warning.text = U kunt het laatste tabblad van de laatst geopende schets niet verwijderen +editor.header.delete.warning.title = Waarschuwing +editor.header.delete.warning.text = U kunt het laatste tabblad van de laatst geopende schets niet verwijderen. From 45342b4797c754c9b7331ce6035a3e0b7e0ac1a3 Mon Sep 17 00:00:00 2001 From: Arty2 Date: Fri, 1 Aug 2014 23:46:16 +0300 Subject: [PATCH 047/134] Greek translation Technical terms based on the translations of LibreOffice. Decided to not translate, Processing Reference till it is also translated. --- .../app/languages/PDE_el.properties | 239 ++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 app/src/processing/app/languages/PDE_el.properties diff --git a/app/src/processing/app/languages/PDE_el.properties b/app/src/processing/app/languages/PDE_el.properties new file mode 100644 index 000000000..3c2c557f2 --- /dev/null +++ b/app/src/processing/app/languages/PDE_el.properties @@ -0,0 +1,239 @@ + + +# --------------------------------------- +# Language: Greek (Ελληνικά) (el) +# --------------------------------------- + + +# --------------------------------------- +# Menu + +# | File | Edit | Sketch | Library | Tools | Help | +# | File | +menu.file = Αρχείο +menu.file.new = Νέο +menu.file.open = Άνοιγμα... +menu.file.sketchbook = Σχεδιοθήκη +menu.file.recent = Πρόσφατα +menu.file.examples = Παραδείγματα... +menu.file.close = Κλείσιμο +menu.file.save = Αποθήκευση +menu.file.save_as = Αποθήκευση ως... +menu.file.export_application = Εξαγωγή Εφαρμογής... +menu.file.page_setup = Διαμόρφωση σελίδας +menu.file.print = Εκτύπωση... +menu.file.preferences = Προτιμήσεις... +menu.file.quit = Έξοδος + +# | File | Edit | Sketch | Library | Tools | Help | +# | Edit | +menu.edit = Επεξεργασία +menu.edit.undo = Αναίρεση +menu.edit.redo = Επανάληψη +menu.edit.cut = Αποκοπή +menu.edit.copy = Αντιγραφή +menu.edit.copy_as_html = Αντιγραφή ως HTML +menu.edit.paste = Επικόλληση +menu.edit.select_all = Επιλογή όλων +menu.edit.auto_format = Αυτόματη διαμόρφωση +menu.edit.comment_uncomment = Σχολιασμός/Αποσχολιασμός +menu.edit.increase_indent = \u2192 Αύξηση εσοχής +menu.edit.decrease_indent = \u2190 Μείωση εσοχής +menu.edit.find = Αναζήτηση... +menu.edit.find_next = Αναζήτηση επόμενου +menu.edit.find_previous = Αναζήτηση προηγούμενου +menu.edit.use_selection_for_find = Χρήση επιλογής για Αναζήτηση + +# | File | Edit | Sketch | Library | Tools | Help | +# | Sketch | +menu.sketch = Σχέδιο +menu.sketch.show_sketch_folder = Προβολή φακέλου του Σχεδίου +menu.sketch.add_file = Προσθήκη αρχείου... + +# | File | Edit | Sketch | Library | Tools | Help | +# | Library | +menu.library = Εισαγωγή Βιβλιοθήκης... +menu.library.add_library = Προσθήκη Βιβλιοθήκης... +menu.library.contributed = Συνεισφερόμενα +menu.library.no_core_libraries = αυτή η λειτουργία δεν έχει βασικές Βιβλιοθήκες + +# | File | Edit | Sketch | Library | Tools | Help | +# | Tools | +menu.tools = Εργαλεία +menu.tools.color_selector = Επιλογέας χρωμάτων... +menu.tools.create_font = Δημιουργία γραμματοσειρά... +menu.tools.archive_sketch = Αρχειοθέτηση Σχεδίου +menu.tools.fix_the_serial_lbrary = Διόρθωση Σειριακής Βιβλιοθήκης +menu.tools.install_processing_java = Εγκατάσταση της "processing-java" +menu.tools.add_tool = Προσθήκη εργαλείου... + +# | File | Edit | Sketch | Library | Tools | Help | +# | Help | +menu.help = Βοήθεια +menu.help.about = Σχετικά με την Processing +menu.help.environment = Περιβάλλον +menu.help.reference = Processing Reference +menu.help.find_in_reference = Αναζήτηση στην Processing Reference +menu.help.online = Online +menu.help.getting_started = Ξεκινώντας +menu.help.getting_started.url = http://processing.org/learning/gettingstarted/ +menu.help.troubleshooting = Αντιμετώπιση προβλημάτων +menu.help.troubleshooting.url = http://wiki.processing.org/w/Troubleshooting +menu.help.faq = Συχνές ερωτήσεις +menu.help.faq.url = http://wiki.processing.org/w/FAQ +menu.help.foundation = The Processing Foundation +menu.help.foundation.url = http://processing.org/foundation/ +menu.help.visit = Επισκευθείτε την Processing.org +menu.help.visit.url = http://processing.org/ + + +# --------------------------------------- +# Basics + +# Buttons +prompt.yes = Ναι +prompt.no = Όχι +prompt.cancel = Ακύρωση +prompt.ok = Εντάξει +prompt.browse = Εξερεύνηση +prompt.export = Εξαγωγή + + +# --------------------------------------- +# Frames + +# Open (Frame) +open = Άνοιγμα Σχεδίου Processing... + +# Save (Frame) +save = Αποθήκευση φακέλου Σχεδίου ως... +save.title = Θέλετε να αποθηκεύσετε τις αλλαγές σε
αυτό το Σχέδιο πριν το κλείσιμο; +save.hint = Αν δεν αποθηκεύσετε, οι αλλαγές σας θα χαθούν. +save.btn.save = Αποθήκευση +save.btn.dont_save = Χωρίς αποθήκευση + +# Preferences (Frame) +preferences = Προτιμήσεις +preferences.button.width = 80 +preferences.requires_restart = χρειάζεται επανεκκίνηση της Processing +preferences.sketchbook_location = Τοποθεσία Σχεδιοθήκης +preferences.language = Γλώσσα +preferences.editor_and_console_font = Γραμματοσειρά Επεξεργαστή και Κονσόλας +preferences.editor_font_size = Μέγεθος γραμματοσειράς Επεξεργαστή +preferences.console_font_size = Μέγεθος γραμματοσειράς Κονσόλας +preferences.background_color = Χρώμα φόντου κατά την Παρουσίαση +preferences.use_smooth_text = Χρήση ομαλού κειμένου στο παράθυρο επεξεργασίας +preferences.enable_complex_text_input = Ενεργοποίηση εισαγωγής σύνθετου κειμένου +preferences.enable_complex_text_input_example = π.χ. Ιαπωνικά +preferences.continuously_check = Συνεχής έλεγχος σφαλμάτων +preferences.show_warnings = Προβολή προειδοποιήσεων +preferences.code_completion = Συμπλήρωση κώδικα +preferences.trigger_with = Αυτόματη εκτέλεση με +preferences.cmd_space = κενό +preferences.increase_max_memory = Άυξηση μέγιστης διαθέσιμης μνήμης σε +preferences.delete_previous_folder_on_export = Διαγραφή προηγούμενου φακέλου κατά την Εξαγωγή +preferences.hide_toolbar_background_image = Απόκρυψη εικόνας φόντου καρτέλας και μπάρας εργαλείων +preferences.check_for_updates_on_startup = Έλεγχος ενημερώσεων κατά την εκκίνηση +preferences.run_sketches_on_display = Εκτέλεση Σχεδίων στην οθόνη +preferences.run_sketches_on_display.tip = \ +Επιλέγει την οθόνη στην οποία τα Σχέδια τοποθετούνται
\ +αρχικά. Συνήθως, αν το παράθυρο του Σχεδίου μετακινηθεί,
\ +θα ανοίξει στην ίδια θέση, όμως κατά την Παρουσίαση
\ +(πλήρης οθόνη), θα χρησιμοποιείται αυτή η οθόνη. +preferences.automatically_associate_pde_files = Αυτόματη συσχέτιση αρχείων .pde με την Processing +preferences.launch_programs_in = Εκτέλεση προγραμμάτων σε +preferences.launch_programs_in.mode = κατάσταση +preferences.file = Μπορείτε να επεξεργαστείτε περισσότερες ρυθμίσεις απευθείας στο αρχείο +preferences.file.hint = επεξεργαστείτε μόνο όταν είναι κλειστή η Processing + +# Sketchbook Location (Frame) +sketchbook_location = Επιλογή νέας τοποθεσίας Σχεδιοθήκης + +# Export (Frame) +export = Επιλογές εξαγωγής +export.platforms = Πλατφόρμες +export.options = Επιλογές +export.options.fullscreen = Πλήρης οθόνη (Παρουσίαση) +export.options.show_stop_button = Προβολή κουμπιού τερματισμού +export.description.line1 = Η εξαγωγή Εφαρμογής δημιουργεί αυτόνομα αρχεία που +export.description.line2 = ανοίγουν με διπλό-κλικ στις επιλεγμένες πλατφόρμες. + +# Find (Frame) +find = Αναζήτηση +find.find = Αναζήτηση: +find.replace_with = Αντικατάσταση με: +find.ignore_case = Αγνόησε μικρά ή κεφαλαία +find.all_tabs = Όλες οι καρτέλες +find.wrap_around = Περιτύλιξη +find.btn.replace_all = Αντικατάσταση όλων +find.btn.replace = Αντικατάσταση +find.btn.find_and_replace = Αναζήτηση και Αντικατάσταση +find.btn.previous = Προηγούμενο +find.btn.find = Αναζήτηση + +# Find in reference (Frame) +find_in_reference = Αναζήτηση στην Processing Reference + +# Library Manager (Frame) +library.category = Κατηγορία: +library.filter_your_search = Φιλτράρισμα αναζήτησης... + +# File (Frame) +file = Επιλέξτε μια εικόνα ή άλλο αρχείο δεδομένων για να αντιγράψετε στο Σχέδιό σας + +# Create Font (Frame) +create_font = Δημιουργία γραμματοσειράς + +# Color Selector (Frame) +color_selector = Επιλογέας χρωμάτων... + +# Archive Sketch (Frame) +archive_sketch = Αρχειοθέτηση Σχεδίου ως... + + +# --------------------------------------- +# Toolbar + +# [Run/Present] [Stop] [New] [Open] [Save] +toolbar.run = Εκτέλεση +toolbar.present = Παρουσίαση +toolbar.stop = Τερματισμός +toolbar.new = Νέο +toolbar.open = Άνοιγμα +toolbar.save = Αποθήκευση +toolbar.export_application = Εξαγωγή Εφαρμογής +toolbar.add_mode = Προσθήκη κατάστασης... + +# [Tab1] [Tab2] [v] +editor.header.new_tab = Νέα Καρτέλα +editor.header.rename = Μετονομασία +editor.header.delete = Διαγραφή +editor.header.previous_tab = Προηγούμενη Καρτέλα +editor.header.next_tab = Επόμενη Καρτέλα +editor.header.delete.warning.title = Ναι, όχι. +editor.header.delete.warning.text = Δεν μπορείτε να διαγράψετε την τελευταία ανοιχτή Καρτέλα του τελευταίου ανοιχτού Σχεδίου. + +editor.status.autoformat.no_changes = Δεν χρειάζονται αλλαγές για την Αυτόματη μορφοποίηση. +editor.status.autoformat.finished = Ολοκληρώθηκε η Αυτόματη μορφοποίηση. +editor.status.find_reference.select_word_first = Επιλέξτε πρώτα μια λέξη προς αναζήτηση στην Processing Reference. +editor.status.find_reference.not_available = Δεν υπάρχει καταχώρηση για το "%s" στην Processing Reference. +editor.status.drag_and_drop.no_files_added = Δεν προστέθηκαν αρχεία στο Σχέδιο. +editor.status.drag_and_drop.one_file_added = Ένα αρχείο προστέθηκε στο Σχέδιο. +editor.status.drag_and_drop.n_files_added = %d files αρχεία προστέθηκαν στο Σχέδιο. +editor.status.saving = Αποθήκευση... +editor.status.saving.done = Ολοκλήρωση αποθήκευσης. +editor.status.saving.canceled = Ακύρωση αποθήκευσης. +editor.status.printing = Εκτύπωση... +editor.status.printing.done = Ολοκλήρωση εκτύπωσης. +editor.status.printing.error = Σφάλμα κατά την εκτύπωση. +editor.status.printing.canceled = Ακύρωση εκτύπωσης. + +# --------------------------------------- +# Contribution Panel +contributions.undo = Αναίρεση +contributions.remove = Διαγραφή +contributions.install = Εγκατάσταση +contributions.progress.starting = Εκκίνηση +contributions.progress.downloading = Μεταφόρτωση +contributions.download_error = Προέκυψε σφάλμα κατά την μεταφόρτωση της συνεισφοράς. +contributions.unsupported_operating_system = Το λειτουργικό σας σύστημα μάλλον δεν υποστηρίζεται. Επισκευθείτε την βιβλιοθήκη των %s για περισσότερα. From 84089e3123fd04b83e092ddc2e15b08c76242057 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 16:46:49 -0400 Subject: [PATCH 048/134] remove extra toolbar buttons, pdex cleanups while looking for trigger key --- app/src/processing/mode/java/JavaEditor.java | 27 ++++---- app/src/processing/mode/java/JavaToolbar.java | 40 +++++------- .../mode/experimental/ASTGenerator.java | 22 +++---- .../mode/experimental/ASTNodeWrapper.java | 4 +- .../mode/experimental/DebugToolbar.java | 64 ++++++++++--------- .../mode/experimental/TextArea.java | 24 ++++--- todo.txt | 34 ++++++---- 7 files changed, 109 insertions(+), 106 deletions(-) diff --git a/app/src/processing/mode/java/JavaEditor.java b/app/src/processing/mode/java/JavaEditor.java index 2bdc199da..aa4b50249 100644 --- a/app/src/processing/mode/java/JavaEditor.java +++ b/app/src/processing/mode/java/JavaEditor.java @@ -48,7 +48,8 @@ public class JavaEditor extends Editor { public JMenu buildFileMenu() { - String appTitle = JavaToolbar.getTitle(JavaToolbar.EXPORT, false); + //String appTitle = JavaToolbar.getTitle(JavaToolbar.EXPORT, false); + String appTitle = Language.text("toolbar.export_application"); JMenuItem exportApplication = Toolkit.newJMenuItem(appTitle, 'E'); exportApplication.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -94,9 +95,7 @@ public class JavaEditor extends Editor { public JMenu buildHelpMenu() { - // To deal with a Mac OS X 10.5 bug, add an extra space after the name - // so that the OS doesn't try to insert its slow help menu. - JMenu menu = new JMenu(Language.text("menu.help")+" "); + JMenu menu = new JMenu(Language.text("menu.help")); JMenuItem item; // macosx already has its own about menu @@ -231,7 +230,7 @@ public class JavaEditor extends Editor { * Handler for Sketch → Export Application */ public void handleExportApplication() { - toolbar.activate(JavaToolbar.EXPORT); +// toolbar.activate(JavaToolbar.EXPORT); if (handleExportCheckModified()) { statusNotice("Exporting application..."); @@ -248,7 +247,7 @@ public class JavaEditor extends Editor { e.printStackTrace(); } } - toolbar.deactivate(JavaToolbar.EXPORT); +// toolbar.deactivate(JavaToolbar.EXPORT); } @@ -759,18 +758,16 @@ public class JavaEditor extends Editor { public void handleSave() { - toolbar.activate(JavaToolbar.SAVE); - //handleStop(); +// toolbar.activate(JavaToolbar.SAVE); super.handleSave(true); - toolbar.deactivate(JavaToolbar.SAVE); +// toolbar.deactivate(JavaToolbar.SAVE); } public boolean handleSaveAs() { - toolbar.activate(JavaToolbar.SAVE); - //handleStop(); +// toolbar.activate(JavaToolbar.SAVE); boolean result = super.handleSaveAs(); - toolbar.deactivate(JavaToolbar.SAVE); +// toolbar.deactivate(JavaToolbar.SAVE); return result; } @@ -826,9 +823,9 @@ public class JavaEditor extends Editor { } - public void deactivateExport() { - toolbar.deactivate(JavaToolbar.EXPORT); - } +// public void deactivateExport() { +// toolbar.deactivate(JavaToolbar.EXPORT); +// } public void internalCloseRunner() { diff --git a/app/src/processing/mode/java/JavaToolbar.java b/app/src/processing/mode/java/JavaToolbar.java index 7cf02a68b..f44c4db0a 100644 --- a/app/src/processing/mode/java/JavaToolbar.java +++ b/app/src/processing/mode/java/JavaToolbar.java @@ -22,7 +22,7 @@ package processing.mode.java; import java.awt.Image; import java.awt.event.MouseEvent; -import javax.swing.JPopupMenu; +//import javax.swing.JPopupMenu; import processing.app.Base; import processing.app.Editor; @@ -31,26 +31,13 @@ import processing.app.Language; public class JavaToolbar extends EditorToolbar { - /** Rollover titles for each button. */ -// static final String title[] = { -// "Run", "Stop", "New", "Open", "Save", "Export" -// }; - - /** Titles for each button when the shift key is pressed. */ -// static final String titleShift[] = { -// "Present", "Stop", "New Editor Window", "Open in Another Window", "Save", "Export to Application" -// }; - static protected final int RUN = 0; static protected final int STOP = 1; - static protected final int NEW = 2; - static protected final int OPEN = 3; - static protected final int SAVE = 4; - static protected final int EXPORT = 5; - -// JPopupMenu popup; -// JMenu menu; +// static protected final int NEW = 2; +// static protected final int OPEN = 3; +// static protected final int SAVE = 4; +// static protected final int EXPORT = 5; public JavaToolbar(Editor editor, Base base) { @@ -60,8 +47,10 @@ public class JavaToolbar extends EditorToolbar { public void init() { Image[][] images = loadImages(); - for (int i = 0; i < 6; i++) { - addButton(getTitle(i, false), getTitle(i, true), images[i], i == NEW); +// for (int i = 0; i < 6; i++) { + for (int i = 0; i < 2; i++) { +// addButton(getTitle(i, false), getTitle(i, true), images[i], i == NEW); + addButton(getTitle(i, false), getTitle(i, true), images[i], false); } } @@ -70,11 +59,10 @@ public class JavaToolbar extends EditorToolbar { switch (index) { case RUN: return !shift ? Language.text("toolbar.run") : Language.text("toolbar.present"); case STOP: return Language.text("toolbar.stop"); - case NEW: return Language.text("toolbar.new"); - case OPEN: return Language.text("toolbar.open"); - case SAVE: return Language.text("toolbar.save"); -// case EXPORT: return !shift ? "Export Application" : "Export Applet"; - case EXPORT: return Language.text("toolbar.export_application"); +// case NEW: return Language.text("toolbar.new"); +// case OPEN: return Language.text("toolbar.open"); +// case SAVE: return Language.text("toolbar.save"); +// case EXPORT: return Language.text("toolbar.export_application"); } return null; } @@ -97,6 +85,7 @@ public class JavaToolbar extends EditorToolbar { jeditor.handleStop(); break; + /* case OPEN: // popup = menu.getPopupMenu(); // TODO I think we need a longer chain of accessors here. @@ -123,6 +112,7 @@ public class JavaToolbar extends EditorToolbar { jeditor.handleExportApplication(); // } break; + */ } } } \ No newline at end of file diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index 1fdf69e0b..723ba302c 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -1128,7 +1128,7 @@ public class ASTGenerator { } ArrayList superClassCandidates = new ArrayList(); - if(td.getSuperclassType() instanceof Type){ + if(td.getSuperclassType() != null){ log(getNodeAsString(td.getSuperclassType()) + " <-Looking into superclass of " + tehClass); superClassCandidates = getMembersForType(new ClassMember(td .getSuperclassType()), @@ -1330,7 +1330,7 @@ public class ASTGenerator { protected Class loadClass(String className){ Class tehClass = null; - if(className instanceof String){ + if (className != null) { try { tehClass = Class.forName(className, false, errorCheckerService.getSketchClassLoader()); @@ -1360,12 +1360,12 @@ public class ASTGenerator { log("definedIn3rdPartyClass-> Looking for " + memberName + " in " + tehClass); String memberNameL = memberName.toLowerCase(); - if(tehClass.getDeclaringNode() instanceof TypeDeclaration){ + if (tehClass.getDeclaringNode() instanceof TypeDeclaration) { TypeDeclaration td = (TypeDeclaration) tehClass.getDeclaringNode(); for (int i = 0; i < td.getFields().length; i++) { - List vdfs = td.getFields()[i] - .fragments(); + List vdfs = + td.getFields()[i].fragments(); for (VariableDeclarationFragment vdf : vdfs) { if (vdf.getName().toString().toLowerCase() .startsWith(memberNameL)) @@ -1378,23 +1378,19 @@ public class ASTGenerator { .startsWith(memberNameL)) return new ClassMember(td.getMethods()[i]); } - if(td.getSuperclassType() instanceof Type){ + if (td.getSuperclassType() != null) { log(getNodeAsString(td.getSuperclassType()) + " <-Looking into superclass of " + tehClass); return definedIn3rdPartyClass(new ClassMember(td .getSuperclassType()),memberName); - } - else - { + } else { return definedIn3rdPartyClass(new ClassMember(Object.class),memberName); } } Class probableClass = null; - if(tehClass.getClass_() != null){ + if (tehClass.getClass_() != null) { probableClass = tehClass.getClass_(); - } - else - { + } else { probableClass = findClassIfExists(tehClass.getTypeAsString()); log("Loaded " + probableClass.toString()); } diff --git a/pdex/src/processing/mode/experimental/ASTNodeWrapper.java b/pdex/src/processing/mode/experimental/ASTNodeWrapper.java index f198c51f7..52aa937f5 100644 --- a/pdex/src/processing/mode/experimental/ASTNodeWrapper.java +++ b/pdex/src/processing/mode/experimental/ASTNodeWrapper.java @@ -213,7 +213,7 @@ public class ASTNodeWrapper { * @return */ private int getJavadocOffset(FieldDeclaration fd){ - List list= (List)fd.modifiers(); + List list = (List) fd.modifiers(); SimpleName sn = (SimpleName) getNode(); Type tp = fd.getType(); @@ -247,7 +247,7 @@ public class ASTNodeWrapper { * @return */ private int getJavadocOffset(MethodDeclaration md) { - List list = (List)md.modifiers(); + List list = (List) md.modifiers(); SimpleName sn = (SimpleName) getNode(); int lineNum = getLineNumber(sn); log("SN " + sn + ", " + lineNum); diff --git a/pdex/src/processing/mode/experimental/DebugToolbar.java b/pdex/src/processing/mode/experimental/DebugToolbar.java index b13d83f45..d22f11fab 100755 --- a/pdex/src/processing/mode/experimental/DebugToolbar.java +++ b/pdex/src/processing/mode/experimental/DebugToolbar.java @@ -52,16 +52,16 @@ public class DebugToolbar extends JavaToolbar { static protected final int STOP = JavaToolbar.STOP; - static protected final int NEW = JavaToolbar.NEW; - static protected final int OPEN = JavaToolbar.OPEN; - static protected final int SAVE = JavaToolbar.SAVE; - static protected final int EXPORT = JavaToolbar.EXPORT; +// static protected final int NEW = JavaToolbar.NEW; +// static protected final int OPEN = JavaToolbar.OPEN; +// static protected final int SAVE = JavaToolbar.SAVE; +// static protected final int EXPORT = JavaToolbar.EXPORT; // the sequence of button ids. (this maps button position = index to button ids) static protected final int[] buttonSequence = { - DEBUG, CONTINUE, STEP, STOP, TOGGLE_BREAKPOINT, TOGGLE_VAR_INSPECTOR, - NEW, OPEN, SAVE, EXPORT + DEBUG, CONTINUE, STEP, STOP, TOGGLE_BREAKPOINT, TOGGLE_VAR_INSPECTOR +// NEW, OPEN, SAVE, EXPORT }; @@ -118,6 +118,7 @@ public class DebugToolbar extends JavaToolbar { return buttonImages; } + /** * Initialize buttons. Loads images and adds the buttons to the toolbar. */ @@ -126,7 +127,8 @@ public class DebugToolbar extends JavaToolbar { Image[][] images = loadDebugImages(); for (int idx = 0; idx < buttonSequence.length; idx++) { int id = buttonId(idx); - addButton(getTitle(id, false), getTitle(id, true), images[idx], id == NEW || id == TOGGLE_BREAKPOINT); + //addButton(getTitle(id, false), getTitle(id, true), images[idx], id == NEW || id == TOGGLE_BREAKPOINT); + addButton(getTitle(id, false), getTitle(id, true), images[idx], id == TOGGLE_BREAKPOINT); } } @@ -144,14 +146,14 @@ public class DebugToolbar extends JavaToolbar { return JavaToolbar.getTitle(JavaToolbar.RUN, shift); case STOP: return JavaToolbar.getTitle(JavaToolbar.STOP, shift); - case NEW: - return JavaToolbar.getTitle(JavaToolbar.NEW, shift); - case OPEN: - return JavaToolbar.getTitle(JavaToolbar.OPEN, shift); - case SAVE: - return JavaToolbar.getTitle(JavaToolbar.SAVE, shift); - case EXPORT: - return JavaToolbar.getTitle(JavaToolbar.EXPORT, shift); +// case NEW: +// return JavaToolbar.getTitle(JavaToolbar.NEW, shift); +// case OPEN: +// return JavaToolbar.getTitle(JavaToolbar.OPEN, shift); +// case SAVE: +// return JavaToolbar.getTitle(JavaToolbar.SAVE, shift); +// case EXPORT: +// return JavaToolbar.getTitle(JavaToolbar.EXPORT, shift); case DEBUG: if (shift) { return "Run"; @@ -194,22 +196,22 @@ public class DebugToolbar extends JavaToolbar { Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Stop' toolbar button"); super.handlePressed(e, JavaToolbar.STOP); break; - case NEW: - Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'New' toolbar button"); - super.handlePressed(e, JavaToolbar.NEW); - break; - case OPEN: - Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Open' toolbar button"); - super.handlePressed(e, JavaToolbar.OPEN); - break; - case SAVE: - Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Save' toolbar button"); - super.handlePressed(e, JavaToolbar.SAVE); - break; - case EXPORT: - Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Export' toolbar button"); - super.handlePressed(e, JavaToolbar.EXPORT); - break; +// case NEW: +// Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'New' toolbar button"); +// super.handlePressed(e, JavaToolbar.NEW); +// break; +// case OPEN: +// Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Open' toolbar button"); +// super.handlePressed(e, JavaToolbar.OPEN); +// break; +// case SAVE: +// Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Save' toolbar button"); +// super.handlePressed(e, JavaToolbar.SAVE); +// break; +// case EXPORT: +// Logger.getLogger(DebugToolbar.class.getName()).log(Level.INFO, "Invoked 'Export' toolbar button"); +// super.handlePressed(e, JavaToolbar.EXPORT); +// break; case DEBUG: deditor.handleStop(); // Close any running sketches deditor.showProblemListView(XQConsoleToggle.CONSOLE); diff --git a/pdex/src/processing/mode/experimental/TextArea.java b/pdex/src/processing/mode/experimental/TextArea.java index 7280b6bbb..639689f2c 100644 --- a/pdex/src/processing/mode/experimental/TextArea.java +++ b/pdex/src/processing/mode/experimental/TextArea.java @@ -36,7 +36,6 @@ import java.util.HashMap; import java.util.Map; import javax.swing.DefaultListModel; -import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import processing.app.syntax.JEditTextArea; @@ -195,6 +194,7 @@ public class TextArea extends JEditTextArea { log("BK Key"); break; case KeyEvent.VK_SPACE: + System.out.println("space: " + evt); if (suggestion != null) if (suggestion.isVisible()) { log("Space bar, hide completion list"); @@ -207,20 +207,22 @@ public class TextArea extends JEditTextArea { } super.processKeyEvent(evt); - if(editor.hasJavaTabs) return; // code completion disabled if java tabs + if (editor.hasJavaTabs) return; // code completion disabled if java tabs + if (evt.getID() == KeyEvent.KEY_TYPED) { - char keyChar = evt.getKeyChar(); - if (keyChar == KeyEvent.VK_ENTER || keyChar == KeyEvent.VK_ESCAPE) { - return; - } else if (keyChar == KeyEvent.VK_TAB - || keyChar == KeyEvent.CHAR_UNDEFINED) { + if (keyChar == KeyEvent.VK_ENTER || + keyChar == KeyEvent.VK_ESCAPE || + keyChar == KeyEvent.VK_TAB || + keyChar == KeyEvent.CHAR_UNDEFINED) { return; } final KeyEvent evt2 = evt; + System.out.println("type: " + evt); if (evt.isAltDown() || evt.isControlDown() || evt.isMetaDown()) { - if (ExperimentalMode.ccTriggerEnabled && keyChar == KeyEvent.VK_SPACE - && (evt.isControlDown() || evt.isMetaDown())) { + if (ExperimentalMode.ccTriggerEnabled && + keyChar == KeyEvent.VK_SPACE && + (evt.isControlDown() || evt.isMetaDown())) { SwingWorker worker = new SwingWorker() { protected Object doInBackground() throws Exception { // Provide completions only if it's enabled @@ -747,6 +749,9 @@ public class TextArea extends JEditTextArea { }); }*/ + + // appears unused, removed when looking to change completion trigger [fry 140801] + /* public void showSuggestionLater(final DefaultListModel defListModel, final String word) { SwingUtilities.invokeLater(new Runnable() { @Override @@ -756,6 +761,7 @@ public class TextArea extends JEditTextArea { }); } + */ /** * Calculates location of caret and displays the suggestion popup at the location. diff --git a/todo.txt b/todo.txt index 4432341a8..d4faa7578 100644 --- a/todo.txt +++ b/todo.txt @@ -1,10 +1,14 @@ 0230 pde (3.0a3) -earlier -X repo cleanup -X remove non-web stuff from web -X remove non-android stuff from android -X remove web and android from the main repo +gsoc +X fixes for mode/tool installation +X https://github.com/processing/processing/pull/2705 +X fix mode updating to work properly +X https://github.com/processing/processing/issues/2579 +X temp folders not always deleting +X https://github.com/processing/processing/issues/2606 +X problem when removing a mode +X https://github.com/processing/processing/issues/2507 pulls X Add polling to detect file system changes @@ -14,7 +18,7 @@ X huge i18n patch X https://github.com/processing/processing/issues/632 X https://github.com/processing/processing/pull/2084 X http://code.google.com/p/processing/issues/detail?id=593 -_ need to make sure the .properties files are read properly as UTF-8 +X need to make sure the .properties files are read properly as UTF-8 X Indent breaks when hitting enter before spaces X https://github.com/processing/processing/issues/2004 X https://github.com/processing/processing/pull/2690 @@ -31,10 +35,19 @@ X Dutch https://github.com/processing/processing/pull/2694 X French https://github.com/processing/processing/pull/2695 X Portugese https://github.com/processing/processing/pull/2701 +earlier +X repo cleanup +X remove non-web stuff from web +X remove non-android stuff from android +X remove web and android from the main repo +X separate prefs and sketch state info? +X this would mean prefs being rewritten far less + high _ export application ubuntu -> windows not working (2.2.1) _ https://github.com/processing/processing/issues/2698 +_ might be something with libraries (native or otherwise) pending @@ -651,15 +664,14 @@ _ when are prefs saved? could instead save whenever changes are made _ and then if the file gets modified, it'll put up an error message _ also, this may be part of why other sketches aren't reloading properly _ simple prefs implementation to set key/value pairs using a JTable -_ separate prefs and sketch state info? -_ this would mean prefs being rewritten far less _ prefs window doesn't swap ok/cancel properly for mac vs. windows/linux _ don't bother having a "cancel" for the prefs window -_ rewrite preferences window to use proper layout? -_ is there already a bug for this? +_ rewrite preferences window to use proper layout +_ https://github.com/processing/processing/issues/67 +_ https://github.com/processing/processing/issues/2708 _ make prefs dialog modal? _ split Preferences and PreferencesFrame? -_ http://code.google.com/p/processing/issues/detail?id=29 +X http://code.google.com/p/processing/issues/detail?id=29 _ preferences window has been hit with the ugly stick _ redo panel to use proper Box layout etc _ also needs to look good across all platforms From 0a2c8b0a11d540c2451240ac4f8976e4a0ddff1d Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 16:54:59 -0400 Subject: [PATCH 049/134] add Greek translation --- app/src/processing/app/Language.java | 3 ++- todo.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 15ae9b685..eca094d6a 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -56,11 +56,12 @@ public class Language { final String[] SUPPORTED = { "de", // de, German, Deutsch "en", // en, English, English + "el", // el, Greek "es", // es, Spanish "fr", // fr, French, Français, Langue française "ja", // ja, Japanese "nl", // nl, Dutch, Nederlands - "pt", //pt, Portuguese + "pt", // pt, Portuguese }; for (String code : SUPPORTED) { diff --git a/todo.txt b/todo.txt index d4faa7578..49fe4fff7 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,5 @@ 0230 pde (3.0a3) +X remove toolbar buttons except for start/stop gsoc X fixes for mode/tool installation From f197d280708a94511a04706c0b8b28553bf926e2 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 17:11:45 -0400 Subject: [PATCH 050/134] change how languages are loaded --- app/src/processing/app/Language.java | 92 ++++++++++++++-------------- todo.txt | 2 + 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index eca094d6a..ca9c48fc0 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -34,11 +34,19 @@ import processing.core.PApplet; * @author Darius Morawiec */ public class Language { - static private Language instance = null; - private String language; - private HashMap languages; - private ResourceBundle bundle; static private final String FILE = "processing.app.languages.PDE"; + static private final String LISTING = "processing/app/languages/languages.txt"; + + /** Single instance of this Language class */ + static private Language instance = null; + + /** The system language */ + private String language; + + /** Available languages */ + private HashMap languages; + + private ResourceBundle bundle; private Language() { @@ -46,47 +54,14 @@ public class Language { this.language = Locale.getDefault().getLanguage(); // Set available languages - this.languages = new HashMap(); - - // Language code: - // http://en.wikipedia.org/wiki/ISO_639-1 - // http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes - - // List of languages in alphabetical order. New additions go here. - final String[] SUPPORTED = { - "de", // de, German, Deutsch - "en", // en, English, English - "el", // el, Greek - "es", // es, Spanish - "fr", // fr, French, Français, Langue française - "ja", // ja, Japanese - "nl", // nl, Dutch, Nederlands - "pt", // pt, Portuguese - }; - - for (String code : SUPPORTED) { + languages = new HashMap(); + for (String code : listSupported()) { languages.put(code, Locale.forLanguageTag(code).getDisplayLanguage(Locale.forLanguageTag(code))); } - /* - // en, English, English - this.languages.put(Locale.ENGLISH.getLanguage(), Locale.ENGLISH.getDisplayLanguage(Locale.ENGLISH)); - // de, German, Deutsch - this.languages.put(Locale.GERMAN.getLanguage(), Locale.GERMAN.getDisplayLanguage(Locale.GERMAN)); - // ja, Japanese - this.languages.put(Locale.JAPANESE.getLanguage(), Locale.JAPANESE.getDisplayLanguage(Locale.JAPANESE)); - // es, Spanish - this.languages.put("es", Locale.forLanguageTag("es").getDisplayLanguage(Locale.forLanguageTag("es"))); - // nl, Dutch, Nederlands - this.languages.put("nl", Locale.forLanguageTag("nl").getDisplayLanguage(Locale.forLanguageTag("nl"))); - // pt, Portuguese - this.languages.put("pt", Locale.forLanguageTag("pt").getDisplayLanguage(Locale.forLanguageTag("pt"))); - - */ - // Set default language - if (!this.languages.containsKey(this.language)) { - this.language = "en"; + if (!languages.containsKey(language)) { + language = "en"; } // Get saved language @@ -106,7 +81,35 @@ public class Language { } // Get bundle with translations (processing.app.language.PDE) - this.bundle = ResourceBundle.getBundle(Language.FILE, new Locale(this.language), new UTF8Control()); + bundle = ResourceBundle.getBundle(Language.FILE, new Locale(this.language), new UTF8Control()); + } + + + String[] listSupported() { +// // List of languages in alphabetical order. New additions go here. +// final String[] SUPPORTED = { +// "de", // de, German, Deutsch +// "en", // en, English, English +// "el", // el, Greek +// "es", // es, Spanish +// "fr", // fr, French, Français, Langue française +// "ja", // ja, Japanese +// "nl", // nl, Dutch, Nederlands +// "pt", // pt, Portuguese +// }; + + InputStream input = getClass().getResourceAsStream(LISTING); + String[] lines = PApplet.loadStrings(input); + ArrayList list = new ArrayList(); + for (String line : lines) { + int index = line.indexOf('#'); + if (index != -1) { + line = line.substring(0, index); + } + line = line.trim(); + list.add(line); + } + return list.toArray(new String[0]); } @@ -149,7 +152,7 @@ public class Language { /** - * Custom Control class for consitent encoding. + * Custom 'Control' class for consistent encoding. * http://stackoverflow.com/questions/4659929/how-to-use-utf-8-in-resource-properties-with-resourcebundle */ class UTF8Control extends ResourceBundle.Control { @@ -173,8 +176,7 @@ public class Language { } if (stream != null) { try { - // Only this line is changed to make it to read properties - // files as UTF-8. + // Only line changed from the original source: bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8")); } finally { stream.close(); diff --git a/todo.txt b/todo.txt index 49fe4fff7..b1e18eec8 100644 --- a/todo.txt +++ b/todo.txt @@ -49,6 +49,8 @@ high _ export application ubuntu -> windows not working (2.2.1) _ https://github.com/processing/processing/issues/2698 _ might be something with libraries (native or otherwise) +_ move the language stuff to the settings folder +_ that way people can modify and test w/o recompiling pending From 785d38ac9e0b8bddd2be225722d8bbc541b4952c Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 17:19:17 -0400 Subject: [PATCH 051/134] change language handling a little --- app/src/processing/app/Language.java | 3 +-- app/src/processing/app/languages/languages.txt | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 app/src/processing/app/languages/languages.txt diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index ca9c48fc0..26a71f347 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -185,5 +185,4 @@ public class Language { return bundle; } } -} - +} \ No newline at end of file diff --git a/app/src/processing/app/languages/languages.txt b/app/src/processing/app/languages/languages.txt new file mode 100644 index 000000000..8620954e2 --- /dev/null +++ b/app/src/processing/app/languages/languages.txt @@ -0,0 +1,15 @@ +# List of supported language codes +# http://en.wikipedia.org/wiki/ISO_639-1 +# http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes + +# Add new languages in alphabetical order to (slightly) +# reduce the risk of merge conflicts + +de # German, Deutsch +en # English, English +el # Greek +es # Spanish +fr # French, Français, Langue française +ja # Japanese +nl # Dutch, Nederlands +pt # Portuguese From f57e9a01246f567d4f06b89c37a50bf4563217d2 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Fri, 1 Aug 2014 18:23:52 -0300 Subject: [PATCH 052/134] Update greek translation --- app/src/processing/app/languages/PDE_el.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/languages/PDE_el.properties b/app/src/processing/app/languages/PDE_el.properties index 3c2c557f2..5b1ba8b2b 100644 --- a/app/src/processing/app/languages/PDE_el.properties +++ b/app/src/processing/app/languages/PDE_el.properties @@ -217,9 +217,9 @@ editor.status.autoformat.no_changes = Δεν χρειάζονται αλλαγέ editor.status.autoformat.finished = Ολοκληρώθηκε η Αυτόματη μορφοποίηση. editor.status.find_reference.select_word_first = Επιλέξτε πρώτα μια λέξη προς αναζήτηση στην Processing Reference. editor.status.find_reference.not_available = Δεν υπάρχει καταχώρηση για το "%s" στην Processing Reference. -editor.status.drag_and_drop.no_files_added = Δεν προστέθηκαν αρχεία στο Σχέδιο. -editor.status.drag_and_drop.one_file_added = Ένα αρχείο προστέθηκε στο Σχέδιο. -editor.status.drag_and_drop.n_files_added = %d files αρχεία προστέθηκαν στο Σχέδιο. +editor.status.drag_and_drop.files_added.0 = Δεν προστέθηκαν αρχεία στο Σχέδιο. +editor.status.drag_and_drop.files_added.1 = Ένα αρχείο προστέθηκε στο Σχέδιο. +editor.status.drag_and_drop.files_added.n = %d files αρχεία προστέθηκαν στο Σχέδιο. editor.status.saving = Αποθήκευση... editor.status.saving.done = Ολοκλήρωση αποθήκευσης. editor.status.saving.canceled = Ακύρωση αποθήκευσης. From 48243e53fa6ec739ffb88f6365ccba4e9e249aa1 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 1 Aug 2014 17:36:44 -0400 Subject: [PATCH 053/134] change how language preference is set and stored --- app/src/processing/app/Language.java | 66 +++++++++++++++---------- app/src/processing/app/Preferences.java | 5 +- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 26a71f347..50b76ff74 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -36,6 +36,7 @@ import processing.core.PApplet; public class Language { static private final String FILE = "processing.app.languages.PDE"; static private final String LISTING = "processing/app/languages/languages.txt"; + static protected final String PREF = "language"; /** Single instance of this Language class */ static private Language instance = null; @@ -50,9 +51,15 @@ public class Language { private Language() { - // Get system language - this.language = Locale.getDefault().getLanguage(); - + String systemLanguage = Locale.getDefault().getLanguage(); + String language = Preferences.get(PREF); + boolean writePrefs = false; + + if (language == null) { + language = systemLanguage; + writePrefs = true; + } + // Set available languages languages = new HashMap(); for (String code : listSupported()) { @@ -62,22 +69,27 @@ public class Language { // Set default language if (!languages.containsKey(language)) { language = "en"; + writePrefs = true; } - // Get saved language - try { - File file = Base.getContentFile("lib/language.txt"); - if (file.exists()) { - String language = PApplet.loadStrings(file)[0]; - language = language.trim().toLowerCase(); - if (!language.equals("")) { - this.language = language; - } else { - Base.saveFile(this.language, file); - } - } - } catch (Exception e) { - e.printStackTrace(); +// // Get saved language +// try { +// File file = Base.getSettingsFile("language.txt"); +// if (file.exists()) { +// String language = PApplet.loadStrings(file)[0]; +// language = language.trim().toLowerCase(); +// if (!language.equals("")) { +// this.language = language; +// } else { +// Base.saveFile(this.language, file); +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } + + if (writePrefs) { + Preferences.save(); } // Get bundle with translations (processing.app.language.PDE) @@ -86,7 +98,7 @@ public class Language { String[] listSupported() { -// // List of languages in alphabetical order. New additions go here. +// // Old list of languages in alphabetical order. // final String[] SUPPORTED = { // "de", // de, German, Deutsch // "en", // en, English, English @@ -140,15 +152,15 @@ public class Language { } - /** Set new language */ - static public void setLanguage(String language) { - try { - File file = Base.getContentFile("lib/language.txt"); - Base.saveFile(language, file); - } catch (Exception e) { - e.printStackTrace(); - } - } +// /** Set new language */ +// static public void setLanguage(String language) { +// try { +// File file = Base.getContentFile("lib/language.txt"); +// Base.saveFile(language, file); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } /** diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 3c2a73aa1..9ece2af18 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -810,13 +810,14 @@ public class Preferences { Map languages = Language.getLanguages(); String language = ""; for (Map.Entry lang : languages.entrySet()) { - if (lang.getValue().equals( String.valueOf(languageSelectionBox.getSelectedItem()))) { + if (lang.getValue().equals(String.valueOf(languageSelectionBox.getSelectedItem()))) { language = lang.getKey().trim().toLowerCase(); break; } } if (!language.equals(Language.getLanguage()) && !language.equals("")) { - Language.setLanguage(language); + //Language.setLanguage(language); + set(Language.PREF, language); } int oldDisplayIndex = getInteger("run.display"); //$NON-NLS-1$ From 4c2adf101bd004097171d2af1f3b6395b5dd9c24 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sat, 2 Aug 2014 03:01:00 -0300 Subject: [PATCH 054/134] Fix typo and add missing string --- app/src/processing/app/languages/PDE.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/languages/PDE.properties b/app/src/processing/app/languages/PDE.properties index 1aa1acbde..a7cd2c1f5 100644 --- a/app/src/processing/app/languages/PDE.properties +++ b/app/src/processing/app/languages/PDE.properties @@ -116,7 +116,8 @@ save.btn.dont_save = Don't Save preferences = Preferences preferences.button.width = 80 preferences.requires_restart = requires restart of Processing -preferences.sketchbook_location = Sketchook location +preferences.sketchbook_location = Sketchbook location +preferences.sketchbook_location.popup = Sketchbook location preferences.language = Language preferences.editor_and_console_font = Editor and Console font preferences.editor_font_size = Editor font size From e7c3f3f2c2bf8c6f68bfd935051832b0c5947254 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 2 Aug 2014 07:08:50 -0400 Subject: [PATCH 055/134] fix AIOOBE when sorting all NaN FloatList or FloatDict --- core/src/processing/data/FloatDict.java | 3 +++ core/src/processing/data/FloatList.java | 3 +++ core/todo.txt | 2 ++ 3 files changed, 8 insertions(+) diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index d300afc1d..eef136d45 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -675,6 +675,9 @@ public class FloatDict { int right = count - 1; while (values[right] != values[right]) { right--; + if (right == -1) { + return 0; // all values are NaN + } } for (int i = right; i >= 0; --i) { if (Float.isNaN(values[i])) { diff --git a/core/src/processing/data/FloatList.java b/core/src/processing/data/FloatList.java index 1e4a85f19..7be02fcc1 100644 --- a/core/src/processing/data/FloatList.java +++ b/core/src/processing/data/FloatList.java @@ -570,6 +570,9 @@ public class FloatList implements Iterable { int right = count - 1; while (data[right] != data[right]) { right--; + if (right == -1) { // all values are NaN + return 0; + } } for (int i = right; i >= 0; --i) { float v = data[i]; diff --git a/core/todo.txt b/core/todo.txt index 9edc000c9..98d4e0183 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,4 +1,6 @@ 0230 core (3.0a3) +X add another NaN check when sorting FloatList/Dict classes +X if all values were NaN, an ArrayIndexOutOfBoundsException was thrown earlier X PShape disableStyle() does not work with createShape() From 7dadaed210b3b79e2d7dcea9ffc04eb4fda594e5 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 2 Aug 2014 07:28:19 -0400 Subject: [PATCH 056/134] cleaning up settings path and language pref handling --- app/src/processing/app/Base.java | 29 +++--- app/src/processing/app/Language.java | 90 ++++++++++++------- app/src/processing/app/Platform.java | 4 + app/src/processing/app/Preferences.java | 3 +- .../app/platform/WindowsPlatform.java | 3 +- build/shared/lib/defaults.txt | 4 - 6 files changed, 81 insertions(+), 52 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 061c44705..145cb093e 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1784,24 +1784,29 @@ public class Base { } - // ................................................................. + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + /** + * Get the directory that can store settings. (Library on OS X, App Data or + * something similar on Windows, a dot folder on Linux.) Removed this as a + * preference for 3.0a3 because we need this to be stable. + */ static public File getSettingsFolder() { File settingsFolder = null; - String preferencesPath = Preferences.get("settings.path"); //$NON-NLS-1$ - if (preferencesPath != null) { - settingsFolder = new File(preferencesPath); - - } else { - try { - settingsFolder = platform.getSettingsFolder(); - } catch (Exception e) { - showError("Problem getting data folder", - "Error getting the Processing data folder.", e); - } +// String preferencesPath = Preferences.get("settings.path"); //$NON-NLS-1$ +// if (preferencesPath != null) { +// settingsFolder = new File(preferencesPath); +// +// } else { + try { + settingsFolder = platform.getSettingsFolder(); + } catch (Exception e) { + showError("Problem getting the settings folder", + "Error getting the Processing the settings folder.", e); } +// } // create the folder if it doesn't exist already if (!settingsFolder.exists()) { diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 50b76ff74..daf9a227a 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -35,8 +35,12 @@ import processing.core.PApplet; */ public class Language { static private final String FILE = "processing.app.languages.PDE"; - static private final String LISTING = "processing/app/languages/languages.txt"; - static protected final String PREF = "language"; + //static private final String LISTING = "processing/app/languages/languages.txt"; + + // Store the language information in a file separate from the preferences, + // because preferences need the language on load time. + static protected final String PREF_FILE = "language.txt"; + static protected final File prefFile = Base.getSettingsFile(PREF_FILE); /** Single instance of this Language class */ static private Language instance = null; @@ -52,7 +56,7 @@ public class Language { private Language() { String systemLanguage = Locale.getDefault().getLanguage(); - String language = Preferences.get(PREF); + language = loadLanguage(); boolean writePrefs = false; if (language == null) { @@ -72,24 +76,8 @@ public class Language { writePrefs = true; } -// // Get saved language -// try { -// File file = Base.getSettingsFile("language.txt"); -// if (file.exists()) { -// String language = PApplet.loadStrings(file)[0]; -// language = language.trim().toLowerCase(); -// if (!language.equals("")) { -// this.language = language; -// } else { -// Base.saveFile(this.language, file); -// } -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } - if (writePrefs) { - Preferences.save(); + saveLanguage(language); } // Get bundle with translations (processing.app.language.PDE) @@ -97,19 +85,22 @@ public class Language { } - String[] listSupported() { -// // Old list of languages in alphabetical order. -// final String[] SUPPORTED = { -// "de", // de, German, Deutsch -// "en", // en, English, English -// "el", // el, Greek -// "es", // es, Spanish -// "fr", // fr, French, Français, Langue française -// "ja", // ja, Japanese -// "nl", // nl, Dutch, Nederlands -// "pt", // pt, Portuguese -// }; + static private String[] listSupported() { + // List of languages in alphabetical order. + final String[] SUPPORTED = { + "de", // de, German, Deutsch + "en", // en, English, English + "el", // el, Greek + "es", // es, Spanish + "fr", // fr, French, Français, Langue française + "ja", // ja, Japanese + "nl", // nl, Dutch, Nederlands + "pt", // pt, Portuguese + }; + return SUPPORTED; + /* + // come back to this when bundles are placed outside the JAR InputStream input = getClass().getResourceAsStream(LISTING); String[] lines = PApplet.loadStrings(input); ArrayList list = new ArrayList(); @@ -122,9 +113,40 @@ public class Language { list.add(line); } return list.toArray(new String[0]); + */ } + /** Read the saved language */ + static private String loadLanguage() { + try { + if (prefFile.exists()) { + String language = PApplet.loadStrings(prefFile)[0]; + language = language.trim().toLowerCase(); + if (!language.equals("")) { + return language; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * Save the language directly to a settings file. This is 'save' and not + * 'set' because a language change requires a restart of Processing. + */ + static public void saveLanguage(String language) { + try { + Base.saveFile(language, prefFile); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** Singleton constructor */ static public synchronized Language init() { if (instance == null) { @@ -152,8 +174,10 @@ public class Language { } -// /** Set new language */ +// /** Set new language (called by Preferences) */ // static public void setLanguage(String language) { +// this.language = language; +// // try { // File file = Base.getContentFile("lib/language.txt"); // Base.saveFile(language, file); diff --git a/app/src/processing/app/Platform.java b/app/src/processing/app/Platform.java index 5b16bd5ff..c5248ec51 100644 --- a/app/src/processing/app/Platform.java +++ b/app/src/processing/app/Platform.java @@ -80,6 +80,10 @@ public class Platform { } + /** + * This function should throw an exception or return a value. + * Do not return null. + */ public File getSettingsFolder() throws Exception { // otherwise make a .processing directory int the user's home dir File home = new File(System.getProperty("user.home")); diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 9ece2af18..bd8c12204 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -816,8 +816,7 @@ public class Preferences { } } if (!language.equals(Language.getLanguage()) && !language.equals("")) { - //Language.setLanguage(language); - set(Language.PREF, language); + Language.saveLanguage(language); } int oldDisplayIndex = getInteger("run.display"); //$NON-NLS-1$ diff --git a/app/src/processing/app/platform/WindowsPlatform.java b/app/src/processing/app/platform/WindowsPlatform.java index 0c14b5ead..47b1d2746 100644 --- a/app/src/processing/app/platform/WindowsPlatform.java +++ b/app/src/processing/app/platform/WindowsPlatform.java @@ -23,6 +23,7 @@ package processing.app.platform; import java.io.File; +import java.io.IOException; import java.io.UnsupportedEncodingException; import com.sun.jna.Library; @@ -261,7 +262,7 @@ public class WindowsPlatform extends Platform { if (appData != null) { return new File(appData, APP_NAME); } - return null; + throw new IOException("Could not get the Application Data folder"); } diff --git a/build/shared/lib/defaults.txt b/build/shared/lib/defaults.txt index a7e5706a8..f8e453211 100644 --- a/build/shared/lib/defaults.txt +++ b/build/shared/lib/defaults.txt @@ -48,10 +48,6 @@ # has gone missing, and that it should instead use the default. #sketchbook.path= -# if you don't want settings to go into "application data" on windows -# and "library" on macosx, set this to the alternate location. -#settings.path=data - # By default, no sketches currently open last.sketch.count=0 From 8405fdcc4f0398ae53deb783b97776e7bd06d06c Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 2 Aug 2014 07:38:34 -0400 Subject: [PATCH 057/134] more NaN check business --- core/src/processing/data/FloatDict.java | 3 +++ core/src/processing/data/FloatList.java | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index eef136d45..ec6fd9bd0 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -671,6 +671,9 @@ public class FloatDict { if (useKeys) { return count; // don't worry about NaN values + } else if (count == 0) { // skip the NaN check, it'll AIOOBE + return 0; + } else { // first move NaN values to the end of the list int right = count - 1; while (values[right] != values[right]) { diff --git a/core/src/processing/data/FloatList.java b/core/src/processing/data/FloatList.java index 7be02fcc1..dd050e111 100644 --- a/core/src/processing/data/FloatList.java +++ b/core/src/processing/data/FloatList.java @@ -566,6 +566,10 @@ public class FloatList implements Iterable { new Sort() { @Override public int size() { + // if empty, don't even mess with the NaN check, it'll AIOOBE + if (count == 0) { + return 0; + } // move NaN values to the end of the list and don't sort them int right = count - 1; while (data[right] != data[right]) { From 829717adedb439665f06548adb604358c97d967a Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 2 Aug 2014 08:40:29 -0400 Subject: [PATCH 058/134] rename sketchbook tree name, re-order menu, add language hooks --- app/src/processing/app/Editor.java | 18 ++++++++---------- app/src/processing/app/Mode.java | 4 ++-- app/src/processing/app/Recent.java | 5 +++-- .../processing/app/languages/PDE.properties | 8 ++++++-- todo.txt | 2 ++ 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 126152f4c..2f7490b7d 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -142,8 +142,8 @@ public abstract class Editor extends JFrame implements RunnerListener { // EditorConsole.systemOut.println("editor window activated"); base.handleActivated(Editor.this); // mode.handleActivated(Editor.this); - fileMenu.insert(base.getSketchbookMenu(), 2); - fileMenu.insert(base.getRecentMenu(), 3); +// fileMenu.insert(base.getSketchbookMenu(), 2); + fileMenu.insert(base.getRecentMenu(), 2); // fileMenu.insert(mode.getExamplesMenu(), 3); sketchMenu.insert(mode.getImportMenu(), 4); mode.insertToolbarRecentMenu(); @@ -154,7 +154,7 @@ public abstract class Editor extends JFrame implements RunnerListener { public void windowDeactivated(WindowEvent e) { // EditorConsole.systemErr.println("editor window deactivated"); // mode.handleDeactivated(Editor.this); - fileMenu.remove(base.getSketchbookMenu()); +// fileMenu.remove(base.getSketchbookMenu()); fileMenu.remove(base.getRecentMenu()); // fileMenu.remove(mode.getExamplesMenu()); sketchMenu.remove(mode.getImportMenu()); @@ -616,20 +616,18 @@ public abstract class Editor extends JFrame implements RunnerListener { }); fileMenu.add(item); - fileMenu.add(base.getSketchbookMenu()); +// fileMenu.add(base.getSketchbookMenu()); - JMenuItem sbMenu = Toolkit.newJMenuItemShift("Sketchbook Tree", 'K'); - sbMenu.addActionListener(new ActionListener() { + item = Toolkit.newJMenuItemShift(Language.text("menu.file.sketchbook"), 'K'); + item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mode.showSketchbookFrame(); } }); - - fileMenu.add(sbMenu); + fileMenu.add(item); -// fileMenu.add(mode.getExamplesMenu()); - item = Toolkit.newJMenuItemShift(Language.text("menu.file.examples"), 'O'); + item = Toolkit.newJMenuItemShift(Language.text("editor.window.examples"), 'O'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mode.showExamplesFrame(); diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index ab7e2d4a8..4256a8584 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -684,7 +684,7 @@ public abstract class Mode { public void showExamplesFrame() { if (examplesFrame == null) { - examplesFrame = new JFrame(getTitle() + " "+Language.text("menu.file.examples")); + examplesFrame = new JFrame(getTitle() + " " + Language.text("editor.window.examples")); Toolkit.setIcon(examplesFrame); Toolkit.registerWindowCloseKeys(examplesFrame.getRootPane(), new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -903,7 +903,7 @@ public abstract class Mode { public void showSketchbookFrame() { if (sketchbookFrame == null) { - sketchbookFrame = new JFrame("Processing Sketchbook"); + sketchbookFrame = new JFrame(Language.text("editor.window.sketchbook")); Toolkit.setIcon(sketchbookFrame); Toolkit.registerWindowCloseKeys(sketchbookFrame.getRootPane(), new ActionListener() { diff --git a/app/src/processing/app/Recent.java b/app/src/processing/app/Recent.java index 8dc1069b1..326cbc96c 100644 --- a/app/src/processing/app/Recent.java +++ b/app/src/processing/app/Recent.java @@ -24,6 +24,7 @@ package processing.app; import java.awt.event.*; import java.io.*; import java.util.ArrayList; + import javax.swing.*; import processing.core.PApplet; @@ -53,8 +54,8 @@ public class Recent { this.base = base; remember = Preferences.getInteger("recent.count"); file = Base.getSettingsFile(FILENAME); - mainMenu = new JMenu("Recent"); - toolbarMenu = new JMenu("Recent"); + mainMenu = new JMenu(Language.text("menu.file.recent")); + toolbarMenu = new JMenu(Language.text("menu.file.open")); try { load(); diff --git a/app/src/processing/app/languages/PDE.properties b/app/src/processing/app/languages/PDE.properties index a7cd2c1f5..1aea584fc 100644 --- a/app/src/processing/app/languages/PDE.properties +++ b/app/src/processing/app/languages/PDE.properties @@ -13,8 +13,8 @@ menu.file = File menu.file.new = New menu.file.open = Open... -menu.file.sketchbook = Sketchbook -menu.file.recent = Recent +menu.file.recent = Open Recent +menu.file.sketchbook = Sketchbook... menu.file.examples = Examples... menu.file.close = Close menu.file.save = Save @@ -205,6 +205,10 @@ toolbar.save = Save toolbar.export_application = Export Application toolbar.add_mode = Add mode... +# the windows accessible from the File menu +editor.window.sketchbook = Sketchbook +editor.window.examples = Examples + # [Tab1] [Tab2] [v] editor.header.new_tab = New Tab editor.header.rename = Rename diff --git a/todo.txt b/todo.txt index b1e18eec8..b44988935 100644 --- a/todo.txt +++ b/todo.txt @@ -1,5 +1,7 @@ 0230 pde (3.0a3) X remove toolbar buttons except for start/stop +X rename sketchbook tree name, re-order menu, add language hooks +_ remove toolbar menu references and code to rebuild gsoc X fixes for mode/tool installation From 2ddbaf136012a1b61c2a2200ff0d5957757ceca9 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 2 Aug 2014 09:19:09 -0400 Subject: [PATCH 059/134] add note about extra methods --- todo.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/todo.txt b/todo.txt index b44988935..6f7d15d4f 100644 --- a/todo.txt +++ b/todo.txt @@ -30,6 +30,8 @@ X https://github.com/processing/processing/pull/2696 X prevent adding files to read-only sketches X https://github.com/processing/processing/issues/2459 X https://github.com/processing/processing/pull/2697 +X Added some helper methods to Language +X https://github.com/processing/processing/pull/2704 languages X Japanese https://github.com/processing/processing/pull/2688 From 419e00ea964ca3f292f27b446b6538748b6e75fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C4=B1l?= Date: Sat, 2 Aug 2014 16:22:15 +0300 Subject: [PATCH 060/134] Turkish translation Hi everyone. This is my first github activity. I hope it was okay. :) --- processing | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 processing diff --git a/processing b/processing new file mode 100644 index 000000000..88a8431bb --- /dev/null +++ b/processing @@ -0,0 +1,210 @@ ++ ++ ++# --------------------------------------- ++# Language: Türkçe (Turkish) (tr) ++# --------------------------------------- ++ ++ ++# --------------------------------------- ++# Menu ++ ++# | File | Edit | Sketch | Library | Tools | Help | ++# | File | ++menu.file = Dosya ++menu.file.new = Yeni ++menu.file.open = Aç... ++menu.file.sketchbook = Sketchbook ++menu.file.recent = En son ++menu.file.sketchbook_tree = Sketchbook Ağacı ++menu.file.examples = Örnekler... ++menu.file.close = Kapat ++menu.file.save = Kaydet ++menu.file.save_as = ... olarak Kaydet ++menu.file.export_application = Aktar ++menu.file.page_setup = Sayfa Yapısı ++menu.file.print = Yazdır ++menu.file.preferences = Tercihler ++menu.file.quit = Çıkış ++ ++# | File | Edit | Sketch | Library | Tools | Help | ++# | Edit | ++menu.edit = Düzenle ++menu.edit.undo = Geri Al ++menu.edit.redo = İleri Al ++menu.edit.cut = Kes ++menu.edit.copy = Kopyala ++menu.edit.copy_as_html = HTML olarak Kopyala ++menu.edit.paste = Yapıştır ++menu.edit.select_all = Tümünü Seç ++menu.edit.auto_format = Otomatik Biçimlendir ++menu.edit.comment_uncomment = Yorumla/Yorumu Kaldır ++menu.edit.increase_indent = Girintiyi Artır ++menu.edit.decrease_indent = Girintiyi Azalt ++menu.edit.find = Bul.. ++menu.edit.find_next = Sonrakini Bul ++menu.edit.find_previous = Öncekini Bul ++menu.edit.use_selection_for_find = Seçimi Bul ++ ++# | File | Edit | Sketch | Library | Tools | Help | ++# | Sketch | ++menu.sketch = Sketch ++menu.sketch.show_sketch_folder = Sketch Klasörünü Görüntüle ++menu.sketch.add_file = Dosya Ekle... ++ ++# | File | Edit | Sketch | Library | Tools | Help | ++# | Library | ++menu.library = Kütüphane... ++menu.library.add_library = Kütüphane Ekle... ++menu.library.contributed = Yüklenenler ++menu.library.no_core_libraries = Esas mod kütüphaneleri yoktur ++ ++# | File | Edit | Sketch | Library | Tools | Help | ++# | Tools | ++menu.tools = Araçlar ++menu.tools.color_selector = Renk Seçici ++menu.tools.create_font = Yazı Tipi Oluştur... ++menu.tools.archive_sketch = Sketch'i Arşivle ++menu.tools.fix_the_serial_lbrary = "Serial Kütüphanesi"ni Onar... ++menu.tools.install_processing_java = "Processing-Java"yı Yükle... ++menu.tools.add_tool = Araç Ekle... ++ ++# | File | Edit | Sketch | Library | Tools | Help | ++# | Help | ++menu.help = Yardım ++menu.help.about = Processing Hakkında (en) ++menu.help.environment = Ortam (en) ++menu.help.reference = Referanslar (en) ++menu.help.find_in_reference = Referanslarda Bul (en) ++menu.help.online = Çevrimiçi ++menu.help.getting_started = Başlarken (en) ++menu.help.getting_started.url = http://processing.org/learning/gettingstarted/ ++menu.help.troubleshooting = Sorun Giderme (en) ++menu.help.troubleshooting.url = http://wiki.processing.org/w/Troubleshooting ++menu.help.faq = Sıkça Sorulan Sorular (en) ++menu.help.faq.url = http://wiki.processing.org/w/FAQ ++menu.help.foundation = "Processing Vakfı" (en) ++menu.help.foundation.url = http://processing.org/foundation/ ++menu.help.visit = Processing.org'u Ziyaret Et (en) ++menu.help.visit.url = http://processing.org/ ++ ++ ++# --------------------------------------- ++# Basics ++ ++# Buttons ++prompt.yes = Evet ++prompt.no = Hayır ++prompt.cancel = İptal ++prompt.ok = Tamam ++prompt.browse = Gözat ++prompt.export = Aktar ++ ++ ++# --------------------------------------- ++# Frames ++ ++# Open (Frame) ++open = Bir Processing Sketch'i Aç... ++ ++# Save (Frame) ++save = Sketch Dosyasını Kaydet... ++save.title = Kapatmadan önce yapılan son değişikleri
kaydetmek istiyor musunuz? ++save.hint = Kaydedilmeyen değişiklikler kaybolur ++save.btn.save = Kaydet ++save.btn.dont_save = Kaydetme ++ ++# Preferences (Frame) ++preferences = Tercihler ++preferences.button.width = 110 ++preferences.requires_restart = Processing'i yeniden başlatmalısınız ++preferences.sketchbook_location = Sketchbook'un Konumu ++preferences.language = Dil ++preferences.editor_and_console_font = Editör ve Konsol Yazı Tipi ++preferences.editor_font_size = Editör Yazı Tipi Boyutu ++preferences.console_font_size = Konsol Yazı Tipi Boyutu ++preferences.background_color = Sunum sırasındaki arkaplan rengi ++preferences.use_smooth_text = Editör penceresinde yazıyı yumuşat ++preferences.enable_complex_text_input = Latin olmayan karakter girişini etkinleştir ++preferences.enable_complex_text_input_example = örn.: Japonca, ++preferences.continuously_check = Hataları sürekli tespit et ++preferences.show_warnings = Uyarıları göster ++preferences.code_completion = Otomatik kod tamamlama ++preferences.trigger_with = ile Başlat ++preferences.cmd_space = Boşluk ++preferences.increase_max_memory = Kullanılabilir maksimum hafızayı artır ++preferences.delete_previous_folder_on_export = Aktarırken önceki uygulama klasörünü sil ++preferences.hide_toolbar_background_image = Araç çubuğu arkaplan görselini gizle ++preferences.check_for_updates_on_startup = Başlangıçta güncellemeleri denetle ++preferences.run_sketches_on_display = Ekranda çalışan sketch sayısı ++preferences.automatically_associate_pde_files = .pde dosyalarını otomatik olarak Processing'le ilişkilendir ++preferences.launch_programs_in = Programları çalıştır ++preferences.launch_programs_in.mode = Mod ++preferences.file = Dosya menüsünde bir çok ayarı düzenleyebilirsiniz ++preferences.file.hint = Tercihleri düzenlemeden önce Processing Sketchlerini kapatın ++ ++# Sketchbook Location (Frame) ++sketchbook_location = Sketchbook'un konumunu seç ++ ++# Export (Frame) ++export = Aktarım Seçenekleri ++export.platforms = Platformlar ++export.options = Seçenekler ++export.options.fullscreen = Tam Ekran (Sunum Modu) ++export.options.show_stop_button = Durdur butonunu göster ++export.description.line1 = Uygulama Aktarımı iki platformda da bağımsız ++export.description.line2 = olarak çalışabilen uygulamalar oluşturabilir. ++ ++# Find (Frame) ++find = Bul ++find.find = Bul: ++find.replace_with = ile Değiştir: ++find.ignore_case = Büyük/Küçük Harf'i Yoksay ++find.all_tabs = Tüm Sekmelerde ++find.wrap_around = Başa Dön ++find.btn.replace_all = Tümünü Değiştir ++find.btn.replace = Değiştir ++find.btn.find_and_replace = Bul ve Değiştir ++find.btn.previous = Önceki ++find.btn.find = Bul ++ ++# Find in reference (Frame) ++find_in_reference = Referans Bul (en) ++ ++# Library Manager (Frame) ++library.category = Kategori: ++library.filter_your_search = Aramayı Filtrele... ++ ++# File (Frame) ++file = Sketch'e eklemek için görüntü veya başka bir data dosyası seç ++ ++# Create Font (Frame) ++create_font = Yazı Tipi Oluştur ++ ++# Color Selector (Frame) ++color_selector = Renk Seçici ++ ++# Archive Sketch (Frame) ++archive_sketch = ... olarak Arşivle ++ ++ ++# --------------------------------------- ++# Toolbar ++ ++# [Run/Present] [Stop] [New] [Open] [Save] ++toolbar.run = Çalıştır ++toolbar.present = Sürmekte ++toolbar.stop = Durdur ++toolbar.new = Yeni ++toolbar.open = Aç ++toolbar.save = Kaydet ++toolbar.export_application = Uygulama Aktarımı ++toolbar.add_mode = Mod ekle... ++ ++# [Tab1] [Tab2] [v] ++editor.header.new_tab = Yeni Sekme ++editor.header.rename = Yeniden İsimlendir ++editor.header.delete = Sil ++editor.header.previous_tab = Önceki Sekme ++editor.header.next_tab = Sonraki Sekme ++editor.header.delete.warning.title = Evet, hayır. ++editor.header.delete.warning.text = Aktif sketchteki son sekmeyi silemezsin. From c6bd6d5becbbf60066c23f82b37d1f5b694de96e Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 2 Aug 2014 09:32:04 -0400 Subject: [PATCH 061/134] additional tweak to add Turkish --- app/src/processing/app/Language.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 669f00196..836b0d211 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -86,16 +86,17 @@ public class Language { static private String[] listSupported() { - // List of languages in alphabetical order. + // List of languages in alphabetical order. (Add yours here.) final String[] SUPPORTED = { - "de", // de, German, Deutsch - "en", // en, English, English - "el", // el, Greek - "es", // es, Spanish - "fr", // fr, French, Français, Langue française - "ja", // ja, Japanese - "nl", // nl, Dutch, Nederlands - "pt", // pt, Portuguese + "de", // German, Deutsch + "en", // English + "el", // Greek + "es", // Spanish + "fr", // French, Français + "ja", // Japanese + "nl", // Dutch, Nederlands + "pt", // Portuguese + "tr" // Turkish }; return SUPPORTED; From a671f76a54ce01d9240d0e6df574af467cc1e058 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sat, 2 Aug 2014 10:47:16 -0300 Subject: [PATCH 062/134] Add missing strings to spanish translation --- .../app/languages/PDE_es.properties | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/src/processing/app/languages/PDE_es.properties b/app/src/processing/app/languages/PDE_es.properties index fdafe3f6e..10b87a8d0 100644 --- a/app/src/processing/app/languages/PDE_es.properties +++ b/app/src/processing/app/languages/PDE_es.properties @@ -212,3 +212,28 @@ editor.header.previous_tab = Pestaña anterior editor.header.next_tab = Pestaña siguiente editor.header.delete.warning.title = No editor.header.delete.warning.text = No puedes eliminar la última pestaña del último sketch abierto + +editor.status.autoformat.no_changes = No se realizaron cambios por Autoformato. +editor.status.autoformat.finished = Autoformato completado. +editor.status.find_reference.select_word_first = Selecciona primero una palabra para buscar en la referencia. +editor.status.find_reference.not_available = No se encontró una referencia disponible para "%s". +editor.status.drag_and_drop.files_added.0 = Ningún archivo añadido al sketch. +editor.status.drag_and_drop.files_added.1 = Un archivo añadido al sketch. +editor.status.drag_and_drop.files_added.n = %d archivos añadidos al sketch. +editor.status.saving = Guardando... +editor.status.saving.done = Guardado finalizado. +editor.status.saving.canceled = Guardado cancelado. +editor.status.printing = Imprimiendo... +editor.status.printing.done = Impresión finalizada. +editor.status.printing.error = Error al imprimir. +editor.status.printing.canceled = Impresión cancelada. + +# --------------------------------------- +# Contribution Panel +contributions.undo = Deshacer +contributions.remove = Eliminar +contributions.install = Instalar +contributions.progress.starting = Iniciando +contributions.progress.downloading = Descargando +contributions.download_error = Ocurrió un error al descargar la contribución. +contributions.unsupported_operating_system = Tu sistema operativo no está soportado. Visita la documentación de la biblioteca para más información. From f6806e6bf6372436aea5924bbbd61c26056e67fd Mon Sep 17 00:00:00 2001 From: aengelke Date: Sat, 2 Aug 2014 16:25:11 +0200 Subject: [PATCH 063/134] Style completion panel for Nimbus LAF --- .../mode/experimental/CompletionPanel.java | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/pdex/src/processing/mode/experimental/CompletionPanel.java b/pdex/src/processing/mode/experimental/CompletionPanel.java index 5c3da8b42..99b98c7e8 100644 --- a/pdex/src/processing/mode/experimental/CompletionPanel.java +++ b/pdex/src/processing/mode/experimental/CompletionPanel.java @@ -22,19 +22,31 @@ import static processing.mode.experimental.ExperimentalMode.log2; import static processing.mode.experimental.ExperimentalMode.logE; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Component; +import java.awt.Dimension; import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.Point; +import java.awt.Rectangle; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; +import javax.swing.Painter; import javax.swing.SwingUtilities; +import javax.swing.UIDefaults; +import javax.swing.UIManager; +import javax.swing.plaf.InsetsUIResource; +import javax.swing.plaf.basic.BasicScrollBarUI; import javax.swing.text.BadLocationException; import processing.app.syntax.JEditTextArea; @@ -98,6 +110,19 @@ public class CompletionPanel { popupMenu.setOpaque(false); popupMenu.setBorder(null); scrollPane = new JScrollPane(); + if (UIManager.getLookAndFeel().getID().equals("Nimbus")) { + UIDefaults defaults = new UIDefaults(); + defaults.put("PopupMenu.contentMargins", new InsetsUIResource(0, 0, 0, 0)); + defaults.put("ScrollPane[Enabled].borderPainter", new Painter() { + public void paint(Graphics2D g, JComponent t, int w, int h) {} + }); + popupMenu.putClientProperty("Nimbus.Overrides", defaults); + scrollPane.putClientProperty("Nimbus.Overrides", defaults); + scrollPane.getHorizontalScrollBar().setPreferredSize(new Dimension(Integer.MAX_VALUE, 8)); + scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(8, Integer.MAX_VALUE)); + scrollPane.getHorizontalScrollBar().setUI(new CompletionScrollBarUI()); + scrollPane.getVerticalScrollBar().setUI(new CompletionScrollBarUI()); + } scrollPane.setViewportView(completionList = createSuggestionList(position, items)); popupMenu.add(scrollPane, BorderLayout.CENTER); popupMenu.setPopupSize(280, setHeight(items.getSize())); //TODO: Eradicate this evil @@ -109,6 +134,33 @@ public class CompletionPanel { //log("Suggestion shown: " + System.currentTimeMillis()); } + public static class CompletionScrollBarUI extends BasicScrollBarUI { + + @Override + protected void paintThumb(Graphics g, JComponent c, Rectangle trackBounds) { + g.setColor((Color) UIManager.get("nimbusBlueGrey")); + g.fillRect(trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height); + } + + @Override + protected JButton createDecreaseButton(int orientation) { + return createZeroButton(); + } + + @Override + protected JButton createIncreaseButton(int orientation) { + return createZeroButton(); + } + + private JButton createZeroButton() { + JButton jbutton = new JButton(); + jbutton.setPreferredSize(new Dimension(0, 0)); + jbutton.setMinimumSize(new Dimension(0, 0)); + jbutton.setMaximumSize(new Dimension(0, 0)); + return jbutton; + } + } + public boolean isVisible() { return popupMenu.isVisible(); } @@ -444,4 +496,4 @@ public class CompletionPanel { } } -} \ No newline at end of file +} From 00c4b0039231aee914306bab7f105b494a6c0c9b Mon Sep 17 00:00:00 2001 From: aengelke Date: Sat, 2 Aug 2014 18:20:55 +0200 Subject: [PATCH 064/134] Sort font names for preferences --- app/src/processing/app/Toolkit.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/Toolkit.java b/app/src/processing/app/Toolkit.java index 83ead7661..c9407ad43 100644 --- a/app/src/processing/app/Toolkit.java +++ b/app/src/processing/app/Toolkit.java @@ -44,6 +44,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.lang.reflect.Field; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -380,7 +381,9 @@ public class Toolkit { for (Font font : getMonoFontList()) { families.add(font.getFamily()); } - return families.toArray(new String[0]); + String[] names = families.toArray(new String[0]); + Arrays.sort(names); + return names; } From cbfda53bd96f0e5104a3fe092cfeb69e9eb082d8 Mon Sep 17 00:00:00 2001 From: aengelke Date: Sat, 2 Aug 2014 18:41:10 +0200 Subject: [PATCH 065/134] Disable memory field if the box is unchecked --- app/src/processing/app/Preferences.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index bd8c12204..1a79bb0ce 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -570,6 +570,12 @@ public class Preferences { memoryOverrideBox = new JCheckBox(Language.text("preferences.increase_max_memory")+": "); memoryBox.add(memoryOverrideBox); memoryField = new JTextField(4); + memoryOverrideBox.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + memoryField.setEnabled(memoryOverrideBox.isSelected()); + } + }); memoryBox.add(memoryField); memoryBox.add(new JLabel(" MB")); pain.add(memoryBox); @@ -936,6 +942,7 @@ public class Preferences { setSelected(getBoolean("run.options.memory")); //$NON-NLS-1$ memoryField. setText(get("run.options.memory.maximum")); //$NON-NLS-1$ + memoryField.setEnabled(memoryOverrideBox.isSelected()); if (autoAssociateBox != null) { autoAssociateBox. From 9ad757cf1db4d7380dd613242a7b5bb257fc33e8 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 2 Aug 2014 13:43:36 -0400 Subject: [PATCH 066/134] moving gui code to a separate class --- .../processing/app/{Preferences.java => PreferencesFrame.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/src/processing/app/{Preferences.java => PreferencesFrame.java} (100%) diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/PreferencesFrame.java similarity index 100% rename from app/src/processing/app/Preferences.java rename to app/src/processing/app/PreferencesFrame.java From bd4886b0089ff61d57058ed516f4d86e6933cf13 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sat, 2 Aug 2014 14:22:05 -0400 Subject: [PATCH 067/134] split prefs frame (issue #68) and dismantle EditorStatus --- app/src/processing/app/Base.java | 4 +- app/src/processing/app/EditorStatus.java | 91 ++-- app/src/processing/app/Preferences.java | 385 ++++++++++++++ app/src/processing/app/PreferencesFrame.java | 502 +++---------------- todo.txt | 7 +- 5 files changed, 503 insertions(+), 486 deletions(-) create mode 100644 app/src/processing/app/Preferences.java diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 145cb093e..b2a5d9710 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -92,7 +92,7 @@ public class Base { static private boolean commandLine; // A single instance of the preferences window - Preferences preferencesFrame; + PreferencesFrame preferencesFrame; // A single instance of the library manager window ContributionManagerDialog libraryManagerFrame; @@ -1605,7 +1605,7 @@ public class Base { */ public void handlePrefs() { if (preferencesFrame == null) { - preferencesFrame = new Preferences(this); + preferencesFrame = new PreferencesFrame(this); } preferencesFrame.showFrame(); } diff --git a/app/src/processing/app/EditorStatus.java b/app/src/processing/app/EditorStatus.java index c99d45f31..81d0f68ce 100644 --- a/app/src/processing/app/EditorStatus.java +++ b/app/src/processing/app/EditorStatus.java @@ -24,7 +24,7 @@ package processing.app; import java.awt.*; -import java.awt.event.*; +//import java.awt.event.*; import javax.swing.*; @@ -36,6 +36,9 @@ public class EditorStatus extends JPanel { Color[] bgcolor; Color[] fgcolor; + @Deprecated + static final int BUTTON_HEIGHT = 24; + static public final int NOTICE = 0; static public final int ERR = 1; static public final int EDIT = 2; @@ -59,9 +62,9 @@ public class EditorStatus extends JPanel { Image offscreen; int sizeW, sizeH; - JButton cancelButton; - JButton okButton; - JTextField editField; +// JButton cancelButton; +// JButton okButton; +// JTextField editField; int response; @@ -122,29 +125,29 @@ public class EditorStatus extends JPanel { } - public void edit(String message, String dflt) { - mode = EDIT; - this.message = message; - - response = 0; - okButton.setVisible(true); - cancelButton.setVisible(true); - editField.setVisible(true); - editField.setText(dflt); - editField.selectAll(); - editField.requestFocusInWindow(); - - repaint(); - } +// public void edit(String message, String dflt) { +// mode = EDIT; +// this.message = message; +// +// response = 0; +// okButton.setVisible(true); +// cancelButton.setVisible(true); +// editField.setVisible(true); +// editField.setText(dflt); +// editField.selectAll(); +// editField.requestFocusInWindow(); +// +// repaint(); +// } - public void unedit() { - okButton.setVisible(false); - cancelButton.setVisible(false); - editField.setVisible(false); - editor.textarea.requestFocusInWindow(); - empty(); - } +// public void unedit() { +// okButton.setVisible(false); +// cancelButton.setVisible(false); +// editField.setVisible(false); +// editor.textarea.requestFocusInWindow(); +// empty(); +// } public void startIndeterminate() { @@ -171,7 +174,7 @@ public class EditorStatus extends JPanel { public void paintComponent(Graphics screen) { - if (okButton == null) setup(); +// if (okButton == null) setup(); Dimension size = getSize(); if ((size.width != sizeW) || (size.height != sizeH)) { @@ -182,7 +185,7 @@ public class EditorStatus extends JPanel { if (offscreen == null) { sizeW = size.width; sizeH = size.height; - setButtonBounds(); +// setButtonBounds(); if (Toolkit.highResDisplay()) { offscreen = createImage(sizeW*2, sizeH*2); } else { @@ -211,8 +214,6 @@ public class EditorStatus extends JPanel { ascent = metrics.getAscent(); } - //setBackground(bgcolor[mode]); // does nothing - g.setColor(bgcolor[mode]); g.fillRect(0, 0, sizeW, sizeH); @@ -221,14 +222,12 @@ public class EditorStatus extends JPanel { g.drawString(message, Preferences.GUI_SMALL, (sizeH + ascent) / 2); if (indeterminate) { - int x = cancelButton.getX(); - int w = cancelButton.getWidth(); + //int x = cancelButton.getX(); + //int w = cancelButton.getWidth(); + int w = Preferences.BUTTON_WIDTH; + int x = getWidth() - Preferences.GUI_SMALL - w; int y = getHeight() / 3; int h = getHeight() / 3; -// int y = cancelButton.getY(); -// int h = cancelButton.getHeight(); -// g.setColor(fgcolor[mode]); -// g.setColor(Color.DARK_GRAY); g.setColor(new Color(0x80000000, true)); g.drawRect(x, y, w, h); for (int i = 0; i < 10; i++) { @@ -241,6 +240,7 @@ public class EditorStatus extends JPanel { } + /* protected void setup() { if (okButton == null) { cancelButton = new JButton(Preferences.PROMPT_CANCEL); @@ -325,12 +325,10 @@ public class EditorStatus extends JPanel { (c == KeyEvent.VK_SHIFT)) { // these events are ignored - /* - } else if (c == KeyEvent.VK_ESCAPE) { - unedit(); - editor.toolbar.clear(); - event.consume(); - */ +// } else if (c == KeyEvent.VK_ESCAPE) { +// unedit(); +// editor.toolbar.clear(); +// event.consume(); } else if (c == KeyEvent.VK_SPACE) { String t = editField.getText(); @@ -371,8 +369,8 @@ public class EditorStatus extends JPanel { } - protected void setButtonBounds() { - int top = (sizeH - Preferences.BUTTON_HEIGHT) / 2; + private void setButtonBounds() { + int top = (sizeH - BUTTON_HEIGHT) / 2; int eachButton = Preferences.GUI_SMALL + Preferences.BUTTON_WIDTH; int cancelLeft = sizeW - eachButton; @@ -386,8 +384,8 @@ public class EditorStatus extends JPanel { //yesButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); //noButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); - cancelButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); - okButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); + cancelButton.setSize(Preferences.BUTTON_WIDTH, BUTTON_HEIGHT); + okButton.setSize(Preferences.BUTTON_WIDTH, BUTTON_HEIGHT); // edit field height is awkward, and very different between mac and pc, // so use at least the preferred height for now. @@ -397,6 +395,7 @@ public class EditorStatus extends JPanel { editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop, editWidth, editHeight); } + */ public Dimension getPreferredSize() { @@ -414,6 +413,7 @@ public class EditorStatus extends JPanel { } + /* public void actionPerformed(ActionEvent e) { if (e.getSource() == cancelButton) { if (mode == EDIT) unedit(); @@ -428,4 +428,5 @@ public class EditorStatus extends JPanel { } } } + */ } diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java new file mode 100644 index 000000000..85bd12ac2 --- /dev/null +++ b/app/src/processing/app/Preferences.java @@ -0,0 +1,385 @@ +/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + Part of the Processing project - http://processing.org + + Copyright (c) 2014 The Processing Foundation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package processing.app; + +import java.awt.*; +import java.io.*; +import java.util.*; + +import processing.core.*; + + +/** + * Storage class for user preferences and environment settings. + *

+ * This class does not use the Properties class because .properties files use + * ISO 8859-1 encoding, which is highly likely to be a problem when trying to + * save sketch folders and locations. Like the rest of Processing, we use UTF8. + *

+ * We don't use the Java Preferences API because it would entail writing to + * the registry (on Windows), or an obscure file location (on Mac OS X) and + * make it far more difficult (impossible) to remove the preferences.txt to + * reset them (when they become corrupt), or to find the the file to make + * edits for numerous obscure preferences that are not part of the preferences + * window. If we added a generic editor (e.g. about:config in Mozilla) for + * such things, we could start using the Java Preferences API. But wow, that + * sounds like a lot of work. Not unlike writing this paragraph. + */ +public class Preferences { + // had to rename this file because people were editing it + static final String DEFAULTS_FILE = "defaults.txt"; //$NON-NLS-1$ + static final String PREFS_FILE = "preferences.txt"; //$NON-NLS-1$ + + static HashMap defaults; + static HashMap table = new HashMap(); + static File preferencesFile; + + static final String PROMPT_YES = Language.text("prompt.yes"); + static final String PROMPT_NO = Language.text("prompt.no"); + static final String PROMPT_CANCEL = Language.text("prompt.cancel"); + static final String PROMPT_OK = Language.text("prompt.ok"); + static final String PROMPT_BROWSE = Language.text("prompt.browse"); + + /** + * Standardized width for buttons. Mac OS X 10.3 wants 70 as its default, + * Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper. + */ + static public int BUTTON_WIDTH = + Integer.valueOf(Language.text("preferences.button.width")); + + /** height of the EditorHeader, EditorToolbar, and EditorStatus */ + static final int GRID_SIZE = 32; + + // Indents and spacing standards. These probably need to be modified + // per platform as well, because Mac OS X is so huge, Windows is smaller, + // and Linux is all over the map. Consider these deprecated. + + static final int GUI_BIG = 13; + static final int GUI_BETWEEN = 8; + static final int GUI_SMALL = 6; + + + static public void init() { + // start by loading the defaults, in case something + // important was deleted from the user prefs + try { + // Name changed for 2.1b2 to avoid problems with users modifying or + // replacing the file after doing a search for "preferences.txt". + load(Base.getLibStream(DEFAULTS_FILE)); + } catch (Exception e) { + Base.showError(null, "Could not read default settings.\n" + + "You'll need to reinstall Processing.", e); + } + + // check for platform-specific properties in the defaults + String platformExt = "." + PConstants.platformNames[PApplet.platform]; //$NON-NLS-1$ + int platformExtLength = platformExt.length(); + + // Get a list of keys that are specific to this platform + ArrayList platformKeys = new ArrayList(); + for (String key : table.keySet()) { + if (key.endsWith(platformExt)) { + platformKeys.add(key); + } + } + + // Use those platform-specific keys to override + for (String key : platformKeys) { + // this is a key specific to a particular platform + String actualKey = key.substring(0, key.length() - platformExtLength); + String value = get(key); + set(actualKey, value); + } + + // clone the hash table + defaults = (HashMap) table.clone(); + + // other things that have to be set explicitly for the defaults + setColor("run.window.bgcolor", SystemColor.control); //$NON-NLS-1$ + + // next load user preferences file + preferencesFile = Base.getSettingsFile(PREFS_FILE); + if (preferencesFile.exists()) { + try { + load(new FileInputStream(preferencesFile)); + + } catch (Exception ex) { + Base.showError("Error reading preferences", + "Error reading the preferences file. " + + "Please delete (or move)\n" + + preferencesFile.getAbsolutePath() + + " and restart Processing.", ex); + } + } + + if (checkSketchbookPref() || !preferencesFile.exists()) { + // create a new preferences file if none exists + // saves the defaults out to the file + save(); + } + + PApplet.useNativeSelect = + Preferences.getBoolean("chooser.files.native"); //$NON-NLS-1$ + + // Set http proxy for folks that require it. + // http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html + String proxyHost = get("proxy.host"); + String proxyPort = get("proxy.port"); + if (proxyHost != null && proxyHost.trim().length() != 0 && + proxyPort != null && proxyPort.trim().length() != 0) { + System.setProperty("http.proxyHost", proxyHost); + System.setProperty("http.proxyPort", proxyPort); + } + } + + + // ................................................................. + + + static public void load(InputStream input) throws IOException { + String[] lines = PApplet.loadStrings(input); // Reads as UTF-8 + for (String line : lines) { + if ((line.length() == 0) || + (line.charAt(0) == '#')) continue; + + // this won't properly handle = signs being in the text + int equals = line.indexOf('='); + if (equals != -1) { + String key = line.substring(0, equals).trim(); + String value = line.substring(equals + 1).trim(); + table.put(key, value); + } + } + } + + + // ................................................................. + + + static protected void save() { +// try { + // on startup, don't worry about it + // this is trying to update the prefs for who is open + // before Preferences.init() has been called. + if (preferencesFile == null) return; + + // Fix for 0163 to properly use Unicode when writing preferences.txt + PrintWriter writer = PApplet.createWriter(preferencesFile); + +// Enumeration e = table.keys(); //properties.propertyNames(); +// while (e.hasMoreElements()) { +// String key = (String) e.nextElement(); +// writer.println(key + "=" + ((String) table.get(key))); +// } + String[] keyList = table.keySet().toArray(new String[table.size()]); + keyList = PApplet.sort(keyList); + for (String key : keyList) { + writer.println(key + "=" + table.get(key)); //$NON-NLS-1$ + } + + writer.flush(); + writer.close(); + +// } catch (Exception ex) { +// Base.showWarning(null, "Error while saving the settings file", ex); +// } + } + + + // ................................................................. + + + // all the information from preferences.txt + + static public String get(String attribute /*, String defaultValue */) { + return table.get(attribute); + } + + + static public String getDefault(String attribute) { + return defaults.get(attribute); + } + + + static public void set(String attribute, String value) { + table.put(attribute, value); + } + + + static public void unset(String attribute) { + table.remove(attribute); + } + + + static public boolean getBoolean(String attribute) { + String value = get(attribute); //, null); + return (new Boolean(value)).booleanValue(); + + /* + supposedly not needed, because anything besides 'true' + (ignoring case) will just be false.. so if malformed -> false + if (value == null) return defaultValue; + + try { + return (new Boolean(value)).booleanValue(); + } catch (NumberFormatException e) { + System.err.println("expecting an integer: " + attribute + " = " + value); + } + return defaultValue; + */ + } + + + static public void setBoolean(String attribute, boolean value) { + set(attribute, value ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + + static public int getInteger(String attribute /*, int defaultValue*/) { + return Integer.parseInt(get(attribute)); + + /* + String value = get(attribute, null); + if (value == null) return defaultValue; + + try { + return Integer.parseInt(value); + } catch (NumberFormatException e) { + // ignored will just fall through to returning the default + System.err.println("expecting an integer: " + attribute + " = " + value); + } + return defaultValue; + //if (value == null) return defaultValue; + //return (value == null) ? defaultValue : + //Integer.parseInt(value); + */ + } + + + static public void setInteger(String key, int value) { + set(key, String.valueOf(value)); + } + + + static public Color getColor(String name) { + Color parsed = Color.GRAY; // set a default + String s = get(name); + if ((s != null) && (s.indexOf("#") == 0)) { //$NON-NLS-1$ + try { + parsed = new Color(Integer.parseInt(s.substring(1), 16)); + } catch (Exception e) { } + } + return parsed; + } + + + static public void setColor(String attr, Color what) { + set(attr, "#" + PApplet.hex(what.getRGB() & 0xffffff, 6)); //$NON-NLS-1$ + } + + + // Identical version found in Settings.java + static public Font getFont(String attr) { + try { + boolean replace = false; + String value = get(attr); + if (value == null) { + // use the default font instead + value = getDefault(attr); + replace = true; + } + + String[] pieces = PApplet.split(value, ','); + + if (pieces.length != 3) { + value = getDefault(attr); + pieces = PApplet.split(value, ','); + replace = true; + } + + String name = pieces[0]; + int style = Font.PLAIN; // equals zero + if (pieces[1].indexOf("bold") != -1) { //$NON-NLS-1$ + style |= Font.BOLD; + } + if (pieces[1].indexOf("italic") != -1) { //$NON-NLS-1$ + style |= Font.ITALIC; + } + int size = PApplet.parseInt(pieces[2], 12); + + // replace bad font with the default from lib/preferences.txt + if (replace) { + set(attr, value); + } + + if (!name.startsWith("processing.")) { + return new Font(name, style, size); + + } else { + if (pieces[0].equals("processing.sans")) { + return Toolkit.getSansFont(size, style); + } else if (pieces[0].equals("processing.mono")) { + return Toolkit.getMonoFont(size, style); + } + } + + } catch (Exception e) { + // Adding try/catch block because this may be where + // a lot of startup crashes are happening. + Base.log("Error with font " + get(attr) + " for attribute " + attr); + } + return new Font("Dialog", Font.PLAIN, 12); + } + + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + + /** + * Check for a 3.0 sketchbook location, and if none exists, + * try to grab it from the 2.0 sketchbook location. + * @return true if a location was found and the pref didn't exist + */ + static protected boolean checkSketchbookPref() { + // If a 3.0 sketchbook location has never been inited + if (getSketchbookPath() == null) { + String twoPath = get("sketchbook.path"); + // If they've run the 2.0 version, start with that location + if (twoPath != null) { + setSketchbookPath(twoPath); + return true; // save the sketchbook right away + } + // Otherwise it'll be null, and reset properly by Base + } + return false; + } + + + static protected String getSketchbookPath() { + return get("sketchbook.path.three"); //$NON-NLS-1$ + } + + + static protected void setSketchbookPath(String path) { + set("sketchbook.path.three", path); //$NON-NLS-1$ + } +} \ No newline at end of file diff --git a/app/src/processing/app/PreferencesFrame.java b/app/src/processing/app/PreferencesFrame.java index 1a79bb0ce..249ab5a0e 100644 --- a/app/src/processing/app/PreferencesFrame.java +++ b/app/src/processing/app/PreferencesFrame.java @@ -3,7 +3,8 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2004-14 Ben Fry and Casey Reas + Copyright (c) 2012-14 The Processing Foundation + Copyright (c) 2004-12 Ben Fry and Casey Reas Copyright (c) 2001-04 Massachusetts Institute of Technology This program is free software; you can redistribute it and/or modify @@ -37,81 +38,19 @@ import processing.core.*; /** - * Storage class for user preferences and environment settings. + * Window for modifying preferences. *

- * This class no longer uses the Properties class, since - * properties files are iso8859-1, which is highly likely to - * be a problem when trying to save sketch folders and locations. - *

- * The GUI portion in here is really ugly, as it uses exact layout. This was - * done in frustration one evening (and pre-Swing), but that's long since past, - * and it should all be moved to a proper swing layout like BoxLayout. - *

- * This is very poorly put together, that the preferences panel and the actual - * preferences i/o is part of the same code. But there hasn't yet been a - * compelling reason to bother with the separation aside from concern about - * being lectured by strangers who feel that it doesn't look like what they - * learned in CS class. - *

- * We don't use the Java Preferences API because it would entail writing to - * the registry (on Windows), or an obscure file location (on Mac OS X) and - * make it far more difficult (impossible) to remove the preferences.txt to - * reset them (when they become corrupt), or to find the the file to make - * edits for numerous obscure preferences that are not part of the preferences - * window. If we added a generic editor (e.g. about:config in Mozilla) for - * such things, we could start using the Java Preferences API. But wow, that - * sounds like a lot of work. Not unlike writing this paragraph. + * This is ugly GUI code that uses exact layout. This was done in frustration + * one evening (and pre-Swing), but that's long since past, and the code + * should instead be ported to a proper Swing layout like Group or BoxLayout. + * See here. */ -public class Preferences { - - static final Integer[] FONT_SIZES = { 10, 12, 14, 18, 24, 36, 48 }; - // what to call the feller - - // had to rename this file because people were editing it - static final String DEFAULTS_FILE = "defaults.txt"; //$NON-NLS-1$ - static final String PREFS_FILE = "preferences.txt"; //$NON-NLS-1$ - - - // prompt text stuff - - static final String PROMPT_YES = Language.text("prompt.yes"); - static final String PROMPT_NO = Language.text("prompt.no"); - static final String PROMPT_CANCEL = Language.text("prompt.cancel"); - static final String PROMPT_OK = Language.text("prompt.ok"); - static final String PROMPT_BROWSE = Language.text("prompt.browse"); - - /** - * Standardized width for buttons. Mac OS X 10.3 wants 70 as its default, - * Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper. - */ - static public int BUTTON_WIDTH = Integer.valueOf(Language.text("preferences.button.width")); - - /** - * Standardized button height. Mac OS X 10.3 (Java 1.4) wants 29, - * presumably because it now includes the blue border, where it didn't - * in Java 1.3. Windows XP only wants 23 (not sure what default Linux - * would be). Because of the disparity, on Mac OS X, it will be set - * inside a static block. - */ - static public int BUTTON_HEIGHT = 24; - - /** height of the EditorHeader, EditorToolbar, and EditorStatus */ - static final int GRID_SIZE = 32; - //static final int GRID_SIZE = 33; - - // indents and spacing standards. these probably need to be modified - // per platform as well, since macosx is so huge, windows is smaller, - // and linux is all over the map - - static final int GUI_BIG = 13; - static final int GUI_BETWEEN = 8; - static final int GUI_SMALL = 6; - - // gui elements - +public class PreferencesFrame { JFrame dialog; int wide, high; + static final Integer[] FONT_SIZES = { 10, 12, 14, 18, 24, 36, 48 }; + JTextField sketchbookLocationField; JTextField presentColor; JTextField presentColorHex; @@ -146,90 +85,7 @@ public class Preferences { Base base; - // data model - - static HashMap defaults; - static HashMap table = new HashMap(); - static File preferencesFile; - - -// static public void init(String commandLinePrefs) { - static public void init() { - // start by loading the defaults, in case something - // important was deleted from the user prefs - try { - // Name changed for 2.1b2 to avoid problems with users modifying or - // replacing the file after doing a search for "preferences.txt". - load(Base.getLibStream(DEFAULTS_FILE)); - } catch (Exception e) { - Base.showError(null, "Could not read default settings.\n" + - "You'll need to reinstall Processing.", e); - } - - // check for platform-specific properties in the defaults - String platformExt = "." + PConstants.platformNames[PApplet.platform]; //$NON-NLS-1$ - int platformExtLength = platformExt.length(); - - // Get a list of keys that are specific to this platform - ArrayList platformKeys = new ArrayList(); - for (String key : table.keySet()) { - if (key.endsWith(platformExt)) { - platformKeys.add(key); - } - } - - // Use those platform-specific keys to override - for (String key : platformKeys) { - // this is a key specific to a particular platform - String actualKey = key.substring(0, key.length() - platformExtLength); - String value = get(key); - set(actualKey, value); - } - - // clone the hash table - defaults = (HashMap) table.clone(); - - // other things that have to be set explicitly for the defaults - setColor("run.window.bgcolor", SystemColor.control); //$NON-NLS-1$ - - // next load user preferences file - preferencesFile = Base.getSettingsFile(PREFS_FILE); - if (preferencesFile.exists()) { - try { - load(new FileInputStream(preferencesFile)); - - } catch (Exception ex) { - Base.showError("Error reading preferences", - "Error reading the preferences file. " + - "Please delete (or move)\n" + - preferencesFile.getAbsolutePath() + - " and restart Processing.", ex); - } - } - - if (checkSketchbookPref() || !preferencesFile.exists()) { - // create a new preferences file if none exists - // saves the defaults out to the file - save(); - } - - PApplet.useNativeSelect = - Preferences.getBoolean("chooser.files.native"); //$NON-NLS-1$ - - // Set http proxy for folks that require it. - // http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html - String proxyHost = get("proxy.host"); - String proxyPort = get("proxy.port"); - if (proxyHost != null && proxyHost.trim().length() != 0 && - proxyPort != null && proxyPort.trim().length() != 0) { - System.setProperty("http.proxyHost", proxyHost); - System.setProperty("http.proxyPort", proxyPort); - } - } - - - // setup dialog for the prefs - public Preferences(Base base) { + public PreferencesFrame(Base base) { this.base = base; //dialog = new JDialog(editor, "Preferences", true); dialog = new JFrame(Language.text("preferences")); @@ -238,6 +94,11 @@ public class Preferences { Container pain = dialog.getContentPane(); pain.setLayout(null); + final int GUI_BETWEEN = Preferences.GUI_BETWEEN; + final int GUI_BIG = Preferences.GUI_BIG; + final int GUI_SMALL = Preferences.GUI_SMALL; + final int BUTTON_WIDTH = Preferences.BUTTON_WIDTH; + int top = GUI_BIG; int left = GUI_BIG; int right = 0; @@ -262,13 +123,13 @@ public class Preferences { pain.add(sketchbookLocationField); d = sketchbookLocationField.getPreferredSize(); - button = new JButton(PROMPT_BROWSE); + button = new JButton(Preferences.PROMPT_BROWSE); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { File dflt = new File(sketchbookLocationField.getText()); PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"), "sketchbookCallback", dflt, - Preferences.this, dialog); + PreferencesFrame.this, dialog); } }); pain.add(button); @@ -655,7 +516,7 @@ public class Preferences { right = Math.max(right, left + d.width); top += d.height; // + GUI_SMALL; - label = new JLabel(preferencesFile.getAbsolutePath()); + label = new JLabel(Preferences.getSketchbookPath()); final JLabel clickable = label; label.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { @@ -687,7 +548,7 @@ public class Preferences { // [ OK ] [ Cancel ] maybe these should be next to the message? - button = new JButton(PROMPT_OK); + button = new JButton(Preferences.PROMPT_OK); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { applyFrame(); @@ -696,13 +557,13 @@ public class Preferences { }); pain.add(button); d2 = button.getPreferredSize(); - BUTTON_HEIGHT = d2.height; + int BUTTON_HEIGHT = d2.height; h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH); button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT); h += BUTTON_WIDTH + GUI_SMALL; - button = new JButton(PROMPT_CANCEL); + button = new JButton(Preferences.PROMPT_CANCEL); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { disposeFrame(); @@ -789,28 +650,28 @@ public class Preferences { * then send a message to the editor saying that it's time to do the same. */ protected void applyFrame() { - setBoolean("editor.smooth", //$NON-NLS-1$ - editorAntialiasBox.isSelected()); + Preferences.setBoolean("editor.smooth", //$NON-NLS-1$ + editorAntialiasBox.isSelected()); - setBoolean("export.delete_target_folder", //$NON-NLS-1$ - deletePreviousBox.isSelected()); + Preferences.setBoolean("export.delete_target_folder", //$NON-NLS-1$ + deletePreviousBox.isSelected()); boolean wine = whinyBox.isSelected(); - setBoolean("header.hide.image", wine); //$NON-NLS-1$ - setBoolean("buttons.hide.image", wine); //$NON-NLS-1$ + Preferences.setBoolean("header.hide.image", wine); //$NON-NLS-1$ + Preferences.setBoolean("buttons.hide.image", wine); //$NON-NLS-1$ // Could iterate through editors here and repaint them all, but probably // requires a doLayout() call, and that may have different effects on // each platform, and nobody wants to debug/support that. // if the sketchbook path has changed, rebuild the menus - String oldPath = getSketchbookPath(); + String oldPath = Preferences.getSketchbookPath(); String newPath = sketchbookLocationField.getText(); if (!newPath.equals(oldPath)) { base.setSketchbookFolder(new File(newPath)); } // setBoolean("editor.external", externalEditorBox.isSelected()); - setBoolean("update.check", checkUpdatesBox.isSelected()); //$NON-NLS-1$ + Preferences.setBoolean("update.check", checkUpdatesBox.isSelected()); //$NON-NLS-1$ // Save Language Map languages = Language.getLanguages(); @@ -825,7 +686,7 @@ public class Preferences { Language.saveLanguage(language); } - int oldDisplayIndex = getInteger("run.display"); //$NON-NLS-1$ + int oldDisplayIndex = Preferences.getInteger("run.display"); //$NON-NLS-1$ int displayIndex = 0; for (int d = 0; d < displaySelectionBox.getItemCount(); d++) { if (displaySelectionBox.getSelectedIndex() == d) { @@ -833,20 +694,20 @@ public class Preferences { } } if (oldDisplayIndex != displayIndex) { - setInteger("run.display", displayIndex); //$NON-NLS-1$ + Preferences.setInteger("run.display", displayIndex); //$NON-NLS-1$ for (Editor editor : base.getEditors()) { editor.setSketchLocation(null); } } - setBoolean("run.options.memory", memoryOverrideBox.isSelected()); //$NON-NLS-1$ + Preferences.setBoolean("run.options.memory", memoryOverrideBox.isSelected()); //$NON-NLS-1$ int memoryMin = Preferences.getInteger("run.options.memory.initial"); //$NON-NLS-1$ int memoryMax = Preferences.getInteger("run.options.memory.maximum"); //$NON-NLS-1$ try { memoryMax = Integer.parseInt(memoryField.getText().trim()); // make sure memory setting isn't too small if (memoryMax < memoryMin) memoryMax = memoryMin; - setInteger("run.options.memory.maximum", memoryMax); //$NON-NLS-1$ + Preferences.setInteger("run.options.memory.maximum", memoryMax); //$NON-NLS-1$ } catch (NumberFormatException e) { System.err.println("Ignoring bad memory setting"); } @@ -854,7 +715,7 @@ public class Preferences { // Don't change anything if the user closes the window before fonts load if (fontSelectionBox.isEnabled()) { String fontFamily = (String) fontSelectionBox.getSelectedItem(); - set("editor.font.family", fontFamily); + Preferences.set("editor.font.family", fontFamily); } try { @@ -863,11 +724,11 @@ public class Preferences { // Replace with Integer version selection = Integer.parseInt((String) selection); } - set("editor.font.size", String.valueOf(selection)); + Preferences.set("editor.font.size", String.valueOf(selection)); } catch (NumberFormatException e) { Base.log("Ignoring invalid font size " + fontSizeField); //$NON-NLS-1$ - fontSizeField.setSelectedItem(getInteger("editor.font.size")); + fontSizeField.setSelectedItem(Preferences.getInteger("editor.font.size")); } try { @@ -876,51 +737,50 @@ public class Preferences { // Replace with Integer version selection = Integer.parseInt((String) selection); } - set("console.font.size", String.valueOf(selection)); + Preferences.set("console.font.size", String.valueOf(selection)); } catch (NumberFormatException e) { Base.log("Ignoring invalid font size " + consoleSizeField); //$NON-NLS-1$ - consoleSizeField.setSelectedItem(getInteger("console.font.size")); + consoleSizeField.setSelectedItem(Preferences.getInteger("console.font.size")); } - setColor("run.present.bgcolor", presentColor.getBackground()); + Preferences.setColor("run.present.bgcolor", presentColor.getBackground()); - setBoolean("editor.input_method_support", inputMethodBox.isSelected()); //$NON-NLS-1$ + Preferences.setBoolean("editor.input_method_support", inputMethodBox.isSelected()); //$NON-NLS-1$ if (autoAssociateBox != null) { - setBoolean("platform.auto_file_type_associations", //$NON-NLS-1$ - autoAssociateBox.isSelected()); + Preferences.setBoolean("platform.auto_file_type_associations", //$NON-NLS-1$ + autoAssociateBox.isSelected()); } - setBoolean("pdex.errorCheckEnabled", errorCheckerBox.isSelected()); - setBoolean("pdex.warningsEnabled", warningsCheckerBox.isSelected()); - setBoolean("pdex.ccEnabled", codeCompletionBox.isSelected()); - setBoolean("pdex.ccTriggerEnabled", codeCompletionTriggerBox.isSelected()); + Preferences.setBoolean("pdex.errorCheckEnabled", errorCheckerBox.isSelected()); + Preferences.setBoolean("pdex.warningsEnabled", warningsCheckerBox.isSelected()); + Preferences.setBoolean("pdex.ccEnabled", codeCompletionBox.isSelected()); + Preferences.setBoolean("pdex.ccTriggerEnabled", codeCompletionTriggerBox.isSelected()); for (Editor editor : base.getEditors()) { editor.applyPreferences(); } - } protected void showFrame() { - editorAntialiasBox.setSelected(getBoolean("editor.smooth")); //$NON-NLS-1$ - inputMethodBox.setSelected(getBoolean("editor.input_method_support")); //$NON-NLS-1$ - errorCheckerBox.setSelected(getBoolean("pdex.errorCheckEnabled")); - warningsCheckerBox.setSelected(getBoolean("pdex.warningsEnabled")); - codeCompletionBox.setSelected(getBoolean("pdex.ccEnabled")); - codeCompletionTriggerBox.setSelected(getBoolean("pdex.ccTriggerEnabled")); + editorAntialiasBox.setSelected(Preferences.getBoolean("editor.smooth")); //$NON-NLS-1$ + inputMethodBox.setSelected(Preferences.getBoolean("editor.input_method_support")); //$NON-NLS-1$ + errorCheckerBox.setSelected(Preferences.getBoolean("pdex.errorCheckEnabled")); + warningsCheckerBox.setSelected(Preferences.getBoolean("pdex.warningsEnabled")); + codeCompletionBox.setSelected(Preferences.getBoolean("pdex.ccEnabled")); + codeCompletionTriggerBox.setSelected(Preferences.getBoolean("pdex.ccTriggerEnabled")); deletePreviousBox. - setSelected(getBoolean("export.delete_target_folder")); //$NON-NLS-1$ + setSelected(Preferences.getBoolean("export.delete_target_folder")); //$NON-NLS-1$ - sketchbookLocationField.setText(getSketchbookPath()); - checkUpdatesBox.setSelected(getBoolean("update.check")); //$NON-NLS-1$ + sketchbookLocationField.setText(Preferences.getSketchbookPath()); + checkUpdatesBox.setSelected(Preferences.getBoolean("update.check")); //$NON-NLS-1$ - whinyBox.setSelected(getBoolean("header.hide.image") || //$NON-NLS-1$ - getBoolean("buttons.hide.image")); //$NON-NLS-1$ + whinyBox.setSelected(Preferences.getBoolean("header.hide.image") || //$NON-NLS-1$ + Preferences.getBoolean("buttons.hide.image")); //$NON-NLS-1$ updateDisplayList(); - int displayNum = getInteger("run.display"); //$NON-NLS-1$ + int displayNum = Preferences.getInteger("run.display"); //$NON-NLS-1$ if (displayNum >= 0 && displayNum < displayCount) { displaySelectionBox.setSelectedIndex(displayNum); } @@ -932,21 +792,21 @@ public class Preferences { } }).start(); - fontSizeField.setSelectedItem(getInteger("editor.font.size")); - consoleSizeField.setSelectedItem(getInteger("console.font.size")); + fontSizeField.setSelectedItem(Preferences.getInteger("editor.font.size")); + consoleSizeField.setSelectedItem(Preferences.getInteger("console.font.size")); presentColor.setBackground(Preferences.getColor("run.present.bgcolor")); presentColorHex.setText(Preferences.get("run.present.bgcolor").substring(1)); memoryOverrideBox. - setSelected(getBoolean("run.options.memory")); //$NON-NLS-1$ + setSelected(Preferences.getBoolean("run.options.memory")); //$NON-NLS-1$ memoryField. - setText(get("run.options.memory.maximum")); //$NON-NLS-1$ + setText(Preferences.get("run.options.memory.maximum")); //$NON-NLS-1$ memoryField.setEnabled(memoryOverrideBox.isSelected()); if (autoAssociateBox != null) { autoAssociateBox. - setSelected(getBoolean("platform.auto_file_type_associations")); //$NON-NLS-1$ + setSelected(Preferences.getBoolean("platform.auto_file_type_associations")); //$NON-NLS-1$ } dialog.setVisible(true); @@ -974,7 +834,7 @@ public class Preferences { if (monoFontFamilies == null) { monoFontFamilies = Toolkit.getMonoFontFamilies(); fontSelectionBox.setModel(new DefaultComboBoxModel(monoFontFamilies)); - String family = get("editor.font.family"); + String family = Preferences.get("editor.font.family"); // Set a reasonable default, in case selecting the family fails fontSelectionBox.setSelectedItem("Monospaced"); @@ -997,236 +857,4 @@ public class Preferences { displaySelectionBox.setModel(new DefaultComboBoxModel(items)); // displaySelectionBox = new JComboBox(items); } - - - // ................................................................. - - - static public void load(InputStream input) throws IOException { - String[] lines = PApplet.loadStrings(input); // Reads as UTF-8 - for (String line : lines) { - if ((line.length() == 0) || - (line.charAt(0) == '#')) continue; - - // this won't properly handle = signs being in the text - int equals = line.indexOf('='); - if (equals != -1) { - String key = line.substring(0, equals).trim(); - String value = line.substring(equals + 1).trim(); - table.put(key, value); - } - } - } - - - // ................................................................. - - - static protected void save() { -// try { - // on startup, don't worry about it - // this is trying to update the prefs for who is open - // before Preferences.init() has been called. - if (preferencesFile == null) return; - - // Fix for 0163 to properly use Unicode when writing preferences.txt - PrintWriter writer = PApplet.createWriter(preferencesFile); - -// Enumeration e = table.keys(); //properties.propertyNames(); -// while (e.hasMoreElements()) { -// String key = (String) e.nextElement(); -// writer.println(key + "=" + ((String) table.get(key))); -// } - String[] keyList = table.keySet().toArray(new String[table.size()]); - keyList = PApplet.sort(keyList); - for (String key : keyList) { - writer.println(key + "=" + table.get(key)); //$NON-NLS-1$ - } - - writer.flush(); - writer.close(); - -// } catch (Exception ex) { -// Base.showWarning(null, "Error while saving the settings file", ex); -// } - } - - - // ................................................................. - - - // all the information from preferences.txt - - static public String get(String attribute /*, String defaultValue */) { - return table.get(attribute); - } - - - static public String getDefault(String attribute) { - return defaults.get(attribute); - } - - - static public void set(String attribute, String value) { - table.put(attribute, value); - } - - - static public void unset(String attribute) { - table.remove(attribute); - } - - - static public boolean getBoolean(String attribute) { - String value = get(attribute); //, null); - return (new Boolean(value)).booleanValue(); - - /* - supposedly not needed, because anything besides 'true' - (ignoring case) will just be false.. so if malformed -> false - if (value == null) return defaultValue; - - try { - return (new Boolean(value)).booleanValue(); - } catch (NumberFormatException e) { - System.err.println("expecting an integer: " + attribute + " = " + value); - } - return defaultValue; - */ - } - - - static public void setBoolean(String attribute, boolean value) { - set(attribute, value ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - - static public int getInteger(String attribute /*, int defaultValue*/) { - return Integer.parseInt(get(attribute)); - - /* - String value = get(attribute, null); - if (value == null) return defaultValue; - - try { - return Integer.parseInt(value); - } catch (NumberFormatException e) { - // ignored will just fall through to returning the default - System.err.println("expecting an integer: " + attribute + " = " + value); - } - return defaultValue; - //if (value == null) return defaultValue; - //return (value == null) ? defaultValue : - //Integer.parseInt(value); - */ - } - - - static public void setInteger(String key, int value) { - set(key, String.valueOf(value)); - } - - - static public Color getColor(String name) { - Color parsed = Color.GRAY; // set a default - String s = get(name); - if ((s != null) && (s.indexOf("#") == 0)) { //$NON-NLS-1$ - try { - parsed = new Color(Integer.parseInt(s.substring(1), 16)); - } catch (Exception e) { } - } - return parsed; - } - - - static public void setColor(String attr, Color what) { - set(attr, "#" + PApplet.hex(what.getRGB() & 0xffffff, 6)); //$NON-NLS-1$ - } - - - // Identical version found in Settings.java - static public Font getFont(String attr) { - try { - boolean replace = false; - String value = get(attr); - if (value == null) { - // use the default font instead - value = getDefault(attr); - replace = true; - } - - String[] pieces = PApplet.split(value, ','); - - if (pieces.length != 3) { - value = getDefault(attr); - pieces = PApplet.split(value, ','); - replace = true; - } - - String name = pieces[0]; - int style = Font.PLAIN; // equals zero - if (pieces[1].indexOf("bold") != -1) { //$NON-NLS-1$ - style |= Font.BOLD; - } - if (pieces[1].indexOf("italic") != -1) { //$NON-NLS-1$ - style |= Font.ITALIC; - } - int size = PApplet.parseInt(pieces[2], 12); - - // replace bad font with the default from lib/preferences.txt - if (replace) { - set(attr, value); - } - - if (!name.startsWith("processing.")) { - return new Font(name, style, size); - - } else { - if (pieces[0].equals("processing.sans")) { - return Toolkit.getSansFont(size, style); - } else if (pieces[0].equals("processing.mono")) { - return Toolkit.getMonoFont(size, style); - } - } - - } catch (Exception e) { - // Adding try/catch block because this may be where - // a lot of startup crashes are happening. - Base.log("Error with font " + get(attr) + " for attribute " + attr); - } - return new Font("Dialog", Font.PLAIN, 12); - } - - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - - /** - * Check for a 3.0 sketchbook location, and if none exists, - * try to grab it from the 2.0 sketchbook location. - * @return true if a location was found and the pref didn't exist - */ - static protected boolean checkSketchbookPref() { - // If a 3.0 sketchbook location has never been inited - if (getSketchbookPath() == null) { - String twoPath = get("sketchbook.path"); - // If they've run the 2.0 version, start with that location - if (twoPath != null) { - setSketchbookPath(twoPath); - return true; // save the sketchbook right away - } - // Otherwise it'll be null, and reset properly by Base - } - return false; - } - - - static protected String getSketchbookPath() { - return get("sketchbook.path.three"); //$NON-NLS-1$ - } - - - static protected void setSketchbookPath(String path) { - set("sketchbook.path.three", path); //$NON-NLS-1$ - } } diff --git a/todo.txt b/todo.txt index 6f7d15d4f..09944714a 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,11 @@ 0230 pde (3.0a3) X remove toolbar buttons except for start/stop X rename sketchbook tree name, re-order menu, add language hooks +X split Preferences and PreferencesFrame +X https://github.com/processing/processing/issues/68 +X http://code.google.com/p/processing/issues/detail?id=29 +X https://github.com/processing/processing/pull/2716 + _ remove toolbar menu references and code to rebuild gsoc @@ -677,8 +682,6 @@ _ rewrite preferences window to use proper layout _ https://github.com/processing/processing/issues/67 _ https://github.com/processing/processing/issues/2708 _ make prefs dialog modal? -_ split Preferences and PreferencesFrame? -X http://code.google.com/p/processing/issues/detail?id=29 _ preferences window has been hit with the ugly stick _ redo panel to use proper Box layout etc _ also needs to look good across all platforms From 73f6cda824a0d7d0437510959978fc3c8ba0969c Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sat, 2 Aug 2014 20:06:44 -0300 Subject: [PATCH 068/134] Use correct collection in Library.list --- app/src/processing/app/Library.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/processing/app/Library.java b/app/src/processing/app/Library.java index 7b8adc556..0ec49106d 100644 --- a/app/src/processing/app/Library.java +++ b/app/src/processing/app/Library.java @@ -498,7 +498,7 @@ public class Library extends LocalContribution { for (String subfolderName : list) { File subfolder = new File(folder, subfolderName); - if (!libraries.contains(subfolder)) { + if (!librariesFolders.contains(subfolder)) { ArrayList discoveredLibFolders = new ArrayList(); discover(subfolder, discoveredLibFolders); From 89994ba4bce8dcf08fea2d4b659a3836abd41955 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sat, 2 Aug 2014 20:48:26 -0300 Subject: [PATCH 069/134] Avoid expensive locking on every Language access --- app/src/processing/app/Language.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 836b0d211..a82f7b2e9 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -43,7 +43,7 @@ public class Language { static protected final File prefFile = Base.getSettingsFile(PREF_FILE); /** Single instance of this Language class */ - static private Language instance = null; + static private volatile Language instance; /** The system language */ private String language; @@ -149,9 +149,13 @@ public class Language { /** Singleton constructor */ - static public synchronized Language init() { + static public Language init() { if (instance == null) { - instance = new Language(); + synchronized(Language.class) { + if (instance == null) { + instance = new Language(); + } + } } return instance; } From 797fb8d264ea88a11d17b2daefb978da8fd4df95 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Sat, 2 Aug 2014 23:21:21 -0400 Subject: [PATCH 070/134] Intial Korean translation contributed by Jihyun Kim --- app/src/processing/app/Language.java | 1 + .../app/languages/PDE_ko.properties | 244 ++++++++++++++++++ .../processing/app/languages/languages.txt | 1 + 3 files changed, 246 insertions(+) create mode 100644 app/src/processing/app/languages/PDE_ko.properties diff --git a/app/src/processing/app/Language.java b/app/src/processing/app/Language.java index 836b0d211..4de451c53 100644 --- a/app/src/processing/app/Language.java +++ b/app/src/processing/app/Language.java @@ -94,6 +94,7 @@ public class Language { "es", // Spanish "fr", // French, Français "ja", // Japanese + "ko", // Korean "nl", // Dutch, Nederlands "pt", // Portuguese "tr" // Turkish diff --git a/app/src/processing/app/languages/PDE_ko.properties b/app/src/processing/app/languages/PDE_ko.properties new file mode 100644 index 000000000..0eff91dbb --- /dev/null +++ b/app/src/processing/app/languages/PDE_ko.properties @@ -0,0 +1,244 @@ + + +# --------------------------------------- +# KOREAN (ko) +# --------------------------------------- + + +# --------------------------------------- +# Menu + +# | File | Edit | Sketch | Library | Tools | Help | +# | File | +menu.file = 파일 +menu.file.new = 새 스케치 +menu.file.open = 열기... +menu.file.sketchbook = 스케치북 +menu.file.recent = 최근 스케치 +menu.file.examples = 예제... +menu.file.close = 닫기 +menu.file.save = 저장 +menu.file.save_as = 다른 이름으로 저장... +menu.file.export_application = 어플리케이션으로 저장... +menu.file.page_setup = 인쇄 설정 +menu.file.print = 인쇄 +menu.file.preferences = 환경 설정 +menu.file.quit = 종료 + +# | File | Edit | Sketch | Library | Tools | Help | +# | Edit | +menu.edit = 편집 +menu.edit.undo = 입력 취소 +menu.edit.redo = 다시 실행 +menu.edit.cut = 잘라내기 +menu.edit.copy = 복사하기 +menu.edit.copy_as_html = HTML 서식으로 복사 +menu.edit.paste = 붙이기 +menu.edit.select_all = 전체선택 +menu.edit.auto_format = 자동 정렬 +menu.edit.comment_uncomment = 주석 처리/해제 +menu.edit.increase_indent = 들여쓰기 +menu.edit.decrease_indent = 내어쓰기 +menu.edit.find = 찾기... +menu.edit.find_next = 다음 찾기 +menu.edit.find_previous = 이전 찾기 +menu.edit.use_selection_for_find = 선택영역으로 찾기 + +# | File | Edit | Sketch | Library | Tools | Help | +# | Sketch | +menu.sketch = 스케치 +menu.sketch.show_sketch_folder = 스케치 폴더 열기 +menu.sketch.add_file = 스케치 불러오기... + +# | File | Edit | Sketch | Library | Tools | Help | +# | Library | +menu.library = 내부 라이브러리... +menu.library.add_library = 라이브러리 추가하기... +menu.library.contributed = 외부 라이브러리 +menu.library.no_core_libraries = 내부 라이브러리 미제공 + +# | File | Edit | Sketch | Library | Tools | Help | +# | Tools | +menu.tools = 도구 +menu.tools.create_font = 폰트 생성... +menu.tools.color_selector = 색상 선택 +menu.tools.archive_sketch = .zip으로 압축하기 +menu.tools.fix_the_serial_lbrary = 시리얼 라이브러리 오류 수정 +menu.tools.install_processing_java = "processing-java" 설치 +menu.tools.add_tool = 추가도구 생성... + +# | File | Edit | Sketch | Library | Tools | Help | +# | Help | +menu.help = 도움말 +menu.help.about = Processing에 관하여 +menu.help.environment = 환경 +menu.help.reference = 레퍼런스 +menu.help.find_in_reference = 레퍼런스 찾기 +menu.help.online = 온라인 +menu.help.getting_started = 시작하기 +menu.help.getting_started.url = http://processing.org/learning/gettingstarted/ +menu.help.troubleshooting = 문제해결 +menu.help.troubleshooting.url = http://wiki.processing.org/w/Troubleshooting +menu.help.faq = f&q +menu.help.faq.url = http://wiki.processing.org/w/FAQ +menu.help.foundation = 프로세싱 재단 +menu.help.foundation.url = http://processing.org/foundation/ +menu.help.visit = Processing.org +menu.help.visit.url = http://processing.org/ + + +# --------------------------------------- +# Basics + +# Buttons +prompt.yes = Yes +prompt.no = No +prompt.cancel = Cancel +prompt.ok = OK +prompt.browse = Browse +prompt.export = Export + + +# --------------------------------------- +# Frames + +# Open (Frame) +open = Open a Processing sketch... + +# Save (Frame) +save = Save sketch folder as... +save.title = Do you want to save changes to this sketch
before closing? +save.hint = If you don't save, your changes will be lost. +save.btn.save = Save +save.btn.dont_save = Don't Save + +# Preferences (Frame) +preferences = Preferences +preferences.button.width = 80 +preferences.requires_restart = requires restart of Processing +preferences.sketchbook_location = Sketchbook location +preferences.sketchbook_location.popup = Sketchbook location +preferences.language = Language +preferences.editor_and_console_font = Editor and Console font +preferences.editor_font_size = Editor font size +preferences.console_font_size = Console font size +preferences.background_color = Background color when Presenting +preferences.use_smooth_text = Use smooth text in editor window +preferences.enable_complex_text_input = Enable complex text input +preferences.enable_complex_text_input_example = i.e. Japanese +preferences.continuously_check = Continuously check for errors +preferences.show_warnings = Show warnings +preferences.code_completion = Code completion +preferences.trigger_with = Trigger with +preferences.cmd_space = space +preferences.increase_max_memory = Increase maximum available memory to +preferences.delete_previous_folder_on_export = Delete previous folder on export +preferences.hide_toolbar_background_image = Hide tab/toolbar background image +preferences.check_for_updates_on_startup = Check for updates on startup +preferences.run_sketches_on_display = Run sketches on display +preferences.run_sketches_on_display.tip = \ +Sets the display where sketches are initially placed.
\ +As usual, if the sketch window is moved, it will re-open
\ +at the same location, however when running in present
\ +(full screen) mode, this display will always be used. +preferences.automatically_associate_pde_files = Automatically associate .pde files with Processing +preferences.launch_programs_in = Launch programs in +preferences.launch_programs_in.mode = mode +preferences.file = More preferences can be edited directly in the file +preferences.file.hint = edit only when Processing is not running + +# Sketchbook Location (Frame) +sketchbook_location = Select new sketchbook location + +# Export (Frame) +export = Export Options +export.platforms = Platforms +export.options = Options +export.options.fullscreen = Full Screen (Present mode) +export.options.show_stop_button = Show a Stop button +export.description.line1 = Export to Application creates double-clickable, +export.description.line2 = standalone applications for the selected platforms. + +# Find (Frame) +find = Find +find.find = Find: +find.replace_with = Replace with: +find.ignore_case = Ignore Case +find.all_tabs = All Tabs +find.wrap_around = Wrap Around +find.btn.replace_all = Replace All +find.btn.replace = Replace +find.btn.find_and_replace = Find & Replace +find.btn.previous = Previous +find.btn.find = Find + +# Find in reference (Frame) +find_in_reference = Find in Reference + +# Library Manager (Frame) +library.category = Category: +library.filter_your_search = Filter your search... + +# File (Frame) +file = Select an image or other data file to copy to your sketch + +# Create Font (Frame) +create_font = Create Font + +# Color Selector (Frame) +color_selector = Color Selector + +# Archive Sketch (Frame) +archive_sketch = Archive sketch as... + + +# --------------------------------------- +# Toolbar + +# [Run/Present] [Stop] [New] [Open] [Save] +toolbar.run = Run +toolbar.present = Present +toolbar.stop = Stop +toolbar.new = New +toolbar.open = Open +toolbar.save = Save +toolbar.export_application = Export Application +toolbar.add_mode = Add mode... + +# the windows accessible from the File menu +editor.window.sketchbook = Sketchbook +editor.window.examples = Examples + +# [Tab1] [Tab2] [v] +editor.header.new_tab = New Tab +editor.header.rename = Rename +editor.header.delete = Delete +editor.header.previous_tab = Previous Tab +editor.header.next_tab = Next Tab +editor.header.delete.warning.title = Yeah, no. +editor.header.delete.warning.text = You can't delete the last tab of the last open sketch. + +editor.status.autoformat.no_changes = No changes necessary for Auto Format. +editor.status.autoformat.finished = Auto Format finished. +editor.status.find_reference.select_word_first = First select a word to find in the reference. +editor.status.find_reference.not_available = No reference available for "%s". +editor.status.drag_and_drop.files_added.0 = No files were added to the sketch. +editor.status.drag_and_drop.files_added.1 = One file added to the sketch. +editor.status.drag_and_drop.files_added.n = %d files added to the sketch. +editor.status.saving = Saving... +editor.status.saving.done = Done saving. +editor.status.saving.canceled = Save canceled. +editor.status.printing = Printing... +editor.status.printing.done = Done printing. +editor.status.printing.error = Error while printing. +editor.status.printing.canceled = Printing canceled. + +# --------------------------------------- +# Contribution Panel +contributions.undo = Undo +contributions.remove = Remove +contributions.install = Install +contributions.progress.starting = Starting +contributions.progress.downloading = Downloading +contributions.download_error = An error occured while downloading the contribution. +contributions.unsupported_operating_system = Your operating system doesn't appear to be supported. You should visit the %s's library for more info. diff --git a/app/src/processing/app/languages/languages.txt b/app/src/processing/app/languages/languages.txt index 8620954e2..5cde8b5bb 100644 --- a/app/src/processing/app/languages/languages.txt +++ b/app/src/processing/app/languages/languages.txt @@ -11,5 +11,6 @@ el # Greek es # Spanish fr # French, Français, Langue française ja # Japanese +ko # Korean nl # Dutch, Nederlands pt # Portuguese From db45aa14c27b111a30b9af9c733c4c9474637b8c Mon Sep 17 00:00:00 2001 From: Darius Morawiec Date: Sun, 3 Aug 2014 12:33:16 +0200 Subject: [PATCH 071/134] removed arrow-symbols from translations --- app/src/processing/app/Editor.java | 8 ++++---- .../processing/app/languages/PDE.properties | 4 ++-- .../processing/app/languages/PDE_de.properties | 4 ++-- .../processing/app/languages/PDE_el.properties | 4 ++-- .../processing/app/languages/PDE_es.properties | 4 ++-- .../processing/app/languages/PDE_nl.properties | 18 +++++++++--------- .../processing/app/languages/PDE_pt.properties | 4 ++-- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 08cf27151..399ec9207 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -825,7 +825,7 @@ public abstract class Editor extends JFrame implements RunnerListener { }); menu.add(item); - item = Toolkit.newJMenuItem(Language.text("menu.edit.increase_indent"), ']'); + item = Toolkit.newJMenuItem("\u2192 "+Language.text("menu.edit.increase_indent"), ']'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(true); @@ -833,7 +833,7 @@ public abstract class Editor extends JFrame implements RunnerListener { }); menu.add(item); - item = Toolkit.newJMenuItem(Language.text("menu.edit.decrease_indent"), '['); + item = Toolkit.newJMenuItem("\u2190 "+Language.text("menu.edit.decrease_indent"), '['); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(false); @@ -2865,7 +2865,7 @@ public abstract class Editor extends JFrame implements RunnerListener { }); this.add(item); - item = new JMenuItem(Language.text("menu.edit.increase_indent")); + item = new JMenuItem("\u2192 "+Language.text("menu.edit.increase_indent")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(true); @@ -2873,7 +2873,7 @@ public abstract class Editor extends JFrame implements RunnerListener { }); this.add(item); - item = new JMenuItem(Language.text("menu.edit.decrease_indent")); + item = new JMenuItem("\u2190 "+Language.text("menu.edit.decrease_indent")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleIndentOutdent(false); diff --git a/app/src/processing/app/languages/PDE.properties b/app/src/processing/app/languages/PDE.properties index 94251d0f2..4bef561e4 100644 --- a/app/src/processing/app/languages/PDE.properties +++ b/app/src/processing/app/languages/PDE.properties @@ -37,8 +37,8 @@ menu.edit.paste = Paste menu.edit.select_all = Select All menu.edit.auto_format = Auto Format menu.edit.comment_uncomment = Comment/Uncomment -menu.edit.increase_indent = \u2192 Increase Indent -menu.edit.decrease_indent = \u2190 Decrease Indent +menu.edit.increase_indent = Increase Indent +menu.edit.decrease_indent = Decrease Indent menu.edit.find = Find... menu.edit.find_next = Find Next menu.edit.find_previous = Find Previous diff --git a/app/src/processing/app/languages/PDE_de.properties b/app/src/processing/app/languages/PDE_de.properties index ce5aeb197..2abe40452 100644 --- a/app/src/processing/app/languages/PDE_de.properties +++ b/app/src/processing/app/languages/PDE_de.properties @@ -37,8 +37,8 @@ menu.edit.paste = Einfügen menu.edit.select_all = Alle auswählen menu.edit.auto_format = Autoformatierung menu.edit.comment_uncomment = Ein- und Auskommentieren -menu.edit.increase_indent = \u2192 Ausrücken -menu.edit.decrease_indent = \u2190 Einrücken +menu.edit.increase_indent = Ausrücken +menu.edit.decrease_indent = Einrücken menu.edit.find = Suchen ... menu.edit.find_next = Weiter suchen menu.edit.find_previous = Vorher suchen diff --git a/app/src/processing/app/languages/PDE_el.properties b/app/src/processing/app/languages/PDE_el.properties index 5b1ba8b2b..336598193 100644 --- a/app/src/processing/app/languages/PDE_el.properties +++ b/app/src/processing/app/languages/PDE_el.properties @@ -37,8 +37,8 @@ menu.edit.paste = Επικόλληση menu.edit.select_all = Επιλογή όλων menu.edit.auto_format = Αυτόματη διαμόρφωση menu.edit.comment_uncomment = Σχολιασμός/Αποσχολιασμός -menu.edit.increase_indent = \u2192 Αύξηση εσοχής -menu.edit.decrease_indent = \u2190 Μείωση εσοχής +menu.edit.increase_indent = Αύξηση εσοχής +menu.edit.decrease_indent = Μείωση εσοχής menu.edit.find = Αναζήτηση... menu.edit.find_next = Αναζήτηση επόμενου menu.edit.find_previous = Αναζήτηση προηγούμενου diff --git a/app/src/processing/app/languages/PDE_es.properties b/app/src/processing/app/languages/PDE_es.properties index 10b87a8d0..5c67e125c 100644 --- a/app/src/processing/app/languages/PDE_es.properties +++ b/app/src/processing/app/languages/PDE_es.properties @@ -37,8 +37,8 @@ menu.edit.paste = Pegar menu.edit.select_all = Seleccionar todo menu.edit.auto_format = Autoformato menu.edit.comment_uncomment = Comentar/Descomentar -menu.edit.increase_indent = \u2192 Aumentar indentación -menu.edit.decrease_indent = \u2190 Reducir indentación +menu.edit.increase_indent = Aumentar indentación +menu.edit.decrease_indent = Reducir indentación menu.edit.find = Buscar... menu.edit.find_next = Buscar siguiente menu.edit.find_previous = Buscar anterior diff --git a/app/src/processing/app/languages/PDE_nl.properties b/app/src/processing/app/languages/PDE_nl.properties index aa32ff702..1f9adafef 100644 --- a/app/src/processing/app/languages/PDE_nl.properties +++ b/app/src/processing/app/languages/PDE_nl.properties @@ -1,4 +1,4 @@ - + # --------------------------------------- # Language: Dutch (Nederlands) (nl) @@ -31,14 +31,14 @@ menu.edit = Bewerken menu.edit.undo = Ongedaan Maken menu.edit.redo = Opnieuw Uitvoeren menu.edit.cut = Knippen -menu.edit.copy = Kopiëren -menu.edit.copy_as_html = Kopiëren als HTML +menu.edit.copy = Kopiren +menu.edit.copy_as_html = Kopiren als HTML menu.edit.paste = Plakken menu.edit.select_all = Alles Selecteren menu.edit.auto_format = Automatische Opmaak menu.edit.comment_uncomment = Commentaar Aan/Uit -menu.edit.increase_indent = \u2192 Inspringen Vergroten -menu.edit.decrease_indent = \u2190 Inspringen Verkleinen +menu.edit.increase_indent = Inspringen Vergroten +menu.edit.decrease_indent = Inspringen Verkleinen menu.edit.find = Zoeken... menu.edit.find_next = Volgende Zoeken menu.edit.find_previous = Vorige Zoeken @@ -63,7 +63,7 @@ menu.tools = Tools menu.tools.color_selector = Kleur Selecteren... menu.tools.create_font = Lettertype Maken... menu.tools.archive_sketch = Schets Archiveren -menu.tools.fix_the_serial_lbrary = Seriële Bibliotheek Herstellen +menu.tools.fix_the_serial_lbrary = Serile Bibliotheek Herstellen menu.tools.install_processing_java = Installeren "processing-java" menu.tools.add_tool = Tool Toevoegen... @@ -140,7 +140,7 @@ Stelt het beeld in waarop schetsen aanvankelijk te zien zijn.
\ Zoals gebruikelijk, als het venster wordt verplaatst, zal het heropenen
\ op die locatie. Wanneer echter gebruik wordt gemaakt van de Presenteer
\ modus (volledig scherm), zal altijd het gekozen beeld worden gebruikt. -preferences.automatically_associate_pde_files = Automatisch associëren .pde bestanden met Processing +preferences.automatically_associate_pde_files = Automatisch associren .pde bestanden met Processing preferences.launch_programs_in = Programma's starten in preferences.launch_programs_in.mode = modus preferences.file = Meer instellingen kunnen direct worden aangepast in het bestand @@ -155,7 +155,7 @@ export.platforms = Platforms export.options = Opties export.options.fullscreen = Volledig Scherm (Presenteer modus) export.options.show_stop_button = Tonen Stop knop -export.description.line1 = Exporteren naar Applicatie creëert dubbel-klikbare, +export.description.line1 = Exporteren naar Applicatie creert dubbel-klikbare, export.description.line2 = zelfstandige applicaties voor de geselecteerde platforms. # Find (Frame) @@ -179,7 +179,7 @@ library.category = Categorie: library.filter_your_search = Filter zoekresultaten... # File (Frame) -file = Selecteer een bestand om te kopiëren naar uw schets +file = Selecteer een bestand om te kopiren naar uw schets # Create Font (Frame) create_font = Lettertype Maken diff --git a/app/src/processing/app/languages/PDE_pt.properties b/app/src/processing/app/languages/PDE_pt.properties index b69607e26..c408559af 100644 --- a/app/src/processing/app/languages/PDE_pt.properties +++ b/app/src/processing/app/languages/PDE_pt.properties @@ -37,8 +37,8 @@ menu.edit.paste = Colar menu.edit.select_all = Seleccionar Tudo menu.edit.auto_format = Auto Formatar menu.edit.comment_uncomment = Comentar/Descomentar -menu.edit.increase_indent = \u2192 Aumentar Indentação -menu.edit.decrease_indent = \u2190 Diminuir Indentação +menu.edit.increase_indent = Aumentar Indentação +menu.edit.decrease_indent = Diminuir Indentação menu.edit.find = Procurar... menu.edit.find_next = Procurar Seguinte menu.edit.find_previous = Procurar Anterior From a6b6c3493035a0cd0561c86b681f13d85b6d1f77 Mon Sep 17 00:00:00 2001 From: Darius Morawiec Date: Sun, 3 Aug 2014 13:19:15 +0200 Subject: [PATCH 072/134] fixed encoding --- app/src/processing/app/languages/PDE_nl.properties | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/processing/app/languages/PDE_nl.properties b/app/src/processing/app/languages/PDE_nl.properties index 1f9adafef..8807017c8 100644 --- a/app/src/processing/app/languages/PDE_nl.properties +++ b/app/src/processing/app/languages/PDE_nl.properties @@ -31,8 +31,8 @@ menu.edit = Bewerken menu.edit.undo = Ongedaan Maken menu.edit.redo = Opnieuw Uitvoeren menu.edit.cut = Knippen -menu.edit.copy = Kopiren -menu.edit.copy_as_html = Kopiren als HTML +menu.edit.copy = Kopiëren +menu.edit.copy_as_html = Kopiëren als HTML menu.edit.paste = Plakken menu.edit.select_all = Alles Selecteren menu.edit.auto_format = Automatische Opmaak @@ -63,7 +63,7 @@ menu.tools = Tools menu.tools.color_selector = Kleur Selecteren... menu.tools.create_font = Lettertype Maken... menu.tools.archive_sketch = Schets Archiveren -menu.tools.fix_the_serial_lbrary = Serile Bibliotheek Herstellen +menu.tools.fix_the_serial_lbrary = Seriële Bibliotheek Herstellen menu.tools.install_processing_java = Installeren "processing-java" menu.tools.add_tool = Tool Toevoegen... @@ -140,7 +140,7 @@ Stelt het beeld in waarop schetsen aanvankelijk te zien zijn.
\ Zoals gebruikelijk, als het venster wordt verplaatst, zal het heropenen
\ op die locatie. Wanneer echter gebruik wordt gemaakt van de Presenteer
\ modus (volledig scherm), zal altijd het gekozen beeld worden gebruikt. -preferences.automatically_associate_pde_files = Automatisch associren .pde bestanden met Processing +preferences.automatically_associate_pde_files = Automatisch associëren .pde bestanden met Processing preferences.launch_programs_in = Programma's starten in preferences.launch_programs_in.mode = modus preferences.file = Meer instellingen kunnen direct worden aangepast in het bestand @@ -155,7 +155,7 @@ export.platforms = Platforms export.options = Opties export.options.fullscreen = Volledig Scherm (Presenteer modus) export.options.show_stop_button = Tonen Stop knop -export.description.line1 = Exporteren naar Applicatie creert dubbel-klikbare, +export.description.line1 = Exporteren naar Applicatie creëert dubbel-klikbare, export.description.line2 = zelfstandige applicaties voor de geselecteerde platforms. # Find (Frame) @@ -179,7 +179,7 @@ library.category = Categorie: library.filter_your_search = Filter zoekresultaten... # File (Frame) -file = Selecteer een bestand om te kopiren naar uw schets +file = Selecteer een bestand om te kopiëren naar uw schets # Create Font (Frame) create_font = Lettertype Maken @@ -211,4 +211,4 @@ editor.header.delete = Verwijderen editor.header.previous_tab = Vorige Tabblad editor.header.next_tab = Volgende Tabblad editor.header.delete.warning.title = Waarschuwing -editor.header.delete.warning.text = U kunt het laatste tabblad van de laatst geopende schets niet verwijderen. +editor.header.delete.warning.text = U kunt het laatste tabblad van de laatst geopende schets niet verwijderen. \ No newline at end of file From e68468147cfd262d2d60ecc9117d27937428c1eb Mon Sep 17 00:00:00 2001 From: Darius Morawiec Date: Sun, 3 Aug 2014 13:19:56 +0200 Subject: [PATCH 073/134] added sketchbook frame translation --- app/src/processing/app/Base.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index b2a5d9710..47423e72c 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1331,7 +1331,7 @@ public class Base { public JMenu getSketchbookMenu() { if (sketchbookMenu == null) { - sketchbookMenu = new JMenu("Sketchbook"); + sketchbookMenu = new JMenu(Language.text("editor.window.sketchbook")); rebuildSketchbookMenu(); } return sketchbookMenu; From cd0670d3f0f647b8fece17e30c16b1d4cb84367b Mon Sep 17 00:00:00 2001 From: Darius Morawiec Date: Sun, 3 Aug 2014 13:29:44 +0200 Subject: [PATCH 074/134] added sketchbook tree translation --- app/src/processing/app/Mode.java | 2 +- app/src/processing/app/languages/PDE.properties | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index 4256a8584..08d95afcf 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -890,7 +890,7 @@ public abstract class Mode { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . public DefaultMutableTreeNode buildSketchbookTree(){ - DefaultMutableTreeNode sbNode = new DefaultMutableTreeNode("Sketchbook"); + DefaultMutableTreeNode sbNode = new DefaultMutableTreeNode(Language.text("editor.window.sketchbook_tree")); try { base.addSketches(sbNode, Base.getSketchbookFolder()); } catch (IOException e) { diff --git a/app/src/processing/app/languages/PDE.properties b/app/src/processing/app/languages/PDE.properties index 4bef561e4..c00beec5e 100644 --- a/app/src/processing/app/languages/PDE.properties +++ b/app/src/processing/app/languages/PDE.properties @@ -207,6 +207,7 @@ toolbar.add_mode = Add mode... # the windows accessible from the File menu editor.window.sketchbook = Sketchbook +editor.window.sketchbook_tree = Sketchbook editor.window.examples = Examples # [Tab1] [Tab2] [v] From 8372abc8deee75565b57a3b644cd6b265f49ac59 Mon Sep 17 00:00:00 2001 From: Darius Morawiec Date: Sun, 3 Aug 2014 14:06:57 +0200 Subject: [PATCH 075/134] added tooltips translations --- app/src/processing/app/PreferencesFrame.java | 12 +++--------- app/src/processing/app/languages/PDE.properties | 8 ++++++++ app/src/processing/app/languages/PDE_de.properties | 8 ++++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/src/processing/app/PreferencesFrame.java b/app/src/processing/app/PreferencesFrame.java index 249ab5a0e..9ed03a78d 100644 --- a/app/src/processing/app/PreferencesFrame.java +++ b/app/src/processing/app/PreferencesFrame.java @@ -185,10 +185,7 @@ public class PreferencesFrame { Container fontBox = Box.createHorizontalBox(); JLabel fontLabel = new JLabel(Language.text("preferences.editor_and_console_font")+": "); - final String fontTip = "" + - "Select the font used in the Editor and the Console.
" + - "Only monospaced (fixed-width) fonts may be used,
" + - "though the list may be imperfect."; + final String fontTip = "" + Language.text("preferences.editor_and_console_font.tip"); fontLabel.setToolTipText(fontTip); fontBox.add(fontLabel); // get a wide name in there before getPreferredSize() is called @@ -236,11 +233,8 @@ public class PreferencesFrame { label = new JLabel(Language.text("preferences.background_color")+": "); colorBox.add(label); - - final String colorTip = "" - + "Select the background color used when using Present.
" - + "Present is used to present a sketch in full-screen,
" - + "accessible from the Sketch menu."; + + final String colorTip = "" + Language.text("preferences.background_color.tip"); label.setToolTipText(colorTip); presentColor = new JTextField(" "); diff --git a/app/src/processing/app/languages/PDE.properties b/app/src/processing/app/languages/PDE.properties index c00beec5e..ed8b464fb 100644 --- a/app/src/processing/app/languages/PDE.properties +++ b/app/src/processing/app/languages/PDE.properties @@ -120,9 +120,17 @@ preferences.sketchbook_location = Sketchbook location preferences.sketchbook_location.popup = Sketchbook location preferences.language = Language preferences.editor_and_console_font = Editor and Console font +preferences.editor_and_console_font.tip = \ +Select the font used in the Editor and the Console.
\ +Only monospaced (fixed-width) fonts may be used,
\ +though the list may be imperfect. preferences.editor_font_size = Editor font size preferences.console_font_size = Console font size preferences.background_color = Background color when Presenting +preferences.background_color.tip = \ +Select the background color used when using Present.
\ +Present is used to present a sketch in full-screen,
\ +accessible from the Sketch menu. preferences.use_smooth_text = Use smooth text in editor window preferences.enable_complex_text_input = Enable complex text input preferences.enable_complex_text_input_example = i.e. Japanese diff --git a/app/src/processing/app/languages/PDE_de.properties b/app/src/processing/app/languages/PDE_de.properties index 2abe40452..73f72e02a 100644 --- a/app/src/processing/app/languages/PDE_de.properties +++ b/app/src/processing/app/languages/PDE_de.properties @@ -114,9 +114,17 @@ preferences.requires_restart = nach Neustart von Processing aktiv preferences.sketchbook_location = Sketchbook Pfad preferences.language = Sprache preferences.editor_and_console_font = Editor und Konsolen Schriftart +preferences.editor_and_console_font.tip = \ +Wähle die Schrift für die Konsole und den Editor.
\ +Es sollte eine dicktengleiche (monospace) Schrift ausgewählt werden,
\ +da die Liste vorgeschlagener Schriftarten mangelhaft sein kann. preferences.editor_font_size = Editor Schriftgröße preferences.console_font_size = Konsolen Schriftgröße preferences.background_color = Hintergrundfarbe im Present Modus +preferences.background_color.tip = \ +Wähle die Hintergrundfarbe im Present Modus.
\ +Im Present Modus erhält ein Sketch eine vollflächige Hintergrundfarbe,
\ +welches man im Sketch Menü auswählen kann. preferences.use_smooth_text = Editor Textglättung preferences.enable_complex_text_input = Komplexe Sprachen erlauben preferences.enable_complex_text_input_example = z.B. Japanisch From 63afa4e810db154b9f1c07dcf0e081a2b5298b3c Mon Sep 17 00:00:00 2001 From: Darius Morawiec Date: Sun, 3 Aug 2014 15:42:44 +0200 Subject: [PATCH 076/134] added new file or tab handling translations --- app/src/processing/app/Sketch.java | 14 +++++++------- app/src/processing/app/languages/PDE.properties | 15 +++++++++++++++ .../processing/app/languages/PDE_de.properties | 17 ++++++++++++++++- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index d0a644c7c..e9af94bcb 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -290,7 +290,7 @@ public class Sketch { renamingCode = false; // editor.status.edit("Name for new file:", ""); - promptForTabName("Name for new file:", ""); + promptForTabName(Language.text("editor.tab.rename.description")+":", ""); } @@ -327,11 +327,11 @@ public class Sketch { // TODO maybe just popup a text area? renamingCode = true; String prompt = (currentIndex == 0) ? - "New name for sketch:" : "New name for file:"; + Language.text("editor.sketch.rename.description") : Language.text("editor.tab.rename.description"); String oldName = (current.isExtension(mode.getDefaultExtension())) ? current.getPrettyName() : current.getFileName(); // editor.status.edit(prompt, oldName); - promptForTabName(prompt, oldName); + promptForTabName(prompt+":", oldName); } /** @@ -405,7 +405,7 @@ public class Sketch { int userReply = JOptionPane.showOptionDialog(editor, new Object[] { prompt, field }, - "New Name", + Language.text("editor.tab.new"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[] { @@ -635,11 +635,11 @@ public class Sketch { // confirm deletion with user, yes/no Object[] options = { "OK", "Cancel" }; String prompt = (currentIndex == 0) ? - "Are you sure you want to delete this sketch?" : - "Are you sure you want to delete \"" + current.getPrettyName() + "\"?"; + Language.text("warn.delete.sketch") : + Language.interpolate("warn.delete.file", current.getPrettyName()); int result = JOptionPane.showOptionDialog(editor, prompt, - "Delete", + Language.text("warn.delete"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, diff --git a/app/src/processing/app/languages/PDE.properties b/app/src/processing/app/languages/PDE.properties index ed8b464fb..470208c2d 100644 --- a/app/src/processing/app/languages/PDE.properties +++ b/app/src/processing/app/languages/PDE.properties @@ -227,6 +227,15 @@ editor.header.next_tab = Next Tab editor.header.delete.warning.title = Yeah, no. editor.header.delete.warning.text = You can't delete the last tab of the last open sketch. +# Tab +editor.tab.new = New Name +editor.tab.new.description = Name for new file +editor.tab.rename = New Name +editor.tab.rename.description = New name for file + +# Sketch +editor.sketch.rename.description = New name for sketch + editor.status.autoformat.no_changes = No changes necessary for Auto Format. editor.status.autoformat.finished = Auto Format finished. editor.status.find_reference.select_word_first = First select a word to find in the reference. @@ -251,3 +260,9 @@ contributions.progress.starting = Starting contributions.progress.downloading = Downloading contributions.download_error = An error occured while downloading the contribution. contributions.unsupported_operating_system = Your operating system doesn't appear to be supported. You should visit the %s's library for more info. + +# --------------------------------------- +# Warnings +warn.delete = Delete +warn.delete.sketch = Are you sure you want to delete this sketch? +warn.delete.file = Are you sure you want to delete "%s"? \ No newline at end of file diff --git a/app/src/processing/app/languages/PDE_de.properties b/app/src/processing/app/languages/PDE_de.properties index 73f72e02a..f0df1ca42 100644 --- a/app/src/processing/app/languages/PDE_de.properties +++ b/app/src/processing/app/languages/PDE_de.properties @@ -209,4 +209,19 @@ editor.header.delete = Löschen editor.header.previous_tab = Nächster Tab editor.header.next_tab = Vorheriger Tab editor.header.delete.warning.title = Yeah, nein. -editor.header.delete.warning.text = Du kannst nicht den letzten Tab des letzten Sketches löschen. \ No newline at end of file +editor.header.delete.warning.text = Du kannst nicht den letzten Tab des letzten Sketches löschen. + +# Tab +editor.tab.new = Neuer Name +editor.tab.new.description = Name der neuen Datei +editor.tab.rename = Neuer Name +editor.tab.rename.description = Name der neuen Datei + +# Sketch +editor.sketch.rename.description = Name des neuen Sketches + +# --------------------------------------- +# Warnings +warn.delete = Löschen +warn.delete.sketch = Den Sketch endgültig löschen? +warn.delete.file = Die Datei "%s" entgültig löschen? \ No newline at end of file From c6774578b624dba7373864a5ef56da19f2cc02f7 Mon Sep 17 00:00:00 2001 From: Darius Morawiec Date: Sun, 3 Aug 2014 15:48:53 +0200 Subject: [PATCH 077/134] added basic prompt messages --- app/src/processing/app/Base.java | 2 +- app/src/processing/app/Editor.java | 2 +- app/src/processing/app/PreferencesFrame.java | 4 ++-- app/src/processing/app/Sketch.java | 4 ++-- app/src/processing/app/tools/CreateFont.java | 6 +++--- app/src/processing/mode/java/JavaEditor.java | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 47423e72c..f4e51f900 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1126,7 +1126,7 @@ public class Base { // If the central menubar isn't supported on this OS X JVM, // we have to do the old behavior. Yuck! if (defaultFileMenu == null) { - Object[] options = { "OK", "Cancel" }; + Object[] options = { Language.text("prompt.ok"), Language.text("prompt.cancel") }; String prompt = " " + "