com.japisoft.xmlpad
Class XMLContainer

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--com.japisoft.xmlpad.XMLContainer
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class XMLContainer
extends javax.swing.JPanel
implements java.awt.event.FocusListener

This is the main container for the XMLEditor. This container manages a toolbar thanks to the ToolBarModel. It contains also the main editor. As a split function is supported, 2 editors are managed. The current one is always available by the getEditor method.

Version:
1.5
Author:
(c) 2002 JAPISoft
See Also:
JPanel, ToolBarModel, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
XMLContainer()
          Create a new XMLContainer, all components are created by the default ComponentFactory
 
Method Summary
 void addNotify()
           
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost(java.awt.event.FocusEvent e)
           
 java.lang.String getCurrentDocumentLocation()
           
 javax.swing.JPopupMenu getCurrentPopup()
          Return the current menu popup
 java.lang.String getDefaultDTDLocation()
           
 java.lang.String getDefaultDTDRoot()
           
 XMLDocumentInfo getDocumentInfo()
           
 XMLIntegrity getDocumentIntegrity()
           
 java.lang.String getDTDLocation(boolean resolve)
           
 XMLEditor getEditor()
           
 RealTimeTreeManager getRealTimeTreeManager()
           
 SyntaxHelper getSyntaxHelper()
           
 java.lang.String getText()
           
 javax.swing.JToolBar getToolBar()
           
 ToolBarModel getToolBarModel()
           
 boolean isEditable()
          By default return true
 boolean isEnabledPopup()
           
 boolean isEnabledToolBar()
           
 boolean isEnabledTreeLocation()
          Is Enabled the view of the tree location in the status bar ?
static void main(java.lang.String[] args)
           
 void removeErrorPanel()
           
 void resetDefaultToolBarActions()
          Update the toolbarModel adding separator.
 boolean searchAndParseDTD()
          Search inside the current document a DTD and parses it for syntax helper.
 void setColorForAttribute(java.lang.String attribute, java.awt.Color c)
          Choose a particular color for this attribute
 void setColorForPrefix(java.lang.String prefix, java.awt.Color c)
          Choose a particular color for this namespace prefix
 void setColorForTag(java.lang.String tag, java.awt.Color c)
          Choose a particular color for this tag
 void setCurrentDocumentLocation(java.lang.String location)
          Reset the current document location.
 void setDefaultDTD(java.lang.String dtdRoot, java.lang.String dtd)
          Reset the default document DTD location
 void setDocumentInfo(XMLDocumentInfo info)
          Reset the current documentation info.
 void setDocumentIntegrity(XMLIntegrity integrity)
          This objet contains data for avoiding to corrupt the current document.
 void setDTD(java.lang.String dtdRoot, java.lang.String dtd)
           
 void setEditable(boolean editable)
          The document is only readable for true
 void setEnabledPopup(boolean enabled)
          Support a popup menu
 void setEnabledToolBar(boolean enabledToolBar)
          Enabled the toolbar
 void setEnabledTreeLocation(boolean location)
          Enable the view of the tree location in the status bar
 void setModifiedState(boolean state)
          Update this container state if the document has been changed
 void setPopableErrorMode(boolean popableErrorMode)
          By default to false, this mode will open a dialog box for each parsing error with the parsing error message
 void setSplit(boolean split)
          if true, it will split the current editors in two one else it will unsplit the two current editors in only one
 void setText(java.lang.String text)
          Set the XML content
 void split()
          Show two editors
 void unSplit()
          Show one editor
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XMLContainer

public XMLContainer()
Create a new XMLContainer, all components are created by the default ComponentFactory

Method Detail

setDocumentInfo

public void setDocumentInfo(XMLDocumentInfo info)
Reset the current documentation info. This objet contains a set of information like the file filter about editable document

Parameters:
info -

getDocumentInfo

public XMLDocumentInfo getDocumentInfo()
Returns:
the current document info

getToolBarModel

public ToolBarModel getToolBarModel()
Returns:
the model for the toolBar

getSyntaxHelper

public SyntaxHelper getSyntaxHelper()
Returns:
the current SyntaxHelper. This helper is used for showing a popup for available tags or entities choice

searchAndParseDTD

public boolean searchAndParseDTD()
Search inside the current document a DTD and parses it for syntax helper. It will return true if the DTD is found


setDefaultDTD

public void setDefaultDTD(java.lang.String dtdRoot,
                          java.lang.String dtd)
Reset the default document DTD location

Parameters:
dtdRoot - The DTD Root element
dtd - The DTD path or URL

setDTD

public void setDTD(java.lang.String dtdRoot,
                   java.lang.String dtd)

getDefaultDTDRoot

public java.lang.String getDefaultDTDRoot()
Returns:
the current DTD root element

getDefaultDTDLocation

public java.lang.String getDefaultDTDLocation()
Returns:
the current DTDLocation built with the current document location

getDTDLocation

public java.lang.String getDTDLocation(boolean resolve)
Parameters:
resolve - if true the location is built using the current document location
Returns:
the current DTD location. This DTD location can take into account relative document location

setCurrentDocumentLocation

public void setCurrentDocumentLocation(java.lang.String location)
Reset the current document location. This is useful for reading/writing a document


getCurrentDocumentLocation

public java.lang.String getCurrentDocumentLocation()
Returns:
the current document location

setModifiedState

public void setModifiedState(boolean state)
Update this container state if the document has been changed


setColorForAttribute

public void setColorForAttribute(java.lang.String attribute,
                                 java.awt.Color c)
Choose a particular color for this attribute


setColorForTag

public void setColorForTag(java.lang.String tag,
                           java.awt.Color c)
Choose a particular color for this tag


setColorForPrefix

public void setColorForPrefix(java.lang.String prefix,
                              java.awt.Color c)
Choose a particular color for this namespace prefix


getCurrentPopup

public javax.swing.JPopupMenu getCurrentPopup()
Return the current menu popup


setEnabledPopup

public void setEnabledPopup(boolean enabled)
Support a popup menu


isEnabledPopup

public boolean isEnabledPopup()

getToolBar

public javax.swing.JToolBar getToolBar()
Returns:
the current toolbar

getEditor

public XMLEditor getEditor()
Returns:
the current editor component

setText

public void setText(java.lang.String text)
Set the XML content


getText

public java.lang.String getText()
Returns:
the XM content

setEditable

public void setEditable(boolean editable)
The document is only readable for true


isEditable

public boolean isEditable()
By default return true


setEnabledToolBar

public void setEnabledToolBar(boolean enabledToolBar)
Enabled the toolbar


isEnabledToolBar

public boolean isEnabledToolBar()
Returns:
the toolbar state

resetDefaultToolBarActions

public void resetDefaultToolBarActions()
Update the toolbarModel adding separator. This method is called by the XMLContainer constructor. It uses the ActionModel for adding action


addNotify

public void addNotify()
Overrides:
addNotify in class javax.swing.JComponent

setPopableErrorMode

public void setPopableErrorMode(boolean popableErrorMode)
By default to false, this mode will open a dialog box for each parsing error with the parsing error message

Parameters:
popableErrorMode -

removeErrorPanel

public void removeErrorPanel()

getRealTimeTreeManager

public RealTimeTreeManager getRealTimeTreeManager()
Returns:
the manager for real time tree location

setEnabledTreeLocation

public void setEnabledTreeLocation(boolean location)
Enable the view of the tree location in the status bar


isEnabledTreeLocation

public boolean isEnabledTreeLocation()
Is Enabled the view of the tree location in the status bar ?


setSplit

public void setSplit(boolean split)
if true, it will split the current editors in two one else it will unsplit the two current editors in only one


split

public void split()
Show two editors


focusGained

public void focusGained(java.awt.event.FocusEvent e)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Specified by:
focusLost in interface java.awt.event.FocusListener

unSplit

public void unSplit()
Show one editor


getDocumentIntegrity

public XMLIntegrity getDocumentIntegrity()
Returns:
the current XML integrity manager

setDocumentIntegrity

public void setDocumentIntegrity(XMLIntegrity integrity)
This objet contains data for avoiding to corrupt the current document.

Parameters:
integrity - XML integrity manager

main

public static void main(java.lang.String[] args)