diff --git a/app/PdeBase.java b/app/PdeBase.java index 290806c16..cfb168dc5 100644 --- a/app/PdeBase.java +++ b/app/PdeBase.java @@ -6,6 +6,63 @@ import java.util.*; import java.awt.event.*; +/* + + +[ File ] +New +Open -> +Save +Duplicate +Export +- +Proce55ing.net +Reference +- +Quit + + +[ Open-> (Sketchbook) ] +sketch-001 +sketch-002 +sketch-003 +-- +Course -> +Examples -> +Users -> +Proce55ing.net -> +-- +Refresh List +Compile All + + +[ Edit ] +Undo +- +Cut +Copy +Paste +- +Select all + + +[ Sketch ] +Play +Present +Stop + + +new sketch just makes a new sketch, doesn't ask for name +tries to do numbered version based on sketches already present + +last section is configurable +choose a name for the entries, and a url for the base of the code + file urls will be local, don't include file:/// to user + http urls are base of directory where the code is found + +*/ + + public class PdeBase /*extends Component*/ implements ActionListener { //static PdeApplet applet; static Properties properties; @@ -19,13 +76,16 @@ public class PdeBase /*extends Component*/ implements ActionListener { static Frame frame; WindowAdapter windowListener; + File sketchbookFolder; + String sketchbookPath; + static final String WINDOW_TITLE = "Proce55ing"; + static public void main(String args[]) { PdeBase app = new PdeBase(); } - public PdeBase() { frame = new Frame(WINDOW_TITLE); @@ -107,6 +167,32 @@ public class PdeBase /*extends Component*/ implements ActionListener { //add("Center", editor); frame.add("Center", editor); + MenuBar menubar = new MenuBar(); + + Menu menu; + MenuItem item; + + fileOpenItem = new MenuItem("Open"); + + menu = new Menu("File"); + menu.add(new MenuItem("New")); + menu.add(new MenuItem("Open")); + menu.add(new MenuItem("New")); + menu.add(new MenuItem("New")); + menu.add(new MenuItem("New")); + menu.add(new MenuItem("New")); + + + /* + Menu fileMenu = new Menu("File"); + MenuItem mi; + goodies.add(new MenuItem("Save QuickTime movie...")); + goodies.add(new MenuItem("Quit")); + goodies.addActionListener(this); + menubar.add(goodies); + frame.setMenuBar(menubar); + */ + Insets insets = frame.getInsets(); Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screen = tk.getScreenSize(); @@ -129,6 +215,91 @@ public class PdeBase /*extends Component*/ implements ActionListener { } + // listener for sketchbk items uses getParent() to figure out + // the directories above it + + class SketchbookMenuListener implements ActionListener { + //PdeEditor editor; + String path; + + public SketchbookMenuListener(/*PdeEditor editor,*/ String path) { + //this.editor = editor; + this.path = path; + } + + public void actionPerformed(ActionEvent e) { + //if (e.getActionCommand().equals(NEW_SKETCH_ITEM)) { + //editor.handleNew(); + + //} else { + editor.sketchbookOpen(path + File.separator + e.getActionCommand()); + //} + } + } + + + public void rebuildSketchbookMenu(Menu menu) { + menu.removeAll(); + + try { + //MenuItem newSketchItem = new MenuItem("New Sketch"); + //newSketchItem.addActionListener(this); + //menu.add(newSkechItem); + //menu.addSeparator(); + + sketchbookFolder = new File("sketchbook"); + sketchbookPath = sketchbookFolder.getCanonicalPath(); + + + // files for the current user (for now, most likely 'default') + + // header knows what the current user is + String userPath = sketchbookPath + File.separator + header.user; + + SketchbookMenuListener userMenuListener = + new SketchbookMenuListener(userPath); + + String entries[] = new File(userPath).list(); + for (int j = 0; j < entries.length; j++) { + if ((entries[j].equals(".")) || + (entries[j].equals(".."))) continue; + MenuItem item = new MenuItem(entries[j]); + item.addActionListener(userMenuListener); + menu.add(item); + //submenu.add(entries[j]); + } + menu.addSeparator(); + + + // other available subdirectories + + String toplevel[] = sketchbookFolder.list(); + for (int i = 0; i < toplevel; i++) { + if ((toplevel[i].equals(header.user)) || + (toplevel[i].equals(".")) || + (toplevel[i].equals(".."))) continue; + + Menu subMenu = new Menu(toplevel[i]); + File subFolder = new File(sketchbookFolder, toplevel[i]); + String subPath = subfolder.getCanonicalPath(); + SketchbookMenuListener subMenuListener = + new SketchbookMenuListener(subPath); + + String entries[] = subfolder.list(); + for (int j = 0; j < entries.length; j++) { + if ((entries[j].equals(".")) || + (entries[j].equals(".."))) continue; + submenu.add(entries[j]); + } + + menu.add(submenu); + } + menu.addSeparator(); + + + Menu skmenu = new Menu("Sketchbook"); + } + public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); //if (command.equals("Save QuickTime movie...")) { diff --git a/app/PdeEditor.java b/app/PdeEditor.java index f855e34f2..6d5521684 100644 --- a/app/PdeEditor.java +++ b/app/PdeEditor.java @@ -8,63 +8,6 @@ import java.util.*; import java.util.zip.*; -/* - - -[ File ] -New -Open -> -Save -Duplicate -Export -- -Proce55ing.net -Reference -- -Quit - - -[ Open-> (Sketchbook) ] -sketch-001 -sketch-002 -sketch-003 --- -Course -> -Examples -> -Users -> -Proce55ing.net -> --- -Refresh List -Compile All - - -[ Edit ] -Undo -- -Cut -Copy -Paste -- -Select all - - -[ Sketch ] -Play -Present -Stop - - -new sketch just makes a new sketch, doesn't ask for name -tries to do numbered version based on sketches already present - -last section is configurable -choose a name for the entries, and a url for the base of the code - file urls will be local, don't include file:/// to user - http urls are base of directory where the code is found - -*/ - - public class PdeEditor extends Panel { static final String DEFAULT_PROGRAM = "// type program here\n"; @@ -265,6 +208,7 @@ public class PdeEditor extends Panel { } buttons.clear(); } + */ public void handleNew() { @@ -314,6 +258,10 @@ public class PdeEditor extends Panel { */ + public void sketchbookOpen() { + } + + public void doOpen() { FileDialog fd = new FileDialog(new Frame(), "Open a PDE program...", diff --git a/todo.txt b/todo.txt index afc35d1e9..397d7eeb5 100644 --- a/todo.txt +++ b/todo.txt @@ -1,11 +1,9 @@ 0031 +_ make all windows 120x120? +_ default program should be large, 300x200 or so + ui -a _ sketch.properties contains the last program run -a _ also the window positions, etc -a _ if it doesn't exist, starts with a new project -a _ for a new project, name it untitled-0001 or as appropriate -a _ so that previous projects aren't written over a _ 'open' button is a switch-to button a _ pops up list of everything in the sketchbook a _ first item is 'new sketch', followed by delimeter @@ -17,6 +15,17 @@ a _ export could be three circles in a row, overlapping a _ everything is a project.. what about short snippets of code? a _ this version won't be able to access everything from scrapbook a _ (that requires a more robust class loader) +a _ sketch.properties contains the last program run +a _ also the window positions, etc +a _ if it doesn't exist, starts with a new project +a _ for a new project, name it untitled-0001 or as appropriate +a _ so that previous projects aren't written over + +users +a _ if default user, don't show the 'user' string in pde window +a _ item in pde.properties to set the name of the current user +_ menu option to change username/login +_ if new user, offer to rename 'default' if it contains things file structure for export a _ exporting to applet/.jar file