@@ -45,20 +45,17 @@ public class Recent {
4545 static final String FILENAME = "recent.txt" ;
4646 static final String VERSION = "2" ;
4747
48- Base base ;
49- File file ;
50- /** How many recent sketches to remember. */
51- int remember ;
52- ArrayList <Record > records ;
48+ static Base base ;
49+ static File file ;
50+ static List <Record > records ;
5351 /** actual menu used in the primary menu bar */
54- JMenu mainMenu ;
52+ static JMenu mainMenu ;
5553 /** copy of the menu to use in the toolbar */
56- JMenu toolbarMenu ;
54+ static JMenu toolbarMenu ;
5755
5856
59- public Recent (Base base ) {
60- this .base = base ;
61- remember = Preferences .getInteger ("recent.count" );
57+ static public void init (Base b ) {
58+ base = b ;
6259 file = Base .getSettingsFile (FILENAME );
6360 mainMenu = new JMenu (Language .text ("menu.file.recent" ));
6461 toolbarMenu = new JMenu (Language .text ("menu.file.open" ));
@@ -71,7 +68,7 @@ public Recent(Base base) {
7168 }
7269
7370
74- protected void load () throws IOException {
71+ static protected void load () throws IOException {
7572 records = new ArrayList <Record >();
7673 if (file .exists ()) {
7774 BufferedReader reader = PApplet .createReader (file );
@@ -86,7 +83,7 @@ protected void load() throws IOException {
8683 if (new File (line ).exists ()) { // don't add ghost entries
8784 records .add (new Record (line ));
8885 } else {
89- Base .log (this , "ghost file: " + line );
86+ Base .log ("ghost file: " + line );
9087 }
9188 }
9289 }
@@ -97,7 +94,7 @@ protected void load() throws IOException {
9794 }
9895
9996
100- protected void save () {
97+ static protected void save () {
10198 PrintWriter writer = PApplet .createWriter (file );
10299 writer .println (VERSION );
103100 for (Record record : records ) {
@@ -112,17 +109,17 @@ protected void save() {
112109 }
113110
114111
115- public JMenu getMenu () {
112+ static public JMenu getMenu () {
116113 return mainMenu ;
117114 }
118115
119116
120- public JMenu getToolbarMenu () {
117+ static public JMenu getToolbarMenu () {
121118 return toolbarMenu ;
122119 }
123120
124121
125- private void updateMenu (JMenu menu ) {
122+ static private void updateMenu (JMenu menu ) {
126123 menu .removeAll ();
127124 String sketchbookPath = Base .getSketchbookFolder ().getAbsolutePath ();
128125 for (Record rec : records ) {
@@ -131,7 +128,7 @@ private void updateMenu(JMenu menu) {
131128 }
132129
133130
134- private void updateMenuRecord (JMenu menu , final Record rec , String sketchbookPath ) {
131+ static private void updateMenuRecord (JMenu menu , final Record rec , String sketchbookPath ) {
135132 try {
136133 String recPath = new File (rec .getPath ()).getParent ();
137134 String purtyPath = null ;
@@ -231,7 +228,7 @@ public void actionPerformed(ActionEvent e) {
231228 }
232229
233230
234- synchronized public void remove (Editor editor ) {
231+ synchronized static public void remove (Editor editor ) {
235232 int index = findRecord (editor .getSketch ().getMainFilePath ());
236233 if (index != -1 ) {
237234 records .remove (index );
@@ -278,12 +275,12 @@ synchronized public void remove(Editor editor) {
278275 * entry on the Recent queue. If the sketch is already in the list, it is
279276 * first removed so it doesn't show up multiple times.
280277 */
281- synchronized public void handle (Editor editor ) {
278+ synchronized static public void handle (Editor editor ) {
282279 if (!editor .getSketch ().isUntitled ()) {
283280 // If this sketch is already in the menu, remove it
284281 remove (editor );
285282
286- if (records .size () == remember ) {
283+ if (records .size () == Preferences . getInteger ( "recent.count" ) ) {
287284 records .remove (0 ); // remove the first entry
288285 }
289286
@@ -299,8 +296,8 @@ synchronized public void handle(Editor editor) {
299296 }
300297
301298//handles renaming done within processing
302- synchronized public void handleRename (Editor editor ,String oldPath ){
303- if (records .size () == remember ) {
299+ synchronized static public void handleRename (Editor editor ,String oldPath ){
300+ if (records .size () == Preferences . getInteger ( "recent.count" ) ) {
304301 records .remove (0 ); // remove the first entry
305302 }
306303 int index = findRecord (oldPath );
@@ -313,7 +310,7 @@ synchronized public void handleRename(Editor editor,String oldPath){
313310 }
314311
315312
316- int findRecord (String path ) {
313+ static int findRecord (String path ) {
317314 for (int i = 0 ; i < records .size (); i ++) {
318315 if (path .equals (records .get (i ).path )) {
319316 return i ;
0 commit comments