detect mode and library example folders for recent menu

This commit is contained in:
benfry
2012-07-24 03:05:06 +00:00
parent 60e801be85
commit 80c873bc7f
4 changed files with 64 additions and 23 deletions

View File

@@ -289,9 +289,6 @@ public class Base {
// Get the sketchbook path, and make sure it's set properly
determineSketchbookFolder();
// Needs to happen after the sketchbook folder has been located
recent = new Recent(this);
// Delete all modes and tools that have been flagged for deletion before
// they are initialized by an editor.
ArrayList<InstalledContribution> contribs = new ArrayList<InstalledContribution>();
@@ -306,6 +303,11 @@ public class Base {
buildCoreModes();
rebuildContribModes();
// Needs to happen after the sketchbook folder has been located.
// Also relies on the modes to be loaded so it knows what can be
// marked as an example.
recent = new Recent(this);
String lastModeIdentifier = Preferences.get("last.sketch.mode");
if (lastModeIdentifier == null) {
nextMode = coreModes[0];

View File

@@ -45,7 +45,7 @@ public abstract class Mode {
public ArrayList<Library> coreLibraries;
public ArrayList<Library> contribLibraries;
/** Library folder for core. (Used for OpenGL in particular.) */
protected Library coreLibrary;
@@ -150,8 +150,8 @@ public abstract class Mode {
public Library getCoreLibrary() {
return null;
}
public Library getLibrary(String pkgName) throws SketchException {
ArrayList<Library> libraries = importToLibraryTable.get(pkgName);
if (libraries == null) {

View File

@@ -112,9 +112,50 @@ public class Recent {
if (purtyPath.startsWith(sketchbookPath)) {
purtyPath = "sketchbook \u2192 " +
purtyPath.substring(sketchbookPath.length() + 1);
} else {
ArrayList<Mode> modes = base.getModeList();
for (Mode mode : modes) {
File examplesFolder = mode.getExamplesFolder();
String examplesPath = examplesFolder.getAbsolutePath();
if (purtyPath.startsWith(examplesPath)) {
String modePrefix = mode.getTitle();
if (mode.getTitle().equals("Standard")) {
modePrefix = ""; // "Standard examples" is dorky
}
purtyPath = modePrefix + "examples \u2192 " +
purtyPath.substring(examplesPath.length() + 1);
break;
}
if (mode.coreLibraries != null) {
for (Library lib : mode.coreLibraries) {
examplesFolder = lib.getExamplesFolder();
examplesPath = examplesFolder.getAbsolutePath();
if (purtyPath.startsWith(examplesPath)) {
purtyPath = lib.getName() + " examples \u2192 " +
purtyPath.substring(examplesPath.length() + 1);
break;
}
}
}
if (mode.contribLibraries != null) {
for (Library lib : mode.contribLibraries) {
examplesFolder = lib.getExamplesFolder();
examplesPath = examplesFolder.getAbsolutePath();
if (purtyPath.startsWith(examplesPath)) {
purtyPath = lib.getName() + " examples \u2192 " +
purtyPath.substring(examplesPath.length() + 1);
break;
}
}
}
}
}
JMenuItem item = new JMenuItem(rec.getName() + " | " + purtyPath);
// JMenuItem item = new JMenuItem(rec.getName() + " | " + purtyPath);
JMenuItem item = new JMenuItem(purtyPath);
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Base will call handle() (below) which will cause this entry to

View File

@@ -23,13 +23,13 @@ o move initRequirements check for JVM to Runner
X remove the shift designation for new and open to open in same editor or not
X code is just getting too messy
X Opening sketch via editor window open-menu ignores mode
_ http://code.google.com/p/processing/issues/detail?id=1034
X http://code.google.com/p/processing/issues/detail?id=1034
X add 64-bit Linux version to the next download
X revisions.txt should have Windows line endings
X change in SVN to be platform specific
X didn't actually do it
_ don't use tmp folder for sketches?
o don't use tmp folder for sketches?
_ or restrict more things like "show sketch folder"
_ don't allow adding files w/o saving
@@ -39,8 +39,9 @@ X use wget to grab it if it doesn't exist
o and include an md5hash to see if the file is correct
X not necessary -- ant takes care of it
recent/open
open/base/recent
X recent sketches
X http://code.google.com/p/processing/issues/detail?id=188
X add EditorState class, device-aware placement
o not properly handling other odd cases
X don't pollute the recent menu with un-saved sketches
@@ -50,24 +51,22 @@ o remove pref for restoring sketches
X implement recent sketches menu
X add "recent files" list to open menu?
o http://dev.processing.org/bugs/show_bug.cgi?id=1335
o don't re-open new window on top of another
X changing how this is handled
X detect mode and library example folders for recent menu
_ don't re-open new window on top of another
_ consider window menu
_ http://code.google.com/p/processing/issues/detail?id=545
_ multiple sketch windows.. having a windows menu?
_ examples button on toolbar? open / recent / sketchbook?
restoring sketches
_ save window positions on quit, and restore them (w/ a preference?)
_ new windows use same mode and dimensions as topmost window
_ saved window position problematic with multiple monitors
_ http://code.google.com/p/processing/issues/detail?id=27
_ Closing the last window doesn't cause PDE to save it's position/contents/etc
_ http://code.google.com/p/processing/issues/detail?id=103
_ consider window menu
_ http://code.google.com/p/processing/issues/detail?id=545
recent sketches: http://code.google.com/p/processing/issues/detail?id=188
_ multiple sketch windows.. having a windows menu?
_ examples button on toolbar? open / recent / sketchbook?
_ Closing the last window doesn't cause PDE to save its position/contents/etc
_ (when the pref for close last window = quit is set)
_ http://dev.processing.org/bugs/show_bug.cgi?id=835
_ not remembering window size/placement preferences
_ http://dev.processing.org/bugs/show_bug.cgi?id=837
_ Blank sketch opened even if opening an existing sketch by double-clicking
@@ -80,7 +79,6 @@ _ GraphicsDevice gd = frame.getGraphicsConfiguration().getDevice();
_ make sure that the application is within the bounds of the current display?
_ (from 0, 0 to width, height)
_ messy since some displays have negative coords
_ http://dev.processing.org/bugs/show_bug.cgi?id=72
_ http://code.google.com/p/processing/issues/detail?id=27
Base.restoreSketches() has commented out code that checked for out of bounds windows with the preferences last.window.x and last.window.y. These prefs don't exist anymore, but it would be quick to implement it again using last.sketch<i>.location instead. It would probably result in less code, because it would mean we could get rid of the windowPositionValid stuff.