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}
0 commit comments