3
3
* Sample Skeleton for 'newVitaminWizard.fxml' Controller Class
4
4
*/
5
5
6
+ import java .io .IOException ;
7
+ import java .net .URISyntaxException ;
6
8
import java .net .URL ;
7
9
import java .util .ArrayList ;
8
10
import java .util .Collections ;
15
17
import java .util .stream .Collectors ;
16
18
17
19
import org .kohsuke .github .GHCreateRepositoryBuilder ;
20
+ import org .kohsuke .github .GHIssueState ;
21
+ import org .kohsuke .github .GHPullRequest ;
18
22
import org .kohsuke .github .GHRepository ;
19
23
import org .kohsuke .github .GitHub ;
20
24
@@ -178,17 +182,24 @@ void onConfirmAndCreate(ActionEvent event) {
178
182
Vitamins .setIsShaft (typeOfVitaminString );
179
183
if (isMotor .isSelected ())
180
184
Vitamins .setIsActuator (typeOfVitaminString );
181
- Vitamins .saveDatabaseForkIfMissing (typeOfVitaminString );
185
+ // Vitamins.saveDatabaseForkIfMissing(typeOfVitaminString);
182
186
183
187
if (newTypeRadio .isSelected ()) {
184
188
callback .addVitaminType (typeOfVitaminString );
185
189
}else
186
- if (!editExisting .isSelected ())
190
+ if (!editExisting .isSelected ()) {
187
191
callback .addSizesToMenu (sizeOfVitaminString , typeOfVitaminString );
192
+ }
188
193
} catch (Exception e1 ) {
189
194
// Auto-generated catch block
190
195
new IssueReportingExceptionHandler ().uncaughtException (Thread .currentThread (), e1 );
191
196
}
197
+ try {
198
+ Vitamins .saveDatabase (typeOfVitaminString );
199
+ } catch (Exception e ) {
200
+ // TODO Auto-generated catch block
201
+ e .printStackTrace ();
202
+ }
192
203
try {
193
204
BowlerStudio .runLater (() -> {
194
205
this .primaryStage .close ();
@@ -200,11 +211,47 @@ void onConfirmAndCreate(ActionEvent event) {
200
211
new IssueReportingExceptionHandler ().uncaughtException (Thread .currentThread (), e );
201
212
202
213
}
203
- Vitamins .clear ();
214
+ org .kohsuke .github .GitHub github = PasswordManager .getGithub ();
215
+
216
+ GHRepository repo ;
217
+ try {
218
+ repo = github .getRepository (Vitamins .getSourcerepo ()+ "/Hardware-Dimensions" );
219
+ String head = PasswordManager .getUsername () + ":master" ;
220
+ List <GHPullRequest > asList = repo .queryPullRequests ().state (GHIssueState .OPEN ).head (head ).list ().asList ();
221
+ if (asList .size () == 0 ) {
222
+ com .neuronrobotics .sdk .common .Log .error ("Creating PR for " + head );
223
+ GHPullRequest request = repo .createPullRequest ("User Added vitamins to " + typeOfVitaminString , head , "master" ,
224
+ "## User added vitamins" , true , true );
225
+ try {
226
+ BowlerKernel .upenURL (request .getHtmlUrl ().toURI ());
227
+ } catch (URISyntaxException e ) {
228
+ // Auto-generated catch block
229
+ e .printStackTrace ();
230
+ }
231
+ } else {
232
+
233
+ }
234
+ } catch (Exception e ) {
235
+ // TODO Auto-generated catch block
236
+ e .printStackTrace ();
237
+ }
238
+
204
239
}).start ();
205
240
206
241
}
242
+ private void saveAndFork () {
243
+
244
+ try {
245
+ Vitamins .saveDatabaseForkIfMissing (typeOfVitaminString ,PasswordManager .getUsername () );
246
+
247
+ } catch (Exception e ) {
248
+ // Auto-generated catch block
249
+ new IssueReportingExceptionHandler ().uncaughtException (Thread .currentThread (), e );
250
+
251
+ }
252
+
207
253
254
+ }
208
255
@ FXML
209
256
void onConfirmSize (ActionEvent event ) {
210
257
if (!editExisting .isSelected ()) {
@@ -318,6 +365,10 @@ void onConfirmSize(ActionEvent event) {
318
365
) {
319
366
setUpVitaminDefaults ();
320
367
}
368
+ BowlerStudio .runLater (()->{
369
+ sizePane .setDisable (true );
370
+ typePane .setDisable (true );
371
+ });
321
372
//new Thread(() -> {
322
373
HashMap <String , Object > required = new HashMap <String , Object >();
323
374
required .put ("massKg" , 0.001 );
@@ -327,10 +378,11 @@ void onConfirmSize(ActionEvent event) {
327
378
required .put ("massCentroidY" , 0.0 );
328
379
required .put ("massCentroidZ" , 0.0 );
329
380
setRequiredFields (required );
381
+ BowlerStudio .runLater (()->{
382
+ measurmentPane .setDisable (false );
383
+ });
330
384
//}).start();
331
- sizePane .setDisable (true );
332
- measurmentPane .setDisable (false );
333
- typePane .setDisable (true );
385
+
334
386
}
335
387
336
388
private void setUpVitaminDefaults () {
@@ -423,10 +475,10 @@ void onConfirmType(ActionEvent event) {
423
475
typeOfVitaminString =slug ;
424
476
sizeComboBox .setDisable (true );
425
477
editExisting .setDisable (true );
426
- saveAndFork ();
478
+ sizePane . setDisable ( false ); // saveAndFork();
427
479
}else {
428
480
typeOfVitaminString =typeComboBox .getSelectionModel ().getSelectedItem ();
429
- saveAndFork ();
481
+ sizePane . setDisable ( false ); // saveAndFork();
430
482
ArrayList <String > sizes = Vitamins .listVitaminSizes (typeOfVitaminString );
431
483
boolean hasSize =false ;
432
484
@@ -457,19 +509,7 @@ void onConfirmType(ActionEvent event) {
457
509
458
510
}
459
511
460
- private void saveAndFork () {
461
- new Thread (() -> {
462
- try {
463
- Vitamins .saveDatabaseForkIfMissing (typeOfVitaminString );
464
- sizePane .setDisable (false );
465
- } catch (Exception e ) {
466
- // Auto-generated catch block
467
- new IssueReportingExceptionHandler ().uncaughtException (Thread .currentThread (), e );
468
-
469
- }
470
- }).start ();
471
512
472
- }
473
513
474
514
475
515
@ FXML
@@ -574,6 +614,7 @@ void initialize() {
574
614
typeComboBox .getSelectionModel ().select (typeOfVitaminString );
575
615
isShaft .setDisable (false );
576
616
isMotor .setDisable (false );
617
+
577
618
}
578
619
579
620
public static void launchWizard (INewVitaminCallback callback ) throws Exception {
@@ -583,11 +624,14 @@ public static void launchWizard(INewVitaminCallback callback) throws Exception {
583
624
primaryStage = s ;
584
625
new Thread (() -> {
585
626
NewVitaminWizardController controller = new NewVitaminWizardController ();
586
-
587
627
try {
628
+ SplashManager .renderSplashFrame (0 , "Creating personal Fork Of Vitamins" );
629
+ controller .saveAndFork ();
630
+ SplashManager .closeSplash ();
588
631
controller .start (s );
589
632
} catch (Exception e ) {
590
633
e .printStackTrace ();
634
+ SplashManager .closeSplash ();
591
635
}
592
636
}).start ();
593
637
});
0 commit comments