Skip to content

Commit 527e07b

Browse files
committed
fixed java 1.5 compatibility issue
moved unknown AutoFormat class to external folder
1 parent f90e200 commit 527e07b

File tree

9 files changed

+102
-58
lines changed

9 files changed

+102
-58
lines changed

app/build.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@
3737
<echo message="override ${env.JAVA_HOME}/lib/tools.jar" />
3838
<fail />
3939
-->
40-
<javac target="1.5"
40+
<javac source="1.5" target="1.5"
4141
srcdir="src"
4242
destdir="bin"
43-
excludes="**/tools/format/**"
4443
encoding="UTF-8"
4544
includeAntRuntime="false"
4645
debug="true"

app/src/processing/app/tools/format/src/AutoFormat.java renamed to app/format/src/AutoFormat.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* <A HREF="http://jalopy.sourceforge.net/">Jalopy</A>. This is to replace
3535
* the buggy code formatter found in previous releases.
3636
*/
37-
public class AutoFormat {
37+
public class AutoFormat {
3838
Editor editor;
3939

4040

app/src/processing/app/Base.java

+51-52
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.List;
3030

3131
import javax.swing.*;
32-
import javax.swing.filechooser.FileNameExtensionFilter;
3332

3433
import processing.app.debug.TargetPackage;
3534
import processing.app.debug.TargetPlatform;
@@ -38,7 +37,7 @@
3837
import processing.app.helpers.PreferencesMap;
3938
import processing.app.helpers.filefilters.OnlyDirs;
4039
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
41-
import processing.app.tools.MapWithSubkeys;
40+
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;import processing.app.tools.MapWithSubkeys;
4241
import processing.app.tools.ZipDeflater;
4342
import processing.core.*;
4443
import static processing.app.I18n._;
@@ -88,18 +87,18 @@ public class Base {
8887
static private File toolsFolder;
8988

9089
static private List<File> librariesFolders;
91-
90+
9291
// maps library name to their library folder
9392
static private Map<String, File> libraries;
94-
93+
9594
// maps #included files to their library folder
9695
static Map<String, File> importToLibraryTable;
9796

9897
// classpath for all known libraries for p5
9998
// (both those in the p5/libs folder and those with lib subfolders
10099
// found in the sketchbook)
101100
static public String librariesClassPath;
102-
101+
103102
static public Map<String, TargetPackage> packages;
104103

105104
// Location for untitled items
@@ -273,7 +272,7 @@ public Base(String[] args) throws Exception {
273272
defaultFolder.mkdirs();
274273
}
275274
}
276-
275+
277276
packages = new HashMap<String, TargetPackage>();
278277
loadHardware(getHardwareFolder());
279278
loadHardware(getSketchbookHardwareFolder());
@@ -993,7 +992,7 @@ public Map<String, File> getUserLibs() {
993992

994993
public void rebuildImportMenu(JMenu importMenu, final Editor editor) {
995994
importMenu.removeAll();
996-
995+
997996
JMenuItem addLibraryMenuItem = new JMenuItem(_("Add Library..."));
998997
addLibraryMenuItem.addActionListener(new ActionListener() {
999998
public void actionPerformed(ActionEvent e) {
@@ -1040,7 +1039,7 @@ public void actionPerformed(ActionEvent e) {
10401039
public void rebuildExamplesMenu(JMenu menu) {
10411040
try {
10421041
menu.removeAll();
1043-
1042+
10441043
// Add examples from distribution "example" folder
10451044
boolean found = addSketches(menu, examplesFolder, false);
10461045
if (found) menu.addSeparator();
@@ -1074,14 +1073,14 @@ public void rebuildExamplesMenu(JMenu menu) {
10741073
e.printStackTrace();
10751074
}
10761075
}
1077-
1076+
10781077
public Map<String, File> scanLibraries(List<File> folders) {
1079-
Map<String, File> res = new HashMap<String, File>();
1078+
Map<String, File> res = new HashMap<String, File>();
10801079
for (File folder : folders)
10811080
res.putAll(scanLibraries(folder));
10821081
return res;
10831082
}
1084-
1083+
10851084
public Map<String, File> scanLibraries(File folder) {
10861085
Map<String, File> res = new HashMap<String, File>();
10871086
String list[] = folder.list(new OnlyDirs());
@@ -1101,7 +1100,7 @@ public Map<String, File> scanLibraries(File folder) {
11011100
}
11021101

11031102
subfolder = scanFatLibrary(subfolder);
1104-
1103+
11051104
// (also replace previously found libs with the same name)
11061105
if (subfolder != null)
11071106
res.put(libName, subfolder);
@@ -1117,7 +1116,7 @@ public Map<String, File> scanLibraries(File folder) {
11171116
* <br />
11181117
* If a non-"FAT" library is detected, we assume that the library is suitable
11191118
* for the current architecture and the libFolder parameter is returned.<br />
1120-
*
1119+
*
11211120
* @param libFolder
11221121
* @return
11231122
*/
@@ -1134,18 +1133,18 @@ public File scanFatLibrary(File libFolder) {
11341133
return null;
11351134
return archSubfolder;
11361135
}
1137-
1136+
11381137
public void onBoardOrPortChange() {
11391138
// Calculate paths for libraries and examples
11401139
examplesFolder = getContentFile("examples");
11411140
toolsFolder = getContentFile("tools");
1142-
1141+
11431142
File platformFolder = getTargetPlatform().getFolder();
11441143
librariesFolders = new ArrayList<File>();
11451144
librariesFolders.add(getContentFile("libraries"));
11461145
librariesFolders.add(new File(platformFolder, "libraries"));
11471146
librariesFolders.add(getSketchbookLibrariesFolder());
1148-
1147+
11491148
// Scan for libraries in each library folder.
11501149
// Libraries located in the latest folders on the list can override
11511150
// other libraries with the same name.
@@ -1158,7 +1157,7 @@ public void onBoardOrPortChange() {
11581157
for (String pkg : packages)
11591158
importToLibraryTable.put(pkg, subfolder);
11601159
}
1161-
1160+
11621161
// Update editors status bar
11631162
for (Editor editor : editors)
11641163
editor.onBoardOrPortChange();
@@ -1170,14 +1169,14 @@ public void rebuildBoardsMenu(JMenu toolsMenu, final Editor editor) {
11701169
String selPackage = Preferences.get("target_package");
11711170
String selPlatform = Preferences.get("target_platform");
11721171
String selBoard = Preferences.get("board");
1173-
1172+
11741173
boolean first = true;
1175-
1174+
11761175
List<JMenuItem> menuItemsToClickAfterStartup = new LinkedList<JMenuItem>();
11771176

11781177
ButtonGroup boardsButtonGroup = new ButtonGroup();
11791178
Map<String, ButtonGroup> buttonGroupsMap = new HashMap<String, ButtonGroup>();
1180-
1179+
11811180
// Cycle through all packages
11821181
for (TargetPackage targetPackage : packages.values()) {
11831182
String packageName = targetPackage.getName();
@@ -1189,17 +1188,17 @@ public void rebuildBoardsMenu(JMenu toolsMenu, final Editor editor) {
11891188
if (targetPlatform.getPreferences().get("name") == null || targetPlatform.getBoards().isEmpty()) {
11901189
continue;
11911190
}
1192-
1191+
11931192
// Add a title for each group of boards
11941193
if (!first) {
11951194
boardsMenu.add(new JSeparator());
11961195
}
11971196
first = false;
1198-
1197+
11991198
JMenuItem separator = new JMenuItem(_(targetPlatform.getPreferences().get("name")));
12001199
separator.setEnabled(false);
12011200
boardsMenu.add(separator);
1202-
1201+
12031202
// For every platform cycle through all boards
12041203
for (final String boardID : targetPlatform.getBoards().keySet()) {
12051204
// Setup a menu item for the current board
@@ -1211,7 +1210,7 @@ public void actionPerformed(ActionEvent actionevent) {
12111210
}
12121211
};
12131212
action.putValue("b", packageName + ":" + platformName + ":" + boardID);
1214-
1213+
12151214
JRadioButtonMenuItem item = new JRadioButtonMenuItem(action);
12161215
boardsMenu.add(item);
12171216
boardsButtonGroup.add(item);
@@ -1256,7 +1255,7 @@ public void actionPerformed(ActionEvent e) {
12561255
if (!buttonGroupsMap.containsKey(customMenuID)) {
12571256
buttonGroupsMap.put(customMenuID, new ButtonGroup());
12581257
}
1259-
1258+
12601259
item = new JRadioButtonMenuItem(subAction);
12611260
menu.add(item);
12621261
buttonGroupsMap.get(customMenuID).add(item);
@@ -1322,7 +1321,7 @@ private JMenu makeOrGetBoardMenu(JMenu toolsMenu, String label) {
13221321
toolsMenu.add(menu);
13231322
return menu;
13241323
}
1325-
1324+
13261325
private static JMenuItem selectVisibleSelectedOrFirstMenuItem(JMenu menu) {
13271326
JMenuItem firstVisible = null;
13281327
for (int i = 0; i < menu.getItemCount(); i++) {
@@ -1336,14 +1335,14 @@ private static JMenuItem selectVisibleSelectedOrFirstMenuItem(JMenu menu) {
13361335
}
13371336
}
13381337
}
1339-
1338+
13401339
if (firstVisible != null) {
13411340
return firstVisible;
13421341
}
1343-
1342+
13441343
throw new IllegalStateException("Menu has no enabled items");
13451344
}
1346-
1345+
13471346
private static JMenuItem selectFirstEnabledMenuItem(JMenu menu) {
13481347
for (int i = 0; i < menu.getItemCount(); i++) {
13491348
JMenuItem item = menu.getItem(i);
@@ -1360,7 +1359,7 @@ private void selectBoard(String selectBoard, Editor editor) {
13601359
Preferences.set("target_package", split[0]);
13611360
Preferences.set("target_platform", split[1]);
13621361
Preferences.set("board", split[2]);
1363-
1362+
13641363
filterVisibilityOfSubsequentBoardMenus(split[2], 1);
13651364

13661365
onBoardOrPortChange();
@@ -1426,7 +1425,7 @@ protected boolean addSketches(JMenu menu, File folder,
14261425
if (addSketchesSubmenu(menu, name, subfolder, replaceExisting))
14271426
ifound = true;
14281427
}
1429-
1428+
14301429
return ifound; // actually ignored, but..
14311430
}
14321431

@@ -1482,7 +1481,7 @@ public void actionPerformed(ActionEvent e) {
14821481
item.setActionCommand(entry.getAbsolutePath());
14831482
menu.add(item);
14841483
return true;
1485-
}
1484+
}
14861485

14871486
// don't create an extra menu level for a folder named "examples"
14881487
if (folder.getName().equals("examples"))
@@ -1500,7 +1499,7 @@ protected void addLibraries(JMenu menu, Map<String, File> libs) throws IOExcepti
15001499

15011500
List<String> list = new ArrayList<String>(libs.keySet());
15021501
Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
1503-
1502+
15041503
ActionListener listener = new ActionListener() {
15051504
public void actionPerformed(ActionEvent e) {
15061505
activeEditor.getSketch().importLibrary(e.getActionCommand());
@@ -1519,7 +1518,7 @@ public void actionPerformed(ActionEvent e) {
15191518
// XXX: DAM: should recurse here so that library folders can be nested
15201519
}
15211520
}
1522-
1521+
15231522
/**
15241523
* Given a folder, return a list of the header files in that folder (but not
15251524
* the header files in its sub-folders, as those should be included from
@@ -1528,19 +1527,19 @@ public void actionPerformed(ActionEvent e) {
15281527
static public String[] headerListFromIncludePath(File path) {
15291528
return path.list(new OnlyFilesWithExtension(".h"));
15301529
}
1531-
1530+
15321531
protected void loadHardware(File folder) {
15331532
if (!folder.isDirectory()) return;
1534-
1533+
15351534
String list[] = folder.list(new OnlyDirs());
1536-
1535+
15371536
// if a bad folder or something like that, this might come back null
15381537
if (list == null) return;
15391538

15401539
// alphabetize list, since it's not always alpha order
15411540
// replaced hella slow bubble sort with this feller for 0093
15421541
Arrays.sort(list, String.CASE_INSENSITIVE_ORDER);
1543-
1542+
15441543
for (String target : list) {
15451544
// Skip reserved 'tools' folder.
15461545
if (target.equals("tools"))
@@ -1809,17 +1808,17 @@ static public File getHardwareFolder() {
18091808
// before the other folders / paths get cached).
18101809
return getContentFile("hardware");
18111810
}
1812-
1811+
18131812
//Get the core libraries
18141813
static public File getCoreLibraries(String path) {
1815-
return getContentFile(path);
1814+
return getContentFile(path);
18161815
}
1817-
1816+
18181817
static public String getHardwarePath() {
18191818
return getHardwareFolder().getAbsolutePath();
18201819
}
1821-
1822-
1820+
1821+
18231822
static public String getAvrBasePath() {
18241823
String path = getHardwarePath() + File.separator + "tools" +
18251824
File.separator + "avr" + File.separator + "bin" + File.separator;
@@ -1828,22 +1827,22 @@ static public String getAvrBasePath() {
18281827
}
18291828
return path;
18301829
}
1831-
1832-
1830+
1831+
18331832
/**
18341833
* Returns the currently selected TargetPlatform.
1835-
*
1834+
*
18361835
* @return
18371836
*/
18381837
static public TargetPlatform getTargetPlatform() {
18391838
String packageName = Preferences.get("target_package");
18401839
String platformName = Preferences.get("target_platform");
18411840
return getTargetPlatform(packageName, platformName);
18421841
}
1843-
1842+
18441843
/**
18451844
* Returns a specific TargetPlatform searching Package/Platform
1846-
*
1845+
*
18471846
* @param packageName
18481847
* @param platformName
18491848
* @return
@@ -1900,8 +1899,8 @@ static public File getSketchbookLibrariesFolder() {
19001899
static public String getSketchbookLibrariesPath() {
19011900
return getSketchbookLibrariesFolder().getAbsolutePath();
19021901
}
1903-
1904-
1902+
1903+
19051904
static public File getSketchbookHardwareFolder() {
19061905
return new File(getSketchbookFolder(), "hardware");
19071906
}
@@ -2054,7 +2053,7 @@ static public void setIcon(Frame frame) {
20542053
// don't use the low-res icon on Mac OS X; the window should
20552054
// already have the right icon from the .app file.
20562055
if (Base.isMacOS()) return;
2057-
2056+
20582057
Image image = Toolkit.getDefaultToolkit().createImage(PApplet.ICON_IMAGE);
20592058
frame.setIconImage(image);
20602059
}
@@ -2138,7 +2137,7 @@ static public void showTroubleshooting() {
21382137
static public void showFAQ() {
21392138
showReference(_("FAQ.html"));
21402139
}
2141-
2140+
21422141

21432142
// .................................................................
21442143

app/src/processing/app/helpers/filefilters/OnlyDirs.java

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
*/
3333
public class OnlyDirs implements FilenameFilter {
3434

35-
@Override
3635
public boolean accept(File dir, String name) {
3736
if (name.charAt(0) == '.')
3837
return false;

0 commit comments

Comments
 (0)