src/Tools/jEdit/src/theories_dockable.scala
changeset 68759 4247e91fa21d
parent 68758 a110e7e24e55
child 68760 0626cae56b6f
equal deleted inserted replaced
68758:a110e7e24e55 68759:4247e91fa21d
    48         val index_location = peer.indexToLocation(index)
    48         val index_location = peer.indexToLocation(index)
    49         if (index >= 0 && in_checkbox(index_location, point))
    49         if (index >= 0 && in_checkbox(index_location, point))
    50           tooltip = "Mark as required for continuous checking"
    50           tooltip = "Mark as required for continuous checking"
    51         else if (index >= 0 && in_label(index_location, point)) {
    51         else if (index >= 0 && in_label(index_location, point)) {
    52           val name = listData(index)
    52           val name = listData(index)
    53           val st = overall_node_status(name)
    53           val st = nodes_status.overall_node_status(name)
    54           tooltip =
    54           tooltip =
    55             "theory " + quote(name.theory) +
    55             "theory " + quote(name.theory) +
    56               (if (st == Overall_Node_Status.ok) "" else " (" + st + ")")
    56               (if (st == Document_Status.Overall_Node_Status.ok) "" else " (" + st + ")")
    57         }
    57         }
    58         else tooltip = null
    58         else tooltip = null
    59     }
    59     }
    60   }
    60   }
    61   status.peer.setLayoutOrientation(JList.HORIZONTAL_WRAP)
    61   status.peer.setLayoutOrientation(JList.HORIZONTAL_WRAP)
    95   add(controls.peer, BorderLayout.NORTH)
    95   add(controls.peer, BorderLayout.NORTH)
    96 
    96 
    97 
    97 
    98   /* component state -- owned by GUI thread */
    98   /* component state -- owned by GUI thread */
    99 
    99 
   100   private var nodes_status: Map[Document.Node.Name, Document_Status.Node_Status] = Map.empty
   100   private var nodes_status = Document_Status.Nodes_Status.empty
   101   private var nodes_required: Set[Document.Node.Name] = Document_Model.required_nodes()
   101   private var nodes_required: Set[Document.Node.Name] = Document_Model.required_nodes()
   102 
       
   103   private object Overall_Node_Status extends Enumeration
       
   104   {
       
   105     val ok, failed, pending = Value
       
   106   }
       
   107 
       
   108   private def overall_node_status(name: Document.Node.Name): Overall_Node_Status.Value =
       
   109     nodes_status.get(name) match {
       
   110       case Some(st) if st.consolidated =>
       
   111         if (st.ok) Overall_Node_Status.ok else Overall_Node_Status.failed
       
   112       case _ => Overall_Node_Status.pending
       
   113     }
       
   114 
   102 
   115   private def in(geometry: Option[(Point, Dimension)], loc0: Point, p: Point): Boolean =
   103   private def in(geometry: Option[(Point, Dimension)], loc0: Point, p: Point): Boolean =
   116     geometry match {
   104     geometry match {
   117       case Some((loc, size)) =>
   105       case Some((loc, size)) =>
   118         loc0.x + loc.x <= p.x && p.x < loc0.x + size.width &&
   106         loc0.x + loc.x <= p.x && p.x < loc0.x + size.width &&
   187       }
   175       }
   188     }
   176     }
   189 
   177 
   190     def label_border(name: Document.Node.Name)
   178     def label_border(name: Document.Node.Name)
   191     {
   179     {
   192       val status = overall_node_status(name)
   180       val status = nodes_status.overall_node_status(name)
   193       val color =
   181       val color =
   194         if (status == Overall_Node_Status.failed) PIDE.options.color_value("error_color")
   182         if (status == Document_Status.Overall_Node_Status.failed)
       
   183           PIDE.options.color_value("error_color")
   195         else label.foreground
   184         else label.foreground
   196       val thickness1 = if (status == Overall_Node_Status.pending) 1 else 2
   185       val thickness1 = if (status == Document_Status.Overall_Node_Status.pending) 1 else 2
   197       val thickness2 = 3 - thickness1
   186       val thickness2 = 3 - thickness1
   198 
   187 
   199       label.border =
   188       label.border =
   200         BorderFactory.createCompoundBorder(
   189         BorderFactory.createCompoundBorder(
   201           BorderFactory.createLineBorder(color, thickness1),
   190           BorderFactory.createLineBorder(color, thickness1),
   239               status + (name -> st)
   228               status + (name -> st)
   240             }
   229             }
   241         })
   230         })
   242 
   231 
   243     val nodes_status2 =
   232     val nodes_status2 =
   244       nodes_status1 -- nodes_status1.keysIterator.filter(nodes.is_suppressed(_))
   233       (nodes_status1 /: nodes_status1.keys_iterator.filter(nodes.is_suppressed(_)))(_ - _)
   245 
   234 
   246     if (nodes_status != nodes_status2) {
   235     if (nodes_status != nodes_status2) {
   247       nodes_status = nodes_status2
   236       nodes_status = nodes_status2
   248       status.listData = nodes.topological_order.filter(nodes_status.isDefinedAt(_))
   237       status.listData = nodes.topological_order.filter(nodes_status.defined(_))
   249     }
   238     }
   250   }
   239   }
   251 
   240 
   252 
   241 
   253   /* main */
   242   /* main */