add stub for apple classes, further progress on multi-window setup

This commit is contained in:
benfry
2007-07-22 13:28:14 +00:00
parent 50ac22a47c
commit c548ea7f0d
10 changed files with 209 additions and 644 deletions
+1
View File
@@ -6,5 +6,6 @@
<classpathentry kind="lib" path="build/shared/lib/antlr.jar"/>
<classpathentry kind="lib" path="build/shared/lib/oro.jar"/>
<classpathentry kind="lib" path="build/shared/lib/registry.jar"/>
<classpathentry kind="lib" path="build/shared/lib/apple.jar"/>
<classpathentry kind="output" path="app/bin"/>
</classpath>
+122 -106
View File
@@ -175,11 +175,12 @@ public class Base {
e.printStackTrace();
}
}
protected void registerMacOS() {
try {
Class osxAdapter = ClassLoader.getSystemClassLoader().loadClass("BaseMacOS");
String name = "processing.app.BaseMacOS";
Class osxAdapter = ClassLoader.getSystemClassLoader().loadClass(name);
Class[] defArgs = { Base.class };
Method registerMethod = osxAdapter.getDeclaredMethod("register", defArgs);
@@ -372,20 +373,12 @@ public class Base {
});
*/
for (int i = 0; i < editorCount; i++) {
editors[i].sketchbookChanged = true; //sketchbook.rebuildMenus();
editors[i].sketchbookUpdated = true; //sketchbook.rebuildMenus();
}
//rebuildMenus();
}
public boolean handleClose(Editor editor) {
// check if modified
// if not canceled, the check if this is the last open window
// if this is the last open window, just do a 'new' instead
return false;
}
public void handleOpen() {
// get the frontmost window frame for placing file dialog
@@ -409,8 +402,8 @@ public class Base {
}
public void handleOpen(String path) {
new Editor(this, path);
public Editor handleOpen(String path) {
return new Editor(this, path);
}
@@ -576,17 +569,19 @@ public class Base {
try {
String path = null;
boolean untitled = false;
if (prompt) {
path = handleNewPrompt(activeEditor);
} else {
path = handleNewUntitled();
untitled = true;
}
if (path != null) {
rebuildMenusAsync();
handleOpen(path);
Editor editor = handleOpen(path);
editor.untitled = true;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@@ -709,12 +704,37 @@ public class Base {
}
/*
public Editor getActiveEditor() {
return activeEditor;
public boolean handleClose(Editor editor) {
// Check if modified
boolean success = editor.checkModified(false);
// If not canceled, remove the editor window.
if (success) {
editor.setVisible(false);
editor.dispose();
for (int i = 0; i < editorCount; i++) {
if (editor == editors[i]) {
for (int j = i; j < editorCount-1; j++) {
editors[j] = editors[j+1];
}
editorCount--;
editors[editorCount] = null;
}
}
// If not canceled, check if this was the last open window.
// If it was the last, could either do a new untitled window,
// or could just quit the application.
if (editorCount == 0) {
handleQuit();
}
return true;
}
return false;
}
*/
public boolean handleQuit() {
boolean canceled = false;
@@ -724,9 +744,20 @@ public class Base {
break;
}
}
return !canceled;
if (!canceled) {
// Clean out empty sketches
Base.cleanSketchbook();
//if (PApplet.platform != PConstants.MACOSX) {
System.exit(0);
//}
}
return !canceled;
}
// .................................................................
/**
* Rebuild the menu full of sketches based on the
@@ -769,9 +800,6 @@ public class Base {
*/
// .................................................................
/*
public JPopupMenu createPopup() {
JMenu menu = new JMenu();
@@ -859,23 +887,15 @@ public class Base {
}
/*
public JMenu getImportMenu() {
return importMenu;
}
*/
protected boolean addSketches(JMenu menu, File folder) throws IOException {
// skip .DS_Store files, etc
// skip .DS_Store files, etc (this shouldn't actually be necessary)
if (!folder.isDirectory()) return false;
String list[] = folder.list();
// if a bad folder or something like that, this might come back null
String[] list = folder.list();
// If a bad folder or unreadable or whatever, this will come back null
if (list == null) return false;
// alphabetize list, since it's not always alpha order
// replaced hella slow bubble sort with this feller for 0093
// Alphabetize list, since it's not always alpha order
Arrays.sort(list, String.CASE_INSENSITIVE_ORDER);
ActionListener listener = new ActionListener() {
@@ -964,7 +984,7 @@ public class Base {
File exported = new File(subfolder, "library");
File entry = new File(exported, list[i] + ".jar");
// if a .jar file of the same prefix as the folder exists
// If a .jar file of the same prefix as the folder exists
// inside the 'library' subfolder of the sketch
if (entry.exists()) {
String sanityCheck = Sketch.sanitizedName(list[i]);
@@ -973,7 +993,7 @@ public class Base {
"The library \"" + list[i] + "\" cannot be used.\n" +
"Library names must contain only basic letters and numbers.\n" +
"(ascii only and no spaces, and it cannot start with a number)";
Base.showMessage("Ignoring bad sketch name", mess);
Base.showMessage("Ignoring bad library name", mess);
continue;
}
@@ -1012,62 +1032,6 @@ public class Base {
return ifound;
}
/**
* Clear out projects that are empty.
*/
public void clean() {
//if (!Preferences.getBoolean("sketchbook.auto_clean")) return;
File sketchbookFolder = new File(getSketchbookPath());
if (!sketchbookFolder.exists()) return;
//String entries[] = new File(userPath).list();
String entries[] = sketchbookFolder.list();
if (entries != null) {
for (int j = 0; j < entries.length; j++) {
//System.out.println(entries[j] + " " + entries.length);
if (entries[j].charAt(0) == '.') continue;
//File prey = new File(userPath, entries[j]);
File prey = new File(sketchbookFolder, entries[j]);
File pde = new File(prey, entries[j] + ".pde");
// make sure this is actually a sketch folder with a .pde,
// not a .DS_Store file or another random user folder
if (pde.exists() &&
(Base.calcFolderSize(prey) == 0)) {
//System.out.println("i want to remove " + prey);
if (Preferences.getBoolean("sketchbook.auto_clean")) {
Base.removeDir(prey);
/*
} else { // otherwise prompt the user
String prompt =
"Remove empty sketch titled \"" + entries[j] + "\"?";
Object[] options = { "Yes", "No" };
int result =
JOptionPane.showOptionDialog(editor,
prompt,
"Housekeeping",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]);
if (result == JOptionPane.YES_OPTION) {
Base.removeDir(prey);
}
*/
}
}
}
}
}
// .................................................................
@@ -1143,17 +1107,6 @@ public class Base {
// .................................................................
/*
static final int kDocumentsFolderType =
('d' << 24) | ('o' << 16) | ('c' << 8) | 's';
static final int kPreferencesFolderType =
('p' << 24) | ('r' << 16) | ('e' << 8) | 'f';
static final int kDomainLibraryFolderType =
('d' << 24) | ('l' << 16) | ('i' << 8) | 'b';
static final short kUserDomain = -32763;
*/
static public File getSettingsFolder() {
File dataFolder = null;
@@ -1276,6 +1229,11 @@ public class Base {
}
/**
* For now, only used by Preferences to get the preferences.txt file.
* @param filename
* @return
*/
static public File getSettingsFile(String filename) {
return new File(getSettingsFolder(), filename);
}
@@ -1487,6 +1445,64 @@ public class Base {
return folder;
}
/**
* Clear out projects that are empty.
*/
static public void cleanSketchbook() {
if (!Preferences.getBoolean("sketchbook.auto_clean")) return;
File sketchbookFolder = new File(getSketchbookPath());
if (!sketchbookFolder.exists()) return;
//String entries[] = new File(userPath).list();
String entries[] = sketchbookFolder.list();
if (entries != null) {
for (int j = 0; j < entries.length; j++) {
//System.out.println(entries[j] + " " + entries.length);
if (entries[j].charAt(0) == '.') continue;
//File prey = new File(userPath, entries[j]);
File prey = new File(sketchbookFolder, entries[j]);
File pde = new File(prey, entries[j] + ".pde");
// make sure this is actually a sketch folder with a .pde,
// not a .DS_Store file or another random user folder
if (pde.exists() && (Base.calcFolderSize(prey) == 0)) {
//System.out.println("i want to remove " + prey);
//if (Preferences.getBoolean("sketchbook.auto_clean")) {
Base.removeDir(prey);
/*
} else { // otherwise prompt the user
String prompt =
"Remove empty sketch titled \"" + entries[j] + "\"?";
Object[] options = { "Yes", "No" };
int result =
JOptionPane.showOptionDialog(editor,
prompt,
"Housekeeping",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]);
if (result == JOptionPane.YES_OPTION) {
Base.removeDir(prey);
}
*/
//}
}
}
}
}
// .................................................................
/**
* Implementation for choosing directories that handles both the
+22
View File
@@ -1,3 +1,25 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2007 Ben Fry and Casey Reas
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
import java.io.FileNotFoundException;
+58 -38
View File
@@ -1,10 +1,9 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Editor - main editor panel for the processing development environment
Part of the Processing project - http://processing.org
Copyright (c) 2004-06 Ben Fry and Casey Reas
Copyright (c) 2004-07 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
@@ -30,26 +29,19 @@ import processing.core.*;
import java.awt.*;
import java.awt.datatransfer.*;
//import java.awt.dnd.*;
import java.awt.event.*;
import java.awt.print.*;
import java.io.*;
//import java.lang.reflect.*;
//import java.net.*;
//import java.util.*;
//import java.util.zip.*;
import javax.swing.*;
//import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.undo.*;
//import com.apple.mrj.*;
//import com.oroinc.text.regex.*;
//import de.hunsicker.jalopy.*;
/**
* Main editor panel for the Processing Development Environment.
*/
public class Editor extends JFrame {
Base base;
@@ -79,6 +71,11 @@ public class Editor extends JFrame {
String handleOpenPath;
boolean handleNewShift;
/**
* true if this file has not yet been given a name by the user
*/
boolean untitled;
PageFormat pageFormat;
PrinterJob printerJob;
@@ -114,7 +111,7 @@ public class Editor extends JFrame {
JMenuItem saveAsMenuItem;
// True if the sketchbook has changed since this Editor was last active.
boolean sketchbookChanged;
boolean sketchbookUpdated;
//
@@ -153,7 +150,9 @@ public class Editor extends JFrame {
// add listener to handle window close box hit event
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
handleQuitInternal();
base.handleClose(Editor.this);
//handleClose2();
//handleQuitInternal();
}
});
// don't close the window when clicked, the app will take care
@@ -165,6 +164,11 @@ public class Editor extends JFrame {
addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
base.handleActivated(Editor.this);
if (sketchbookUpdated) {
base.rebuildSketchbookMenu(sketchbookMenu);
base.rebuildToolbarMenu(toolbarMenu);
sketchbookUpdated = false;
}
}
});
@@ -529,6 +533,14 @@ public class Editor extends JFrame {
});
menu.add(item);
item = Editor.newJMenuItem("Close", 'W', false);
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
base.handleClose(Editor.this);
}
});
menu.add(item);
sketchbookMenu = new JMenu("Sketchbook");
base.rebuildSketchbookMenu(sketchbookMenu);
menu.add(sketchbookMenu);
@@ -608,7 +620,7 @@ public class Editor extends JFrame {
item = newJMenuItem("Quit", 'Q');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleQuitInternal();
base.handleQuit();
}
});
menu.add(item);
@@ -1668,9 +1680,11 @@ public class Editor extends JFrame {
*/
/*
public void handleClose2() {
base.handleClose(this);
}
*/
/**
@@ -1685,12 +1699,13 @@ public class Editor extends JFrame {
public boolean handleSave(boolean immediately) {
doStop();
if (sketch.untitled) {
if (untitled) {
return handleSaveAs();
// need to get the name, user might also cancel here
}
if (immediately) {
} else if (immediately) {
handleSave2();
} else {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@@ -1731,29 +1746,32 @@ public class Editor extends JFrame {
}
public void handleSaveAs() {
public boolean handleSaveAs() {
doStop();
toolbar.activate(EditorToolbar.SAVE);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
message("Saving...");
try {
if (sketch.saveAs()) {
message("Done Saving.");
// Disabling this for 0125, instead rebuild the menu inside
// the Save As method of the Sketch object, since that's the
// only one who knows whether something was renamed.
//sketchbook.rebuildMenusAsync();
} else {
message("Save Cancelled.");
}
} catch (Exception e) {
// show the error as a message in the window
error(e);
}
toolbar.clear();
}});
//SwingUtilities.invokeLater(new Runnable() {
//public void run() {
message("Saving...");
try {
if (sketch.saveAs()) {
message("Done Saving.");
// Disabling this for 0125, instead rebuild the menu inside
// the Save As method of the Sketch object, since that's the
// only one who knows whether something was renamed.
//sketchbook.rebuildMenusAsync();
} else {
message("Save Canceled.");
return false;
}
} catch (Exception e) {
// show the error as a message in the window
error(e);
}
toolbar.clear();
//}});
return true;
}
@@ -1896,6 +1914,7 @@ public class Editor extends JFrame {
* to disk just in case they want to quit. Final exit() happens
* in Editor since it has the callback from EditorStatus.
*/
/*
public void handleQuitInternal() {
// doStop() isn't sufficient with external vm & quit
// instead use doClose() which will kill the external vm
@@ -1903,6 +1922,7 @@ public class Editor extends JFrame {
checkModified(true);
}
*/
/**
+1 -1
View File
@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2005-06 Ben Fry and Casey Reas
Copyright (c) 2005-07 Ben Fry and Casey Reas
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
+3 -7
View File
@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-06 Ben Fry and Casey Reas
Copyright (c) 2004-07 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
@@ -60,11 +60,6 @@ public class Sketch {
*/
boolean modified;
/**
* true if this file has not yet been given a name by the user
*/
boolean untitled;
public File folder;
public File dataFolder;
public File codeFolder;
@@ -593,7 +588,8 @@ public class Sketch {
// make a new sketch, and i think this will rebuild the sketch menu
//editor.handleNewUnchecked();
editor.handleClose2();
//editor.handleClose2();
editor.base.handleClose(editor);
} else {
// delete the file
-357
View File
@@ -1,357 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
SketchHistory - handler for storing history information about a project
Part of the Processing project - http://processing.org
Copyright (c) 2004-06 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import javax.swing.*;
public class SketchHistory {
Editor editor;
// why things have been saved for history
static final int RUN = 5;
static final int SAVE = 6;
static final int AUTOSAVE = 7;
static final int BEAUTIFY = 8;
static final String HISTORY_SEPARATOR =
"#################################################";
JMenu menu;
// true if the sketch is read-only,
// meaning that no history will be recorded
boolean readOnlySketch;
File historyFile;
String lastRecorded;
ActionListener menuListener;
//public SketchHistory(Editor editor) {
//this.editor = editor;
//}
public SketchHistory(Sketch sketch) {
menu = new JMenu("History");
menuListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
retrieve(e.getActionCommand());
}
};
}
/// Set the path for the current sketch
public void setPath(String path, boolean readOnlySketch) {
this.readOnlySketch = true;
if (readOnlySketch) return;
historyFile = new File(path, "history.gz");
}
public void attachMenu(JMenu parent) {
//if (Preferences.getBoolean("history.recording")) {
parent.add(menu);
// should leave enabled, since can still get old history
// even if the new stuff isn't being recorded
//menu.setEnabled(Preferences.getBoolean("history.recording"));
//}
}
/// Check to see if history should be recorded.
/// mode is RUN, SAVE, AUTOSAVE, or BEAUTIFY
public void record(String program, int mode) {
if (readOnlySketch) return;
if (!Preferences.getBoolean("history.recording")) return;
if ((lastRecorded != null) &&
(lastRecorded.equals(program))) return;
String modeStr = null;
switch (mode) {
case RUN: modeStr = "run"; break;
case SAVE: modeStr = "save"; break;
case AUTOSAVE: modeStr = "autosave"; break;
case BEAUTIFY: modeStr = "beautify"; break;
}
try {
boolean noPreviousHistory = false;
ByteArrayOutputStream old = null;
if (historyFile.exists()) {
InputStream oldStream = new GZIPInputStream(new BufferedInputStream(new FileInputStream(historyFile)));
old = new ByteArrayOutputStream();
int c = oldStream.read();
while (c != -1) {
old.write(c);
c = oldStream.read();
}
//return out.toByteArray();
oldStream.close();
} else {
noPreviousHistory = true; // rebuild menu
}
OutputStream historyStream =
new GZIPOutputStream(new FileOutputStream(historyFile));
if (old != null) {
historyStream.write(old.toByteArray());
}
PrintWriter historyWriter =
new PrintWriter(new OutputStreamWriter(historyStream));
historyWriter.println();
historyWriter.println(HISTORY_SEPARATOR);
Calendar now = Calendar.getInstance();
// 2002 06 18 11 43 29
// when listing, study for descrepancies.. if all are
// 2002, then don't list the year and soforth.
// for the other end, if all minutes are unique,
// then don't show seconds
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH) + 1;
int day = now.get(Calendar.DAY_OF_MONTH);
int hour = now.get(Calendar.HOUR_OF_DAY);
int minute = now.get(Calendar.MINUTE);
int second = now.get(Calendar.SECOND);
String parseDate = year + " " + month + " " + day + " " +
hour + " " + minute + " " + second;
String readableDate = now.getTime().toString();
// increment this so sketchbook won't be mangled
// each time this format has to change
String historyVersion = "1";
//Date date = new Date();
//String datestamp = date.toString();
historyWriter.println(historyVersion + " " + modeStr + " - " +
parseDate + " - " + readableDate);
historyWriter.println();
historyWriter.println(program);
historyWriter.flush(); // ??
lastRecorded = program;
//JMenuItem menuItem = new JMenuItem(modeStr + " - " + readableDate);
JMenuItem menuItem = new JMenuItem(modeStr + " - " + readableDate);
menuItem.addActionListener(menuListener);
menu.insert(menuItem, 2);
historyWriter.flush();
historyWriter.close();
if (noPreviousHistory) {
// to get add the actual menu, to get the 'clear' item in there
//rebuildMenu(historyFile.getPath());
rebuildMenu();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public void retrieve(String selection) {
//System.out.println("sel '" + selection + "'");
String readableDate =
selection.substring(selection.indexOf("-") + 2);
// make history for the current guy
record(editor.textarea.getText(), AUTOSAVE);
// mark editor text as having been edited
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(historyFile))));
String line = null;
int historyCount = 0;
String historyList[] = new String[100];
try {
boolean found = false;
while ((line = reader.readLine()) != null) {
//System.out.println("->" + line);
if (line.equals(HISTORY_SEPARATOR)) {
line = reader.readLine();
if (line.indexOf(readableDate) != -1) { // this is the one
found = true;
break;
}
}
}
if (found) {
// read lines until the next separator
line = reader.readLine(); // ignored
//String sep = System.getProperty("line.separator");
StringBuffer buffer = new StringBuffer();
while ((line = reader.readLine()) != null) {
if (line.equals(HISTORY_SEPARATOR)) break;
//textarea.append(line + sep);
//buffer.append(line + sep); // JTextPane wants only \n going in
buffer.append(line + "\n");
//System.out.println("'" + line + "'");
}
//textarea.editorSetText(buffer.toString());
editor.changeText(buffer.toString(), true);
lastRecorded = editor.textarea.getText();
editor.setSketchModified(false);
} else {
System.err.println("couldn't find history entry for " +
"'" + readableDate + "'");
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
// class HistoryMenuListener implements ActionListener {
// public void actionPerformed(ActionEvent e) {
// editor.selectHistory(e.getActionCommand);
// }
// }
//public void rebuildHistoryMenu(String path) {
//rebuildHistoryMenu(historyMenu, path);
//}
//public void rebuildHistoryMenu(Menu menu, String path) {
public void rebuildMenu() { //String path) {
//if (!recordingHistory) return;
//if (!Preferences.getBoolean("history.recording")) return;
menu.removeAll();
//File hfile = new File(path);
//if (!hfile.exists()) return; // no history yet
if (!historyFile.exists()) return;
JMenuItem item = new JMenuItem("Clear History");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (!historyFile.delete()) {
//System.err.println("couldn't erase history");
Base.showWarning("History Problem",
"Could not erase history", null);
}
rebuildMenu();
//SketchHistory.this.rebuildMenu(historyFile.getPath());
}
});
menu.add(item);
menu.addSeparator();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(historyFile))));
String line = null;
int historyCount = 0;
String historyList[] = new String[100];
try {
while ((line = reader.readLine()) != null) {
//while (line = reader.readLine()) {
//while (true) { line = reader.readLine();
//if (line == null) continue;
//System.out.println("line: " + line);
if (line.equals(HISTORY_SEPARATOR)) {
// next line is the good stuff
line = reader.readLine();
int version =
Integer.parseInt(line.substring(0, line.indexOf(' ')));
if (version == 1) {
String whysub = line.substring(2); // after "1 "
String why = whysub.substring(0, whysub.indexOf(" -"));
//System.out.println("'" + why + "'");
String readable = line.substring(line.lastIndexOf("-") + 2);
if (historyList.length == historyCount) {
String temp[] = new String[historyCount*2];
System.arraycopy(historyList, 0, temp, 0, historyCount);
historyList = temp;
}
historyList[historyCount++] = why + " - " + readable;
} // otherwise don't know what to do
}
}
//System.out.println(line);
} catch (IOException e) {
e.printStackTrace();
}
// add the items to the menu in reverse order
//ActionListener historyMenuListener =
// new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// editor.retrieveHistory(e.getActionCommand());
//}
//};
for (int i = historyCount-1; i >= 0; --i) {
JMenuItem mi = new JMenuItem(historyList[i]);
mi.addActionListener(menuListener);
menu.add(mi);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
*/
-131
View File
@@ -1,131 +0,0 @@
package processing.app;
import javax.swing.SwingUtilities;
/**
* This is the 3rd version of SwingWorker (also known as
* SwingWorker 3), an abstract class that you subclass to
* perform GUI-related work in a dedicated thread. For
* instructions on and examples of using this class, see:
*
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
*
* Note that the API changed slightly in the 3rd version:
* You must now invoke start() on the SwingWorker after
* creating it.
*/
public abstract class SwingWorker {
private Object value; // see getValue(), setValue()
/**
* Class to maintain reference to current worker thread
* under separate synchronization control.
*/
private static class ThreadVar {
private Thread thread;
ThreadVar(Thread t) { thread = t; }
synchronized Thread get() { return thread; }
synchronized void clear() { thread = null; }
}
private ThreadVar threadVar;
/**
* Get the value produced by the worker thread, or null if it
* hasn't been constructed yet.
*/
protected synchronized Object getValue() {
return value;
}
/**
* Set the value produced by worker thread
*/
private synchronized void setValue(Object x) {
value = x;
}
/**
* Compute the value to be returned by the <code>get</code> method.
*/
public abstract Object construct();
/**
* Called on the event dispatching thread (not on the worker thread)
* after the <code>construct</code> method has returned.
*/
public void finished() {
}
/**
* A new method that interrupts the worker thread. Call this method
* to force the worker to stop what it's doing.
*/
public void interrupt() {
Thread t = threadVar.get();
if (t != null) {
t.interrupt();
}
threadVar.clear();
}
/**
* Return the value created by the <code>construct</code> method.
* Returns null if either the constructing thread or the current
* thread was interrupted before a value was produced.
*
* @return the value created by the <code>construct</code> method
*/
public Object get() {
while (true) {
Thread t = threadVar.get();
if (t == null) {
return getValue();
}
try {
t.join();
}
catch (InterruptedException e) {
Thread.currentThread().interrupt(); // propagate
return null;
}
}
}
/**
* Start a thread that will call the <code>construct</code> method
* and then exit.
*/
public SwingWorker() {
final Runnable doFinished = new Runnable() {
public void run() { finished(); }
};
Runnable doConstruct = new Runnable() {
public void run() {
try {
setValue(construct());
}
finally {
threadVar.clear();
}
SwingUtilities.invokeLater(doFinished);
}
};
Thread t = new Thread(doConstruct);
threadVar = new ThreadVar(t);
}
/**
* Start the worker thread.
*/
public void start() {
Thread t = threadVar.get();
if (t != null) {
t.start();
}
}
}
+1 -2
View File
@@ -107,8 +107,7 @@ cd ../..
cd app
#CLASSPATH="../build/linux/work/lib/core.jar:../build/linux/work/lib/mrj.jar:../build/linux/work/lib/antlr.jar:../build/linux/work/lib/oro.jar:../build/linux/work/lib/registry.jar:../build/linux/work/java/lib/rt.jar"
CLASSPATH="../build/linux/work/lib/core.jar:../build/linux/work/lib/antlr.jar:../build/linux/work/lib/oro.jar:../build/linux/work/lib/registry.jar:../build/linux/work/java/lib/rt.jar"
CLASSPATH="../build/linux/work/lib/core.jar:../build/linux/work/lib/apple.jar:../build/linux/work/lib/antlr.jar:../build/linux/work/lib/oro.jar:../build/linux/work/lib/registry.jar:../build/linux/work/java/lib/rt.jar"
../build/linux/work/jikes -target 1.3 +D -classpath $CLASSPATH:../build/linux/work/classes -d ../build/linux/work/classes src/processing/app/*.java src/processing/app/preproc/*.java src/processing/app/syntax/*.java src/processing/app/tools/*.java
+1 -2
View File
@@ -145,8 +145,7 @@ fi
cd app
#CLASSPATH="..\\build\\windows\\work\\lib\\core.jar;..\\build\\windows\\work\\lib\\mrj.jar;..\\build\\windows\\work\\lib\antlr.jar;..\\build\\windows\\work\\lib\\oro.jar;..\\build\\windows\\work\\lib\\registry.jar;..\\build\\windows\\work\\java\\lib\\rt.jar"
CLASSPATH="..\\build\\windows\\work\\lib\\core.jar;..\\build\\windows\\work\\lib\antlr.jar;..\\build\\windows\\work\\lib\\oro.jar;..\\build\\windows\\work\\lib\\registry.jar;..\\build\\windows\\work\\java\\lib\\rt.jar"
CLASSPATH="..\\build\\windows\\work\\lib\\core.jar;..\\build\\windows\\work\\lib\\apple.jar;..\\build\\windows\\work\\lib\antlr.jar;..\\build\\windows\\work\\lib\\oro.jar;..\\build\\windows\\work\\lib\\registry.jar;..\\build\\windows\\work\\java\\lib\\rt.jar"
# compile the code as java 1.3, so that the application will run and
# show the user an error, rather than crapping out with some strange