src/Tools/Graphview/mutator_dialog.scala
changeset 59228 56b34fc7a015
parent 59224 e3f90d5c0006
child 59229 7b4b025b0599
--- a/src/Tools/Graphview/mutator_dialog.scala	Thu Jan 01 14:53:57 2015 +0100
+++ b/src/Tools/Graphview/mutator_dialog.scala	Thu Jan 01 15:58:30 2015 +0100
@@ -288,7 +288,7 @@
           List(
             ("", new iCheckBox("Parents", check_children)),
             ("", new iCheckBox("Children", check_parents)),
-            ("Regex", new iTextField(regex, x => Library.make_regex(x).isEmpty)),
+            ("Regex", new iTextField(regex, x => Library.make_regex(x).isDefined)),
             ("", new iCheckBox(reverse_caption, reverse)))
         case Mutator.Node_List(list, reverse, check_parents, check_children) =>
           List(
@@ -301,7 +301,7 @@
             ("Source", new iTextField(source)),
             ("Destination", new iTextField(dest)))
         case Mutator.Add_Node_Expression(regex) =>
-          List(("Regex", new iTextField(regex, x => Library.make_regex(x).isEmpty)))
+          List(("Regex", new iTextField(regex, x => Library.make_regex(x).isDefined)))
         case Mutator.Add_Transitive_Closure(parents, children) =>
           List(
             ("", new iCheckBox("Parents", parents)),
@@ -316,18 +316,16 @@
     def get_bool: Boolean
   }
 
-  private class iTextField(t: String, colorator: String => Boolean)
-  extends TextField(t) with Mutator_Input_Value
+  private class iTextField(t: String, check: String => Boolean = (_: String) => true)
+    extends TextField(t) with Mutator_Input_Value
   {
-    def this(t: String) = this(t, x => false)
-
     preferredSize = new Dimension(125, 18)
 
+    private val default_foreground = foreground
     reactions +=
     {
       case ValueChanged(_) =>
-        if (colorator(text)) background = Color.RED
-        else background = Color.WHITE
+        foreground = if (check(text)) default_foreground else visualizer.error_color
     }
 
     def get_string = text