src/Tools/jEdit/src/jedit/PhaseOverviewPanel.scala
changeset 34513 411017e76e98
parent 34503 7d0726f19d04
child 34538 20bfcca24658
equal deleted inserted replaced
34512:14d70378f1c7 34513:411017e76e98
    15 import org.gjt.sp.jedit.gui.RolloverButton;
    15 import org.gjt.sp.jedit.gui.RolloverButton;
    16 import org.gjt.sp.jedit.textarea.JEditTextArea;
    16 import org.gjt.sp.jedit.textarea.JEditTextArea;
    17 import org.gjt.sp.jedit.buffer.JEditBuffer;
    17 import org.gjt.sp.jedit.buffer.JEditBuffer;
    18 import org.gjt.sp.jedit._
    18 import org.gjt.sp.jedit._
    19 
    19 
    20 class PhaseOverviewPanel(prover : isabelle.prover.Prover) extends JPanel(new BorderLayout) {
    20 class PhaseOverviewPanel(prover: isabelle.prover.Prover, to_current: Int => Int) extends JPanel(new BorderLayout) {
    21 
    21 
    22   private val WIDTH = 10
    22   private val WIDTH = 10
    23 	private val HILITE_HEIGHT = 2
    23 	private val HILITE_HEIGHT = 2
    24   var textarea : JEditTextArea = null
    24   var textarea : JEditTextArea = null
    25 
    25 
    26   val repaint_delay = new isabelle.utils.Delay(100, () => repaint())
    26   val repaint_delay = new isabelle.utils.Delay(100, () => repaint())
    27   prover.command_info += (_ => repaint_delay.delay_or_ignore())
    27   prover.command_info += (_ => repaint_delay.delay_or_ignore())
    28     
    28 
    29   setRequestFocusEnabled(false);
    29   setRequestFocusEnabled(false);
    30 
    30 
    31   addMouseListener(new MouseAdapter {
    31   addMouseListener(new MouseAdapter {
    32     override def mousePressed(evt : MouseEvent) {
    32     override def mousePressed(evt : MouseEvent) {
    33       val line = yToLine(evt.getY)
    33       val line = yToLine(evt.getY)
    57       "TODO: Tooltip"
    57       "TODO: Tooltip"
    58     } else ""
    58     } else ""
    59 	}
    59 	}
    60 
    60 
    61   private def paintCommand(command : Command, buffer : JEditBuffer, gfx : Graphics) {
    61   private def paintCommand(command : Command, buffer : JEditBuffer, gfx : Graphics) {
    62       val line1 = buffer.getLineOfOffset(command.start)
    62       val line1 = buffer.getLineOfOffset(to_current(command.start))
    63       val line2 = buffer.getLineOfOffset(command.stop - 1) + 1
    63       val line2 = buffer.getLineOfOffset(to_current(command.stop - 1)) + 1
    64       val y = lineToY(line1)
    64       val y = lineToY(line1)
    65       val height = lineToY(line2) - y - 1
    65       val height = lineToY(line2) - y - 1
    66       val (light, dark) = command.status match {
    66       val (light, dark) = command.status match {
    67         case Command.Status.UNPROCESSED => (Color.yellow, new Color(128,128,0))
    67         case Command.Status.UNPROCESSED => (Color.yellow, new Color(128,128,0))
    68         case Command.Status.FINISHED => (Color.green, new Color(0, 128, 0))
    68         case Command.Status.FINISHED => (Color.green, new Color(0, 128, 0))
    82 		super.paintComponent(gfx)
    82 		super.paintComponent(gfx)
    83 
    83 
    84 		val buffer = textarea.getBuffer
    84 		val buffer = textarea.getBuffer
    85     for (c <- prover.document.commands)
    85     for (c <- prover.document.commands)
    86       paintCommand(c, buffer, gfx)
    86       paintCommand(c, buffer, gfx)
    87     
    87 
    88 	}
    88 	}
    89 
    89 
    90 	override def getPreferredSize : Dimension =
    90 	override def getPreferredSize : Dimension =
    91 	{
    91 	{
    92 		new Dimension(10,0)
    92 		new Dimension(10,0)