org.ceryle.ui
Class DocumentView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.ceryle.ui.View
                      extended by org.ceryle.ui.DocumentView
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ListDataListener, ListSelectionListener, EditView
Direct Known Subclasses:
OccurrenceViewer.OccurrenceView

public class DocumentView
extends View
implements EditView, ListDataListener, ListSelectionListener

A class that extends View to provide document editing facilities. This uses a CardLayout to enable a two-mode layout: either as a simple note card, or as a full-blown editor. While internally, an individual database record is referred to as a "node", users will see the word "document."

This includes a number of methods exposing the internal JTextArea so that it can be manipulated as a JTextComponent. This also includes a split pane area for access to the XNode database. This is meant to be embedded in a ViewFrame.

Note

This and the GraphView class have historically been places where a great deal of experimental coding has happened, so there may be variables and methods here that are not meant to be permanent parts of the application.

Since:
JDK1.4
Version:
$Id: DocumentView.java,v 3.80 2007-06-20 01:28:16 altheim Exp $
Author:
Murray Altheim
See Also:
Serialized Form

Nested Class Summary
protected  class DocumentView.FileImporter
          Internal class extends Thread to import/convert a file, provided either a File or URL object.
protected  class DocumentView.PositionTracker
          Internal class extends JLabel to track the location of the editor caret.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
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 boolean autoIndex
          Variable controlling whether an index should be created upon changes to the collection or node lists.
static String AUX_CARD
          An identifier for the auxiliary card (not used by this class).
static String EDITOR_CARD
          An identifier for the editor card.
static String LIST_CARD
          An identifier for the list-style database navigator card.
protected  JToolBar m_alttools
          The alternate tool bar used by extensions.
protected  JComponent m_container
          The internal panel containing the entire view content, used for class extensibility.
protected  JToolBar m_doctools
          The document tool bar.
protected  JComponent m_docview
          The internal panel containing the document view content.
protected  JPanel m_outerNest
           
protected  NotePopupMenu m_popupmenu
          The popup menu used with notes.
protected  JComponent m_southComponent
          The internal panel containing any BorderLayout.SOUTH extension content.
protected  JToolBar m_toolbar
          The current tool bar.
static String NOTE_CARD
          An identifier for the note card.
 boolean showNodeTitles
          When true, the Node titles are shown rather than IDs.
 boolean suspendTracking
          A boolean indicating that the caret tracker should cease functioning temporarily.
static String TREE_CARD
          An identifier for the tree-style database navigator card.
static boolean useDragAndDrop
          Variable controlling whether drag and drop is supported.
 
Fields inherited from class org.ceryle.ui.View
DOCUMENT, GRAPH, isClosing, m_desktop, m_verbose, mh, NOTE, pm, PROJECT, srvs, vf, vmgr
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
DocumentView(ViewFrame viewframe, int type)
          Constructor with a reference to its wrapper ViewFrame (not used with a tabbed pane model).
DocumentView(ViewFrame viewframe, int type, String title)
          A "convenience constructor" that allows the View title to be set at construction time.
 
Method Summary
 ToolButton addToolbarButton(String tooltip, ActionListener listener)
          This is a feature meant to be exploited by developers and/or external Groovy scripts.
 void archiveCollections()
          Archives the selected Collections to a selected Zip file.
 boolean changeID()
          Change the ID of the current document.
 void checkRevisionLimits(String cid, XNode xnode)
          If revision control limits are active, alerts the user if either the revision count or space limit of the provided XNode has been exceeded.
protected  void clearNodes()
          Clear the node list.
protected  boolean closeDocument()
          Checks to see that the current document is unmodified, providing a save option.
protected  boolean closeDocument(boolean confirm, boolean forced)
          Checks to see that the current document is unmodified, providing a save option if confirm is true.
 void closeForm(FormPanel formpanel)
          Closes any open FormPanel, redisplaying the editor card.
 void closing()
          This method should be called before closing the DocumentView to allow safe closing of any dirty content, removing listeners, etc.
 void colTitleMode(boolean showTitles)
          Sets the state of showing either Node IDs or titles.
protected  void composeView(int type)
          Put the highest-level components together.
 void contentsChanged(ListDataEvent e)
          A method required by the ListDataListener API informing the framework of any changes to the collections list.
 String createCollection()
          Create a new Collection , querying for ID and title.
 String createCollection(String cid, String title)
          Create a new Collection whose identifier is the String cid, with optional title.
protected  JSplitPane createCollectionPanel()
          Creates a scrollable, clickable selection list (as a JList), returning it as a new panel.
protected  boolean createNode()
          Add the current view content as a new Node, using the current Collection and Node ID fields as its identifiers.
protected  boolean createNode(String cid, String nid)
          Add the current view content as a new Node.
protected  void deleteCollection()
          Delete the Collection at index index.
protected  void deleteNode(boolean confirm)
          Delete the Node using the ID field as its identifier.
 void deselectNode()
          Clears any selection in the Node list.
 void differenceDialog()
          Temporary differenceDialog TEMP.
 void disableTools()
          Hides any visible tools, and disables the ability to set them visible again.
 boolean docCheck(boolean verbose)
          Checks the current document for well-formedness or valid content, depending on the property validating set from the command line at the start of the application.
 void docPlink()
          Plinks the current document after checking for well-formedness or valid content.
 void docTidy()
          Fixes the markup in the current document using an instance of JTidy.
 String documentSummary(int maxLength)
          Produces a text summary of the current XNode, returning the first maxLength characters of the text of the node, doing the best it can based upon each node's MIME type.
 void dump(boolean exit)
          Closes the current Document with no checks for saving its content.
 boolean duplicateNode(boolean canSelectCID)
          Duplicate the currently-loaded Node in the current collection, querying for the Collection and Node IDs, returning true if successful.
 void editCopy()
          Copies the text area's selection to the system clipboard.
 void editCut()
          Deletes the text area's current selection, placing it into the system clipboard.
 void editPaste()
          Pastes the system clipboard to either the text area's selection or its current caret 'dot' position.
 void editRedo()
          Reverses the previous undo action.
 void editSelectAll()
          Selects the entire content of the text area.
 void editUndo()
          Reverses the previous edit action.
protected  void exportCollection(String cid)
          Exports the currently-selected Collection.
 void exportPDB()
          Exports the current contents of the DocumentView as a PilotDoc file.
 boolean fileClose(boolean forced)
          Closes the current Document, first checking to be sure that the text is unmodified.
 boolean fileImport(Object source)
          If source is null, displays a FileChooser and obtains the selected File, then uses methods within SourceProcessor to determine which import processor to call to import the file type.
 boolean fileNew()
          Creates a new, empty Document.
 boolean fileOpen(File file)
          Opens the selected File, then creates a org.ceryle.util.ResourceOpener thread to open the File into the current View.
 boolean fileSave(File file)
          If the systemId of this DocumentView has been set (eg., by an earlier file open or import), displays a file selection dialog box with the existing filepath (otherwise uses the current default directory), returns the selected path, then exports the contents of the current Document to the chosen path.
 void find()
          Find.
 void findNext()
          Repeats the previous Find operation.
 JToolBar getAltToolBar()
          Returns the alternative toolbar if it has been initialized, null if not.
 JPanel getAuxCard()
          Returns the Auxiliary card (empty on creation).
 String getCollectionID()
          Returns the currently-selected Collection ID, or null if there is either no Collections or none is selected in the list.
protected  CollectionList getCollectionList()
          Returns the CollectionList for this DocumentView.
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.
 DatabaseToolBar getDatabaseTools()
          Returns the database toolbar.
 String getDefaultCollection()
          Returns a String containing the name of the default Collection, throwing a ProcessException if it has not been set.
 DocumentToolBar getDocumentToolBar()
          Returns the lazily-created DocumentToolBar.
 EditorPanel getEditor()
          Returns the EditorPanel.
 Color getEditorBackground()
          Returns the background color of this DocumentView's editor.
 Font getEditorFont()
          Returns the Font used by the editor.
 boolean getEditorLineWrap()
          Returns the line wrapping policy of the editor, true if wrapping.
 String getNIDFromList()
          Gets the ID value based on the current node list selection.
protected  Set getNIDs(String cid)
          Returns the current Node ID list if the Collection ID matches that supplied, otherwise null.
protected  void getNode()
          Display the Node identified by the default Collection and the Node ID field in the document view pane.
 void getNode(String cid, String nid)
          Display Node ID nid of Collection ID cid in the document view pane.
protected  JPopupMenu getPopupMenu()
          Return the JPopupMenu for the DocumentView (this is currently only used with Notes).
 XNodeRevisionManagerDialog getRevisionManagerDialog()
          Returns the Revision Manager dialog, null if it has not been created already by showRevisionManager().
 SearchTool getSearchTool()
          Returns the Search toolbar.
 String getSelectedResource()
          Returns the URI (as a String) of the selected resource, within the context of its View type, null if unavailable or inappropriate.
 JTextArea getTextArea()
          Returns the EditorArea (an extension of a Swing JTextArea) used as the text editor component of this DocumentView, to be used for presentation, relative size, positioning of forms, and caret attachment.
 JToolBar getToolBar()
          Returns the JToolbar of this panel.
 int getType()
          Returns the View type as an int.
 WikiTools getWikiTools()
          Returns the WikiTools subpanel, creating if necessary.
 void importCollection()
          Imports a new collection from a user-selected directory of files.
 Document importPDB(TypedInputSource source)
          Imports the PDB file as a TypedInputSource source, populating this DocumentView's text area.
 void importPSIDocument(String filename)
          Parse LTM using Ceryle's LtmParser, suitable for PSI document creation (retains comments and order of declaration).
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.
 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 interpretGroovy(String script)
          Interprets the String script as a Groovy script.
 void intervalAdded(ListDataEvent e)
          A stub method required for API compliance.
 void intervalRemoved(ListDataEvent e)
          A stub method required for API compliance.
 boolean isDatabaseVisible()
          Returns true if the database collection/node list is visible.
 boolean isDirty()
          Returns an indication of true if the current document has been edited.
 boolean isDocument()
          Convenience indicator that this is a Document view.
 boolean isExtendedView()
          Returns true if either the alternative toolbar or the optional southern component are set (non-null).
 boolean isNote()
          Convenience indicator that this is a Note view.
 boolean isStoredNode()
          Returns true if the Collection and Node IDs indicate an XMLDB URI matching the system identifier, and the node exists.
 boolean isWikiToolsMaximized()
          Returns true if the embedded Wiki Tools subpanel is currently maximized.
protected  void matchUndoRedoState(boolean undoable, boolean redoable)
          Sets the enabled or disabled state of the undo and redo buttons and menu items as appropriate to the state of the UndoManager.
 boolean modifyNode()
          Modify an existing Node whose ID matches the current collection and node ID fields, returning true if successful.
 boolean modifyNode(String cid, String nid)
          Modify an existing Node whose ID matches the String nid, in Collection ID cid, returning true if successful.
protected  boolean nodeModifyPossible()
          Returns true if there is a default Collection set and the ID field has an XML Name as its content.
 void nodeTitleMode(boolean showTitles)
          Sets the state of showing either Node IDs or titles.
protected  String openCollection()
          Opens a Collection whose cid matches the current selection from the Collection list, returning the Collection cid as a String.
protected  String openCollection(String cid)
          Opens the Collection cid as the default Collection.
 void overrideDisable()
          If the tools have been disabled, calling this method will re-enable them (though not actually show them).
 void packView()
          Suggests to the DocumentView that it resize any internal components appropriate to its current size.
 void popUpWindow()
          [TEMP] Opens a PopUpWindow.
 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 reindexNodes()
          Reindex and update the display of the current Node list.
 void removeExtensions()
          If the alternative toolbar and/or southern component have been set, this re-creates a normal DocumentView by removing the extensions.
 void replace()
          Replace.
 void requestFocus()
          Sets the current focus to the editor's text area.
 void resetDividers()
          Resets the split pane dividers to their default locations.
protected  void restoreCollections()
          Restores one or more Collections from a user-selected Zip file.
 void saveProperties()
          Saves any document editor properties to the property file.
 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.
protected  void serializeToDocumentView(Document doc, int method)
          Provided with a DOM Document, serializes as an XML document to the editor text area.
protected  void serializeToDocumentView(Document doc, int method, boolean sniff)
          Provided with a DOM Document, serializes as an XML document to the editor text area.
 void setDatabaseToolsVisible(boolean visible)
          Sets the visibility of the database toolbar to the boolean visible, updating the menu item appropriately.
protected  void setDatabaseVisible(boolean viz)
          Sets the visibility of the database toolbar and the node metadata to the boolean viz.
 void setEditable(boolean editable)
          Sets the editor's editable state to the boolean editable.
 void setEditorDocument(Document doc)
          Sets the editor document to the provided java.text.Document.
 void setEditorFont(Font font)
          Sets the Font used by the editor.
 void setEditorLineWrap(boolean wrap)
          Sets the line wrapping policy for the editor to the boolean wrap.
 void setEditorText(String content)
          Sets the content of the editor to the String content.
 void setMode(int mode)
          Sets the display mode of this DocumentView.
 void setNIDFieldFromNodeList()
          Sets the Node ID field based on the current selection in the Node list.
 void setSearchToolVisible(boolean visible)
          Toggles visibility of the Search toolbar to the boolean visible, updating the menu item appropriately.
 void setSystemId(String systemId)
          Stores the value of the last-opened file's pathname as a String.
 void setTitle(String title)
          Sets the title of this View to the String title.
 void setTitle(String title, boolean query)
          Sets the title of this View's document to the String title.
 void setToolBar(JToolBar toolbar)
          Sets the tool bar of this DocumentView to the provided tool bar.
 void setToolsVisible(boolean visible)
          Sets the visibility of the current toolbar to the boolean visible, updating the menu item appropriately.
 void setWikiToolsMaximized(boolean maximized)
          Sets visibility of the WikiTools subpanel.
 void showDatabaseManager()
          Displays the Database Manager dialog.
 FormPanel showForm(Element root, String cid, String nid)
          Creates a FormPanel from the supplied DOM node, collection and node IDs, displaying in the auxiliary card.
 void showRevisionManager()
          Displays the Revision Manager dialog for the currently loaded collection.
 void showStatistics()
          Display document statistics in a dialog.
 boolean storeOnImport(String uri)
          Called by a ResourceOpener upon receipt of a document.
protected  void toggleDivider()
          Toggles position of the Collection and Node list divider.
 void valueChanged(ListSelectionEvent e)
           
 void visualizeCollections()
          Visualizes one or more Collections (selected via dialog) using a new GraphView, or the current one if this View is a ProjectView.
 void yoi()
          In one fell motion, simplifies the display.
 
Methods inherited from class org.ceryle.ui.View
deactivate, fileSave, fileSaveAs, getDesktop, getSystemId, getTitle, getTypeName, getViewFrame, getViewManager, hasDatabase, hasEditing, hasGraph, isDocumentOrNoteView, isDocumentView, isGraphView, isNoteView, isProjectView, setViewFrame
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOTE_CARD

public static final String NOTE_CARD
An identifier for the note card.

See Also:
Constant Field Values

EDITOR_CARD

public static final String EDITOR_CARD
An identifier for the editor card.

See Also:
Constant Field Values

AUX_CARD

public static final String AUX_CARD
An identifier for the auxiliary card (not used by this class).

See Also:
Constant Field Values

TREE_CARD

public static final String TREE_CARD
An identifier for the tree-style database navigator card.

See Also:
Constant Field Values

LIST_CARD

public static final String LIST_CARD
An identifier for the list-style database navigator card.

See Also:
Constant Field Values

useDragAndDrop

public static boolean useDragAndDrop
Variable controlling whether drag and drop is supported. Default is true, but this can be altered via the http://purl.org/ceryle/prop/#dragAndDrop property.


autoIndex

public static boolean autoIndex
Variable controlling whether an index should be created upon changes to the collection or node lists.


showNodeTitles

public boolean showNodeTitles
When true, the Node titles are shown rather than IDs.


suspendTracking

public boolean suspendTracking
A boolean indicating that the caret tracker should cease functioning temporarily.


m_container

protected JComponent m_container
The internal panel containing the entire view content, used for class extensibility.


m_docview

protected JComponent m_docview
The internal panel containing the document view content.


m_southComponent

protected JComponent m_southComponent
The internal panel containing any BorderLayout.SOUTH extension content.


m_toolbar

protected JToolBar m_toolbar
The current tool bar.


m_doctools

protected JToolBar m_doctools
The document tool bar.


m_alttools

protected JToolBar m_alttools
The alternate tool bar used by extensions.


m_popupmenu

protected NotePopupMenu m_popupmenu
The popup menu used with notes.


m_outerNest

protected final JPanel m_outerNest
Constructor Detail

DocumentView

public DocumentView(ViewFrame viewframe,
                    int type,
                    String title)
A "convenience constructor" that allows the View title to be set at construction time.


DocumentView

public DocumentView(ViewFrame viewframe,
                    int type)
Constructor with a reference to its wrapper ViewFrame (not used with a tabbed pane model). If the int editorMode is View.PROJECT or View.DOCUMENT, the initial display shows as a full-blown editor window; if View.NOTE, as a simple note field. (The only influence of type as View.PROJECT is whether or not the DocumentToolBar is floatable. In all other respects the embedded DocumentView is identical.)

Note that the DocumentView itself (which is a JPanel underneath all) does not commit its BorderLayout.SOUTH area.

Parameters:
viewframe - the parent ViewFrame container
type - the initial display mode
Method Detail

isExtendedView

public boolean isExtendedView()
Returns true if either the alternative toolbar or the optional southern component are set (non-null).


removeExtensions

public void removeExtensions()
If the alternative toolbar and/or southern component have been set, this re-creates a normal DocumentView by removing the extensions.


disableTools

public void disableTools()
Hides any visible tools, and disables the ability to set them visible again.


overrideDisable

public void overrideDisable()
If the tools have been disabled, calling this method will re-enable them (though not actually show them).


composeView

protected void composeView(int type)
Put the highest-level components together.


setMode

public void setMode(int mode)
Sets the display mode of this DocumentView. When editorMode is View.NOTE, the window displays a simple "post-it" note window. Otherwise, it displays the full complement of its "normal" features.


getDefaultCollection

public String getDefaultCollection()
                            throws ProcessException
Returns a String containing the name of the default Collection, throwing a ProcessException if it has not been set. If the DocumentView is in Note mode, this returns the default Notes collection ID. This doesn't load the collection, only return the ID.

Throws:
ProcessException

showForm

public FormPanel showForm(Element root,
                          String cid,
                          String nid)
                   throws ProcessException
Creates a FormPanel from the supplied DOM node, collection and node IDs, displaying in the auxiliary card.

Returns:
the resulting FormPanel
Throws:
ProcessException

closeForm

public void closeForm(FormPanel formpanel)
Closes any open FormPanel, redisplaying the editor card.


saveProperties

public void saveProperties()
Saves any document editor properties to the property file.


getPopupMenu

protected JPopupMenu getPopupMenu()
Return the JPopupMenu for the DocumentView (this is currently only used with Notes).


isNote

public boolean isNote()
Convenience indicator that this is a Note view.


isDocument

public boolean isDocument()
Convenience indicator that this is a Document view. This also returns true when the DocumentView is embedded in a ProjectView.


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).

Specified by:
refresh in class View

setSystemId

public void setSystemId(String systemId)
Stores the value of the last-opened file's pathname as a String. Clear by setting to null.

Overrides:
setSystemId in class View

setTitle

public void setTitle(String title)
Sets the title of this View to the String title. This is a protected method, as the title should only be set by the parent ViewFrame, as in view.getViewFrame().setTitle(title).

Overrides:
setTitle in class View

setTitle

public void setTitle(String title,
                     boolean query)
Sets the title of this View's document to the String title. This method differs from the setTitle(String) method in that if query is true, a user query dialog is displayed using the provided String title as default.

Overrides:
setTitle in class View

changeID

public boolean changeID()
Change the ID of the current document.

Returns:
true if changed

resetDividers

public void resetDividers()
Resets the split pane dividers to their default locations.


toggleDivider

protected void toggleDivider()
Toggles position of the Collection and Node list divider.


closing

public void closing()
This method should be called before closing the DocumentView to allow safe closing of any dirty content, removing listeners, etc.

Specified by:
closing in class View

addToolbarButton

public ToolButton addToolbarButton(String tooltip,
                                   ActionListener listener)
This is a feature meant to be exploited by developers and/or external Groovy scripts. The listener parameter is optional, as in Groovy 1.0 inner classes aren't supported, so rather than adding a listener at the point of creation, in Groovy you'd add a closure after the button is returned to you.

This will ignore requests after 26 buttons, as there are no icons available and having more than that many extra buttons is completely insane.


yoi

public void yoi()
In one fell motion, simplifies the display.


createCollectionPanel

protected JSplitPane createCollectionPanel()
Creates a scrollable, clickable selection list (as a JList), returning it as a new panel.


colTitleMode

public void colTitleMode(boolean showTitles)
Sets the state of showing either Node IDs or titles.


getSelectedResource

public String getSelectedResource()
Returns the URI (as a String) of the selected resource, within the context of its View type, null if unavailable or inappropriate.

Specified by:
getSelectedResource in class View
See Also:
View

createCollection

public String createCollection()
Create a new Collection , querying for ID and title.

Returns:
the new Collection ID, or null if cancelled or otherwise failed.

createCollection

public String createCollection(String cid,
                               String title)
Create a new Collection whose identifier is the String cid, with optional title. If the ID is null, it will be requested via a dialog box.

Parameters:
cid - the new Collection ID
title - the optional Collection title
Returns:
the new Collection ID, or null if cancelled or otherwise failed.

getCollectionList

protected CollectionList getCollectionList()
Returns the CollectionList for this DocumentView.


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.


openCollection

protected String openCollection()
Opens a Collection whose cid matches the current selection from the Collection list, returning the Collection cid as a String.


openCollection

protected String openCollection(String cid)
Opens the Collection cid as the default Collection. Returns a String containing the CID of the default Collection, null is unavailable.


deleteCollection

protected void deleteCollection()
Delete the Collection at index index.


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.


indexCollections

public 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).


archiveCollections

public void archiveCollections()
Archives the selected Collections to a selected Zip file.


importCollection

public void importCollection()
Imports a new collection from a user-selected directory of files. This imports *.txt, *.htm, *.html, and *.xml files.


exportCollection

protected void exportCollection(String cid)
Exports the currently-selected Collection.


restoreCollections

protected void restoreCollections()
Restores one or more Collections from a user-selected Zip file.


visualizeCollections

public void visualizeCollections()
Visualizes one or more Collections (selected via dialog) using a new GraphView, or the current one if this View is a ProjectView.


createNode

protected boolean createNode()
Add the current view content as a new Node, using the current Collection and Node ID fields as its identifiers.

Returns:
true if the node was created

createNode

protected boolean createNode(String cid,
                             String nid)
                      throws ProcessException
Add the current view content as a new Node. This queries for a title, and populates the node ID field with an ID-converted form of the title.

Returns:
true if the node was created.
Throws:
ProcessException

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.


modifyNode

public boolean modifyNode()
Modify an existing Node whose ID matches the current collection and node ID fields, returning true if successful. If the node doesn't exist, this is identical in functionality to createNode(). If the node already exists, its content will be changed and its metadata updated accordingly.


modifyNode

public boolean modifyNode(String cid,
                          String nid)
Modify an existing Node whose ID matches the String nid, in Collection ID cid, returning true if successful. If the node doesn't exist, this is identical in functionality to createNode(cid,nid). If the node already exists, its content will be changed and its metadata updated accordingly.


checkRevisionLimits

public void checkRevisionLimits(String cid,
                                XNode xnode)
If revision control limits are active, alerts the user if either the revision count or space limit of the provided XNode has been exceeded. If limits are inactive, this method does nothing.


duplicateNode

public boolean duplicateNode(boolean canSelectCID)
Duplicate the currently-loaded Node in the current collection, querying for the Collection and Node IDs, returning true if successful. If canSelectCID is true, the collection ID is selectable.


getNode

protected void getNode()
Display the Node identified by the default Collection and the Node ID field in the document view pane.


getNode

public void getNode(String cid,
                    String nid)
Display Node ID nid of Collection ID cid in the document view pane.


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.


setNIDFieldFromNodeList

public void setNIDFieldFromNodeList()
Sets the Node ID field based on the current selection in the Node list. If there is no selection, clears the field.


getNIDFromList

public String getNIDFromList()
Gets the ID value based on the current node list selection. Returns null if there is no selection.


deselectNode

public void deselectNode()
Clears any selection in the Node list. This is to indicate that the current editor text area's content not longer matches the content of the selected node.


nodeModifyPossible

protected boolean nodeModifyPossible()
Returns true if there is a default Collection set and the ID field has an XML Name as its content.


deleteNode

protected void deleteNode(boolean confirm)
Delete the Node using the ID field as its identifier.


getNIDs

protected Set getNIDs(String cid)
Returns the current Node ID list if the Collection ID matches that supplied, otherwise null.


reindexNodes

public void reindexNodes()
Reindex and update the display of the current Node list. If there is no current Collection nothing happens.


clearNodes

protected void clearNodes()
Clear the node list.


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 selectnid 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).


nodeTitleMode

public void nodeTitleMode(boolean showTitles)
Sets the state of showing either Node IDs or titles.


showDatabaseManager

public void showDatabaseManager()
Displays the Database Manager dialog.


getRevisionManagerDialog

public XNodeRevisionManagerDialog getRevisionManagerDialog()
Returns the Revision Manager dialog, null if it has not been created already by showRevisionManager().


showRevisionManager

public void showRevisionManager()
Displays the Revision Manager dialog for the currently loaded collection.


showStatistics

public void showStatistics()
Display document statistics in a dialog.


getEditor

public EditorPanel getEditor()
Returns the EditorPanel.

Specified by:
getEditor in interface EditView

setToolBar

public void setToolBar(JToolBar toolbar)
Sets the tool bar of this DocumentView to the provided tool bar.


getToolBar

public JToolBar getToolBar()
Returns the JToolbar of this panel. This can be overridden to return a toolbar specific to a given subclass by setting m_alttools.


getAltToolBar

public JToolBar getAltToolBar()
Returns the alternative toolbar if it has been initialized, null if not.


getAuxCard

public JPanel getAuxCard()
Returns the Auxiliary card (empty on creation).


getDocumentToolBar

public DocumentToolBar getDocumentToolBar()
Returns the lazily-created DocumentToolBar. If the tool bar of this DocumentView is not an instance of a DocumentToolBar, this method returns null. (Generally, this should not happen, as a DocumentView should have only one tool bar.)


setToolsVisible

public void setToolsVisible(boolean visible)
Sets the visibility of the current toolbar to the boolean visible, updating the menu item appropriately.

Specified by:
setToolsVisible in interface EditView

setDatabaseToolsVisible

public void setDatabaseToolsVisible(boolean visible)
Sets the visibility of the database toolbar to the boolean visible, updating the menu item appropriately.


isDatabaseVisible

public boolean isDatabaseVisible()
Returns true if the database collection/node list is visible.


getDatabaseTools

public DatabaseToolBar getDatabaseTools()
Returns the database toolbar.


setDatabaseVisible

protected void setDatabaseVisible(boolean viz)
Sets the visibility of the database toolbar and the node metadata to the boolean viz.


getEditorFont

public Font getEditorFont()
Returns the Font used by the editor. This is a convenience method.


setEditorFont

public void setEditorFont(Font font)
Sets the Font used by the editor. This is a convenience method.


setEditorLineWrap

public void setEditorLineWrap(boolean wrap)
Sets the line wrapping policy for the editor to the boolean wrap. This is a convenience method.


getEditorLineWrap

public boolean getEditorLineWrap()
Returns the line wrapping policy of the editor, true if wrapping. This is a convenience method.


getEditorBackground

public Color getEditorBackground()
Returns the background color of this DocumentView's editor.


setEditorText

public void setEditorText(String content)
Sets the content of the editor to the String content. This does not reset the UndoManager.


setEditable

public void setEditable(boolean editable)
Sets the editor's editable state to the boolean editable.


getTextArea

public JTextArea getTextArea()
Returns the EditorArea (an extension of a Swing JTextArea) used as the text editor component of this DocumentView, to be used for presentation, relative size, positioning of forms, and caret attachment. No editing of its content should be performed using this method.


editUndo

public void editUndo()
Reverses the previous edit action. This is a convenience method.

Specified by:
editUndo in interface EditView

editRedo

public void editRedo()
Reverses the previous undo action. This is a convenience method.

Specified by:
editRedo in interface EditView

editCut

public void editCut()
Deletes the text area's current selection, placing it into the system clipboard. This is a convenience method.

Specified by:
editCut in interface EditView

editCopy

public void editCopy()
Copies the text area's selection to the system clipboard. This is a convenience method.

Specified by:
editCopy in interface EditView

editPaste

public void editPaste()
Pastes the system clipboard to either the text area's selection or its current caret 'dot' position. If the clipboard's text contains any return characters these are replaced by newlines. This is a convenience method.

Specified by:
editPaste in interface EditView

editSelectAll

public void editSelectAll()
Selects the entire content of the text area. This is a convenience method.

Specified by:
editSelectAll in interface EditView

find

public void find()
Find. Shows the FindReplace dialog in find mode.

Specified by:
find in interface EditView

replace

public void replace()
Replace. Shows the FindReplace dialog in replace mode.

Specified by:
replace in interface EditView

findNext

public void findNext()
Repeats the previous Find operation. This is ignored if the FindReplaceDialog does not exist or no search string exists.

Specified by:
findNext in interface EditView

serializeToDocumentView

protected void serializeToDocumentView(Document doc,
                                       int method)
Provided with a DOM Document, serializes as an XML document to the editor text area. This calls serializeToDocumentView(Document,int,boolean) with a value of true for sniffing.


serializeToDocumentView

protected void serializeToDocumentView(Document doc,
                                       int method,
                                       boolean sniff)
Provided with a DOM Document, serializes as an XML document to the editor text area. If the boolean sniff is true, will sniff the document and set title and various metadata properties. The available serialization methods are XMLUtils.SERIALIZE_XML, XMLUtils.SERIALIZE_XHTML, XMLUtils.SERIALIZE_HTML, and XMLUtils.SERIALIZE_TEXT.


getWikiTools

public WikiTools getWikiTools()
Returns the WikiTools subpanel, creating if necessary.


isWikiToolsMaximized

public boolean isWikiToolsMaximized()
Returns true if the embedded Wiki Tools subpanel is currently maximized.


setWikiToolsMaximized

public void setWikiToolsMaximized(boolean maximized)
Sets visibility of the WikiTools subpanel.


setEditorDocument

public void setEditorDocument(Document doc)
Sets the editor document to the provided java.text.Document.


fileNew

public boolean fileNew()
Creates a new, empty Document.

Specified by:
fileNew in class View
Returns:
true if able to close any existing content and establish a new document

fileOpen

public boolean fileOpen(File file)
Opens the selected File, then creates a org.ceryle.util.ResourceOpener thread to open the File into the current View. If file is null, displays a FileChooser allowing user selection.

Specified by:
fileOpen in class View
Returns:
true if opened

fileImport

public boolean fileImport(Object source)
If source is null, displays a FileChooser and obtains the selected File, then uses methods within SourceProcessor to determine which import processor to call to import the file type. Returns true if the File was imported successfully, or at least the import thread was started.

Specified by:
fileImport in class View
Returns:
true if opened

storeOnImport

public boolean storeOnImport(String uri)
Called by a ResourceOpener upon receipt of a document. An attempt is made to decompose the provided URI to Collection and Node IDs. If the URI is an XMLDB URI, the Collection and Node IDs can be obtained, and the collection exists, the user is queried on whether or not to store the incoming document in the database. This will set the cid and nid of the Document View's metadata if the URI is an XMLDB URI that can be successfully decomposed to provide the values.

Additionally, if the Collection matches the HelpDialog's HelpDialog.helpCID, the messages are simplified somewhat.

Returns:
true if stored successfully

importPSIDocument

public void importPSIDocument(String filename)
Parse LTM using Ceryle's LtmParser, suitable for PSI document creation (retains comments and order of declaration). Serializes output to the current editor panel.


fileSave

public boolean fileSave(File file)
If the systemId of this DocumentView has been set (eg., by an earlier file open or import), displays a file selection dialog box with the existing filepath (otherwise uses the current default directory), returns the selected path, then exports the contents of the current Document to the chosen path.

Specified by:
fileSave in class View
Returns:
false if the user cancels the file selection dialog or chooses not to overwrite an existing file. Returns true if the the save was successful or the document (content) is empty.

importPDB

public Document importPDB(TypedInputSource source)
Imports the PDB file as a TypedInputSource source, populating this DocumentView's text area.

Returns:
the imported javax.swing.text.Document.

exportPDB

public void exportPDB()
Exports the current contents of the DocumentView as a PilotDoc file.


isDirty

public boolean isDirty()
Returns an indication of true if the current document has been edited.

Specified by:
isDirty in class View

closeDocument

protected boolean closeDocument()
Checks to see that the current document is unmodified, providing a save option. This queries the user to save if the text is dirty.


closeDocument

protected boolean closeDocument(boolean confirm,
                                boolean forced)
Checks to see that the current document is unmodified, providing a save option if confirm is true. If the document is empty, assumes there's nothing valuable (ignoring any contents in the editor's UndoManager), returning true. Returns false if the user aborts the Save operation. If the window or frame is closing it may be too late anyway. This is indicated when forced is true, in which case no "cancel" option is provided.


fileClose

public boolean fileClose(boolean forced)
Closes the current Document, first checking to be sure that the text is unmodified. If the boolean forced is true, provides only a "yes" or "no" option for the save dialog if the existing content is dirty, "cancel" as well if false.

Specified by:
fileClose in class View
Returns:
true if closed

isStoredNode

public boolean isStoredNode()
Returns true if the Collection and Node IDs indicate an XMLDB URI matching the system identifier, and the node exists.


dump

public void dump(boolean exit)
Closes the current Document with no checks for saving its content. The boolean exit indicates that the application is exiting, so no updates of UndoManagers, menus, etc. is necessary.


docCheck

public boolean docCheck(boolean verbose)
Checks the current document for well-formedness or valid content, depending on the property validating set from the command line at the start of the application.

Parameters:
verbose - if true, provides feedback in the form of a progress bar and dialog-based message
Returns:
true if the document is either well-formed or valid

docTidy

public void docTidy()
Fixes the markup in the current document using an instance of JTidy. The document markup is assumed to be XHTML.

See Also:
Tidy

interpretGroovy

public void interpretGroovy(String script)
Interprets the String script as a Groovy script. Any messages, warnings or errors are sent to the MessageHandler.


docPlink

public void docPlink()
Plinks the current document after checking for well-formedness or valid content.


scrollToLine

public void scrollToLine(int line)
Scrolls the document content to line line of the document. This is a convenience method that passes the message to the EditorPanel.

Specified by:
scrollToLine in interface EditView

matchUndoRedoState

protected void matchUndoRedoState(boolean undoable,
                                  boolean redoable)
Sets the enabled or disabled state of the undo and redo buttons and menu items as appropriate to the state of the UndoManager.


packView

public void packView()
Suggests to the DocumentView that it resize any internal components appropriate to its current size.

Specified by:
packView in class View

requestFocus

public void requestFocus()
Sets the current focus to the editor's text area.

Specified by:
requestFocus in class View

getType

public int getType()
Returns the View type as an int.

Overrides:
getType in class View
See Also:
View.NOTE, View.DOCUMENT

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

getSearchTool

public SearchTool getSearchTool()
Returns the Search toolbar.


setSearchToolVisible

public void setSearchToolVisible(boolean visible)
Toggles visibility of the Search toolbar to the boolean visible, updating the menu item appropriately.


differenceDialog

public void differenceDialog()
Temporary differenceDialog TEMP.


popUpWindow

public void popUpWindow()
[TEMP] Opens a PopUpWindow.


documentSummary

public String documentSummary(int maxLength)
Produces a text summary of the current XNode, returning the first maxLength characters of the text of the node, doing the best it can based upon each node's MIME type.



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