deal with some warnings, minor cleanups

This commit is contained in:
benfry
2009-12-02 16:57:25 +00:00
parent 805f8dc614
commit 029fab7227
5 changed files with 79 additions and 69 deletions
+2
View File
@@ -7,5 +7,7 @@
<classpathentry kind="lib" path="app/lib/apple.jar"/>
<classpathentry kind="lib" path="app/lib/ecj.jar"/>
<classpathentry kind="lib" path="app/lib/jna.jar"/>
<classpathentry kind="lib" path="app/lib/ant-launcher.jar"/>
<classpathentry kind="lib" path="app/lib/ant.jar"/>
<classpathentry kind="output" path="app/bin"/>
</classpath>
+3 -3
View File
@@ -193,7 +193,7 @@ public class Base {
static protected void initPlatform() {
try {
Class platformClass = Class.forName("processing.app.Platform");
Class<?> platformClass = Class.forName("processing.app.Platform");
if (Base.isMacOS()) {
platformClass = Class.forName("processing.app.macosx.Platform");
} else if (Base.isWindows()) {
@@ -2075,7 +2075,7 @@ public class Base {
static public String[] listFiles(File folder, boolean relative) {
String path = folder.getAbsolutePath();
Vector vector = new Vector();
Vector<String> vector = new Vector<String>();
listFiles(relative ? (path + File.separator) : "", path, vector);
String outgoing[] = new String[vector.size()];
vector.copyInto(outgoing);
@@ -2084,7 +2084,7 @@ public class Base {
static protected void listFiles(String basePath,
String path, Vector vector) {
String path, Vector<String> vector) {
File folder = new File(path);
String list[] = folder.list();
if (list == null) return;
+71 -64
View File
@@ -22,7 +22,6 @@
package processing.app;
import processing.app.debug.*;
import processing.app.syntax.*;
import processing.app.tools.*;
@@ -248,64 +247,7 @@ public class Editor extends JFrame implements RunnerListener {
listener = new EditorListener(this, textarea);
pain.add(box);
pain.setTransferHandler(new TransferHandler() {
public boolean canImport(JComponent dest, DataFlavor[] flavors) {
return true;
}
public boolean importData(JComponent src, Transferable transferable) {
int successful = 0;
try {
DataFlavor uriListFlavor =
new DataFlavor("text/uri-list;class=java.lang.String");
if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
java.util.List list = (java.util.List)
transferable.getTransferData(DataFlavor.javaFileListFlavor);
for (int i = 0; i < list.size(); i++) {
File file = (File) list.get(i);
if (sketch.addFile(file)) {
successful++;
}
}
} else if (transferable.isDataFlavorSupported(uriListFlavor)) {
//System.out.println("uri list");
String data = (String)transferable.getTransferData(uriListFlavor);
String[] pieces = PApplet.splitTokens(data, "\r\n");
//PApplet.println(pieces);
for (int i = 0; i < pieces.length; i++) {
if (pieces[i].startsWith("#")) continue;
String path = null;
if (pieces[i].startsWith("file:///")) {
path = pieces[i].substring(7);
} else if (pieces[i].startsWith("file:/")) {
path = pieces[i].substring(5);
}
if (sketch.addFile(new File(path))) {
successful++;
}
}
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
if (successful == 0) {
statusError("No files were added to the sketch.");
} else if (successful == 1) {
statusNotice("One file added to the sketch.");
} else {
statusNotice(successful + " files added to the sketch.");
}
return true;
}
});
pain.setTransferHandler(new FileDropHandler());
// System.out.println("t1");
@@ -333,6 +275,71 @@ public class Editor extends JFrame implements RunnerListener {
// All set, now show the window
//setVisible(true);
}
/**
* Handles files dragged & dropped from the desktop and into the editor
* window. Dragging files into the editor window is the same as using
* "Sketch &rarr; Add File" for each file.
*/
class FileDropHandler extends TransferHandler {
public boolean canImport(JComponent dest, DataFlavor[] flavors) {
return true;
}
@SuppressWarnings("unchecked")
public boolean importData(JComponent src, Transferable transferable) {
int successful = 0;
try {
DataFlavor uriListFlavor =
new DataFlavor("text/uri-list;class=java.lang.String");
if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
java.util.List list = (java.util.List)
transferable.getTransferData(DataFlavor.javaFileListFlavor);
for (int i = 0; i < list.size(); i++) {
File file = (File) list.get(i);
if (sketch.addFile(file)) {
successful++;
}
}
} else if (transferable.isDataFlavorSupported(uriListFlavor)) {
// Some platforms (Mac OS X and Linux, when this began) preferred
// this method of moving files.
String data = (String)transferable.getTransferData(uriListFlavor);
String[] pieces = PApplet.splitTokens(data, "\r\n");
for (int i = 0; i < pieces.length; i++) {
if (pieces[i].startsWith("#")) continue;
String path = null;
if (pieces[i].startsWith("file:///")) {
path = pieces[i].substring(7);
} else if (pieces[i].startsWith("file:/")) {
path = pieces[i].substring(5);
}
if (sketch.addFile(new File(path))) {
successful++;
}
}
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
if (successful == 0) {
statusError("No files were added to the sketch.");
} else if (successful == 1) {
statusNotice("One file added to the sketch.");
} else {
statusNotice(successful + " files added to the sketch.");
}
return true;
}
}
protected void setPlacement(int[] location) {
@@ -627,7 +634,7 @@ public class Editor extends JFrame implements RunnerListener {
protected void addTools(JMenu menu, File sourceFolder) {
HashMap toolItems = new HashMap();
HashMap<String, JMenuItem> toolItems = new HashMap<String, JMenuItem>();
File[] folders = sourceFolder.listFiles(new FileFilter() {
public boolean accept(File folder) {
@@ -697,7 +704,7 @@ public class Editor extends JFrame implements RunnerListener {
// If no class name found, just move on.
if (className == null) continue;
Class toolClass = Class.forName(className, true, loader);
Class<?> toolClass = Class.forName(className, true, loader);
final Tool tool = (Tool) toolClass.newInstance();
tool.init(Editor.this);
@@ -717,7 +724,7 @@ public class Editor extends JFrame implements RunnerListener {
e.printStackTrace();
}
}
ArrayList<String> toolList = new ArrayList(toolItems.keySet());
ArrayList<String> toolList = new ArrayList<String>(toolItems.keySet());
if (toolList.size() == 0) return;
menu.addSeparator();
@@ -734,7 +741,7 @@ public class Editor extends JFrame implements RunnerListener {
try {
ZipFile zipFile = new ZipFile(file);
Enumeration entries = zipFile.entries();
Enumeration<?> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
@@ -760,7 +767,7 @@ public class Editor extends JFrame implements RunnerListener {
protected JMenuItem createToolMenuItem(String className) {
try {
Class toolClass = Class.forName(className);
Class<?> toolClass = Class.forName(className);
final Tool tool = (Tool) toolClass.newInstance();
JMenuItem item = new JMenuItem(tool.getMenuTitle());
+2 -1
View File
@@ -28,6 +28,7 @@ import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.text.*;
import java.util.*;
@@ -389,7 +390,7 @@ public class EditorConsole extends JScrollPane {
* swing event thread, so they need to be synchronized
*/
class BufferedStyledDocument extends DefaultStyledDocument {
ArrayList elements = new ArrayList();
ArrayList<ElementSpec> elements = new ArrayList<ElementSpec>();
int maxLineLength, maxLineCount;
int currentLineLength = 0;
boolean needLineBreak = false;
+1 -1
View File
@@ -126,7 +126,7 @@ public class Runner implements MessageConsumer {
protected String[] getMachineParams() {
ArrayList params = new ArrayList();
ArrayList<String> params = new ArrayList<String>();
//params.add("-Xint"); // interpreted mode
//params.add("-Xprof"); // profiler