From 7d3bf8bb245204fa53cb2cbb1ec4aa1461e621af Mon Sep 17 00:00:00 2001 From: benfry Date: Mon, 21 Jun 2004 19:43:20 +0000 Subject: [PATCH] sort sketches in their menu, also rebuild sketch menu after save just in case --- processing/app/PdeEditor.java | 2 ++ processing/app/PdeSketchbook.java | 22 ++++++++++++++++++++-- processing/todo.txt | 20 +++++++++++--------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/processing/app/PdeEditor.java b/processing/app/PdeEditor.java index 3dd8c16bf..871a81033 100644 --- a/processing/app/PdeEditor.java +++ b/processing/app/PdeEditor.java @@ -1235,6 +1235,8 @@ public class PdeEditor extends JFrame try { sketch.save(); message("Done Saving."); + // rebuild sketch menu in case a save-as was forced + sketchbook.rebuildMenu(); } catch (Exception e) { // show the error as a message in the window diff --git a/processing/app/PdeSketchbook.java b/processing/app/PdeSketchbook.java index 52297ec66..3a6f930c6 100644 --- a/processing/app/PdeSketchbook.java +++ b/processing/app/PdeSketchbook.java @@ -4,8 +4,8 @@ PdeSketchbook - handles sketchbook mechanics for the sketch menu Part of the Processing project - http://processing.org - Except where noted, code is written by Ben Fry - Copyright (c) 2001-03 Massachusetts Institute of Technology + Except where noted, code is written by Ben Fry and is + 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 @@ -247,6 +247,24 @@ public class PdeSketchbook { if (!folder.isDirectory()) return false; String list[] = folder.list(); + // alphabetize list, since it's not always alpha order + // use cheapie bubble-style sort which should be fine + // since not a tone of files, and things will mostly be sorted + // or may be completely sorted already by the os + for (int i = 0; i < list.length; i++) { + int who = i; + for (int j = i+1; j < list.length; j++) { + if (list[j].compareTo(list[who]) < 0) { + who = j; // this guy is earlier in the alphabet + } + } + if (who != i) { // swap with someone if changes made + String temp = list[who]; + list[who] = list[i]; + list[i] = temp; + } + } + //SketchbookMenuListener listener = //new SketchbookMenuListener(folder.getAbsolutePath()); diff --git a/processing/todo.txt b/processing/todo.txt index 8d395e66d..fdc62498f 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -69,8 +69,15 @@ X on application open, override 'open' mode X and just open an empty sketch in the sketchbook folder X when 'skNew' is cancelled in 'open' mode, nullpointerex at the top +040622 monday afternoon +X if a "save as" is forced, make sure that the sketchbook menu is updated +X sort sketch names in the open menu +X http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1074981609 + +_ warn about writing non-1.1 code. +_ will jikes do it if the -source is set to 1.1? +_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1079867179;start=0 -_ if a "save as" is forced, make sure that the sketchbook menu is updated _ dashes shouldn't be allowed in filenames for sketches _ actually, lost the naming stuff because now using FileDialog _ can this requirement just be on the pde file, not the directory? @@ -97,7 +104,9 @@ _ i.e. flash programs 'import' all data, etc _ same with how imovie works _ comments -> embedding in applet text? (ala javadoc) _ would this help casey with the examples? - +_ how to handle .pde vs .java +_ how to determine what the 'main' file is +_ sun won't want us to say things are .java when they aren't _ NullPointerException when alt is pressed _ might be something to do with the applet frame being an awt not swing @@ -137,13 +146,6 @@ _ include 'netscape.javascript' as a library to be added _ but don't export it.. ugh.. -SKETCHBOOK -_ sort sketch names in the open menu -_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1074981609 -_ warn about writing non-1.1 code. -_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1079867179;start=0 - - LIBRARIES _ "add library" menu item and submenu _ iterate through the 'library' folders