|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--net.sf.vex.VexComponent
A Swing component that allows the display and edit of an XML document with an associated CSS stylesheet.
Field Summary |
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 | |
VexComponent()
Class constructor. |
Method Summary | |
void |
addSelectionListener(SelectionListener listener)
Add the given SelectionChangeListener to be notified when
the current selection changes. |
void |
beginWork()
Signals the start of a set of operations that should be considered a single unit for undo/redo purposes. |
boolean |
canPaste()
Returns true if the clipboard has content that can be pasted. |
boolean |
canPasteText()
Returns true if the clipboard has plain text content that can be pasted. |
boolean |
canRedo()
|
boolean |
canUndo()
|
boolean |
canUnwrap()
Returns true if the current element can be unwrapped, i.e. |
void |
copySelection()
Copy the current selection to the clipboard. |
static javax.swing.InputMap |
createInputMap()
Create the input map for the control. |
void |
cutSelection()
Cuts the current selection to the clipboard. |
void |
deleteNextChar()
Deletes the character to the right of the caret. |
void |
deletePreviousChar()
Deletes the character to the left of the caret. |
void |
deleteSelection()
Delete the current selection. |
void |
endWork(boolean success)
Signals the end of a set of operations that should be treated as a single unit for undo/redo purposes. |
BoxFactory |
getBoxFactory()
Returns the BoxFactory used for generating boxes in the
layout. |
java.awt.Rectangle |
getCaretBounds()
Returns the rectangle occupied by the caret. |
int |
getCaretOffset()
Return the offset into the document represented by the caret. |
Element |
getCurrentElement()
Returns the element at the current caret offset. |
Document |
getDocument()
Returns the document associated with this component. |
javax.swing.Action[] |
getInsertElementActions()
Returns an array of InsertElementAction objects that are valid for the given caret offset and selection |
static VexComponent |
getLastFocusedComponent()
Returns the VexComponent that last had focus. |
int |
getMagicX()
Returns the "magic x" coordinate. |
javax.swing.Action[] |
getMorphActions()
Returns an array of MorphAction objects representing valid morphs at the given caret offset. |
java.awt.Dimension |
getPreferredScrollableViewportSize()
|
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
|
boolean |
getScrollableTracksViewportHeight()
|
boolean |
getScrollableTracksViewportWidth()
|
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
|
DocumentFragment |
getSelectedFragment()
Returns the currently selected document fragment, or null if there is no current selection. |
java.lang.String |
getSelectedText()
Returns the currently selected string, or an empty string if there is no current selection. |
int |
getSelectionEnd()
Returns the offset at which the selection ends. |
int |
getSelectionStart()
Returns the offset at which the selection starts. |
StyleSheet |
getStyleSheet()
Returns the style sheet used to format the document while editing. |
static java.lang.String |
getUIString(java.lang.String name)
Returns a string from the resource bundle for the current locale. |
int |
getUndoDepth()
Returns the number of undoable edits that have occurred on this document since editing has started, not including limitations due to maximum undo depth. |
boolean |
hasSelection()
Returns true if the user currently has some text selected. |
void |
insertElement(Element element)
Inserts the given element at the current caret position. |
void |
insertFragment(DocumentFragment frag)
Inserts the given document fragment at the current caret position. |
void |
insertText(java.lang.String text)
Inserts the given text at the current caret position. |
boolean |
isAntiAliased()
Returns the value of the antiAliased flag. |
void |
morph(Element element)
Replaces the current element with the given element. |
void |
moveRelative(int distance)
Moves the caret a given distance relative to the current caret offset. |
void |
moveRelative(int distance,
boolean select)
Moves the caret a given distance relative to the current caret offset. |
void |
moveTo(int offset)
Moves the caret to a new offset. |
void |
moveTo(int offset,
boolean select)
Moves the caret to the new offset, possibly changing the selection. |
void |
moveToLineEnd(boolean select)
Move the caret to the end of the current line. |
void |
moveToLineStart(boolean select)
Move the caret to the start of the current line. |
void |
moveToNextLine(boolean select)
Move the caret down to the next line. |
void |
moveToNextWord(boolean select)
Moves the caret to the end of the current or next word. |
void |
moveToPreviousLine(boolean select)
Moves the caret up to the previous line. |
void |
moveToPreviousWord(boolean select)
Moves the caret to the start of the current or previous word. |
protected void |
paintComponent(java.awt.Graphics g)
|
void |
paste()
Paste the current clipboard contents into the document at the current caret position. |
void |
pasteText()
Paste the current clipboard contents as plain text into the document at the current caret position. |
void |
redo()
Redoes the last action on the redo stack. |
void |
relayout(boolean force)
Causes this control to be laid out at a convenient time. |
void |
relayoutLater(boolean force)
Calls relayout from the Swing event loop rather than immediately. |
void |
removeAttribute(java.lang.String attributeName)
Removes an attribute from the current element. |
void |
removeSelectionListener(SelectionListener listener)
Remove the given SelectionChangeListener from the
notification list. |
void |
selectWord()
Selects the word at the current caret offset. |
void |
setAntiAliased(boolean antiAliased)
Sets the value of the antiAliased flag. |
void |
setAttribute(java.lang.String attributeName,
java.lang.String value)
Sets the value of an attribute in the current element. |
void |
setBoxFactory(BoxFactory boxFactory)
Sets the box factory to be applied to the current document during editing. |
void |
setDocument(Document document,
StyleSheet styleSheet)
Sets a new document for this control. |
void |
setDocument(Document document,
StyleSheet styleSheet,
BoxFactory boxFactory)
Sets a new document for this control, providing a custom BoxFactory . |
void |
setDocument(java.net.URL docUrl,
java.net.URL ssUrl)
Sets the document to be displayed in the component. |
void |
setMagicX(int magicX)
Sets the magic X value. |
void |
setStyleSheet(StyleSheet styleSheet)
Sets the style sheet to be applied to the current document during editing. |
void |
showInsertElementPopup()
Display a popup menu of valid elements to insert at the current caret position. |
void |
showMorphElementPopup()
Display a popup menu of valid elements to which the current element can be morphed. |
void |
split()
Split the element at the current caret offset. |
void |
undo()
Undoes the last action on the undo stack. |
void |
unwrap()
Unwraps the current element. |
int |
viewToModel(int x,
int y)
Return the offset into the document for the given coordinates. |
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, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, 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 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public VexComponent()
Method Detail |
public java.awt.Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize
in interface javax.swing.Scrollable
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableBlockIncrement
in interface javax.swing.Scrollable
public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight
in interface javax.swing.Scrollable
public boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface javax.swing.Scrollable
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface javax.swing.Scrollable
public void addSelectionListener(SelectionListener listener)
SelectionProvider
SelectionChangeListener
to be notified when
the current selection changes.
addSelectionListener
in interface SelectionProvider
listener
- SelectionChangeListener to add.SelectionProvider.addSelectionListener(net.sf.vex.SelectionListener)
public void beginWork()
VexComponent c = ...; boolean success = false; try { c.beginWork(); // do multiple inserts/deletes success = true; } finally { c.endWork(success); }
In the case of nested beginWork/endWork calls, only the outermost results in an undoable event.
endWork(boolean)
public boolean canPaste()
public boolean canPasteText()
public boolean canRedo()
public boolean canUndo()
public boolean canUnwrap()
public void copySelection()
public void cutSelection()
public void deleteNextChar() throws DocumentValidationException
DocumentValidationException
public void deletePreviousChar() throws DocumentValidationException
DocumentValidationException
public void deleteSelection()
public void endWork(boolean success)
success
- If true, an edit is added to the undo stack.
If false, all the changes since the matching beginWork call
are undone.beginWork()
public BoxFactory getBoxFactory()
BoxFactory
used for generating boxes in the
layout.
public int getCaretOffset()
public Element getCurrentElement()
public java.awt.Rectangle getCaretBounds()
public Document getDocument()
public javax.swing.Action[] getInsertElementActions()
public boolean isAntiAliased()
public static VexComponent getLastFocusedComponent()
public int getMagicX()
setCaretOffset
.
public javax.swing.Action[] getMorphActions()
public int getSelectionEnd()
public int getSelectionStart()
public DocumentFragment getSelectedFragment()
public java.lang.String getSelectedText()
public StyleSheet getStyleSheet()
public static java.lang.String getUIString(java.lang.String name)
name
- property for which to return the string.public int getUndoDepth()
public boolean hasSelection()
public void insertFragment(DocumentFragment frag) throws DocumentValidationException
frag
- DocumentFragment to insert.
DocumentValidationException
public void insertElement(Element element) throws DocumentValidationException
element
- Element to insert.
DocumentValidationException
public void insertText(java.lang.String text) throws DocumentValidationException
text
- String to insert.
DocumentValidationException
public void morph(Element element) throws DocumentValidationException
element
- Element to replace the current element with.
DocumentValidationException
- if the given element is
not valid at this place in the document, or if the current
element's content is not compatible with the given element.public void moveRelative(int distance)
distance
- Amount by which to alter the caret offset.
Positive values increase the caret offset.public void moveRelative(int distance, boolean select)
distance
- Amount by which to alter the caret offset.
Positive values increase the caret offset.select
- if true, the current selection is extended to
match the new caret offsetpublic void moveTo(int offset)
moveTo(offset, false)
.
public void moveTo(int offset, boolean select)
select
- if true, the current selection is extended to
match the new caret offset.public void moveToLineEnd(boolean select)
select
- If true, the selection is extended.public void moveToLineStart(boolean select)
select
- If true, the selection is extended.public void moveToNextLine(boolean select)
select
- If true, the selection is extended.public void moveToNextWord(boolean select)
select
- If true, the selection is extended.public void moveToPreviousLine(boolean select)
select
- If true, the selection is extendedpublic void moveToPreviousWord(boolean select)
select
- If true, the selection is extended.protected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public void paste() throws DocumentValidationException
DocumentValidationException
public void pasteText() throws DocumentValidationException
DocumentValidationException
public void redo() throws javax.swing.undo.CannotRedoException
javax.swing.undo.CannotRedoException
public void relayout(boolean force)
layout
directly.
force
- Layout should be forced, e.g. when the width of
the component changed.public void relayoutLater(boolean force)
force
- Layout should be forced, e.g. when the width of
the component changed.public void removeAttribute(java.lang.String attributeName)
attributeName
- Name of the attribute to remove.public void removeSelectionListener(SelectionListener listener)
SelectionProvider
SelectionChangeListener
from the
notification list.
removeSelectionListener
in interface SelectionProvider
listener
- SelectionChangeListener to remove.SelectionProvider.removeSelectionListener(net.sf.vex.SelectionListener)
public void selectWord()
public void setAntiAliased(boolean antiAliased)
antiAliased
- if true, text is rendered using antialiasing.public void setAttribute(java.lang.String attributeName, java.lang.String value)
attributeName
- Name of the attribute being changed.value
- New value for the attribute. If null, the attribute is
removed from the element.public void setBoxFactory(BoxFactory boxFactory)
boxFactory
- the new BoxFactory to usepublic void setDocument(Document document, StyleSheet styleSheet)
document
- new Document to displaystyleSheet
- StyleSheet to use for formattingpublic void setDocument(Document document, StyleSheet styleSheet, BoxFactory boxFactory)
BoxFactory
.
document
- new Document to displaystyleSheet
- StyleSheet to use for formattingboxFactory
- BoxFactory to use during layoutpublic void setDocument(java.net.URL docUrl, java.net.URL ssUrl) throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
CssBoxFactory
for the normal, CSS-styled layout.
docUrl
- URL of the document to be displayed.ssUrl
- URL of the CSS style sheet to use.
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
public void setMagicX(int magicX)
magicX
- the new value for magic X.public void setStyleSheet(StyleSheet styleSheet)
styleSheet
- the new StyleSheet to usepublic void showInsertElementPopup()
public void showMorphElementPopup()
public void split() throws DocumentValidationException
DocumentValidationException
public void undo() throws javax.swing.undo.CannotUndoException
javax.swing.undo.CannotUndoException
public void unwrap() throws DocumentValidationException
DocumentValidationException
public int viewToModel(int x, int y)
x
- the x-coordinatey
- the y-coordinatepublic static javax.swing.InputMap createInputMap()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |