Commit 616a122c by Facundo Javier Gelatti

Extract method to run something in the main thread

1 parent 0667a84d
......@@ -223,7 +223,7 @@ public class EmbedUi implements StegosuiteUI {
@Override
public void extractingCompleted(String extractedMessage, String statusMessage, Visualizer visualizer, ImageData imageData) {
Display.getDefault().asyncExec(() -> {
runInGuiThread(() -> {
messageField.setText(extractedMessage);
Gui.setStatusBarMsg(statusMessage);
imageContainer.setImageData(ImageState.STEG, imageData);
......@@ -238,9 +238,13 @@ public class EmbedUi implements StegosuiteUI {
});
}
private void runInGuiThread(Runnable runnable) {
Display.getDefault().asyncExec(runnable);
}
@Override
public void embeddingCompleted(ImageFormat embeddedImage, String outputPath, Visualizer visualizer) {
Display.getDefault().asyncExec(() -> {
runInGuiThread(() -> {
imageContainer.setImageData(ImageState.STEG, embeddedImage.getImageData());
if (visualizer != null) {
imageContainer.setImageData(ImageState.STEG_VISUALIZED, visualizer.getImageData());
......@@ -263,7 +267,7 @@ public class EmbedUi implements StegosuiteUI {
}
private void displayError(String statusBarMessage, Button actionButton, String message) {
Display.getDefault().syncExec(() -> {
runInGuiThread(() -> {
MessageBox dialog = new MessageBox(composite.getShell(), SWT.ICON_ERROR | SWT.OK);
dialog.setText("Error");
dialog.setMessage(message);
......@@ -312,7 +316,7 @@ public class EmbedUi implements StegosuiteUI {
runInNewThread(() -> {
int capacity = presenter.getEmbeddingCapacity();
Display.getDefault().asyncExec(() -> {
runInGuiThread(() -> {
Gui.setStatusBarMsg(L.getString("statusbar_capacity") + ": " + ImageUtils.formatSize(capacity));
embedButton.setEnabled(true);
extractButton.setEnabled(true);
......@@ -351,7 +355,7 @@ public class EmbedUi implements StegosuiteUI {
@Override
public void addPayloadFile(String filename, String extension, long fileSize) {
Display.getDefault().asyncExec(() -> {
runInGuiThread(() -> {
fileSizeSum += fileSize;
addTableItemForFile(filename, fileSize, systemIconFor(extension));
updateFilesCount();
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!