mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
updates for async behavior
This commit is contained in:
parent
dc53c93eec
commit
1f7ab40a4d
@ -22,6 +22,7 @@ import java.awt.Component;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.texttranslation.NoServiceProviderException;
|
||||
@ -103,12 +104,15 @@ final class TextTranslatableComponent implements TranslatablePanel.TranslatableC
|
||||
this.translate = translate;
|
||||
if (this.translate) {
|
||||
if (this.translated == null) {
|
||||
try {
|
||||
this.translated = this.translationService.translate(this.origContent);
|
||||
} catch (NoServiceProviderException | TranslationException ex) {
|
||||
LOGGER.log(Level.WARNING, "Unable to translate text with translation service", ex);
|
||||
return Bundle.TextTranslatableComponent_setTranslated_onTranslateError();
|
||||
}
|
||||
final String originalContent = this.origContent;
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
try {
|
||||
this.translated = this.translationService.translate(originalContent);
|
||||
} catch (NoServiceProviderException | TranslationException ex) {
|
||||
LOGGER.log(Level.WARNING, "Unable to translate text with translation service", ex);
|
||||
return Bundle.TextTranslatableComponent_setTranslated_onTranslateError();
|
||||
}
|
||||
});
|
||||
}
|
||||
return onErr(setPanelContent(this.translated == null ? "" : this.translated));
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user