package org.jabref.gui.actions;

import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.BasePanelPreferences;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.auximport.FromAuxDialog;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.Defaults;
import org.jabref.model.database.BibDatabaseContext;

/**
 * The action concerned with generate a new (sub-)database from latex AUX file.
 */
public class NewSubLibraryAction extends SimpleCommand {

    private final JabRefFrame jabRefFrame;

    public NewSubLibraryAction(JabRefFrame jabRefFrame) {
        this.jabRefFrame = jabRefFrame;
    }

    @Override
    public void execute() {
        FromAuxDialog dialog = new FromAuxDialog(jabRefFrame, "", true, jabRefFrame.getTabbedPane());

        dialog.setVisible(true);

        if (dialog.generatePressed()) {
            Defaults defaults = new Defaults(Globals.prefs.getDefaultBibDatabaseMode());
            BasePanel bp = new BasePanel(jabRefFrame, BasePanelPreferences.from(Globals.prefs), new BibDatabaseContext(dialog.getGenerateDB(), defaults), ExternalFileTypes.getInstance());
            jabRefFrame.addTab(bp, true);
            jabRefFrame.output(Localization.lang("New library created."));
        }
    }

}

@@ -26,16 +26,52 @@
 tions;%0A%0A
+import javax.swing.SwingUtilities;%0A%0A
 import o
@@ -770,24 +770,71 @@
 execute() %7B%0A
+        SwingUtilities.invokeLater(() -%3E %7B%0A    
         From
@@ -932,16 +932,20 @@
         
+    
 dialog.s
@@ -958,24 +958,28 @@
 ble(true);%0A%0A
+    
         if (
@@ -1018,16 +1018,20 @@
         
+    
 Defaults
@@ -1095,24 +1095,28 @@
 aseMode());%0A
+    
             
@@ -1295,32 +1295,36 @@
 ));%0A            
+   
+ 
 jabRefFrame.addT
@@ -1337,16 +1337,20 @@
  true);%0A
+    
         
@@ -1424,17 +1424,33 @@
         
-%7D
+    %7D%0A        %7D);
 %0A    %7D%0A%0A

Fix #4134: no longer freeze when clicking browse in aux import dialog (#4181)