Skip to content

Commit 862721e

Browse files
committed
sensible renaming
1 parent beac2df commit 862721e

3 files changed

Lines changed: 27 additions & 21 deletions

File tree

app/src/processing/app/Base.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ protected Editor handleOpen(String path, boolean untitled,
871871
if (tab.getFile().equals(file)) {
872872
editor.toFront();
873873
// move back to the top of the recent list
874-
Recent.handle(editor);
874+
Recent.append(editor);
875875
return editor;
876876
}
877877
}
@@ -899,7 +899,7 @@ protected Editor handleOpen(String path, boolean untitled,
899899
// opened successfully, let's go to work
900900
editor.getSketch().setUntitled(untitled);
901901
editors.add(editor);
902-
Recent.handle(editor);
902+
Recent.append(editor);
903903

904904
// now that we're ready, show the window
905905
// (don't do earlier, cuz we might move it based on a window being closed)

app/src/processing/app/Sketch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ public void run() {
966966
setUntitled(false);
967967

968968
// Add this sketch back using the new name
969-
Recent.handle(editor);
969+
Recent.append(editor);
970970

971971
// let Editor know that the save was successful
972972
return true;
@@ -998,7 +998,7 @@ protected void updateInternal(String sketchName, File sketchFolder) {
998998
// System.out.println("modified is now " + modified);
999999
editor.updateTitle();
10001000
editor.getBase().rebuildSketchbookMenus();
1001-
Recent.handleRename(editor, oldPath);
1001+
Recent.rename(editor, oldPath);
10021002
// editor.header.rebuild();
10031003
}
10041004

app/src/processing/app/ui/Recent.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@
2121

2222
package processing.app.ui;
2323

24-
import java.awt.event.*;
25-
import java.io.*;
24+
import java.awt.event.ActionEvent;
25+
import java.awt.event.ActionListener;
26+
import java.io.BufferedReader;
27+
import java.io.File;
28+
import java.io.IOException;
29+
import java.io.PrintWriter;
2630
import java.util.ArrayList;
2731
import java.util.List;
2832

29-
import javax.swing.*;
33+
import javax.swing.JMenu;
34+
import javax.swing.JMenuItem;
3035

3136
import processing.app.Base;
3237
import processing.app.Language;
@@ -128,7 +133,8 @@ static private void updateMenu(JMenu menu) {
128133
}
129134

130135

131-
static private void updateMenuRecord(JMenu menu, final Record rec, String sketchbookPath) {
136+
static private void updateMenuRecord(JMenu menu, final Record rec,
137+
String sketchbookPath) {
132138
try {
133139
String recPath = new File(rec.getPath()).getParent();
134140
String purtyPath = null;
@@ -275,7 +281,7 @@ synchronized static public void remove(Editor editor) {
275281
* entry on the Recent queue. If the sketch is already in the list, it is
276282
* first removed so it doesn't show up multiple times.
277283
*/
278-
synchronized static public void handle(Editor editor) {
284+
synchronized static public void append(Editor editor) {
279285
if (!editor.getSketch().isUntitled()) {
280286
// If this sketch is already in the menu, remove it
281287
remove(editor);
@@ -295,18 +301,18 @@ synchronized static public void handle(Editor editor) {
295301
}
296302
}
297303

298-
//handles renaming done within processing
299-
synchronized static public void handleRename(Editor editor,String oldPath){
300-
if (records.size() == Preferences.getInteger("recent.count")) {
301-
records.remove(0); // remove the first entry
302-
}
303-
int index = findRecord(oldPath);
304-
//check if record exists
305-
if (index != -1) {
306-
records.remove(index);
307-
}
308-
records.add(new Record(editor));
309-
save();
304+
305+
synchronized static public void rename(Editor editor, String oldPath) {
306+
if (records.size() == Preferences.getInteger("recent.count")) {
307+
records.remove(0); // remove the first entry
308+
}
309+
int index = findRecord(oldPath);
310+
//check if record exists
311+
if (index != -1) {
312+
records.remove(index);
313+
}
314+
records.add(new Record(editor));
315+
save();
310316
}
311317

312318

0 commit comments

Comments
 (0)