mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
working on async method for rebuilding sketch menu
This commit is contained in:
+5
-3
@@ -1563,7 +1563,8 @@ public class Editor extends JFrame
|
||||
if (!oldPath.equals(newPath)) {
|
||||
if (Base.calcFolderSize(sketch.folder) == 0) {
|
||||
Base.removeDir(sketch.folder);
|
||||
sketchbook.rebuildMenus();
|
||||
//sketchbook.rebuildMenus();
|
||||
sketchbook.rebuildMenusAsync();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) { } // oh well
|
||||
@@ -1695,7 +1696,8 @@ public class Editor extends JFrame
|
||||
message(EMPTY);
|
||||
}
|
||||
// rebuild sketch menu in case a save-as was forced
|
||||
sketchbook.rebuildMenus();
|
||||
//sketchbook.rebuildMenus();
|
||||
sketchbook.rebuildMenusAsync();
|
||||
|
||||
} catch (Exception e) {
|
||||
// show the error as a message in the window
|
||||
@@ -1720,7 +1722,7 @@ public class Editor extends JFrame
|
||||
try {
|
||||
if (sketch.saveAs()) {
|
||||
message("Done Saving.");
|
||||
sketchbook.rebuildMenus();
|
||||
sketchbook.rebuildMenusAsync();
|
||||
} else {
|
||||
message("Save Cancelled.");
|
||||
}
|
||||
|
||||
+16
-1
@@ -224,7 +224,7 @@ public class Sketchbook {
|
||||
}
|
||||
|
||||
// make a note of a newly added sketch in the sketchbook menu
|
||||
rebuildMenus();
|
||||
rebuildMenusAsync();
|
||||
|
||||
// now open it up
|
||||
//handleOpen(newbieName, newbieFile, newbieDir);
|
||||
@@ -340,6 +340,19 @@ public class Sketchbook {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Asynchronous version of menu rebuild to be used on 'new' and 'save',
|
||||
* to prevent the interface from locking up until the menus are done.
|
||||
*/
|
||||
public void rebuildMenusAsync() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
rebuildMenus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rebuild the menu full of sketches based on the
|
||||
* contents of the sketchbook.
|
||||
@@ -349,6 +362,7 @@ public class Sketchbook {
|
||||
* the menu will disappear from its original location.
|
||||
*/
|
||||
public void rebuildMenus() {
|
||||
//EditorConsole.systemOut.println("rebuilding menus");
|
||||
try {
|
||||
// rebuild file/open and the toolbar popup menus
|
||||
buildMenu(openMenu);
|
||||
@@ -373,6 +387,7 @@ public class Sketchbook {
|
||||
"sketchbook menu. Things might get a little\n" +
|
||||
"kooky around here.", e);
|
||||
}
|
||||
//EditorConsole.systemOut.println("done rebuilding menus");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user