Skip to content

Commit 0398780

Browse files
committed
break up the overly large processing.app pkg and get some distance between ui and non-ui code
1 parent 1256c15 commit 0398780

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+199
-118
lines changed

app/src/processing/app/Base.java

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
import javax.swing.tree.DefaultMutableTreeNode;
4444

4545
import processing.app.contrib.*;
46+
import processing.app.ui.Editor;
47+
import processing.app.ui.EditorConsole;
48+
import processing.app.ui.EditorState;
49+
import processing.app.ui.PreferencesFrame;
50+
import processing.app.ui.Recent;
4651
import processing.core.*;
4752
import processing.data.StringDict;
4853
import processing.data.StringList;
@@ -237,7 +242,7 @@ public static void setCommandLine() {
237242
}
238243

239244

240-
static protected boolean isCommandLine() {
245+
static public boolean isCommandLine() {
241246
return commandLine;
242247
}
243248

@@ -446,7 +451,7 @@ public List<Editor> getEditors() {
446451
* The call has already checked to make sure this sketch is not modified,
447452
* now change the mode.
448453
*/
449-
protected void changeMode(Mode mode) {
454+
public void changeMode(Mode mode) {
450455
if (activeEditor.getMode() != mode) {
451456
Sketch sketch = activeEditor.getSketch();
452457
nextMode = mode;
@@ -558,7 +563,7 @@ public byte[] getInstalledContribsInfo() {
558563
// changes to the focused and active Windows can be made. Developers must
559564
// never assume that this Window is the focused or active Window until this
560565
// Window receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED event.
561-
protected void handleActivated(Editor whichEditor) {
566+
public void handleActivated(Editor whichEditor) {
562567
activeEditor = whichEditor;
563568

564569
// set the current window to be the console that's getting output
@@ -1192,25 +1197,6 @@ public void populateSketchbookMenu(JMenu menu) {
11921197
}
11931198

11941199

1195-
// public JMenu getSketchbookMenu() {
1196-
// if (sketchbookMenu == null) {
1197-
// sketchbookMenu = new JMenu(Language.text("menu.file.sketchbook"));
1198-
// rebuildSketchbookMenu();
1199-
// }
1200-
// return sketchbookMenu;
1201-
// }
1202-
1203-
1204-
// public JMenu getRecentMenu() {
1205-
// if (recentMenu == null) {
1206-
// recentMenu = recent.createMenu();
1207-
// } else {
1208-
// recent.updateMenu(recentMenu);
1209-
// }
1210-
// return recentMenu;
1211-
// }
1212-
1213-
12141200
public JMenu getRecentMenu() {
12151201
return recent.getMenu();
12161202
}
@@ -1224,10 +1210,13 @@ public JMenu getToolbarRecentMenu() {
12241210
public void handleRecent(Editor editor) {
12251211
recent.handle(editor);
12261212
}
1213+
1214+
12271215
public void handleRecentRename(Editor editor,String oldPath){
12281216
recent.handleRename(editor,oldPath);
12291217
}
12301218

1219+
12311220
/**
12321221
* Called before a sketch is renamed so that its old name is
12331222
* no longer in the menu.
@@ -1863,7 +1852,7 @@ static public void openURL(String url) {
18631852
* Used to determine whether to disable the "Show Sketch Folder" option.
18641853
* @return true If a means of opening a folder is known to be available.
18651854
*/
1866-
static protected boolean openFolderAvailable() {
1855+
static public boolean openFolderAvailable() {
18671856
return platform.openFolderAvailable();
18681857
}
18691858

app/src/processing/app/Mode.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
import processing.app.contrib.ContributionType;
4242
import processing.app.contrib.ExamplesContribution;
4343
import processing.app.syntax.*;
44+
import processing.app.ui.Editor;
45+
import processing.app.ui.EditorState;
46+
import processing.app.ui.Toolkit;
4447
import processing.core.PApplet;
4548
import processing.core.PConstants;
4649

app/src/processing/app/Preferences.java

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.io.*;
2626
import java.util.*;
2727

28+
import processing.app.ui.Toolkit;
2829
import processing.core.*;
2930

3031

@@ -53,27 +54,6 @@ public class Preferences {
5354
static HashMap<String, String> table = new HashMap<String, String>();
5455
static File preferencesFile;
5556

56-
static final String PROMPT_YES = Language.text("prompt.yes");
57-
static final String PROMPT_NO = Language.text("prompt.no");
58-
static final String PROMPT_CANCEL = Language.text("prompt.cancel");
59-
static final String PROMPT_OK = Language.text("prompt.ok");
60-
static final String PROMPT_BROWSE = Language.text("prompt.browse");
61-
62-
/**
63-
* Standardized width for buttons. Mac OS X 10.3 wants 70 as its default,
64-
* Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper.
65-
*/
66-
static public int BUTTON_WIDTH =
67-
Integer.parseInt(Language.text("preferences.button.width"));
68-
69-
// Indents and spacing standards. These probably need to be modified
70-
// per platform as well, because Mac OS X is so huge, Windows is smaller,
71-
// and Linux is all over the map. Consider these deprecated.
72-
73-
static final int GUI_BIG = 13;
74-
static final int GUI_BETWEEN = 8;
75-
static final int GUI_SMALL = 6;
76-
7757

7858
static public void init() {
7959
// start by loading the defaults, in case something
@@ -192,7 +172,7 @@ static void handleProxy(String protocol, String hostProp, String portProp) {
192172
}
193173

194174

195-
static protected String getPreferencesPath() {
175+
static public String getPreferencesPath() {
196176
return preferencesFile.getAbsolutePath();
197177
}
198178

@@ -262,7 +242,7 @@ static protected boolean isPlatformSpecific(String key, String value,
262242
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
263243

264244

265-
static protected void save() {
245+
static public void save() {
266246
// on startup, don't worry about it
267247
// this is trying to update the prefs for who is open
268248
// before Preferences.init() has been called.
@@ -452,7 +432,7 @@ static protected boolean checkSketchbookPref() {
452432
}
453433

454434

455-
static protected String getSketchbookPath() {
435+
static public String getSketchbookPath() {
456436
return get("sketchbook.path.three"); //$NON-NLS-1$
457437
}
458438

app/src/processing/app/Settings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.io.*;
2828
import java.util.*;
2929

30+
import processing.app.ui.Toolkit;
3031
import processing.core.*;
3132

3233

app/src/processing/app/Sketch.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
package processing.app;
2525

26+
import processing.app.ui.Editor;
27+
import processing.app.ui.ProgressFrame;
28+
import processing.app.ui.Toolkit;
2629
import processing.core.*;
2730

2831
import java.awt.Component;
@@ -407,8 +410,8 @@ public void keyTyped(KeyEvent event) {
407410
JOptionPane.OK_CANCEL_OPTION,
408411
JOptionPane.PLAIN_MESSAGE,
409412
null, new Object[] {
410-
Preferences.PROMPT_OK,
411-
Preferences.PROMPT_CANCEL },
413+
Toolkit.PROMPT_OK,
414+
Toolkit.PROMPT_CANCEL },
412415
field);
413416

414417
if (userReply == JOptionPane.OK_OPTION) {
@@ -604,7 +607,7 @@ protected void nameCode(String newName) {
604607
setCurrentCode(newName);
605608

606609
// update the tabs
607-
editor.header.rebuild();
610+
editor.rebuildHeader();
608611
}
609612

610613

@@ -657,7 +660,7 @@ public void handleDeleteCode() {
657660
// make a new sketch, and i think this will rebuild the sketch menu
658661
//editor.handleNewUnchecked();
659662
//editor.handleClose2();
660-
editor.base.handleClose(editor, false);
663+
editor.getBase().handleClose(editor, false);
661664

662665
} else {
663666
// delete the file
@@ -675,7 +678,7 @@ public void handleDeleteCode() {
675678
setCurrentCode(0);
676679

677680
// update the tabs
678-
editor.header.repaint();
681+
editor.repaintHeader();
679682
}
680683
}
681684
}
@@ -737,7 +740,7 @@ protected void calcModified() {
737740
break;
738741
}
739742
}
740-
editor.header.repaint();
743+
editor.repaintHeader();
741744

742745
if (Base.isMacOS()) {
743746
// http://developer.apple.com/qa/qa2001/qa1146.html
@@ -797,7 +800,7 @@ public boolean save() throws IOException {
797800
* Also removes the previously-generated .class and .jar files,
798801
* because they can cause trouble.
799802
*/
800-
protected boolean saveAs() throws IOException {
803+
public boolean saveAs() throws IOException {
801804
String newParentDir = null;
802805
String newName = null;
803806

@@ -1005,8 +1008,8 @@ protected void updateInternal(String sketchName, File sketchFolder) {
10051008
calcModified();
10061009
// System.out.println("modified is now " + modified);
10071010
editor.updateTitle();
1008-
editor.base.rebuildSketchbookMenus();
1009-
editor.base.handleRecentRename(editor,oldPath);
1011+
editor.getBase().rebuildSketchbookMenus();
1012+
editor.getBase().handleRecentRename(editor,oldPath);
10101013
// editor.header.rebuild();
10111014
}
10121015

@@ -1099,7 +1102,7 @@ public boolean addFile(File sourceFile) {
10991102
// check whether this file already exists
11001103
if (destFile.exists()) {
11011104
Object[] options = { Language.text("prompt.ok"), Language.text("prompt.cancel") };
1102-
String prompt = Language.interpolate("add_file.messages.confirm_replace",
1105+
String prompt = Language.interpolate("add_file.messages.confirm_replace",
11031106
filename);
11041107
int result = JOptionPane.showOptionDialog(editor,
11051108
prompt,
@@ -1167,7 +1170,7 @@ public boolean addFile(File sourceFile) {
11671170
sortCode();
11681171
}
11691172
setCurrentCode(filename);
1170-
editor.header.repaint();
1173+
editor.repaintHeader();
11711174
if (isUntitled()) { // TODO probably not necessary? problematic?
11721175
// Mark the new code as modified so that the sketch is saved
11731176
current.setModified(true);
@@ -1217,16 +1220,15 @@ public void setCurrentCode(int which) {
12171220
current.visited = System.currentTimeMillis();
12181221

12191222
editor.setCode(current);
1220-
// editor.header.rebuild();
1221-
editor.header.repaint();
1223+
editor.repaintHeader();
12221224
}
12231225

12241226

12251227
/**
12261228
* Internal helper function to set the current tab based on a name.
12271229
* @param findName the file name (not pretty name) to be shown
12281230
*/
1229-
protected void setCurrentCode(String findName) {
1231+
public void setCurrentCode(String findName) {
12301232
for (int i = 0; i < codeCount; i++) {
12311233
if (findName.equals(code[i].getFileName()) ||
12321234
findName.equals(code[i].getPrettyName())) {

app/src/processing/app/contrib/ContributionManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import javax.swing.SwingWorker;
3030

3131
import processing.app.Base;
32-
import processing.app.Editor;
3332
import processing.app.Language;
33+
import processing.app.ui.Editor;
3434
import processing.core.PApplet;
3535
import processing.data.StringDict;
3636

app/src/processing/app/contrib/ContributionManagerDialog.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import javax.swing.*;
3232

3333
import processing.app.*;
34+
import processing.app.ui.Editor;
35+
import processing.app.ui.Toolkit;
3436

3537
/**
3638
*

app/src/processing/app/contrib/ContributionPanel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
import javax.swing.text.html.StyleSheet;
4242

4343
import processing.app.Base;
44-
import processing.app.Editor;
45-
import processing.app.Toolkit;
4644
import processing.app.Language;
45+
import processing.app.ui.Editor;
46+
import processing.app.ui.Toolkit;
4747

4848

4949
// TODO clean up accessors (too many cases of several de-references for basic tasks

app/src/processing/app/contrib/ContributionTab.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import javax.swing.event.*;
3939

4040
import processing.app.*;
41+
import processing.app.ui.Editor;
4142

4243

4344
public class ContributionTab {

app/src/processing/app/contrib/ContributionType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import java.util.ArrayList;
2828

2929
import processing.app.Base;
30-
import processing.app.Editor;
3130
import processing.app.Library;
31+
import processing.app.ui.Editor;
3232

3333
public enum ContributionType {
3434
LIBRARY, TOOL, MODE, EXAMPLES;

0 commit comments

Comments
 (0)