|
@@ -26,6 +26,7 @@ import com.dmdirc.DMDircMBassador;
|
26
|
26
|
import com.dmdirc.addons.ui_swing.components.DMDircUndoableEditListener;
|
27
|
27
|
import com.dmdirc.addons.ui_swing.components.RunnableLoggingSwingWorker;
|
28
|
28
|
import com.dmdirc.addons.ui_swing.components.RunnableSwingWorker;
|
|
29
|
+import com.dmdirc.addons.ui_swing.components.SupplierLoggingSwingWorker;
|
29
|
30
|
import com.dmdirc.util.colours.Colour;
|
30
|
31
|
|
31
|
32
|
import java.awt.Color;
|
|
@@ -41,6 +42,7 @@ import java.lang.reflect.InvocationTargetException;
|
41
|
42
|
import java.util.concurrent.Callable;
|
42
|
43
|
import java.util.concurrent.FutureTask;
|
43
|
44
|
import java.util.function.Consumer;
|
|
45
|
+import java.util.function.Supplier;
|
44
|
46
|
|
45
|
47
|
import javax.swing.BorderFactory;
|
46
|
48
|
import javax.swing.JComboBox;
|
|
@@ -282,6 +284,21 @@ public final class UIUtilities {
|
282
|
284
|
new RunnableLoggingSwingWorker<>(eventBus, runnable, consumer).execute();
|
283
|
285
|
}
|
284
|
286
|
|
|
287
|
+ /**
|
|
288
|
+ * Invokes something off the EDT, handling the result when its finished on the EDT, logging
|
|
289
|
+ * any exceptions that occur.
|
|
290
|
+ *
|
|
291
|
+ * @param eventBus Eventbus to post errors to
|
|
292
|
+ * @param runnable Runnable to execute off the EDT
|
|
293
|
+ * @param consumer Consumer to finalise the runnable on the EDT
|
|
294
|
+ *
|
|
295
|
+ * @param <T> Type the consumer takes
|
|
296
|
+ */
|
|
297
|
+ public static <T> void invokeOffEDT(final DMDircMBassador eventBus, final Supplier<T> runnable,
|
|
298
|
+ final Consumer<T> consumer) {
|
|
299
|
+ new SupplierLoggingSwingWorker<>(eventBus, runnable, consumer).execute();
|
|
300
|
+ }
|
|
301
|
+
|
285
|
302
|
/**
|
286
|
303
|
* Check if we are using the GTK look and feel.
|
287
|
304
|
*
|