@@ -234,15 +234,17 @@ public static AndroidSDK load() throws BadSDKException, IOException {
234
234
235
235
236
236
static public AndroidSDK locate (final Frame window )
237
- throws BadSDKException , IOException {
237
+ throws BadSDKException , IOException {
238
238
final int result = showLocateDialog (window );
239
239
if (result == JOptionPane .CANCEL_OPTION ) {
240
240
throw new BadSDKException ("User canceled attempt to find SDK." );
241
241
}
242
242
if (result == JOptionPane .YES_OPTION ) {
243
243
// here we are going to download sdk automatically
244
- Base .openURL (ANDROID_SDK_URL );
245
- throw new BadSDKException ("No SDK installed." );
244
+ //Base.openURL(ANDROID_SDK_URL);
245
+ //throw new BadSDKException("No SDK installed.");
246
+
247
+ return download ();
246
248
}
247
249
while (true ) {
248
250
// TODO this is really a yucky way to do this stuff. fix it.
@@ -261,46 +263,50 @@ static public AndroidSDK locate(final Frame window)
261
263
}
262
264
}
263
265
266
+ static public AndroidSDK download () throws BadSDKException {
267
+ AndroidMode .sdkDownloadInProgress = true ;
268
+
269
+ SwingUtilities .invokeLater (new Runnable () {
270
+ @ Override
271
+ public void run () {
272
+ SDKDownloader downloader = new SDKDownloader ();
273
+ downloader .startDownload ();
274
+ }
275
+ });
276
+ return null ;
277
+ }
278
+
264
279
static public int showLocateDialog (Frame editor ) {
265
- if (!Base .isMacOS ()) {
266
- return JOptionPane .showConfirmDialog (editor ,
267
- "<html><body>" +
268
- "<b>" + ANDROID_SDK_PRIMARY + "</b>" +
269
- "<br>" + ANDROID_SDK_SECONDARY , "Android SDK" ,
270
- JOptionPane .YES_NO_OPTION ,
271
- JOptionPane .QUESTION_MESSAGE );
280
+ // Pane formatting adapted from the Quaqua guide
281
+ // http://www.randelshofer.ch/quaqua/guide/joptionpane.html
282
+ JOptionPane pane =
283
+ new JOptionPane ("<html> " +
284
+ "<head> <style type=\" text/css\" >" +
285
+ "b { font: 13pt \" Lucida Grande\" }" +
286
+ "p { font: 11pt \" Lucida Grande\" ; margin-top: 8px; width: 300px }" +
287
+ "</style> </head>" +
288
+ "<b>" + ANDROID_SDK_PRIMARY + "</b>" +
289
+ "<p>" + ANDROID_SDK_SECONDARY + "</p>" ,
290
+ JOptionPane .QUESTION_MESSAGE );
291
+
292
+ String [] options = new String [] {
293
+ "Download SDK automatically" , "Locate SDK path manually"
294
+ };
295
+ pane .setOptions (options );
296
+
297
+ // highlight the safest option ala apple hig
298
+ pane .setInitialValue (options [0 ]);
299
+
300
+ JDialog dialog = pane .createDialog (editor , null );
301
+ dialog .setVisible (true );
302
+
303
+ Object result = pane .getValue ();
304
+ if (result == options [0 ]) {
305
+ return JOptionPane .YES_OPTION ;
306
+ } else if (result == options [1 ]) {
307
+ return JOptionPane .NO_OPTION ;
272
308
} else {
273
- // Pane formatting adapted from the Quaqua guide
274
- // http://www.randelshofer.ch/quaqua/guide/joptionpane.html
275
- JOptionPane pane =
276
- new JOptionPane ("<html> " +
277
- "<head> <style type=\" text/css\" >" +
278
- "b { font: 13pt \" Lucida Grande\" }" +
279
- "p { font: 11pt \" Lucida Grande\" ; margin-top: 8px; width: 300px }" +
280
- "</style> </head>" +
281
- "<b>" + ANDROID_SDK_PRIMARY + "</b>" +
282
- "<p>" + ANDROID_SDK_SECONDARY + "</p>" ,
283
- JOptionPane .QUESTION_MESSAGE );
284
-
285
- String [] options = new String [] {
286
- "Download SDK automatically" , "Locate SDK path manually"
287
- };
288
- pane .setOptions (options );
289
-
290
- // highlight the safest option ala apple hig
291
- pane .setInitialValue (options [0 ]);
292
-
293
- JDialog dialog = pane .createDialog (editor , null );
294
- dialog .setVisible (true );
295
-
296
- Object result = pane .getValue ();
297
- if (result == options [0 ]) {
298
- return JOptionPane .YES_OPTION ;
299
- } else if (result == options [1 ]) {
300
- return JOptionPane .NO_OPTION ;
301
- } else {
302
- return JOptionPane .CLOSED_OPTION ;
303
- }
309
+ return JOptionPane .CLOSED_OPTION ;
304
310
}
305
311
}
306
312
0 commit comments