com.fg.xmleditor
Class FXBasicView

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bycom.fg.xmleditor.FXBasicView
All Implemented Interfaces:
java.util.EventListener, FXModelStatusListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
FXView

public class FXBasicView
extends javax.swing.JComponent
implements FXModelStatusListener

FXBasicView Swing component provides all the basic XML viewer/editor functionality. A data model object for the FXBasicView has to implement FXModel interface.

Version:
2.0
Author:
Felix Golubov
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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
FXBasicView()
          Creates an instance of FXBasicView component with default FXDocumentModelImpl data model.
FXBasicView(FXModel model)
          Creates an instance of FXBasicView component, which refers to the specified data model object.
 
Method Summary
 void addExternalDialog(java.lang.String id, javax.swing.JDialog dialog)
          Method registers an external dialog under the specified id.
 void addViewStatusListener(FXViewStatusListener l)
          Adds an FXChangeListener listener.
static void cancelCellEditing(javax.swing.JComponent editor)
          Method has to be called from some "valueChanged" event handler of the field editing component in order to cancel editing.
 boolean cancelEditing()
          Method cancels node editing and discards a value from the editor.
 boolean canInsert()
          Returns true if the parent of the current selected node allows performing insertNodeBefore() and insertNodeAfter() operations and false otherwise.
 boolean canMoveDown()
          Returns true if the current selected node can swap position with its following sibling (see moveNodeDown()) and false otherwise.
 boolean canMoveUp()
          Returns true if the current selected node can swap position with its preceding sibling (see moveNodeUp()) and false otherwise.
 boolean canRemove()
          Returns true if the current selected node can be removed (see removeNode()) and false otherwise.
static void cellEditorValueChanged(javax.swing.JComponent editor, java.lang.Object event)
          Method has to be called from some "valueChanged" event handler of the field editing component in order to notify FXBasicView of the event occurred.
 void docValidityStatusChanged(FXStatusEvent e)
          Method implements respective method of the FXModelStatusListener interface.
 FXModel getFXModel()
          Method returns a reference to the current FXModel data model object.
 FTree getTree()
          Method returns a reference to the underlying com.fg.ftree.FTree component.
 boolean hasDocument()
          Returns true when current FXModel contains an XML document and false otherwise.
 void insertNodeAfter()
          If canInsert() returns true, the method inserts a new sibling node, following the current selected node, otherwise it does nothing.
 void insertNodeBefore()
          If canInsert() returns true, the method inserts a new sibling node, preceding the current selected node, otherwise it does nothing.
 boolean isDocChanged()
          Returns true if current XML document has been changed by the editor and false otherwise.
 boolean isDocValid()
          Returns true if current XML document is valid and false otherwise.
 boolean isReducedView()
          Returns true when component is in the Viewer mode (aditional structural elements such as XSD Groups folders and array folders are not shown) and false when component is in Editor mode.
 void moveNodeDown()
          If canMoveDown() returns true, the method swaps positions of the current selected node and its following sibling, otherwise it does nothing.
 void moveNodeUp()
          If canMoveUp() returns true, the method swaps positions of the current selected node and its preceding sibling, otherwise it does nothing.
 void newDocumentLoaded(FXStatusEvent e)
          Method implements respective method of the FXModelStatusListener interface.
 void removeAllExternalDialogs()
          Method removes all the registered external dialogs.
 void removeExternalDialog(java.lang.String id)
          Method removes an external dialog which was registered under the specified id.
 void removeNode()
          If canRemove() returns true, the method removes the current selected node, otherwise it does nothing.
 void removeViewStatusListener(FXViewStatusListener l)
          Removes an FXChangeListener listener.
 void setBackground(java.awt.Color color)
          Sets a new background color.
 void setFXModel(FXModel newModel)
          Method sets an instance of FXModel data model.
 void setReducedView(boolean reduced)
          Sets Viewer/Editor mode.
 void showErrorMessage(java.lang.String message)
          Shows a message in the right-bottom text area.
 void showInfoMessage(java.lang.String message)
          Shows a message in the left-bottom text area.
 void showInvalidNode()
          Makes visible and selects a first invalid node next to the currently selected node.
 void showNSQualifiersDialog()
          Creates and shows an instance of the NSQualifiersDialog, which allows user to edit namespace qualifiers.
 void showSearchDialog()
          Method shows a search dialog SearchDialog.
static void stopCellEditing(javax.swing.JComponent editor)
          Method has to be called from some "valueChanged" event handler of the field editing component in order to stop editing.
 boolean stopEditing()
          Method stops cell editing and assignes edited value to the respective node.
 void updateUI()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, getUIClassID, 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, 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

FXBasicView

public FXBasicView(FXModel model)
Creates an instance of FXBasicView component, which refers to the specified data model object.

Parameters:
model - an FXModel object.

FXBasicView

public FXBasicView()
Creates an instance of FXBasicView component with default FXDocumentModelImpl data model.

Method Detail

setFXModel

public void setFXModel(FXModel newModel)
Method sets an instance of FXModel data model.

Parameters:
newModel - a FXModel data model object.

newDocumentLoaded

public void newDocumentLoaded(FXStatusEvent e)
Method implements respective method of the FXModelStatusListener interface. The method is called when new XML document is loaded.

Specified by:
newDocumentLoaded in interface FXModelStatusListener
Parameters:
e - an FXStatusEvent instance.

docValidityStatusChanged

public void docValidityStatusChanged(FXStatusEvent e)
Method implements respective method of the FXModelStatusListener interface. The method is called document validity dtatus is changed.

Specified by:
docValidityStatusChanged in interface FXModelStatusListener
Parameters:
e - an FXStatusEvent instance.

getFXModel

public FXModel getFXModel()
Method returns a reference to the current FXModel data model object.

Returns:
a reference to the current FXModel data model object.

getTree

public FTree getTree()
Method returns a reference to the underlying com.fg.ftree.FTree component.

Returns:
a reference to the underlying com.fg.ftree.FTree component.

updateUI

public void updateUI()

addExternalDialog

public void addExternalDialog(java.lang.String id,
                              javax.swing.JDialog dialog)
Method registers an external dialog under the specified id.

Parameters:
id - a string identifier of the external dialog.
dialog - a JDialog external field editor.

removeExternalDialog

public void removeExternalDialog(java.lang.String id)
Method removes an external dialog which was registered under the specified id.

Parameters:
id - a string identifier of the external dialog.

removeAllExternalDialogs

public void removeAllExternalDialogs()
Method removes all the registered external dialogs.


setBackground

public void setBackground(java.awt.Color color)
Sets a new background color.

Parameters:
color - new background color

isReducedView

public boolean isReducedView()
Returns true when component is in the Viewer mode (aditional structural elements such as XSD Groups folders and array folders are not shown) and false when component is in Editor mode.

Returns:
true when component is in Viewer mode and false when component is in Editor mode.

setReducedView

public void setReducedView(boolean reduced)
Sets Viewer/Editor mode. In the Viewer mode the view is reduced (aditional structural elements such as XSD Groups folders and array folders are not shown).

Parameters:
reduced - true sets component to the Viewer mode and false - to the Editor mode.

stopEditing

public boolean stopEditing()
Method stops cell editing and assignes edited value to the respective node. It does nothing when no field is currently editing.

Returns:
true when node editing was actually stopped.

cancelEditing

public boolean cancelEditing()
Method cancels node editing and discards a value from the editor. It does nothing when no field is currently editing.

Returns:
true when node editing was actually canceled.

stopCellEditing

public static void stopCellEditing(javax.swing.JComponent editor)
Method has to be called from some "valueChanged" event handler of the field editing component in order to stop editing. Although the method is static, it finds the proper FXBasicView instance, which is an ancestor of the editor object passed.

Parameters:
editor - a field editor, which implements IFieldEditor interface

cancelCellEditing

public static void cancelCellEditing(javax.swing.JComponent editor)
Method has to be called from some "valueChanged" event handler of the field editing component in order to cancel editing. Although the method is static, it finds the proper FXBasicView instance, which is an ancestor of the editor object passed.

Parameters:
editor - a field editor, which implements IFieldEditor interface

cellEditorValueChanged

public static void cellEditorValueChanged(javax.swing.JComponent editor,
                                          java.lang.Object event)
Method has to be called from some "valueChanged" event handler of the field editing component in order to notify FXBasicView of the event occurred. Although the method is static, it finds the proper FXBasicView instance, which is an ancestor of the editor object passed.

Parameters:
editor - a field editor, which implements IFieldEditor interface
event - an original event object

showInfoMessage

public void showInfoMessage(java.lang.String message)
Shows a message in the left-bottom text area. The area is used to show info messages.

Parameters:
message - a message to show

showErrorMessage

public void showErrorMessage(java.lang.String message)
Shows a message in the right-bottom text area. The area is used to show errors.

Parameters:
message - a message to show

addViewStatusListener

public void addViewStatusListener(FXViewStatusListener l)
Adds an FXChangeListener listener.

Parameters:
l - an FXChangeListener implementation

removeViewStatusListener

public void removeViewStatusListener(FXViewStatusListener l)
Removes an FXChangeListener listener.

Parameters:
l - an FXChangeListener implementation

hasDocument

public boolean hasDocument()
Returns true when current FXModel contains an XML document and false otherwise.

Returns:
true when current FXModel contains an XML document and false otherwise.

isDocChanged

public boolean isDocChanged()
Returns true if current XML document has been changed by the editor and false otherwise.

Returns:
true if current XML document has been changed by the editor and false otherwise.

isDocValid

public boolean isDocValid()
Returns true if current XML document is valid and false otherwise.

Returns:
true if current XML document is valid and false otherwise.

canInsert

public boolean canInsert()
Returns true if the parent of the current selected node allows performing insertNodeBefore() and insertNodeAfter() operations and false otherwise.

Returns:
true if the parent of the current selected node allows performing insertNodeBefore() and insertNodeAfter() operations and false otherwise.

canRemove

public boolean canRemove()
Returns true if the current selected node can be removed (see removeNode()) and false otherwise.

Returns:
true if the current selected node can be removed (see removeNode()) and false otherwise.

canMoveUp

public boolean canMoveUp()
Returns true if the current selected node can swap position with its preceding sibling (see moveNodeUp()) and false otherwise.

Returns:
true if the current selected node can swap position with its preceding sibling (see moveNodeUp()) and false otherwise.

canMoveDown

public boolean canMoveDown()
Returns true if the current selected node can swap position with its following sibling (see moveNodeDown()) and false otherwise.

Returns:
true if the current selected node can swap position with its following sibling (see moveNodeDown()) and false otherwise.

insertNodeBefore

public void insertNodeBefore()
If canInsert() returns true, the method inserts a new sibling node, preceding the current selected node, otherwise it does nothing.


insertNodeAfter

public void insertNodeAfter()
If canInsert() returns true, the method inserts a new sibling node, following the current selected node, otherwise it does nothing.


removeNode

public void removeNode()
If canRemove() returns true, the method removes the current selected node, otherwise it does nothing.


moveNodeUp

public void moveNodeUp()
If canMoveUp() returns true, the method swaps positions of the current selected node and its preceding sibling, otherwise it does nothing.


moveNodeDown

public void moveNodeDown()
If canMoveDown() returns true, the method swaps positions of the current selected node and its following sibling, otherwise it does nothing.


showNSQualifiersDialog

public void showNSQualifiersDialog()
Creates and shows an instance of the NSQualifiersDialog, which allows user to edit namespace qualifiers.


showInvalidNode

public void showInvalidNode()
Makes visible and selects a first invalid node next to the currently selected node. If no node is selected then the method shows the first invalid node starting from the tree root.


showSearchDialog

public void showSearchDialog()
Method shows a search dialog SearchDialog.