@@ -2171,72 +2171,56 @@ protected boolean handleOpenInternal(File sketchFile) {
2171
2171
2172
2172
File file = SketchData .checkSketchFile (sketchFile );
2173
2173
2174
- if (file == null )
2175
- {
2174
+ if (file == null ) {
2176
2175
if (!fileName .endsWith (".ino" ) && !fileName .endsWith (".pde" )) {
2177
2176
2178
- Base .showWarning (tr ("Bad file selected" ),
2179
- tr ("Arduino can only open its own sketches\n " +
2180
- "and other files ending in .ino or .pde" ), null );
2177
+ Base .showWarning (tr ("Bad file selected" ), tr ("Arduino can only open its own sketches\n " +
2178
+ "and other files ending in .ino or .pde" ), null );
2181
2179
return false ;
2182
2180
2183
2181
} else {
2184
- String properParent =
2185
- fileName .substring (0 , fileName .length () - 4 );
2182
+ String properParent = fileName .substring (0 , fileName .length () - 4 );
2186
2183
2187
- Object [] options = { tr ("OK" ), tr ("Cancel" ) };
2184
+ Object [] options = {tr ("OK" ), tr ("Cancel" )};
2188
2185
String prompt = I18n .format (tr ("The file \" {0}\" needs to be inside\n " +
2189
- "a sketch folder named \" {1}\" .\n " +
2190
- "Create this folder, move the file, and continue?" ),
2191
- fileName ,
2192
- properParent );
2193
-
2194
- int result = JOptionPane .showOptionDialog (this ,
2195
- prompt ,
2196
- tr ("Moving" ),
2197
- JOptionPane .YES_NO_OPTION ,
2198
- JOptionPane .QUESTION_MESSAGE ,
2199
- null ,
2200
- options ,
2201
- options [0 ]);
2202
-
2203
- if (result == JOptionPane .YES_OPTION ) {
2204
- // create properly named folder
2205
- File properFolder = new File (sketchFile .getParent (), properParent );
2206
- if (properFolder .exists ()) {
2207
- Base .showWarning (tr ("Error" ),
2208
- I18n .format (
2209
- tr ("A folder named \" {0}\" already exists. " +
2210
- "Can't open sketch." ),
2211
- properParent
2212
- ),
2213
- null );
2214
- return false ;
2215
- }
2216
- if (!properFolder .mkdirs ()) {
2217
- //throw new IOException("Couldn't create sketch folder");
2218
- Base .showWarning (tr ("Error" ),
2219
- tr ("Could not create the sketch folder." ), null );
2220
- return false ;
2221
- }
2222
- // copy the sketch inside
2223
- File properPdeFile = new File (properFolder , sketchFile .getName ());
2224
- try {
2225
- Base .copyFile (sketchFile , properPdeFile );
2226
- } catch (IOException e ) {
2227
- Base .showWarning (tr ("Error" ), tr ("Could not copy to a proper location." ), e );
2228
- return false ;
2229
- }
2186
+ "a sketch folder named \" {1}\" .\n " +
2187
+ "Create this folder, move the file, and continue?" ),
2188
+ fileName ,
2189
+ properParent );
2230
2190
2231
- // remove the original file, so user doesn't get confused
2232
- sketchFile .delete ();
2191
+ int result = JOptionPane .showOptionDialog (this , prompt , tr ("Moving" ), JOptionPane .YES_NO_OPTION , JOptionPane .QUESTION_MESSAGE , null , options , options [0 ]);
2233
2192
2234
- // update with the new path
2235
- file = properPdeFile ;
2193
+ if (result != JOptionPane .YES_OPTION ) {
2194
+ return false ;
2195
+ }
2236
2196
2237
- } else if (result == JOptionPane .NO_OPTION ) {
2197
+ // create properly named folder
2198
+ File properFolder = new File (sketchFile .getParent (), properParent );
2199
+ if (properFolder .exists ()) {
2200
+ Base .showWarning (tr ("Error" ), I18n .format (tr ("A folder named \" {0}\" already exists. " +
2201
+ "Can't open sketch." ), properParent ), null );
2202
+ return false ;
2203
+ }
2204
+ if (!properFolder .mkdirs ()) {
2205
+ //throw new IOException("Couldn't create sketch folder");
2206
+ Base .showWarning (tr ("Error" ), tr ("Could not create the sketch folder." ), null );
2238
2207
return false ;
2239
2208
}
2209
+ // copy the sketch inside
2210
+ File properPdeFile = new File (properFolder , sketchFile .getName ());
2211
+ try {
2212
+ Base .copyFile (sketchFile , properPdeFile );
2213
+ } catch (IOException e ) {
2214
+ Base .showWarning (tr ("Error" ), tr ("Could not copy to a proper location." ), e );
2215
+ return false ;
2216
+ }
2217
+
2218
+ // remove the original file, so user doesn't get confused
2219
+ sketchFile .delete ();
2220
+
2221
+ // update with the new path
2222
+ file = properPdeFile ;
2223
+
2240
2224
}
2241
2225
}
2242
2226
@@ -2253,12 +2237,6 @@ protected boolean handleOpenInternal(File sketchFile) {
2253
2237
2254
2238
// opening was successful
2255
2239
return true ;
2256
-
2257
- // } catch (Exception e) {
2258
- // e.printStackTrace();
2259
- // statusError(e);
2260
- // return false;
2261
- // }
2262
2240
}
2263
2241
2264
2242
private void updateTitle () {
0 commit comments