Building Parsers with Java

sjm.examples.logic
Class LogikusMediator

java.lang.Object
  |
  +--sjm.examples.logic.LogikusMediator

public class LogikusMediator
extends java.lang.Object
implements java.awt.event.ActionListener, java.lang.Runnable

This class supports a LogikusIde object, handling the interaction of the IDE's components.

An object of the IDE (Interactive Development Environment) has text areas for a Logikus program, a query against the program, and for the results of a query.

When a user clicks on the "Next" or "Rest" button, the mediator parses the program (if it has changed), and parses the query (if the query has changed). The mediator then proves the query against the program. After each proof, the mediator displays the query's variables in the results text area.

The mediator uses a separate thread to prove the query. While this thread conducts a proof, the mediator disables most of the IDE's components, except for the "Halt" button, which stops the proof thread.


Field Summary
protected  javax.swing.JButton clearProgramButton
           
protected  javax.swing.JButton clearResultsButton
           
protected  java.lang.Thread computeThread
           
protected  javax.swing.JButton haltButton
           
protected  java.lang.String lastProgramText
           
protected  java.lang.String lastQueryText
           
protected  Program program
           
protected  javax.swing.JTextArea programArea
           
protected  javax.swing.JButton proveNextButton
           
protected  boolean proveRemaining
           
protected  javax.swing.JButton proveRestButton
           
protected  Query query
           
protected  javax.swing.JTextArea queryArea
           
protected  javax.swing.JTextArea resultsArea
           
 
Constructor Summary
LogikusMediator()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          This method reacts, when the user presses one of the IDE's buttons.
protected  void conductProof()
           
protected  void display(java.lang.String s)
          Appends the given line to the results text area, scheduling this event with the event-dispatching thread.
 void initialize(javax.swing.JButton proveNextButton, javax.swing.JButton proveRestButton, javax.swing.JButton haltButton, javax.swing.JButton clearProgramButton, javax.swing.JButton clearResultsButton, javax.swing.JTextArea programArea, javax.swing.JTextArea resultsArea, javax.swing.JTextArea queryArea)
          Make the IDE's GUI components available.
protected  void parseProgramAndQuery()
           
protected  void proveNext()
           
protected  void proveRemaining()
           
 void run()
          Proves the query against the program.
protected  void setComputing(boolean computing)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

proveNextButton

protected javax.swing.JButton proveNextButton

proveRestButton

protected javax.swing.JButton proveRestButton

haltButton

protected javax.swing.JButton haltButton

clearProgramButton

protected javax.swing.JButton clearProgramButton

clearResultsButton

protected javax.swing.JButton clearResultsButton

programArea

protected javax.swing.JTextArea programArea

resultsArea

protected javax.swing.JTextArea resultsArea

queryArea

protected javax.swing.JTextArea queryArea

proveRemaining

protected boolean proveRemaining

computeThread

protected java.lang.Thread computeThread

lastProgramText

protected java.lang.String lastProgramText

lastQueryText

protected java.lang.String lastQueryText

program

protected Program program

query

protected Query query
Constructor Detail

LogikusMediator

public LogikusMediator()
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
This method reacts, when the user presses one of the IDE's buttons.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
ActionEvent - the event

conductProof

protected void conductProof()

display

protected void display(java.lang.String s)
Appends the given line to the results text area, scheduling this event with the event-dispatching thread.
Parameters:
String - the string to append to the results area

initialize

public void initialize(javax.swing.JButton proveNextButton,
                       javax.swing.JButton proveRestButton,
                       javax.swing.JButton haltButton,
                       javax.swing.JButton clearProgramButton,
                       javax.swing.JButton clearResultsButton,
                       javax.swing.JTextArea programArea,
                       javax.swing.JTextArea resultsArea,
                       javax.swing.JTextArea queryArea)
Make the IDE's GUI components available.

parseProgramAndQuery

protected void parseProgramAndQuery()

proveNext

protected void proveNext()

proveRemaining

protected void proveRemaining()

run

public void run()
Proves the query against the program.
Specified by:
run in interface java.lang.Runnable

setComputing

protected void setComputing(boolean computing)

by Steve Metsker