Skip to content

Commit

Permalink
🐛 fixed "TreeUI should be accessed only from EDT" error
Browse files Browse the repository at this point in the history
  • Loading branch information
noyshabtay committed Dec 12, 2023
1 parent 021e47c commit f2dbe85
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/main/java/com/jfrog/ide/idea/ui/LocalComponentsTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ public static LocalComponentsTree getInstance(@NotNull Project project) {

public void addScanResults(List<FileTreeNode> fileTreeNodes) {
setCellRenderer(new ComponentsTreeCellRenderer());
ApplicationManager.getApplication().invokeLater(() -> {
doAddScanResults(fileTreeNodes);
});
ApplicationManager.getApplication().invokeLater(() -> doAddScanResults(fileTreeNodes));
}

/**
Expand Down Expand Up @@ -172,10 +170,9 @@ private JMenuItem createNavigationMenuItem(NavigationTarget navigationTarget, St
return new JBMenuItem(new AbstractAction(headLine) {
@Override
public void actionPerformed(ActionEvent e) {
if (!(navigationTarget.getElement() instanceof Navigatable)) {
if (!(navigationTarget.getElement() instanceof Navigatable navigatable)) {
return;
}
Navigatable navigatable = (Navigatable) navigationTarget.getElement();
if (navigatable.canNavigate()) {
navigatable.navigate(true);
}
Expand Down Expand Up @@ -245,21 +242,21 @@ public Long lastScanTime() {
* It means that this text will be shown only if the tree is empty.
*/
public void setScanningEmptyText() {
getEmptyText().setText(SCANNING);
SwingUtilities.invokeLater(() -> getEmptyText().setText(SCANNING));
}

/**
* Sets the empty text to indicate that the project was scanned and no issues were found.
* It means that this indication will be shown only if the tree is empty.
*/
public void setNoIssuesEmptyText() {
getEmptyText().setText(NO_ISSUES);
SwingUtilities.invokeLater(() -> getEmptyText().setText(NO_ISSUES));
}

/**
* Sets the empty text to indicate that during the project scan an error occurred.
*/
public void setScanErrorEmptyText() {
getEmptyText().setText(ERROR_WHILE_SCANNING);
SwingUtilities.invokeLater(() -> getEmptyText().setText(ERROR_WHILE_SCANNING));
}
}

0 comments on commit f2dbe85

Please sign in to comment.