src/Tools/jEdit/src/jedit/StateViewDockable.scala
author wenzelm
Tue, 20 Jan 2009 18:23:40 +0100
changeset 34489 7b7ccf0ff629
parent 34456 14367c0715e8
child 34552 65f1b2261cc6
permissions -rw-r--r--
replaced java.util.Property by plain association list; handle_result: do not parse ignored messages; tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34408
ad7b6c4813c8 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     1
/*
ad7b6c4813c8 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     2
 * Dockable window with rendered state output
ad7b6c4813c8 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     3
 *
ad7b6c4813c8 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     4
 * @author Fabian Immler, TU Munich
ad7b6c4813c8 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     5
 * @author Johannes Hölzl, TU Munich
ad7b6c4813c8 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     6
 */
ad7b6c4813c8 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     7
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
     8
package isabelle.jedit
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
     9
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    10
34424
c880492754d0 setPreferredSize for floating dockables;
wenzelm
parents: 34408
diff changeset
    11
import java.awt.{BorderLayout, Dimension}
c880492754d0 setPreferredSize for floating dockables;
wenzelm
parents: 34408
diff changeset
    12
import javax.swing.{JButton, JPanel, JScrollPane}
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    13
34438
2faedc70b52d proper import isabelle.renderer.UserAgent;
wenzelm
parents: 34434
diff changeset
    14
import isabelle.renderer.UserAgent
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    15
34428
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    16
import org.xhtmlrenderer.simple.{XHTMLPanel, FSScrollPane}
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    17
import org.xhtmlrenderer.context.AWTFontResolver
34428
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    18
import org.xhtmlrenderer.layout.SharedContext;
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    19
import org.xhtmlrenderer.extend.TextRenderer;
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    20
import org.xhtmlrenderer.swing.Java2DTextRenderer;
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    21
34428
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    22
import org.gjt.sp.jedit.jEdit
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    23
import org.gjt.sp.jedit.View
34424
c880492754d0 setPreferredSize for floating dockables;
wenzelm
parents: 34408
diff changeset
    24
import org.gjt.sp.jedit.gui.DockableWindowManager
34428
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    25
import org.gjt.sp.jedit.textarea.AntiAlias
34424
c880492754d0 setPreferredSize for floating dockables;
wenzelm
parents: 34408
diff changeset
    26
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    27
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    28
class StateViewDockable(view : View, position : String) extends JPanel {
34424
c880492754d0 setPreferredSize for floating dockables;
wenzelm
parents: 34408
diff changeset
    29
34428
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    30
  // outer panel
34424
c880492754d0 setPreferredSize for floating dockables;
wenzelm
parents: 34408
diff changeset
    31
  if (position == DockableWindowManager.FLOATING)
c880492754d0 setPreferredSize for floating dockables;
wenzelm
parents: 34408
diff changeset
    32
    setPreferredSize(new Dimension(500, 250))
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34397
diff changeset
    33
  setLayout(new BorderLayout)
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34397
diff changeset
    34
34428
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    35
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    36
  // XHTML panel
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    37
  val panel = new XHTMLPanel(new UserAgent)
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    38
34361
3e7568e833d9 selecting text of state view
immler@in.tum.de
parents: 34353
diff changeset
    39
34428
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    40
  // anti-aliasing
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    41
  // TODO: proper EditBus event handling
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    42
  {
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    43
    val aa = jEdit.getProperty("view.antiAlias")
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    44
    if (aa != null && aa != AntiAlias.NONE) {
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    45
      panel.getSharedContext.setTextRenderer(
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    46
        {
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    47
          val renderer = new Java2DTextRenderer
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    48
          renderer.setSmoothingThreshold(0)
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    49
          renderer.setSmoothingLevel(TextRenderer.HIGH)
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    50
          renderer
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    51
        })
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    52
    }
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    53
  }
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    54
34434
ba08fc74f98a renamed Plugin.plugin to Plugin.self;
wenzelm
parents: 34428
diff changeset
    55
  
34428
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    56
  // copy & paste
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    57
  (new SelectionActions).install(panel)
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    58
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    59
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    60
  // scrolling
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    61
  add(new FSScrollPane(panel), BorderLayout.CENTER)
d69fd18f37f9 basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents: 34424
diff changeset
    62
34361
3e7568e833d9 selecting text of state view
immler@in.tum.de
parents: 34353
diff changeset
    63
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34397
diff changeset
    64
  private val fontResolver =
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34397
diff changeset
    65
    panel.getSharedContext.getFontResolver.asInstanceOf[AWTFontResolver]
34440
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34438
diff changeset
    66
  if (Isabelle.plugin.font != null)
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34438
diff changeset
    67
    fontResolver.setFontMapping("Isabelle", Isabelle.plugin.font)
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34397
diff changeset
    68
34456
14367c0715e8 replaced EventSource by EventBus;
wenzelm
parents: 34441
diff changeset
    69
  Isabelle.plugin.font_changed += (font => {
34440
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34438
diff changeset
    70
    if (Isabelle.plugin.font != null)
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34438
diff changeset
    71
      fontResolver.setFontMapping("Isabelle", Isabelle.plugin.font)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    72
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34397
diff changeset
    73
    panel.relayout()
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34397
diff changeset
    74
  })
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34397
diff changeset
    75
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    76
}