handle a few warnings

This commit is contained in:
Ben Fry
2021-07-07 06:29:17 -04:00
parent 36ffdec4d8
commit 453cddf786
+11 -29
View File
@@ -24,7 +24,6 @@
package processing.app;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
@@ -135,21 +134,6 @@ public class Platform {
}
// static public void openURL(String url) throws Exception {
// inst.openURL(url);
// }
//
//
// public boolean openFolderAvailable() {
// return inst.openFolderAvailable();
// }
//
//
// public void openFolder(File file) throws Exception {
// inst.openFolder(file);
// }
/**
* Implements the cross-platform headache of opening URLs.
*
@@ -257,7 +241,7 @@ public class Platform {
static public int getIndex(String what) {
Integer entry = platformIndices.get(what);
return (entry == null) ? -1 : entry.intValue();
return (entry == null) ? -1 : entry;
}
@@ -270,7 +254,7 @@ public class Platform {
* returns true if Processing is running on a Mac OS X machine.
*/
static public boolean isMacOS() {
return System.getProperty("os.name").indexOf("Mac") != -1; //$NON-NLS-1$ //$NON-NLS-2$
return System.getProperty("os.name").contains("Mac"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -278,7 +262,7 @@ public class Platform {
* returns true if running on windows.
*/
static public boolean isWindows() {
return System.getProperty("os.name").indexOf("Windows") != -1; //$NON-NLS-1$ //$NON-NLS-2$
return System.getProperty("os.name").contains("Windows"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -286,7 +270,7 @@ public class Platform {
* true if running on linux.
*/
static public boolean isLinux() {
return System.getProperty("os.name").indexOf("Linux") != -1; //$NON-NLS-1$ //$NON-NLS-2$
return System.getProperty("os.name").contains("Linux"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -310,7 +294,10 @@ public class Platform {
try {
decodedPath = pathURL.toURI().getSchemeSpecificPart();
} catch (URISyntaxException e) {
e.printStackTrace();
Messages.showError("Missing File",
"Could not access a required file:\n" +
"<b>" + name + "</b>\n" +
"You may need to reinstall Processing.", e);
return null;
}
@@ -351,12 +338,8 @@ public class Platform {
static public File getJavaHome() {
if (Platform.isMacOS()) {
//return "Contents/PlugIns/jdk1.7.0_40.jdk/Contents/Home/jre/bin/java";
File[] plugins = getContentFile("../PlugIns").listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return dir.isDirectory() &&
name.contains("jdk") && !name.startsWith(".");
}
});
File[] plugins = getContentFile("../PlugIns").listFiles((dir, name) -> dir.isDirectory() &&
name.contains("jdk") && !name.startsWith("."));
return new File(plugins[0], "Contents/Home");
}
// On all other platforms, it's the 'java' folder adjacent to Processing
@@ -385,13 +368,12 @@ public class Platform {
* If not possible, just deletes the file or folder instead.
* @param file the folder or file to be removed/deleted
* @return true if the folder was successfully removed
* @throws IOException
*/
static public boolean deleteFile(File file) throws IOException {
try {
FileUtils fu = FileUtils.getInstance();
if (fu.hasTrash()) {
fu.moveToTrash(new File[]{file});
fu.moveToTrash(file);
return true;
}
} catch (Throwable t) {