mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-28 09:24:14 +01:00
fixed java 1.5 compatibility issue
moved unknown AutoFormat class to external folder
This commit is contained in:
parent
f90e200a34
commit
527e07b26f
@ -37,10 +37,9 @@
|
||||
<echo message="override ${env.JAVA_HOME}/lib/tools.jar" />
|
||||
<fail />
|
||||
-->
|
||||
<javac target="1.5"
|
||||
<javac source="1.5" target="1.5"
|
||||
srcdir="src"
|
||||
destdir="bin"
|
||||
excludes="**/tools/format/**"
|
||||
encoding="UTF-8"
|
||||
includeAntRuntime="false"
|
||||
debug="true"
|
||||
|
@ -34,7 +34,7 @@ import java.io.*;
|
||||
* <A HREF="http://jalopy.sourceforge.net/">Jalopy</A>. This is to replace
|
||||
* the buggy code formatter found in previous releases.
|
||||
*/
|
||||
public class AutoFormat {
|
||||
public class AutoFormat {
|
||||
Editor editor;
|
||||
|
||||
|
@ -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<File> librariesFolders;
|
||||
|
||||
|
||||
// maps library name to their library folder
|
||||
static private Map<String, File> libraries;
|
||||
|
||||
|
||||
// maps #included files to their library folder
|
||||
static Map<String, File> 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<String, TargetPackage> packages;
|
||||
|
||||
// Location for untitled items
|
||||
@ -273,7 +272,7 @@ public class Base {
|
||||
defaultFolder.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
packages = new HashMap<String, TargetPackage>();
|
||||
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<String, File> scanLibraries(List<File> folders) {
|
||||
Map<String, File> res = new HashMap<String, File>();
|
||||
Map<String, File> res = new HashMap<String, File>();
|
||||
for (File folder : folders)
|
||||
res.putAll(scanLibraries(folder));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, File> scanLibraries(File folder) {
|
||||
Map<String, File> res = new HashMap<String, File>();
|
||||
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 {
|
||||
* <br />
|
||||
* If a non-"FAT" library is detected, we assume that the library is suitable
|
||||
* for the current architecture and the libFolder parameter is returned.<br />
|
||||
*
|
||||
*
|
||||
* @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<File>();
|
||||
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<JMenuItem> menuItemsToClickAfterStartup = new LinkedList<JMenuItem>();
|
||||
|
||||
ButtonGroup boardsButtonGroup = new ButtonGroup();
|
||||
Map<String, ButtonGroup> buttonGroupsMap = new HashMap<String, ButtonGroup>();
|
||||
|
||||
|
||||
// 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<String> list = new ArrayList<String>(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"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// .................................................................
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
<methods dir="${basedir}/src/processing/core" />
|
||||
|
||||
<mkdir dir="bin" />
|
||||
<javac target="1.5"
|
||||
<javac source="1.5" target="1.5"
|
||||
encoding="UTF-8"
|
||||
includeAntRuntime="false"
|
||||
srcdir="src" destdir="bin"/>
|
||||
|
Loading…
Reference in New Issue
Block a user