ix.ip2
Class ObjectWhiteboard

java.lang.Object
  extended by ix.ip2.ObjectWhiteboard
All Implemented Interfaces:
ProcessStatusListener, StateViewer, java.util.EventListener

public class ObjectWhiteboard
extends java.lang.Object
implements StateViewer


Nested Class Summary
(package private)  class ObjectWhiteboard.Fact
          What we need to know about world-state entries ("facts").
(package private)  class ObjectWhiteboard.HtmlAnalyser
          The variation on HtmlTableWalker used by the analyseHTML method.
(package private) static class ObjectWhiteboard.NewRowDialog
          A modal dialog that requests the information needed to create a new row in the table.
(package private)  class ObjectWhiteboard.ResetHook
           
(package private) static class ObjectWhiteboard.ViewHtmlStringWriter
          The type of HtmlStringWriter used when constructing the HTML table that describes an ObjectView.
(package private)  class ObjectWhiteboard.WhiteboardFrame
          An ObjectWhiteboard's GUI.
 
Field Summary
(package private)  java.lang.Object BLANK
           
(package private)  ObjectWhiteboard.WhiteboardFrame frame
           
(package private)  java.util.Map fromPattern
           
(package private)  java.util.Map fromTD
           
(package private) static boolean hasBeenVisible
           
(package private)  Ip2 ip2
           
(package private)  Ip2ModelManager mm
           
(package private)  java.util.SortedMap nameToViewMap
           
(package private)  java.util.SortedSet objects
           
(package private)  java.util.List properties
           
(package private)  StructuralEquality structEqual
           
(package private)  ObjectView view
           
 
Constructor Summary
  ObjectWhiteboard(Ip2 ip2)
          Create a viewer for the indicated agent.
protected ObjectWhiteboard(Ip2 ip2, java.util.SortedMap nameToViews)
          Create a viewer for the indicated agent with references to any existing views.
 
Method Summary
(package private)  void addObject(Symbol name)
           
(package private)  void addObject(Symbol name, java.lang.Object type)
           
(package private)  void analyseHTML(java.util.Map state, javax.swing.text.html.HTMLDocument doc)
          Sets up connections between the world state and the HTML.
(package private)  void clearFacts()
           
(package private)  ObjectWhiteboard.Fact getFact(javax.swing.text.Element elt)
           
(package private)  ObjectWhiteboard.Fact getFact(LList pattern)
           
(package private)  java.util.Collection getFacts()
           
(package private)  Plan getFactsAsPlan()
           
 ObjectView getObjectView()
           
 ObjectView getObjectView(java.lang.String name)
           
(package private)  java.lang.Object getPropValue(ObjectProperty prop, java.lang.Object obj, java.util.Map state)
           
(package private)  javax.swing.text.html.HTML.Tag getTag(javax.swing.text.Element elt)
          Returns the HTML.Tag of an Element.
 java.awt.Component getView(PanelFrame panelFrame)
          Return the GUI component that should be placed in the agent's main user-interface frame.
(package private)  void loadViewContents()
          Reload the current view from the agent's current world-state.
(package private)  void loadViewContentsSavingState()
          Reload the current view without losing any editing the user may have done.
(package private)  void loadViews(java.lang.String viewDir)
          Adds views from the indicated directory.
(package private)  java.lang.String makeHtmlTable(java.util.Map worldState)
          Constructs an HTML table that describes the current view.
 void newBindings(ProcessStatusEvent event, java.util.Map bindings)
          Ignored by this viewer.
(package private)  void processStateDelta(java.util.Map delta, boolean isDeletion)
           
 java.util.SortedMap readViews(java.lang.String directoryName)
          Tries to read an ObjectView from each file in the indicated directory that might contain one.
 void reset()
          Sets the viewer back to its initial state (or a reasonable approximation).
(package private)  void restoreFactEditState(java.util.Map savedState)
           
(package private)  java.util.Map saveFactEditState()
           
 void setObjectView(ObjectView view)
           
 void setObjectView(java.lang.String name)
           
 void setVisible(boolean v)
           
 void stateChange(ProcessStatusEvent event, java.util.Map delta)
           
 void stateDeletion(ProcessStatusEvent event, java.util.Map delta)
           
 void statusUpdate(ProcessStatusEvent event)
          Ignored by this viewer.
(package private)  void submitChanges()
           
(package private)  void whenFirstMadeVisible()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ip2

Ip2 ip2

mm

Ip2ModelManager mm

frame

ObjectWhiteboard.WhiteboardFrame frame

nameToViewMap

java.util.SortedMap nameToViewMap

view

ObjectView view

objects

java.util.SortedSet objects

properties

java.util.List properties

hasBeenVisible

static boolean hasBeenVisible

fromPattern

java.util.Map fromPattern

fromTD

java.util.Map fromTD

structEqual

StructuralEquality structEqual

BLANK

final java.lang.Object BLANK
Constructor Detail

ObjectWhiteboard

public ObjectWhiteboard(Ip2 ip2)
Create a viewer for the indicated agent.


ObjectWhiteboard

protected ObjectWhiteboard(Ip2 ip2,
                           java.util.SortedMap nameToViews)
Create a viewer for the indicated agent with references to any existing views.

Method Detail

setVisible

public void setVisible(boolean v)

whenFirstMadeVisible

void whenFirstMadeVisible()

getView

public java.awt.Component getView(PanelFrame panelFrame)
Description copied from interface: StateViewer
Return the GUI component that should be placed in the agent's main user-interface frame. The frame is passed as a parameter in case different objects must be returned for different frame classes.

Specified by:
getView in interface StateViewer

reset

public void reset()
Description copied from interface: StateViewer
Sets the viewer back to its initial state (or a reasonable approximation).

Specified by:
reset in interface StateViewer

statusUpdate

public void statusUpdate(ProcessStatusEvent event)
Ignored by this viewer.

Specified by:
statusUpdate in interface ProcessStatusListener

newBindings

public void newBindings(ProcessStatusEvent event,
                        java.util.Map bindings)
Ignored by this viewer.

Specified by:
newBindings in interface ProcessStatusListener

stateChange

public void stateChange(ProcessStatusEvent event,
                        java.util.Map delta)
Specified by:
stateChange in interface ProcessStatusListener

stateDeletion

public void stateDeletion(ProcessStatusEvent event,
                          java.util.Map delta)
Specified by:
stateDeletion in interface ProcessStatusListener

processStateDelta

void processStateDelta(java.util.Map delta,
                       boolean isDeletion)

getObjectView

public ObjectView getObjectView()

getObjectView

public ObjectView getObjectView(java.lang.String name)

setObjectView

public void setObjectView(java.lang.String name)

setObjectView

public void setObjectView(ObjectView view)

addObject

void addObject(Symbol name)

addObject

void addObject(Symbol name,
               java.lang.Object type)

loadViewContentsSavingState

void loadViewContentsSavingState()
Reload the current view without losing any editing the user may have done.


loadViewContents

void loadViewContents()
Reload the current view from the agent's current world-state.


loadViews

void loadViews(java.lang.String viewDir)
Adds views from the indicated directory.


readViews

public java.util.SortedMap readViews(java.lang.String directoryName)
Tries to read an ObjectView from each file in the indicated directory that might contain one. If any view does not have a name, it is given the name of the corresponding file. View names must be unique within the directory. Returns a map from names to ObjectViews.


makeHtmlTable

java.lang.String makeHtmlTable(java.util.Map worldState)
Constructs an HTML table that describes the current view. However, property values are not included; instead each "td" element that will contain a value instead contains the text "BLANK". The correct values are filled-in later by calling analyseHTML after the HTML has been installed as a document.

For a description of the HTML's structure, see HtmlTableWalker.

See Also:
ObjectWhiteboard.WhiteboardFrame.setHtml(String htmlText), analyseHTML(Map state, HTMLDocument doc)

getPropValue

java.lang.Object getPropValue(ObjectProperty prop,
                              java.lang.Object obj,
                              java.util.Map state)

analyseHTML

void analyseHTML(java.util.Map state,
                 javax.swing.text.html.HTMLDocument doc)
Sets up connections between the world state and the HTML. Finds each part of an HTML table that represent the value of an object property, creates a ObjectWhiteboard.Fact to connect the world-state pattern with the HTML element, and asks the Fact to write in the current value of the property.

The HTML must have the same structure as that created by makeHtmlTable(Map worldState).


getTag

javax.swing.text.html.HTML.Tag getTag(javax.swing.text.Element elt)
Returns the HTML.Tag of an Element.


getFact

ObjectWhiteboard.Fact getFact(LList pattern)

getFact

ObjectWhiteboard.Fact getFact(javax.swing.text.Element elt)

getFacts

java.util.Collection getFacts()

getFactsAsPlan

Plan getFactsAsPlan()

clearFacts

void clearFacts()

submitChanges

void submitChanges()

saveFactEditState

java.util.Map saveFactEditState()

restoreFactEditState

void restoreFactEditState(java.util.Map savedState)