@@ -86,6 +86,7 @@ public class MainForm {
8686 @ Nullable Integer fiddApiPort ;
8787
8888 @ FXML @ Nullable TabPane mainTabPane ;
89+ @ FXML @ Nullable Tab fiddConnectionsTab ;
8990 @ FXML @ Nullable AnchorPane topPane ;
9091 @ FXML @ Nullable TableView <FiddConnection > fiddConnectionTableView ;
9192 @ FXML @ Nullable CheckBox encryptDecryptFiddConnectionsCheckBox ;
@@ -128,16 +129,23 @@ public void init(Stage mainStage, BaseRepositories repositories, FiddContentServ
128129 String fiddConnectionsFileStr = UserPreferencesManager .getUserPreference (FIDD_VIEW_FIDD_CONNECTIONS_FILE );
129130 String encryptDecryptFileStr = UserPreferencesManager .getUserPreference (FIDD_VIEW_ENCRYPT_DECRYPT );
130131 try {
131- boolean encryptDecryptFile = Boolean .parseBoolean (encryptDecryptFileStr );
132- checkNotNull (encryptDecryptFiddConnectionsCheckBox ).selectedProperty ().set (encryptDecryptFile );
132+ if (!StringUtils .isBlank (encryptDecryptFileStr )) {
133+ boolean encryptDecryptFile = Boolean .parseBoolean (encryptDecryptFileStr );
134+ checkNotNull (encryptDecryptFiddConnectionsCheckBox ).selectedProperty ().set (encryptDecryptFile );
135+ }
133136 } catch (Exception e ) { }
134137
135138 if (!StringUtils .isBlank (fiddConnectionsFileStr )) {
136139 checkNotNull (fiddConnectionsFileTextField ).textProperty ().set (fiddConnectionsFileStr );
137- loadFiddConnections (false );
138140 }
139141 checkNotNull (fiddConnectionsFileTextField ).textProperty ().addListener (
140142 (observableValue , s , t1 ) -> fiddConnectionsFileChanged ());
143+
144+ checkNotNull (mainTabPane ).getSelectionModel ().selectedItemProperty ().addListener ((obs , oldTab , newTab ) -> {
145+ if (newTab == fiddConnectionsTab && checkNotNull (fiddConnections ).isEmpty ()) {
146+ loadFiddConnections (false );
147+ }
148+ });
141149 }
142150
143151 private static TabKeyProvider buildMainKeyProvider (Stage mainStage ) {
@@ -463,7 +471,7 @@ public void openFiddConnections() {
463471 }
464472
465473 public void loadFiddConnections (boolean showAlerts ) {
466- if (!checkNotNull (fiddConnections ).isEmpty ()) {
474+ if (showAlerts && !checkNotNull (fiddConnections ).isEmpty ()) {
467475 if (JavaFxUtils .YesNo .NO ==
468476 JavaFxUtils .showYesNoDialog ("Load Fidd Connections File" ,
469477 "Current Fidd Connections will be lost. Continue?" )) {
@@ -487,8 +495,10 @@ public void loadFiddConnections(boolean showAlerts) {
487495 if (decrypt ) {
488496 Pair <X509Certificate , PrivateKey > pair = getCurrentCertificate ();
489497 if (pair == null ) {
490- JavaFxUtils .showMessage ("Certificate load error" ,
491- "Certificate load error. If you do not plan to use a certificate, uncheck \" Decrypt / Encrypt\" checkbox." );
498+ if (showAlerts ) {
499+ JavaFxUtils .showMessage ("Certificate load error" ,
500+ "Certificate load error. If you do not plan to use a certificate, uncheck \" Decrypt / Encrypt\" checkbox." );
501+ }
492502 return ;
493503 }
494504
0 commit comments