Skip to content

Commit 4a3d522

Browse files
committed
add separate preference for 3.0 sketchbook location, other prefs cleanups
1 parent 3655e1c commit 4a3d522

5 files changed

Lines changed: 93 additions & 84 deletions

File tree

app/src/processing/app/Base.java

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,41 +1859,15 @@ static public File createTempFolder(String prefix, String suffix, File directory
18591859
}
18601860

18611861

1862-
// static public String getExamplesPath() {
1863-
// return examplesFolder.getAbsolutePath();
1864-
// }
1865-
1866-
// public File getExamplesFolder() {
1867-
// return examplesFolder;
1868-
// }
1869-
1870-
1871-
// static public String getLibrariesPath() {
1872-
// return librariesFolder.getAbsolutePath();
1873-
// }
1874-
1875-
1876-
// public File getLibrariesFolder() {
1877-
// return librariesFolder;
1878-
// }
1879-
1880-
1881-
// static public File getToolsFolder() {
18821862
static public File getToolsFolder() {
1883-
// return toolsFolder;
18841863
return getContentFile("tools");
18851864
}
18861865

18871866

1888-
// static public String getToolsPath() {
1889-
// return toolsFolder.getAbsolutePath();
1890-
// }
1891-
1892-
18931867
static public void locateSketchbookFolder() {
18941868
// If a value is at least set, first check to see if the folder exists.
18951869
// If it doesn't, warn the user that the sketchbook folder is being reset.
1896-
String sketchbookPath = Preferences.get("sketchbook.path"); //$NON-NLS-1$
1870+
String sketchbookPath = Preferences.getSketchbookPath();
18971871
if (sketchbookPath != null) {
18981872
sketchbookFolder = new File(sketchbookPath);
18991873
if (!sketchbookFolder.exists()) {
@@ -1910,7 +1884,7 @@ static public void locateSketchbookFolder() {
19101884
// If no path is set, get the default sketchbook folder for this platform
19111885
if (sketchbookFolder == null) {
19121886
sketchbookFolder = getDefaultSketchbookFolder();
1913-
Preferences.set("sketchbook.path", sketchbookFolder.getAbsolutePath());
1887+
Preferences.setSketchbookPath(sketchbookFolder.getAbsolutePath());
19141888
if (!sketchbookFolder.exists()) {
19151889
sketchbookFolder.mkdirs();
19161890
}
@@ -1925,19 +1899,17 @@ static public void locateSketchbookFolder() {
19251899

19261900
public void setSketchbookFolder(File folder) {
19271901
sketchbookFolder = folder;
1928-
Preferences.set("sketchbook.path", folder.getAbsolutePath());
1902+
Preferences.setSketchbookPath(folder.getAbsolutePath());
19291903
rebuildSketchbookMenus();
19301904
}
19311905

19321906

19331907
static public File getSketchbookFolder() {
1934-
// return new File(Preferences.get("sketchbook.path"));
19351908
return sketchbookFolder;
19361909
}
19371910

19381911

19391912
static public File getSketchbookLibrariesFolder() {
1940-
// return new File(getSketchbookFolder(), "libraries");
19411913
return new File(sketchbookFolder, "libraries");
19421914
}
19431915

app/src/processing/app/Preferences.java

Lines changed: 60 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
Part of the Processing project - http://processing.org
55
6-
Copyright (c) 2004-12 Ben Fry and Casey Reas
6+
Copyright (c) 2004-14 Ben Fry and Casey Reas
77
Copyright (c) 2001-04 Massachusetts Institute of Technology
88
99
This program is free software; you can redistribute it and/or modify
@@ -100,7 +100,7 @@ public class Preferences {
100100
// and linux is all over the map
101101

102102
static final int GUI_BIG = 13;
103-
static final int GUI_BETWEEN = 10;
103+
static final int GUI_BETWEEN = 8;
104104
static final int GUI_SMALL = 6;
105105

106106
// gui elements
@@ -185,17 +185,10 @@ static public void init() {
185185

186186
// other things that have to be set explicitly for the defaults
187187
setColor("run.window.bgcolor", SystemColor.control); //$NON-NLS-1$
188-
188+
189189
// next load user preferences file
190190
preferencesFile = Base.getSettingsFile(PREFS_FILE);
191-
if (!preferencesFile.exists()) {
192-
// create a new preferences file if none exists
193-
// saves the defaults out to the file
194-
save();
195-
196-
} else {
197-
// load the previous preferences file
198-
191+
if (preferencesFile.exists()) {
199192
try {
200193
load(new FileInputStream(preferencesFile));
201194

@@ -206,6 +199,12 @@ static public void init() {
206199
preferencesFile.getAbsolutePath() +
207200
" and restart Processing.", ex);
208201
}
202+
}
203+
204+
if (checkSketchbookPref() || !preferencesFile.exists()) {
205+
// create a new preferences file if none exists
206+
// saves the defaults out to the file
207+
save();
209208
}
210209

211210
PApplet.useNativeSelect =
@@ -485,24 +484,25 @@ public void mouseClicked(MouseEvent e) {
485484
right = Math.max(right, left + d.width);
486485
top += d.height + GUI_BETWEEN;
487486

488-
// [ ] Enable Error Checking - PDE X
487+
// [ ] Continuously check for errors - PDE X
489488

490489
errorCheckerBox =
491-
new JCheckBox("Enable error checking");
490+
new JCheckBox("Continuously check for errors");
492491
pain.add(errorCheckerBox);
493492
d = errorCheckerBox.getPreferredSize();
494493
errorCheckerBox.setBounds(left, top, d.width + 10, d.height);
495-
right = Math.max(right, left + d.width);
496-
top += d.height + GUI_BETWEEN;
494+
//right = Math.max(right, left + d.width);
495+
//top += d.height + GUI_BETWEEN;
496+
int warningLeft = left + d.width;
497497

498-
// [ ] Enable Warnings - PDE X
498+
// [ ] Show Warnings - PDE X
499499

500500
warningsCheckerBox =
501-
new JCheckBox("Enable warnings");
501+
new JCheckBox("Show warnings");
502502
pain.add(warningsCheckerBox);
503503
d = warningsCheckerBox.getPreferredSize();
504-
warningsCheckerBox.setBounds(left, top, d.width + 10, d.height);
505-
right = Math.max(right, left + d.width);
504+
warningsCheckerBox.setBounds(warningLeft, top, d.width + 10, d.height);
505+
right = Math.max(right, warningLeft + d.width);
506506
top += d.height + GUI_BETWEEN;
507507

508508
// [ ] Enable Code Completion - PDE X
@@ -512,17 +512,17 @@ public void mouseClicked(MouseEvent e) {
512512
pain.add(codeCompletionBox);
513513
d = codeCompletionBox.getPreferredSize();
514514
codeCompletionBox.setBounds(left, top, d.width + 10, d.height);
515-
right = Math.max(right, left + d.width);
516-
top += d.height + GUI_BETWEEN;
515+
int toggleLeft = left + d.width;
517516

518517
// [ ] Toggle Code Completion Trigger - PDE X
519518

519+
final String modifier = Base.isMacOS() ? "\u2318" : "Ctrl";
520520
codeCompletionTriggerBox =
521-
new JCheckBox("Trigger code completion on Ctrl(Cmd) + Space");
521+
new JCheckBox("Trigger with " + modifier + "-space");
522522
pain.add(codeCompletionTriggerBox);
523523
d = codeCompletionTriggerBox.getPreferredSize();
524-
codeCompletionTriggerBox.setBounds(left, top, d.width + 10, d.height);
525-
right = Math.max(right, left + d.width);
524+
codeCompletionTriggerBox.setBounds(toggleLeft, top, d.width + 10, d.height);
525+
right = Math.max(right, toggleLeft + d.width);
526526
top += d.height + GUI_BETWEEN;
527527

528528

@@ -762,7 +762,7 @@ protected void applyFrame() {
762762
// each platform, and nobody wants to debug/support that.
763763

764764
// if the sketchbook path has changed, rebuild the menus
765-
String oldPath = get("sketchbook.path"); //$NON-NLS-1$
765+
String oldPath = getSketchbookPath();
766766
String newPath = sketchbookLocationField.getText();
767767
if (!newPath.equals(oldPath)) {
768768
base.setSketchbookFolder(new File(newPath));
@@ -859,10 +859,8 @@ protected void showFrame() {
859859
deletePreviousBox.
860860
setSelected(getBoolean("export.delete_target_folder")); //$NON-NLS-1$
861861

862-
sketchbookLocationField.
863-
setText(get("sketchbook.path")); //$NON-NLS-1$
864-
checkUpdatesBox.
865-
setSelected(getBoolean("update.check")); //$NON-NLS-1$
862+
sketchbookLocationField.setText(getSketchbookPath());
863+
checkUpdatesBox.setSelected(getBoolean("update.check")); //$NON-NLS-1$
866864

867865
whinyBox.setSelected(getBoolean("header.hide.image") || //$NON-NLS-1$
868866
getBoolean("buttons.hide.image")); //$NON-NLS-1$
@@ -1143,4 +1141,37 @@ static public Font getFont(String attr) {
11431141
}
11441142
return new Font("Dialog", Font.PLAIN, 12);
11451143
}
1144+
1145+
1146+
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1147+
1148+
1149+
/**
1150+
* Check for a 3.0 sketchbook location, and if none exists,
1151+
* try to grab it from the 2.0 sketchbook location.
1152+
* @return true if a location was found and the pref didn't exist
1153+
*/
1154+
static protected boolean checkSketchbookPref() {
1155+
// If a 3.0 sketchbook location has never been inited
1156+
if (getSketchbookPath() == null) {
1157+
String twoPath = get("sketchbook.path");
1158+
// If they've run the 2.0 version, start with that location
1159+
if (twoPath != null) {
1160+
setSketchbookPath(twoPath);
1161+
return true; // save the sketchbook right away
1162+
}
1163+
// Otherwise it'll be null, and reset properly by Base
1164+
}
1165+
return false;
1166+
}
1167+
1168+
1169+
static protected String getSketchbookPath() {
1170+
return get("sketchbook.path.three"); //$NON-NLS-1$
1171+
}
1172+
1173+
1174+
static protected void setSketchbookPath(String path) {
1175+
set("sketchbook.path.three", path); //$NON-NLS-1$
1176+
}
11461177
}

app/src/processing/app/Sketch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ protected boolean saveAs() throws IOException {
816816
FileDialog fd = new FileDialog(editor, PROMPT, FileDialog.SAVE);
817817
if (isReadOnly() || isUntitled()) {
818818
// default to the sketchbook folder
819-
fd.setDirectory(Preferences.get("sketchbook.path"));
819+
fd.setDirectory(Preferences.getSketchbookPath());
820820
} else {
821821
// default to the parent folder of where this was
822822
fd.setDirectory(folder.getParent());
@@ -831,7 +831,7 @@ protected boolean saveAs() throws IOException {
831831
fc.setDialogTitle(PROMPT);
832832
if (isReadOnly() || isUntitled()) {
833833
// default to the sketchbook folder
834-
fc.setCurrentDirectory(new File(Preferences.get("sketchbook.path")));
834+
fc.setCurrentDirectory(new File(Preferences.getSketchbookPath()));
835835
} else {
836836
// default to the parent folder of where this was
837837
fc.setCurrentDirectory(folder.getParentFile());

build/shared/revisions.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ PROCESSING 3.0a2 (REV 0229) - ?? August 2014
33

44
[ fixes ]
55

6-
+ The Examples and Reference weren't included in 3.0a1. Oops.
6+
+ The Examples weren't included in 3.0a1. Oops.
77
https://github.com/processing/processing/issues/2652
88

99

1010
[ changes ]
1111

12+
+ Added a new sketchbook location, so that you can have separate sketchbooks
13+
with 2.0 and 3.0 releases. The downside is that they won't stay in sync,
14+
but the upside is that sketches that haven't been updated, or conflicting
15+
Libraries, Modes, or Tools won't cause trouble with the other version.
16+
The new preference is called sketchbook.location.three (the old preference
17+
was sketchbook.location). If you already have a 2.0 sketchbook, that will
18+
be used by default with 3.0 until you change it in the Preferences window.
19+
1220
+ Neglected to mention with the previous release that the video library has
1321
been removed from the default download. This decreases the size of the
1422
Processing download by about 20%. In addition, it was only the video

todo.txt

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ X all examples are out of "processing/java" and are now in "processing-docs/co
2727
o "Platform is ${platform}" message during 'ant clean'
2828
o on OS X, but not Windows (haven't checked Linux)
2929
X this was in pdex/build.xml
30+
X remove welcome message from the sound library
31+
X URL opening problem fixed by use of getCanonicalPath() on Windows
32+
X https://github.com/processing/processing/issues/2656
33+
X add a new pref for the 3.0 sketchbook location
3034

3135
gsoc
3236
X clear status messages in the Contribution Manager
@@ -57,22 +61,19 @@ o https://github.com/processing/processing/issues/2639
5761
X moving p5 examples to the web repo
5862
X move examples into web repo
5963

60-
_ add a new pref for the 3.0 sketchbook location
61-
_ make reference and examples build process part of dist
62-
_ separate ant targets, but only require them for dist
63-
_ as separate targets, folks can build explicitly if they'd like
64-
_ reference wasn't included either
65-
_ https://github.com/processing/processing/issues/2656
66-
_ processing-web/java_generate/ReferenceGenerator
67-
_ remove reference.zip from main repo
68-
6964

7065
pending
7166
_ huge i18n patch
7267
_ https://github.com/processing/processing/pull/2084
7368
_ look at the sound library https://github.com/wirsing/ProcessingSound
7469
_ sound is not yet supported on Windows
7570
_ glw? lwjgl? retina jogl?
71+
_ make reference build process part of dist
72+
_ https://github.com/processing/processing-docs/issues/85
73+
_ separate ant target, but only require them for dist
74+
_ as separate targets, folks can build explicitly if they'd like
75+
_ processing-docs/java_generate/ReferenceGenerator/processingrefBuild.sh
76+
_ remove reference.zip from main repo
7677

7778

7879
gsoc/help me
@@ -92,6 +93,15 @@ _ needs to recognize the p5 app folder
9293
_ also should recognize the user's home dir
9394
_ incorporate new preproc
9495
_ https://github.com/fjenett/processing-preprocessor-antlr4
96+
_ SOCKS proxy not working:
97+
_ https://github.com/processing/processing/issues/2643
98+
_ the current code that gets/sets the pref is in Preferences
99+
_ instead of current implementation, can we auto-detect proxy settings?
100+
_ old issue: https://github.com/processing/processing/issues/1476
101+
_ http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html
102+
_ http://docs.oracle.com/javase/1.5.0/docs/guide/net/proxies.html
103+
_ http://stackoverflow.com/questions/4933677/detecting-windows-ie-proxy-setting-using-java
104+
_ http://www.java2s.com/Code/Java/Network-Protocol/DetectProxySettingsforInternetConnection.htm
95105

96106

97107
medium
@@ -144,18 +154,6 @@ _ PDE and sketches are 2x smaller on high-res Windows 8 machines
144154
_ https://github.com/processing/processing/issues/2411
145155

146156

147-
lower
148-
_ SOCKS proxy not working:
149-
_ https://github.com/processing/processing/issues/2643
150-
_ the code that gets/sets the pref is in Preferences
151-
_ detect proxy settings?
152-
_ old issue: https://github.com/processing/processing/issues/1476
153-
_ http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html
154-
_ http://docs.oracle.com/javase/1.5.0/docs/guide/net/proxies.html
155-
_ http://stackoverflow.com/questions/4933677/detecting-windows-ie-proxy-setting-using-java
156-
_ http://www.java2s.com/Code/Java/Network-Protocol/DetectProxySettingsforInternetConnection.htm
157-
158-
159157
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
160158

161159

0 commit comments

Comments
 (0)