X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2FColorHelper.java;fp=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2FColorHelper.java;h=0000000000000000000000000000000000000000;hb=1e4c26b6d59f2cc40ce5af657c54ce65788e2c43;hp=0b65d2bec8ecf83891cd766bfd4cef246f0772d2;hpb=01c5d7035474a5eb58f216b6831b2c0d8c174efa;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java deleted file mode 100644 index 0b65d2be..00000000 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/ColorHelper.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.mograsim.logic.ui; - -import java.util.function.Consumer; -import java.util.function.Supplier; - -import org.eclipse.swt.graphics.Color; - -import net.haspamelodica.swt.helper.gcs.GeneralGC; -import net.mograsim.preferences.ColorDefinition; -import net.mograsim.preferences.ColorManager; - -public class ColorHelper -{ - public static void executeWithDifferentForeground(GeneralGC gc, ColorDefinition col, Runnable exec) - { - executeWithDifferentColor(col, gc::getForeground, gc::setForeground, exec); - } - - public static void executeWithDifferentBackground(GeneralGC gc, ColorDefinition col, Runnable exec) - { - executeWithDifferentColor(col, gc::getBackground, gc::setBackground, exec); - } - - private static void executeWithDifferentColor(ColorDefinition col, Supplier getColor, Consumer setColor, Runnable exec) - { - if (col == null) - exec.run(); - else - { - ColorManager cm = ColorManager.current(); - Color oldColor = getColor.get(); - Color newColor = cm.toColor(col); - setColor.accept(newColor); - exec.run(); - setColor.accept(oldColor); - } - } - - private ColorHelper() - { - throw new UnsupportedOperationException("No instances of ColorHelper"); - } -} \ No newline at end of file