@@ -462,7 +462,7 @@ public Base(String[] args) throws Exception {
462
462
}
463
463
464
464
boolean showEditor = (action == ACTION .GUI );
465
- if (handleOpen (path , nextEditorLocation (), showEditor ) == null ) {
465
+ if (handleOpen (new File ( path ) , nextEditorLocation (), showEditor ) == null ) {
466
466
String mess = I18n .format (_ ("Failed to open sketch: \" {0}\" " ), path );
467
467
// Open failure is fatal in upload/verify mode
468
468
if (action == ACTION .VERIFY || action == ACTION .UPLOAD )
@@ -654,7 +654,7 @@ protected boolean restoreSketches() throws Exception {
654
654
location = nextEditorLocation ();
655
655
}
656
656
// If file did not exist, null will be returned for the Editor
657
- if (handleOpen (path , location , true ) != null ) {
657
+ if (handleOpen (new File ( path ) , location , true ) != null ) {
658
658
opened ++;
659
659
}
660
660
}
@@ -812,7 +812,7 @@ protected int[] nextEditorLocation() {
812
812
* @param shift whether shift is pressed, which will invert prompt setting
813
813
* @param noPrompt disable prompt, no matter the setting
814
814
*/
815
- protected String createNewUntitled () throws IOException {
815
+ protected File createNewUntitled () throws IOException {
816
816
File newbieDir = null ;
817
817
String newbieName = null ;
818
818
@@ -859,7 +859,7 @@ protected String createNewUntitled() throws IOException {
859
859
throw new IOException ();
860
860
}
861
861
FileUtils .copyFile (new File (getContentFile ("examples" ), "01.Basics" + File .separator + "BareMinimum" + File .separator + "BareMinimum.ino" ), newbieFile );
862
- return newbieFile . getAbsolutePath () ;
862
+ return newbieFile ;
863
863
}
864
864
865
865
@@ -869,9 +869,9 @@ protected String createNewUntitled() throws IOException {
869
869
*/
870
870
public void handleNew () throws Exception {
871
871
try {
872
- String path = createNewUntitled ();
873
- if (path != null ) {
874
- Editor editor = handleOpen (path );
872
+ File file = createNewUntitled ();
873
+ if (file != null ) {
874
+ Editor editor = handleOpen (file );
875
875
editor .untitled = true ;
876
876
}
877
877
@@ -900,9 +900,9 @@ public void handleNewReplace() {
900
900
901
901
protected void handleNewReplaceImpl () {
902
902
try {
903
- String path = createNewUntitled ();
904
- if (path != null ) {
905
- activeEditor .handleOpenInternal (path );
903
+ File file = createNewUntitled ();
904
+ if (file != null ) {
905
+ activeEditor .handleOpenInternal (file );
906
906
activeEditor .untitled = true ;
907
907
}
908
908
// return true;
@@ -918,14 +918,14 @@ protected void handleNewReplaceImpl() {
918
918
* Open a sketch, replacing the sketch in the current window.
919
919
* @param path Location of the primary pde file for the sketch.
920
920
*/
921
- public void handleOpenReplace (String path ) {
921
+ public void handleOpenReplace (File file ) {
922
922
if (!activeEditor .checkModified ()) {
923
923
return ; // sketch was modified, and user canceled
924
924
}
925
925
// Close the running window, avoid window boogers with multiple sketches
926
926
activeEditor .internalCloseRunner ();
927
927
928
- boolean loaded = activeEditor .handleOpenInternal (path );
928
+ boolean loaded = activeEditor .handleOpenInternal (file );
929
929
if (!loaded ) {
930
930
// replace the document without checking if that's ok
931
931
handleNewReplaceImpl ();
@@ -956,30 +956,30 @@ public void handleOpenPrompt() throws Exception {
956
956
File inputFile = fd .getSelectedFile ();
957
957
958
958
Preferences .set ("last.folder" , inputFile .getAbsolutePath ());
959
- handleOpen (inputFile . getAbsolutePath () );
959
+ handleOpen (inputFile );
960
960
}
961
961
962
962
963
963
/**
964
964
* Open a sketch in a new window.
965
- * @param path Path to the pde file for the sketch in question
965
+ * @param file File to open
966
966
* @return the Editor object, so that properties (like 'untitled')
967
967
* can be set by the caller
968
968
* @throws Exception
969
969
*/
970
- public Editor handleOpen (String path ) throws Exception {
971
- return handleOpen (path , nextEditorLocation (), true );
970
+ public Editor handleOpen (File file ) throws Exception {
971
+ return handleOpen (file , nextEditorLocation (), true );
972
972
}
973
973
974
974
975
- protected Editor handleOpen (String path , int [] location , boolean showEditor ) throws Exception {
975
+ protected Editor handleOpen (File file , int [] location , boolean showEditor ) throws Exception {
976
976
// System.err.println("entering handleOpen " + path);
977
977
978
- File file = new File (path );
979
978
if (!file .exists ()) return null ;
980
979
981
980
// System.err.println(" editors: " + editors);
982
981
// Cycle through open windows to make sure that it's not already open.
982
+ String path = file .getAbsolutePath ();
983
983
for (Editor editor : editors ) {
984
984
if (editor .getSketch ().getMainFilePath ().equals (path )) {
985
985
editor .toFront ();
@@ -1003,7 +1003,7 @@ protected Editor handleOpen(String path, int[] location, boolean showEditor) thr
1003
1003
// }
1004
1004
1005
1005
// System.err.println(" creating new editor");
1006
- Editor editor = new Editor (this , path , location );
1006
+ Editor editor = new Editor (this , file , location );
1007
1007
// Editor editor = null;
1008
1008
// try {
1009
1009
// editor = new Editor(this, path, location);
@@ -1746,16 +1746,17 @@ private boolean addSketchesSubmenu(JMenu menu, String name, File folder,
1746
1746
ActionListener listener = new ActionListener () {
1747
1747
public void actionPerformed (ActionEvent e ) {
1748
1748
String path = e .getActionCommand ();
1749
- if (new File (path ).exists ()) {
1749
+ File file = new File (path );
1750
+ if (file .exists ()) {
1750
1751
boolean replace = replaceExisting ;
1751
1752
if ((e .getModifiers () & ActionEvent .SHIFT_MASK ) != 0 ) {
1752
1753
replace = !replace ;
1753
1754
}
1754
1755
if (replace ) {
1755
- handleOpenReplace (path );
1756
+ handleOpenReplace (file );
1756
1757
} else {
1757
1758
try {
1758
- handleOpen (path );
1759
+ handleOpen (file );
1759
1760
} catch (Exception e1 ) {
1760
1761
e1 .printStackTrace ();
1761
1762
}
0 commit comments