Swing Fixes

Call on the tree update from the swing thread
This commit is contained in:
Konloch 2021-07-15 08:29:42 -07:00
parent 0d27212f07
commit 39233ca3eb
2 changed files with 18 additions and 15 deletions

View file

@ -14,14 +14,7 @@ import java.io.File;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import javax.swing.AbstractAction; import javax.swing.*;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode; import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
@ -163,7 +156,6 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
{ {
try try
{ {
//TODO refresh while preserving the opened files from before the refresh //TODO refresh while preserving the opened files from before the refresh
treeRoot.removeAllChildren(); treeRoot.removeAllChildren();
for (ResourceContainer container : BytecodeViewer.resourceContainers) for (ResourceContainer container : BytecodeViewer.resourceContainers)
@ -347,9 +339,14 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
try try
{ {
imp.getImporter().open(tempFile); imp.getImporter().open(tempFile);
try { SwingUtilities.invokeLater(()->
updateTree(); {
} catch (NullPointerException ignored) { } try
{
updateTree();
}
catch (NullPointerException ignored) { }
});
} }
catch (Exception e) catch (Exception e)
{ {

View file

@ -4,6 +4,7 @@ import org.apache.commons.io.FilenameUtils;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Settings; import the.bytecode.club.bytecodeviewer.Settings;
import javax.swing.*;
import java.io.File; import java.io.File;
/*************************************************************************** /***************************************************************************
@ -74,9 +75,14 @@ public class ImportResource implements Runnable
finally finally
{ {
BytecodeViewer.updateBusyStatus(false); BytecodeViewer.updateBusyStatus(false);
try { SwingUtilities.invokeLater(()->
BytecodeViewer.viewer.resourcePane.updateTree(); {
} catch (NullPointerException ignored) { } try
{
BytecodeViewer.viewer.resourcePane.updateTree();
}
catch (NullPointerException ignored) { }
});
} }
} }