org.ceryle
Class XNodeShell

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 javax.swing.JFrame
                      extended by org.ceryle.XNodeShell
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ListDataListener, ListSelectionListener, RootPaneContainer, WindowConstants, MessageWriter

public class XNodeShell
extends JFrame
implements MessageWriter, ListDataListener, ListSelectionListener

This driver class can be used to launch the XNode shell UI application. This includes a lightweight application framework with a menu bar and editable text area. This is a singleton class because the XNode database implementation doesn't currently implement record locking.

Ceryle XNodeShell
The XNode Implementation (the package org.ceryle.xnode.*, both its source code and documentation), are released under the Apache 2.0 License. For more details, check the LICENSE file contained with the distribution, or see The Ceryle Project for more information. It is distributed with no warranty.

ResourceBundles and I18N/L10N

Note that the XNodeShell implementation uses the core set of the Ceryle message text resources, using only the ResourceBundle associated with the org.ceryle.util.MsgId/org.ceryle.util.Msg classes (but not MessageId/Messages). All MsgId keys must begin with an underscore character ("_").

Since:
JDK1.3
Version:
$Id: XNodeShell.java,v 3.6 2007-06-20 01:28:08 altheim Exp $
Author:
Murray Altheim
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String APP_NAME
          The displayed name of the application.
 File homeDirectory
          The Ceryle application home directory.
 File m_defaultDirectory
          The default directory used by the application for file operations.
static int maxOutputChars
          The maximum number of characters to show in the message area at any time.
static String PROPERTY_USER_DIR
          The System property name for the user directory.
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
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 javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Method Summary
protected  void clearDocument()
          Clears the document content.
 void contentsChanged(ListDataEvent e)
          A method required by the ListDataListener API informing the framework of any changes to the collections list.
static XNodeShell createInstance(String[] args)
          The XNodeShell factory method, returning an instance of XNodeShell.
 void dbAction(XNodeState state)
          Uses an XNodeState as a directive to control the database.
 void deleteCollection(String cid)
          Delete an XNodeCollection.
 void deleteDocument(String cid, String nid)
          Delete an XNode.
 void displayShell()
          Display the UI frame.
 JCheckBoxMenuItem getCheckBoxMenuItem(String name, String label, int key, boolean checked, Action action)
          Return a checkbox menu item provided with its features.
 String getCollectionID()
          Returns the currently-selected Collection ID, or null if there is either no Collections or none is selected in the list.
 List getCollectionIndex()
          Returns a List view of the collection index, as provided by the root collection.
protected  Document getContentAsDocument(String content)
          Turns the String content into an XML Document, either as valid or well-formed XML, or as a CDATA section.
 PlainDocument getDocument()
          Returns the document used in the JTextArea.
 MIME getFormat()
          Returns the content type (DC.format) of the loaded document.
 XNodeStore getXNodeStore()
          Returns a lazily-instantiated XNodeStore, providing database services.
protected  void indexCollection()
          Indexes the currently-selected Collection, returning an iterator over the node IDs.
protected  void indexCollection(String cid)
          Indexes a Collection whose ID is the String cid, returning an iterator over the node IDs.
protected  void indexCollections()
          Set the Collection list to the current list provided by the XNodeStore, and enable the collection buttons, returning an Iterator over the list of collections.
 void indexNodes(String cid, String selectnid)
          Set the Node list to the contents of the Collection whose ID is cid, enable the node buttons, returning an Iterator over the node list.
 void intervalAdded(ListDataEvent e)
          A stub method required for API compliance.
 void intervalRemoved(ListDataEvent e)
          A stub method required for API compliance.
 boolean isConnected()
          Returns true if a database connection is currently available.
 boolean isWriteable(String cid, String nid)
          Returns true if we can write to the provided collection and document ID.
static void main(String[] args)
          The XNodeShell main class, calling the factory method.
 void modifyDocument(String cid, String nid)
          Modify an existing XNode.
 void newCollection(String cid)
          Create a new XNodeCollection.
 void newDocument(String cid, String nid)
          Create a new XNode.
 void op1()
          unused.
 String openCollection(String cid)
          Open an XNodeCollection, returning the Collection ID, null if unavailable.
 void openDocument(String cid, String nid)
          Open an XNode.
 void refresh()
          Refreshes the display upon activating this DocumentView, such as updating the database node list (which is local to each DocumentView but may be altered by changes made in others).
 void scrollToLine(int line)
          Scrolls the document content to line line of the document.
 void selectCollectionInList(String cid)
          Selects the current collection in the Collection list based on the Collection ID String cid, if such a collection actually appears in the list.
 void selectNodeInList(String nid)
          Selects the current node in the Node list based on the Node ID String nid, if such a node actually appears in the list.
 void setFormat(MIME mime)
          Sets the content type (DC.format) of the loaded document to the MIME type mime.
 void setMessageDividerLocation(double loc)
          Sets the position of the vertical divider location between the center pane and the message area.
 void unimplemented()
          A temporary method to handle unimplemented menu and button method calls.
 void valueChanged(ListSelectionEvent e)
           
 String writeMessage(int status, String message)
          Appends the String message to the message area, prepending a status indicator for errors and warnings.
 void writeMessage(String message)
          Appends the String message to the message area.
 void writeStatus(String message)
          Sets the status text to the String message.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, 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, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, 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, 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, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

APP_NAME

public static final String APP_NAME
The displayed name of the application.

See Also:
Constant Field Values

PROPERTY_USER_DIR

public static final String PROPERTY_USER_DIR
The System property name for the user directory. The value is "user.dir".

See Also:
Constant Field Values

maxOutputChars

public static int maxOutputChars
The maximum number of characters to show in the message area at any time. Setting this less than zero will disable the feature. The default is 10000.


m_defaultDirectory

public File m_defaultDirectory
The default directory used by the application for file operations.


homeDirectory

public final File homeDirectory
The Ceryle application home directory.

Method Detail

displayShell

public void displayShell()
Display the UI frame.


newCollection

public void newCollection(String cid)
Create a new XNodeCollection.


openCollection

public String openCollection(String cid)
Open an XNodeCollection, returning the Collection ID, null if unavailable.


deleteCollection

public void deleteCollection(String cid)
Delete an XNodeCollection.


newDocument

public void newDocument(String cid,
                        String nid)
Create a new XNode.


openDocument

public void openDocument(String cid,
                         String nid)
Open an XNode.


modifyDocument

public void modifyDocument(String cid,
                           String nid)
Modify an existing XNode.


deleteDocument

public void deleteDocument(String cid,
                           String nid)
Delete an XNode.


isWriteable

public boolean isWriteable(String cid,
                           String nid)
Returns true if we can write to the provided collection and document ID.


getContentAsDocument

protected Document getContentAsDocument(String content)
Turns the String content into an XML Document, either as valid or well-formed XML, or as a CDATA section. If unable, returns null.


getDocument

public PlainDocument getDocument()
Returns the document used in the JTextArea.


clearDocument

protected void clearDocument()
Clears the document content. This will eliminate any selection as a side effect.


scrollToLine

public void scrollToLine(int line)
Scrolls the document content to line line of the document. This will change the current selection as a side effect. If the provided line offset is 0, scrolls to the top of the document. If the provided line offset is -1, a dialog box queries the user.


indexCollections

protected void indexCollections()
Set the Collection list to the current list provided by the XNodeStore, and enable the collection buttons, returning an Iterator over the list of collections. This replaces any existing collection list. If there are no collections or the database is unavailable, removes all elements (this can be used to clear the list).


indexCollection

protected void indexCollection()
Indexes the currently-selected Collection, returning an iterator over the node IDs.


indexCollection

protected void indexCollection(String cid)
Indexes a Collection whose ID is the String cid, returning an iterator over the node IDs.


indexNodes

public void indexNodes(String cid,
                       String selectnid)
Set the Node list to the contents of the Collection whose ID is cid, enable the node buttons, returning an Iterator over the node list. If the Node nid is not null and is a member of the specified collection, its ID will be selected and the list will scroll to display it. This replaces any existing node list. If cid is null, removes all elements (used to clear the list).


refresh

public void refresh()
Refreshes the display upon activating this DocumentView, such as updating the database node list (which is local to each DocumentView but may be altered by changes made in others).


getCollectionID

public String getCollectionID()
Returns the currently-selected Collection ID, or null if there is either no Collections or none is selected in the list.


getCollectionIndex

public List getCollectionIndex()
Returns a List view of the collection index, as provided by the root collection. Like the method in the XNodeCollection API, this returns an empty list rather than null.


selectCollectionInList

public void selectCollectionInList(String cid)
Selects the current collection in the Collection list based on the Collection ID String cid, if such a collection actually appears in the list. Clears the selection otherwise. This does not cause the Collection to be reloaded, unless it has changed.


selectNodeInList

public void selectNodeInList(String nid)
Selects the current node in the Node list based on the Node ID String nid, if such a node actually appears in the list. Clears the selection otherwise. This does not cause the node to be loaded.


dbAction

public void dbAction(XNodeState state)
Uses an XNodeState as a directive to control the database. The accepted states include:
XNodeState.START
A directive to start the database kernel (if not already running).
XNodeState.STOP
A directive to stop the database kernel (if running).
XNodeState.STATUS
Print the status of the database.
Other XNodeStates are ignored.


getXNodeStore

public XNodeStore getXNodeStore()
Returns a lazily-instantiated XNodeStore, providing database services.


isConnected

public boolean isConnected()
Returns true if a database connection is currently available.


writeMessage

public void writeMessage(String message)
Appends the String message to the message area. Implements the MessageWriter API.

Specified by:
writeMessage in interface MessageWriter

writeMessage

public String writeMessage(int status,
                           String message)
Appends the String message to the message area, prepending a status indicator for errors and warnings. Implements the MessageWriter API.

Specified by:
writeMessage in interface MessageWriter
Returns:
the String value of the message, including any changes made.
See Also:
MessageHandler

writeStatus

public void writeStatus(String message)
Sets the status text to the String message. Implements the MessageWriter API.

Specified by:
writeStatus in interface MessageWriter

getCheckBoxMenuItem

public JCheckBoxMenuItem getCheckBoxMenuItem(String name,
                                             String label,
                                             int key,
                                             boolean checked,
                                             Action action)
Return a checkbox menu item provided with its features. Negative numbers for key will use no Control key.

Parameters:
name - the menu item mnemonic identifier.
label - the label text.
key - the menu item accelerator keystroke.
checked - the initial checked state.
action - the action to be taken.

setFormat

public void setFormat(MIME mime)
Sets the content type (DC.format) of the loaded document to the MIME type mime. This is meant to be used by processes that load content into the view.


getFormat

public MIME getFormat()
Returns the content type (DC.format) of the loaded document.


setMessageDividerLocation

public void setMessageDividerLocation(double loc)
Sets the position of the vertical divider location between the center pane and the message area.


contentsChanged

public void contentsChanged(ListDataEvent e)
A method required by the ListDataListener API informing the framework of any changes to the collections list.

Specified by:
contentsChanged in interface ListDataListener

intervalAdded

public void intervalAdded(ListDataEvent e)
A stub method required for API compliance.

Specified by:
intervalAdded in interface ListDataListener

intervalRemoved

public void intervalRemoved(ListDataEvent e)
A stub method required for API compliance.

Specified by:
intervalRemoved in interface ListDataListener

valueChanged

public void valueChanged(ListSelectionEvent e)
Specified by:
valueChanged in interface ListSelectionListener

op1

public void op1()
unused.


unimplemented

public void unimplemented()
A temporary method to handle unimplemented menu and button method calls.


createInstance

public static XNodeShell createInstance(String[] args)
The XNodeShell factory method, returning an instance of XNodeShell.


main

public static void main(String[] args)
The XNodeShell main class, calling the factory method.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.