| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -97,7 +97,7 @@ public class Base { | |||
| 97 | 97 | ||
| 98 | 98 | private JMenu sketchbookMenu; | |
| 99 | 99 | ||
| 100 | - private Recent recent; | ||
| 100 | + // private Recent recent; | ||
| 101 | 101 | ||
| 102 | 102 | // Used by handleOpen(), this saves the chooser to remember the directory. | |
| 103 | 103 | // Doesn't appear to be necessary with the AWT native file dialog. | |
@@ -277,7 +277,8 @@ public Base(String[] args) throws Exception { | |||
| 277 | 277 | // Needs to happen after the sketchbook folder has been located. | |
| 278 | 278 | // Also relies on the modes to be loaded so it knows what can be | |
| 279 | 279 | // marked as an example. | |
| 280 | - recent = new Recent(this); | ||
| 280 | + // recent = new Recent(this); | ||
| 281 | + Recent.init(this); | ||
| 281 | 282 | ||
| 282 | 283 | String lastModeIdentifier = Preferences.get("mode.last"); //$NON-NLS-1$ | |
| 283 | 284 | if (lastModeIdentifier == null) { | |
@@ -870,7 +871,7 @@ protected Editor handleOpen(String path, boolean untitled, | |||
| 870 | 871 | if (tab.getFile().equals(file)) { | |
| 871 | 872 | editor.toFront(); | |
| 872 | 873 | // move back to the top of the recent list | |
| 873 | - handleRecent(editor); | ||
| 874 | + Recent.handle(editor); | ||
| 874 | 875 | return editor; | |
| 875 | 876 | } | |
| 876 | 877 | } | |
@@ -898,7 +899,7 @@ protected Editor handleOpen(String path, boolean untitled, | |||
| 898 | 899 | // opened successfully, let's go to work | |
| 899 | 900 | editor.getSketch().setUntitled(untitled); | |
| 900 | 901 | editors.add(editor); | |
| 901 | - handleRecent(editor); | ||
| 902 | + Recent.handle(editor); | ||
| 902 | 903 | ||
| 903 | 904 | // now that we're ready, show the window | |
| 904 | 905 | // (don't do earlier, cuz we might move it based on a window being closed) | |
@@ -1034,7 +1035,7 @@ public boolean handleClose(Editor editor, boolean modeSwitch) { | |||
| 1034 | 1035 | } else { // on OS X, update the default file menu | |
| 1035 | 1036 | editor.setVisible(false); | |
| 1036 | 1037 | editor.dispose(); | |
| 1037 | - defaultFileMenu.insert(getRecentMenu(), 2); | ||
| 1038 | + defaultFileMenu.insert(Recent.getMenu(), 2); | ||
| 1038 | 1039 | activeEditor = null; | |
| 1039 | 1040 | editors.remove(editor); | |
| 1040 | 1041 | } | |
@@ -1159,6 +1160,7 @@ public void populateSketchbookMenu(JMenu menu) { | |||
| 1159 | 1160 | } | |
| 1160 | 1161 | ||
| 1161 | 1162 | ||
| 1163 | + /* | ||
| 1162 | 1164 | public JMenu getRecentMenu() { | |
| 1163 | 1165 | return recent.getMenu(); | |
| 1164 | 1166 | } | |
@@ -1179,13 +1181,12 @@ public void handleRecentRename(Editor editor, String oldPath) { | |||
| 1179 | 1181 | } | |
| 1180 | 1182 | ||
| 1181 | 1183 | ||
| 1182 | - /** | ||
| 1183 | - * Called before a sketch is renamed so that its old name is | ||
| 1184 | - * no longer in the menu. | ||
| 1185 | - */ | ||
| 1184 | + // Called before a sketch is renamed so that its old name is | ||
| 1185 | + // no longer in the menu. | ||
| 1186 | 1186 | public void removeRecent(Editor editor) { | |
| 1187 | 1187 | recent.remove(editor); | |
| 1188 | 1188 | } | |
| 1189 | + */ | ||
| 1189 | 1190 | ||
| 1190 | 1191 | ||
| 1191 | 1192 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,6 +40,7 @@ | |||
| 40 | 40 | import processing.app.ui.EditorException; | |
| 41 | 41 | import processing.app.ui.EditorState; | |
| 42 | 42 | import processing.app.ui.ExamplesFrame; | |
| 43 | + import processing.app.ui.Recent; | ||
| 43 | 44 | import processing.app.ui.SketchbookFrame; | |
| 44 | 45 | import processing.app.ui.Toolkit; | |
| 45 | 46 | import processing.core.PApplet; | |
@@ -374,13 +375,13 @@ public void insertToolbarRecentMenu() { | |||
| 374 | 375 | if (toolbarMenu == null) { | |
| 375 | 376 | rebuildToolbarMenu(); | |
| 376 | 377 | } else { | |
| 377 | - toolbarMenu.insert(base.getToolbarRecentMenu(), 1); | ||
| 378 | + toolbarMenu.insert(Recent.getToolbarMenu(), 1); | ||
| 378 | 379 | } | |
| 379 | 380 | } | |
| 380 | 381 | ||
| 381 | 382 | ||
| 382 | 383 | public void removeToolbarRecentMenu() { | |
| 383 | - toolbarMenu.remove(base.getToolbarRecentMenu()); | ||
| 384 | + toolbarMenu.remove(Recent.getToolbarMenu()); | ||
| 384 | 385 | } | |
| 385 | 386 | ||
| 386 | 387 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | 26 | import processing.app.ui.Editor; | |
| 27 | 27 | import processing.app.ui.ProgressFrame; | |
| 28 | + import processing.app.ui.Recent; | ||
| 28 | 29 | import processing.app.ui.Toolkit; | |
| 29 | 30 | import processing.core.*; | |
| 30 | 31 | ||
@@ -952,7 +953,7 @@ public void run() { | |||
| 952 | 953 | // the Recent menu so that it's not sticking around after the rename. | |
| 953 | 954 | // If untitled, it won't be in the menu, so there's no point. | |
| 954 | 955 | if (!isUntitled()) { | |
| 955 | - editor.removeRecent(); | ||
| 956 | + Recent.remove(editor); | ||
| 956 | 957 | } | |
| 957 | 958 | ||
| 958 | 959 | // save the main tab with its new name | |
@@ -965,7 +966,7 @@ public void run() { | |||
| 965 | 966 | setUntitled(false); | |
| 966 | 967 | ||
| 967 | 968 | // Add this sketch back using the new name | |
| 968 | - editor.addRecent(); | ||
| 969 | + Recent.handle(editor); | ||
| 969 | 970 | ||
| 970 | 971 | // let Editor know that the save was successful | |
| 971 | 972 | return true; | |
@@ -997,7 +998,7 @@ protected void updateInternal(String sketchName, File sketchFolder) { | |||
| 997 | 998 | // System.out.println("modified is now " + modified); | |
| 998 | 999 | editor.updateTitle(); | |
| 999 | 1000 | editor.getBase().rebuildSketchbookMenus(); | |
| 1000 | - editor.getBase().handleRecentRename(editor,oldPath); | ||
| 1001 | + Recent.handleRename(editor, oldPath); | ||
| 1001 | 1002 | // editor.header.rebuild(); | |
| 1002 | 1003 | } | |
| 1003 | 1004 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -182,7 +182,7 @@ public void windowClosing(WindowEvent e) { | |||
| 182 | 182 | ||
| 183 | 183 | public void windowActivated(WindowEvent e) { | |
| 184 | 184 | base.handleActivated(Editor.this); | |
| 185 | - fileMenu.insert(base.getRecentMenu(), 2); | ||
| 185 | + fileMenu.insert(Recent.getMenu(), 2); | ||
| 186 | 186 | Toolkit.setMenuMnemsInside(fileMenu); | |
| 187 | 187 | ||
| 188 | 188 | //sketchMenu.insert(mode.getImportMenu(), 5); | |
@@ -193,7 +193,7 @@ public void windowActivated(WindowEvent e) { | |||
| 193 | 193 | } | |
| 194 | 194 | ||
| 195 | 195 | public void windowDeactivated(WindowEvent e) { | |
| 196 | - fileMenu.remove(base.getRecentMenu()); | ||
| 196 | + fileMenu.remove(Recent.getMenu()); | ||
| 197 | 197 | // JMenu importMenu = mode.getImportMenu(); | |
| 198 | 198 | // importIndex = sketchMenu.getComponentZOrder(mode.getImportMenu()); | |
| 199 | 199 | // sketchMenu.remove(mode.getImportMenu()); | |
@@ -462,14 +462,14 @@ public EditorState getEditorState() { | |||
| 462 | 462 | } | |
| 463 | 463 | ||
| 464 | 464 | ||
| 465 | - public void removeRecent() { | ||
| 466 | - base.removeRecent(this); | ||
| 467 | - } | ||
| 468 | - | ||
| 469 | - | ||
| 470 | - public void addRecent() { | ||
| 471 | - base.handleRecent(this); | ||
| 472 | - } | ||
| 465 | + // public void removeRecent() { | ||
| 466 | + // Recent.remove(this); | ||
| 467 | + // } | ||
| 468 | + // | ||
| 469 | + // | ||
| 470 | + // public void addRecent() { | ||
| 471 | + // Recent.handle(this); | ||
| 472 | + // } | ||
| 473 | 473 | ||
| 474 | 474 | ||
| 475 | 475 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,20 +45,17 @@ public class Recent { | |||
| 45 | 45 | static final String FILENAME = "recent.txt"; | |
| 46 | 46 | static final String VERSION = "2"; | |
| 47 | 47 | ||
| 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; | ||
| 53 | 51 | /** actual menu used in the primary menu bar */ | |
| 54 | - JMenu mainMenu; | ||
| 52 | + static JMenu mainMenu; | ||
| 55 | 53 | /** copy of the menu to use in the toolbar */ | |
| 56 | - JMenu toolbarMenu; | ||
| 54 | + static JMenu toolbarMenu; | ||
| 57 | 55 | ||
| 58 | 56 | ||
| 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; | ||
| 62 | 59 | file = Base.getSettingsFile(FILENAME); | |
| 63 | 60 | mainMenu = new JMenu(Language.text("menu.file.recent")); | |
| 64 | 61 | toolbarMenu = new JMenu(Language.text("menu.file.open")); | |
@@ -71,7 +68,7 @@ public Recent(Base base) { | |||
| 71 | 68 | } | |
| 72 | 69 | ||
| 73 | 70 | ||
| 74 | - protected void load() throws IOException { | ||
| 71 | + static protected void load() throws IOException { | ||
| 75 | 72 | records = new ArrayList<Record>(); | |
| 76 | 73 | if (file.exists()) { | |
| 77 | 74 | BufferedReader reader = PApplet.createReader(file); | |
@@ -86,7 +83,7 @@ protected void load() throws IOException { | |||
| 86 | 83 | if (new File(line).exists()) { // don't add ghost entries | |
| 87 | 84 | records.add(new Record(line)); | |
| 88 | 85 | } else { | |
| 89 | - Base.log(this, "ghost file: " + line); | ||
| 86 | + Base.log("ghost file: " + line); | ||
| 90 | 87 | } | |
| 91 | 88 | } | |
| 92 | 89 | } | |
@@ -97,7 +94,7 @@ protected void load() throws IOException { | |||
| 97 | 94 | } | |
| 98 | 95 | ||
| 99 | 96 | ||
| 100 | - protected void save() { | ||
| 97 | + static protected void save() { | ||
| 101 | 98 | PrintWriter writer = PApplet.createWriter(file); | |
| 102 | 99 | writer.println(VERSION); | |
| 103 | 100 | for (Record record : records) { | |
@@ -112,17 +109,17 @@ protected void save() { | |||
| 112 | 109 | } | |
| 113 | 110 | ||
| 114 | 111 | ||
| 115 | - public JMenu getMenu() { | ||
| 112 | + static public JMenu getMenu() { | ||
| 116 | 113 | return mainMenu; | |
| 117 | 114 | } | |
| 118 | 115 | ||
| 119 | 116 | ||
| 120 | - public JMenu getToolbarMenu() { | ||
| 117 | + static public JMenu getToolbarMenu() { | ||
| 121 | 118 | return toolbarMenu; | |
| 122 | 119 | } | |
| 123 | 120 | ||
| 124 | 121 | ||
| 125 | - private void updateMenu(JMenu menu) { | ||
| 122 | + static private void updateMenu(JMenu menu) { | ||
| 126 | 123 | menu.removeAll(); | |
| 127 | 124 | String sketchbookPath = Base.getSketchbookFolder().getAbsolutePath(); | |
| 128 | 125 | for (Record rec : records) { | |
@@ -131,7 +128,7 @@ private void updateMenu(JMenu menu) { | |||
| 131 | 128 | } | |
| 132 | 129 | ||
| 133 | 130 | ||
| 134 | - private void updateMenuRecord(JMenu menu, final Record rec, String sketchbookPath) { | ||
| 131 | + static private void updateMenuRecord(JMenu menu, final Record rec, String sketchbookPath) { | ||
| 135 | 132 | try { | |
| 136 | 133 | String recPath = new File(rec.getPath()).getParent(); | |
| 137 | 134 | String purtyPath = null; | |
@@ -231,7 +228,7 @@ public void actionPerformed(ActionEvent e) { | |||
| 231 | 228 | } | |
| 232 | 229 | ||
| 233 | 230 | ||
| 234 | - synchronized public void remove(Editor editor) { | ||
| 231 | + synchronized static public void remove(Editor editor) { | ||
| 235 | 232 | int index = findRecord(editor.getSketch().getMainFilePath()); | |
| 236 | 233 | if (index != -1) { | |
| 237 | 234 | records.remove(index); | |
@@ -278,12 +275,12 @@ synchronized public void remove(Editor editor) { | |||
| 278 | 275 | * entry on the Recent queue. If the sketch is already in the list, it is | |
| 279 | 276 | * first removed so it doesn't show up multiple times. | |
| 280 | 277 | */ | |
| 281 | - synchronized public void handle(Editor editor) { | ||
| 278 | + synchronized static public void handle(Editor editor) { | ||
| 282 | 279 | if (!editor.getSketch().isUntitled()) { | |
| 283 | 280 | // If this sketch is already in the menu, remove it | |
| 284 | 281 | remove(editor); | |
| 285 | 282 | ||
| 286 | - if (records.size() == remember) { | ||
| 283 | + if (records.size() == Preferences.getInteger("recent.count")) { | ||
| 287 | 284 | records.remove(0); // remove the first entry | |
| 288 | 285 | } | |
| 289 | 286 | ||
@@ -299,8 +296,8 @@ synchronized public void handle(Editor editor) { | |||
| 299 | 296 | } | |
| 300 | 297 | ||
| 301 | 298 | //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")) { | ||
| 304 | 301 | records.remove(0); // remove the first entry | |
| 305 | 302 | } | |
| 306 | 303 | int index = findRecord(oldPath); | |
@@ -313,7 +310,7 @@ synchronized public void handleRename(Editor editor,String oldPath){ | |||
| 313 | 310 | } | |
| 314 | 311 | ||
| 315 | 312 | ||
| 316 | - int findRecord(String path) { | ||
| 313 | + static int findRecord(String path) { | ||
| 317 | 314 | for (int i = 0; i < records.size(); i++) { | |
| 318 | 315 | if (path.equals(records.get(i).path)) { | |
| 319 | 316 | return i; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments