ubc.cs.JLog.Applet
Class gJLogApplicationBase

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by ubc.cs.JLog.Applet.gJLogApplicationBase
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, iJLogApplBaseServices, iMenuServiceRequester, iPrologFileServices
Direct Known Subclasses:
gJLogApplication

public abstract class gJLogApplicationBase
extends java.awt.Frame
implements iJLogApplBaseServices, iMenuServiceRequester

This is the abstract Application class for the Prolog in Java environment. It includes jPrologServices, but does not specify the user interface. It is designed as a super class for any applications which needs the jPrologServices. Derivative authors should inherit from this class to preserve the getApplicationInfo() credits. This class also supports the use of a single menu bar for all windows of the application. This is not straightforward because Java uses a per window menu bar by default. This class supports the construction of duplicate menu bars, so that each window can have the same menu bar (by appearance, but it is a copy), and also supports updating some common menu items so that they appear the same (e.g., same hilight, same check state) for all menu bar copies.

Author:
Glendon Holst
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected static gJLogBase base
           
protected  java.lang.String current_directory
           
protected static java.util.Vector kb_windows
           
static java.lang.String MENU_BREAK
           
static java.lang.String MENU_CLOSE
           
static java.lang.String MENU_CONSULTALLKB
           
static java.lang.String MENU_CONSULTKB
           
static java.lang.String MENU_COPY
           
static java.lang.String MENU_CUT
           
static java.lang.String MENU_DEBUG
           
static java.lang.String MENU_FIND
           
static java.lang.String MENU_FINDNEXT
           
static java.lang.String MENU_GOTOLINE
           
static java.lang.String MENU_LABEL_PAUSEQ_CONT
           
static java.lang.String MENU_LABEL_PAUSEQ_PAUSE
           
static java.lang.String MENU_PASTE
           
static java.lang.String MENU_PAUSEQ
           
static java.lang.String MENU_RESETKB
           
static java.lang.String MENU_SAVE
           
static java.lang.String MENU_SAVEAS
           
static java.lang.String MENU_SELECTALL
           
static java.lang.String MENU_STOPQ
           
static java.lang.String MENU_TRACE
           
static java.lang.String MENU_UNKNOWNPRED
           
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
gJLogApplicationBase()
           
 
Method Summary
 void addKBWindow(gConsultWindow w)
           
 java.lang.String convertStringLinebreaks(java.lang.String param)
           
 java.awt.MenuBar createMenuBar(iMenuServiceRequester s)
          This function returns a new menu bar, customized for the given iMenuServiceRequester.
 java.lang.String getApplicationInfo()
          This function returns the credit assignment and copyright informaiton string.
 java.lang.String getCurrentDirectory()
           
 java.awt.Image getImage(java.lang.String name)
           
 java.io.InputStream getInputStreamFromFilename(java.lang.String name)
           
 int getKBWindowCount()
           
 java.lang.String getParameter(java.lang.String name)
           
 jPrologServices getPrologServices()
           
 java.lang.String getRequiredCreditInfo()
           
 java.io.InputStream getResourceInputStreamFromFilename(java.lang.String name)
           
 java.net.URL getResourceURLFromFilename(java.lang.String name)
           
 java.lang.String getSource()
           
 java.lang.String getTextFromInputStream(java.io.InputStream in_strm)
           
protected  int getToolMenuID()
          Returns the index of the tool menu in the menu bar.
 java.net.URL getURLFromFilename(java.lang.String name)
           
protected  int getWindowMenuDynamicStart()
          Returns the index where the dynamic elements of the window menu start.
protected  int getWindowMenuID()
          Returns the index of the window menu in the menu bar.
 void removeKBWindow(gConsultWindow w)
           
 void setCurrentDirectory(java.lang.String d)
           
 void updateToolMenuConsultAll(boolean state)
           
 void updateToolMenuConsultAll(java.awt.MenuBar menubar, boolean state)
           
 void updateToolMenuDebug(boolean dbg, boolean unkpred, boolean trce, boolean brk, boolean in_query)
          This function updates the debug portion of the tool menu for all registered windows.
protected  void updateToolMenuDebug(java.awt.MenuBar menubar, boolean dbg, boolean unkpred, boolean trce, boolean brk, boolean in_query)
          This function updates the debug portion of the tool menu for all registered windows.
 void updateToolMenuQuery(boolean in_query, boolean paused)
           
protected  void updateToolMenuQuery(java.awt.MenuBar menubar, boolean in_query, boolean paused)
           
 void updateToolMenuReset(java.awt.MenuBar menubar, boolean state)
           
 void updateWindowMenu()
          Recreates the dynamic window menu for all registered windows.
protected  void updateWindowMenu(java.awt.MenuBar menubar)
          Recreates the dynamic portion of the window menu for the given menu bar.
 
Methods inherited from class java.awt.Frame
addNotify, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ubc.cs.JLog.Applet.iMenuServiceRequester
useMenuItem
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

MENU_CLOSE

public static final java.lang.String MENU_CLOSE
See Also:
Constant Field Values

MENU_SAVE

public static final java.lang.String MENU_SAVE
See Also:
Constant Field Values

MENU_SAVEAS

public static final java.lang.String MENU_SAVEAS
See Also:
Constant Field Values

MENU_CUT

public static final java.lang.String MENU_CUT
See Also:
Constant Field Values

MENU_COPY

public static final java.lang.String MENU_COPY
See Also:
Constant Field Values

MENU_PASTE

public static final java.lang.String MENU_PASTE
See Also:
Constant Field Values

MENU_SELECTALL

public static final java.lang.String MENU_SELECTALL
See Also:
Constant Field Values

MENU_FIND

public static final java.lang.String MENU_FIND
See Also:
Constant Field Values

MENU_FINDNEXT

public static final java.lang.String MENU_FINDNEXT
See Also:
Constant Field Values

MENU_GOTOLINE

public static final java.lang.String MENU_GOTOLINE
See Also:
Constant Field Values

MENU_CONSULTKB

public static final java.lang.String MENU_CONSULTKB
See Also:
Constant Field Values

MENU_CONSULTALLKB

public static final java.lang.String MENU_CONSULTALLKB
See Also:
Constant Field Values

MENU_RESETKB

public static final java.lang.String MENU_RESETKB
See Also:
Constant Field Values

MENU_PAUSEQ

public static final java.lang.String MENU_PAUSEQ
See Also:
Constant Field Values

MENU_STOPQ

public static final java.lang.String MENU_STOPQ
See Also:
Constant Field Values

MENU_DEBUG

public static final java.lang.String MENU_DEBUG
See Also:
Constant Field Values

MENU_UNKNOWNPRED

public static final java.lang.String MENU_UNKNOWNPRED
See Also:
Constant Field Values

MENU_TRACE

public static final java.lang.String MENU_TRACE
See Also:
Constant Field Values

MENU_BREAK

public static final java.lang.String MENU_BREAK
See Also:
Constant Field Values

MENU_LABEL_PAUSEQ_PAUSE

public static final java.lang.String MENU_LABEL_PAUSEQ_PAUSE
See Also:
Constant Field Values

MENU_LABEL_PAUSEQ_CONT

public static final java.lang.String MENU_LABEL_PAUSEQ_CONT
See Also:
Constant Field Values

base

protected static gJLogBase base

kb_windows

protected static java.util.Vector kb_windows

current_directory

protected java.lang.String current_directory
Constructor Detail

gJLogApplicationBase

public gJLogApplicationBase()
Method Detail

getApplicationInfo

public java.lang.String getApplicationInfo()
This function returns the credit assignment and copyright informaiton string. It must be preserved by authors of derivative works. All applications should be derived from the gJLogApplicationBase class, and if they provide their own getApplicationInfo() function it should invoke this version first. For example: return super.getApplicationInfo() + "derivative information";

Returns:
The credit and information string.

getRequiredCreditInfo

public java.lang.String getRequiredCreditInfo()
Specified by:
getRequiredCreditInfo in interface iJLogApplBaseServices

getSource

public java.lang.String getSource()
                           throws java.io.IOException
Specified by:
getSource in interface iJLogApplBaseServices
Throws:
java.io.IOException

getURLFromFilename

public java.net.URL getURLFromFilename(java.lang.String name)
                                throws java.net.MalformedURLException,
                                       java.io.IOException
Specified by:
getURLFromFilename in interface iJLogApplBaseServices
Specified by:
getURLFromFilename in interface iPrologFileServices
Throws:
java.net.MalformedURLException
java.io.IOException

getInputStreamFromFilename

public java.io.InputStream getInputStreamFromFilename(java.lang.String name)
                                               throws java.net.MalformedURLException,
                                                      java.io.IOException
Specified by:
getInputStreamFromFilename in interface iJLogApplBaseServices
Specified by:
getInputStreamFromFilename in interface iPrologFileServices
Throws:
java.net.MalformedURLException
java.io.IOException

getResourceURLFromFilename

public java.net.URL getResourceURLFromFilename(java.lang.String name)
                                        throws java.net.MalformedURLException,
                                               java.io.IOException
Specified by:
getResourceURLFromFilename in interface iPrologFileServices
Throws:
java.net.MalformedURLException
java.io.IOException

getResourceInputStreamFromFilename

public java.io.InputStream getResourceInputStreamFromFilename(java.lang.String name)
                                                       throws java.net.MalformedURLException,
                                                              java.io.IOException
Specified by:
getResourceInputStreamFromFilename in interface iPrologFileServices
Throws:
java.net.MalformedURLException
java.io.IOException

getTextFromInputStream

public java.lang.String getTextFromInputStream(java.io.InputStream in_strm)
                                        throws java.io.IOException
Specified by:
getTextFromInputStream in interface iJLogApplBaseServices
Specified by:
getTextFromInputStream in interface iPrologFileServices
Throws:
java.io.IOException

getParameter

public java.lang.String getParameter(java.lang.String name)
Specified by:
getParameter in interface iJLogApplBaseServices

convertStringLinebreaks

public java.lang.String convertStringLinebreaks(java.lang.String param)
Specified by:
convertStringLinebreaks in interface iJLogApplBaseServices

getImage

public java.awt.Image getImage(java.lang.String name)
Specified by:
getImage in interface iJLogApplBaseServices

createMenuBar

public java.awt.MenuBar createMenuBar(iMenuServiceRequester s)
This function returns a new menu bar, customized for the given iMenuServiceRequester. The menu bar will have the same layout and items, so that all windows have the same menus, but those menus items not handled by the application will be passed to the iMenuServiceRequester so that it can register a listener and the appropriate action.

Parameters:
s - The iMenuServiceRequester that this menu bar is for.
Returns:
A menu bar, customized for the given iMenuServiceRequester.

updateWindowMenu

public void updateWindowMenu()
Recreates the dynamic window menu for all registered windows.


updateWindowMenu

protected void updateWindowMenu(java.awt.MenuBar menubar)
Recreates the dynamic portion of the window menu for the given menu bar.

Parameters:
menubar - The MenuBar to update.

updateToolMenuDebug

public void updateToolMenuDebug(boolean dbg,
                                boolean unkpred,
                                boolean trce,
                                boolean brk,
                                boolean in_query)
This function updates the debug portion of the tool menu for all registered windows.

Parameters:
dbg - true is the debugging is on.
unkpred - true if prolog throws an error on unknown predicates. false if if unknown predicates are false.
trce - true is trace all goals.
brk - true if break after each step.
in_query - true if a query is presently underway.

updateToolMenuDebug

protected void updateToolMenuDebug(java.awt.MenuBar menubar,
                                   boolean dbg,
                                   boolean unkpred,
                                   boolean trce,
                                   boolean brk,
                                   boolean in_query)
This function updates the debug portion of the tool menu for all registered windows.

Parameters:
menubar - The iMenuServiceRequester that this menu bar is for.
dbg - true is the debugging is on.
unkpred - true if prolog throws an error on unknown predicates. false if if unknown predicates are false.
trce - true is trace all goals.
brk - true if break after each step.
in_query - true if a query is presently underway.

updateToolMenuQuery

public void updateToolMenuQuery(boolean in_query,
                                boolean paused)

updateToolMenuQuery

protected void updateToolMenuQuery(java.awt.MenuBar menubar,
                                   boolean in_query,
                                   boolean paused)

updateToolMenuReset

public void updateToolMenuReset(java.awt.MenuBar menubar,
                                boolean state)

updateToolMenuConsultAll

public void updateToolMenuConsultAll(boolean state)

updateToolMenuConsultAll

public void updateToolMenuConsultAll(java.awt.MenuBar menubar,
                                     boolean state)

addKBWindow

public void addKBWindow(gConsultWindow w)

removeKBWindow

public void removeKBWindow(gConsultWindow w)

getKBWindowCount

public int getKBWindowCount()

getToolMenuID

protected int getToolMenuID()
Returns the index of the tool menu in the menu bar.

Returns:
index number of tool menu in menu bar.

getWindowMenuID

protected int getWindowMenuID()
Returns the index of the window menu in the menu bar.

Returns:
index number of window menu in menu bar.

getWindowMenuDynamicStart

protected int getWindowMenuDynamicStart()
Returns the index where the dynamic elements of the window menu start.

Returns:
index number of first dynamic element in window menu.

getCurrentDirectory

public java.lang.String getCurrentDirectory()

setCurrentDirectory

public void setCurrentDirectory(java.lang.String d)

getPrologServices

public jPrologServices getPrologServices()
Specified by:
getPrologServices in interface iJLogApplBaseServices