diff --git a/app/build.xml b/app/build.xml
index 06cc52fd7..d1863147f 100644
--- a/app/build.xml
+++ b/app/build.xml
@@ -37,10 +37,9 @@
-->
- Jalopy. This is to replace
* the buggy code formatter found in previous releases.
*/
-public class AutoFormat {
+ public class AutoFormat {
Editor editor;
diff --git a/app/src/processing/app/tools/format/tool/jalopy.jar b/app/format/tool/jalopy.jar
similarity index 100%
rename from app/src/processing/app/tools/format/tool/jalopy.jar
rename to app/format/tool/jalopy.jar
diff --git a/app/src/processing/app/tools/format/tool/log4j.jar b/app/format/tool/log4j.jar
similarity index 100%
rename from app/src/processing/app/tools/format/tool/log4j.jar
rename to app/format/tool/log4j.jar
diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java
index 781a6e1ea..fe6f6673e 100644
--- a/app/src/processing/app/Base.java
+++ b/app/src/processing/app/Base.java
@@ -29,7 +29,6 @@ import java.util.*;
import java.util.List;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
import processing.app.debug.TargetPackage;
import processing.app.debug.TargetPlatform;
@@ -38,7 +37,7 @@ import processing.app.helpers.Maps;
import processing.app.helpers.PreferencesMap;
import processing.app.helpers.filefilters.OnlyDirs;
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
-import processing.app.tools.MapWithSubkeys;
+import processing.app.javax.swing.filechooser.FileNameExtensionFilter;import processing.app.tools.MapWithSubkeys;
import processing.app.tools.ZipDeflater;
import processing.core.*;
import static processing.app.I18n._;
@@ -88,10 +87,10 @@ public class Base {
static private File toolsFolder;
static private List librariesFolders;
-
+
// maps library name to their library folder
static private Map libraries;
-
+
// maps #included files to their library folder
static Map importToLibraryTable;
@@ -99,7 +98,7 @@ public class Base {
// (both those in the p5/libs folder and those with lib subfolders
// found in the sketchbook)
static public String librariesClassPath;
-
+
static public Map packages;
// Location for untitled items
@@ -273,7 +272,7 @@ public class Base {
defaultFolder.mkdirs();
}
}
-
+
packages = new HashMap();
loadHardware(getHardwareFolder());
loadHardware(getSketchbookHardwareFolder());
@@ -993,7 +992,7 @@ public class Base {
public void rebuildImportMenu(JMenu importMenu, final Editor editor) {
importMenu.removeAll();
-
+
JMenuItem addLibraryMenuItem = new JMenuItem(_("Add Library..."));
addLibraryMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -1040,7 +1039,7 @@ public class Base {
public void rebuildExamplesMenu(JMenu menu) {
try {
menu.removeAll();
-
+
// Add examples from distribution "example" folder
boolean found = addSketches(menu, examplesFolder, false);
if (found) menu.addSeparator();
@@ -1074,14 +1073,14 @@ public class Base {
e.printStackTrace();
}
}
-
+
public Map scanLibraries(List folders) {
- Map res = new HashMap();
+ Map res = new HashMap();
for (File folder : folders)
res.putAll(scanLibraries(folder));
return res;
}
-
+
public Map scanLibraries(File folder) {
Map res = new HashMap();
String list[] = folder.list(new OnlyDirs());
@@ -1101,7 +1100,7 @@ public class Base {
}
subfolder = scanFatLibrary(subfolder);
-
+
// (also replace previously found libs with the same name)
if (subfolder != null)
res.put(libName, subfolder);
@@ -1117,7 +1116,7 @@ public class Base {
*
* If a non-"FAT" library is detected, we assume that the library is suitable
* for the current architecture and the libFolder parameter is returned.
- *
+ *
* @param libFolder
* @return
*/
@@ -1134,18 +1133,18 @@ public class Base {
return null;
return archSubfolder;
}
-
+
public void onBoardOrPortChange() {
// Calculate paths for libraries and examples
examplesFolder = getContentFile("examples");
toolsFolder = getContentFile("tools");
-
+
File platformFolder = getTargetPlatform().getFolder();
librariesFolders = new ArrayList();
librariesFolders.add(getContentFile("libraries"));
librariesFolders.add(new File(platformFolder, "libraries"));
librariesFolders.add(getSketchbookLibrariesFolder());
-
+
// Scan for libraries in each library folder.
// Libraries located in the latest folders on the list can override
// other libraries with the same name.
@@ -1158,7 +1157,7 @@ public class Base {
for (String pkg : packages)
importToLibraryTable.put(pkg, subfolder);
}
-
+
// Update editors status bar
for (Editor editor : editors)
editor.onBoardOrPortChange();
@@ -1170,14 +1169,14 @@ public class Base {
String selPackage = Preferences.get("target_package");
String selPlatform = Preferences.get("target_platform");
String selBoard = Preferences.get("board");
-
+
boolean first = true;
-
+
List menuItemsToClickAfterStartup = new LinkedList();
ButtonGroup boardsButtonGroup = new ButtonGroup();
Map buttonGroupsMap = new HashMap();
-
+
// Cycle through all packages
for (TargetPackage targetPackage : packages.values()) {
String packageName = targetPackage.getName();
@@ -1189,17 +1188,17 @@ public class Base {
if (targetPlatform.getPreferences().get("name") == null || targetPlatform.getBoards().isEmpty()) {
continue;
}
-
+
// Add a title for each group of boards
if (!first) {
boardsMenu.add(new JSeparator());
}
first = false;
-
+
JMenuItem separator = new JMenuItem(_(targetPlatform.getPreferences().get("name")));
separator.setEnabled(false);
boardsMenu.add(separator);
-
+
// For every platform cycle through all boards
for (final String boardID : targetPlatform.getBoards().keySet()) {
// Setup a menu item for the current board
@@ -1211,7 +1210,7 @@ public class Base {
}
};
action.putValue("b", packageName + ":" + platformName + ":" + boardID);
-
+
JRadioButtonMenuItem item = new JRadioButtonMenuItem(action);
boardsMenu.add(item);
boardsButtonGroup.add(item);
@@ -1256,7 +1255,7 @@ public class Base {
if (!buttonGroupsMap.containsKey(customMenuID)) {
buttonGroupsMap.put(customMenuID, new ButtonGroup());
}
-
+
item = new JRadioButtonMenuItem(subAction);
menu.add(item);
buttonGroupsMap.get(customMenuID).add(item);
@@ -1322,7 +1321,7 @@ public class Base {
toolsMenu.add(menu);
return menu;
}
-
+
private static JMenuItem selectVisibleSelectedOrFirstMenuItem(JMenu menu) {
JMenuItem firstVisible = null;
for (int i = 0; i < menu.getItemCount(); i++) {
@@ -1336,14 +1335,14 @@ public class Base {
}
}
}
-
+
if (firstVisible != null) {
return firstVisible;
}
-
+
throw new IllegalStateException("Menu has no enabled items");
}
-
+
private static JMenuItem selectFirstEnabledMenuItem(JMenu menu) {
for (int i = 0; i < menu.getItemCount(); i++) {
JMenuItem item = menu.getItem(i);
@@ -1360,7 +1359,7 @@ public class Base {
Preferences.set("target_package", split[0]);
Preferences.set("target_platform", split[1]);
Preferences.set("board", split[2]);
-
+
filterVisibilityOfSubsequentBoardMenus(split[2], 1);
onBoardOrPortChange();
@@ -1426,7 +1425,7 @@ public class Base {
if (addSketchesSubmenu(menu, name, subfolder, replaceExisting))
ifound = true;
}
-
+
return ifound; // actually ignored, but..
}
@@ -1482,7 +1481,7 @@ public class Base {
item.setActionCommand(entry.getAbsolutePath());
menu.add(item);
return true;
- }
+ }
// don't create an extra menu level for a folder named "examples"
if (folder.getName().equals("examples"))
@@ -1500,7 +1499,7 @@ public class Base {
List list = new ArrayList(libs.keySet());
Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
-
+
ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
activeEditor.getSketch().importLibrary(e.getActionCommand());
@@ -1519,7 +1518,7 @@ public class Base {
// XXX: DAM: should recurse here so that library folders can be nested
}
}
-
+
/**
* Given a folder, return a list of the header files in that folder (but not
* the header files in its sub-folders, as those should be included from
@@ -1528,19 +1527,19 @@ public class Base {
static public String[] headerListFromIncludePath(File path) {
return path.list(new OnlyFilesWithExtension(".h"));
}
-
+
protected void loadHardware(File folder) {
if (!folder.isDirectory()) return;
-
+
String list[] = folder.list(new OnlyDirs());
-
+
// if a bad folder or something like that, this might come back null
if (list == null) return;
// alphabetize list, since it's not always alpha order
// replaced hella slow bubble sort with this feller for 0093
Arrays.sort(list, String.CASE_INSENSITIVE_ORDER);
-
+
for (String target : list) {
// Skip reserved 'tools' folder.
if (target.equals("tools"))
@@ -1809,17 +1808,17 @@ public class Base {
// before the other folders / paths get cached).
return getContentFile("hardware");
}
-
+
//Get the core libraries
static public File getCoreLibraries(String path) {
- return getContentFile(path);
+ return getContentFile(path);
}
-
+
static public String getHardwarePath() {
return getHardwareFolder().getAbsolutePath();
}
-
-
+
+
static public String getAvrBasePath() {
String path = getHardwarePath() + File.separator + "tools" +
File.separator + "avr" + File.separator + "bin" + File.separator;
@@ -1828,11 +1827,11 @@ public class Base {
}
return path;
}
-
-
+
+
/**
* Returns the currently selected TargetPlatform.
- *
+ *
* @return
*/
static public TargetPlatform getTargetPlatform() {
@@ -1840,10 +1839,10 @@ public class Base {
String platformName = Preferences.get("target_platform");
return getTargetPlatform(packageName, platformName);
}
-
+
/**
* Returns a specific TargetPlatform searching Package/Platform
- *
+ *
* @param packageName
* @param platformName
* @return
@@ -1900,8 +1899,8 @@ public class Base {
static public String getSketchbookLibrariesPath() {
return getSketchbookLibrariesFolder().getAbsolutePath();
}
-
-
+
+
static public File getSketchbookHardwareFolder() {
return new File(getSketchbookFolder(), "hardware");
}
@@ -2054,7 +2053,7 @@ public class Base {
// don't use the low-res icon on Mac OS X; the window should
// already have the right icon from the .app file.
if (Base.isMacOS()) return;
-
+
Image image = Toolkit.getDefaultToolkit().createImage(PApplet.ICON_IMAGE);
frame.setIconImage(image);
}
@@ -2138,7 +2137,7 @@ public class Base {
static public void showFAQ() {
showReference(_("FAQ.html"));
}
-
+
// .................................................................
diff --git a/app/src/processing/app/helpers/filefilters/OnlyDirs.java b/app/src/processing/app/helpers/filefilters/OnlyDirs.java
index bd26e12b3..46f407248 100644
--- a/app/src/processing/app/helpers/filefilters/OnlyDirs.java
+++ b/app/src/processing/app/helpers/filefilters/OnlyDirs.java
@@ -32,7 +32,6 @@ import java.io.FilenameFilter;
*/
public class OnlyDirs implements FilenameFilter {
- @Override
public boolean accept(File dir, String name) {
if (name.charAt(0) == '.')
return false;
diff --git a/app/src/processing/app/helpers/filefilters/OnlyFilesWithExtension.java b/app/src/processing/app/helpers/filefilters/OnlyFilesWithExtension.java
index 3b2f8a3a6..d57599942 100644
--- a/app/src/processing/app/helpers/filefilters/OnlyFilesWithExtension.java
+++ b/app/src/processing/app/helpers/filefilters/OnlyFilesWithExtension.java
@@ -32,7 +32,6 @@ public class OnlyFilesWithExtension implements FilenameFilter {
extensions = ext;
}
- @Override
public boolean accept(File dir, String name) {
for (String ext : extensions)
if (name.endsWith(ext))
diff --git a/app/src/processing/app/javax/swing/filechooser/FileNameExtensionFilter.java b/app/src/processing/app/javax/swing/filechooser/FileNameExtensionFilter.java
new file mode 100644
index 000000000..a0ef01318
--- /dev/null
+++ b/app/src/processing/app/javax/swing/filechooser/FileNameExtensionFilter.java
@@ -0,0 +1,48 @@
+package processing.app.javax.swing.filechooser;
+
+import javax.swing.filechooser.FileFilter;
+import java.io.File;
+import java.util.Locale;
+
+public class FileNameExtensionFilter extends FileFilter {
+
+ private final String description;
+ private final String[] extensions;
+
+ public FileNameExtensionFilter(String description, String... exts) {
+ this.description = description;
+ this.extensions = new String[exts.length];
+ for (int i = 0; i < exts.length; i++) {
+ this.extensions[i] = exts[i].toLowerCase(Locale.ENGLISH);
+ }
+ }
+
+ @Override
+ public boolean accept(File f) {
+ if (f == null) {
+ return false;
+ }
+
+ if (f.isDirectory()) {
+ return true;
+ }
+
+ String fileName = f.getName();
+ int i = fileName.lastIndexOf('.');
+ if (i > 0 && i < fileName.length() - 1) {
+ String fileExtension = fileName.substring(i + 1).toLowerCase(Locale.ENGLISH);
+ for (String extension : extensions) {
+ if (extension.equals(fileExtension)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+}
diff --git a/core/build.xml b/core/build.xml
index 5a8836abe..307999071 100644
--- a/core/build.xml
+++ b/core/build.xml
@@ -13,7 +13,7 @@
-