|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JEditorPane
com.lightdev.app.shtm.SHTMLEditorPane
public class SHTMLEditorPane
An editor pane for application SimplyHTML.
This is extending JEditorPane
by cut and paste
and drag and drop for HTML text.
JEditorPane
inherits cut and paste from
JTextComponent
where handling for plain text is implemented only.
JEditorPane
has no additional functionality to add cut
and paste for the various content types it supports
(such as 'text/html').
In stage 4 support for caret movement inside tables and table manipulation methods are added.
In stage 6 support for list manipulation was added.
HTMLText
,
HTMLTextSelection
,
Serialized FormNested Class Summary | |
---|---|
class |
SHTMLEditorPane.NewListItemAction
Action to create a new list item. |
class |
SHTMLEditorPane.NextTableCellAction
Action to move the caret from the current table cell
to the next table cell. |
class |
SHTMLEditorPane.PrevTableCellAction
Action to move the caret from the current table cell
to the previous table cell. |
Nested classes/interfaces inherited from class javax.swing.JEditorPane |
---|
javax.swing.JEditorPane.AccessibleJEditorPane, javax.swing.JEditorPane.AccessibleJEditorPaneHTML, javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport |
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent |
---|
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.DropLocation, javax.swing.text.JTextComponent.KeyBinding |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
ALL_CELLS
range indicator for applying attributes to all cells |
static java.lang.String |
DEFAULT_TABLE_WIDTH
default table width |
static java.lang.String |
DEFAULT_VERTICAL_ALIGN
default vertical alignment |
static java.lang.String |
newListItemAction
|
static int |
THIS_CELL
range indicator for applying attributes to the current cell only |
static int |
THIS_COLUMN
range indicator for applying attributes to cells of the current column only |
static int |
THIS_ROW
range indicator for applying attributes to cells of the current row only |
Fields inherited from class javax.swing.JEditorPane |
---|
HONOR_DISPLAY_PROPERTIES, W3C_LENGTH_UNITS |
Fields inherited from class javax.swing.text.JTextComponent |
---|
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
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 | |
---|---|
SHTMLEditorPane()
construct a new SHTMLEditorPane |
Method Summary | |
---|---|
void |
appendTableColumn()
append a table column after the last column (if any) |
void |
appendTableRow()
append a row to a table assuming the caret currently is inside a table |
void |
applyAttributes(javax.swing.text.AttributeSet a,
boolean para)
|
void |
applyAttributes(javax.swing.text.AttributeSet a,
boolean para,
boolean replace)
set the attributes for a given part of this editor. |
void |
applyCellAttributes(javax.swing.text.AttributeSet a,
int range)
apply a set of attributes to a given range of cells of the table the caret is currently in (if any) |
void |
applyListAttributes(javax.swing.text.AttributeSet a)
apply a set of attributes to the list the caret is currently in (if any) |
void |
applyTableAttributes(javax.swing.text.AttributeSet a)
apply a set of attributes to the table the caret is currently in (if any) |
void |
applyTag(java.lang.String tag,
java.util.Vector allowedTags)
switch elements in the current selection to a given tag |
void |
copy()
Transfers the currently selected range in the associated text model to the system clipboard, leaving the contents in the text model. |
void |
cut()
Transfers the currently selected range in the associated text model to the system clipboard, removing the contents from the model. |
void |
deleteTableCol()
delete the column of the table the caret is currently in (if any) |
void |
deleteTableRow()
delete the row of the table the caret is currently in (if any) |
void |
dragDropEnd(java.awt.dnd.DragSourceDropEvent event)
this message goes to DragSourceListener, informing it that the dragging has ended |
void |
dragEnter(java.awt.dnd.DragSourceDragEvent event)
this message goes to DragSourceListener, informing it that the dragging has entered the DropSite |
void |
dragEnter(java.awt.dnd.DropTargetDragEvent event)
is invoked when you are dragging over the DropSite |
void |
dragExit(java.awt.dnd.DragSourceEvent event)
this message goes to DragSourceListener, informing it that the dragging has exited the DropSite |
void |
dragExit(java.awt.dnd.DropTargetEvent event)
is invoked when you are exit the DropSite without dropping |
void |
dragGestureRecognized(java.awt.dnd.DragGestureEvent event)
a drag gesture has been initiated |
void |
dragOver(java.awt.dnd.DragSourceDragEvent event)
this message goes to DragSourceListener, informing it that the dragging is currently ocurring over the DropSite |
void |
dragOver(java.awt.dnd.DropTargetDragEvent event)
is invoked when a drag operation is going on |
void |
drop(java.awt.dnd.DropTargetDropEvent event)
a drop has occurred. |
void |
dropActionChanged(java.awt.dnd.DragSourceDragEvent event)
is invoked when the user changes the dropAction |
void |
dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
is invoked if the user modifies the current drop gesture |
javax.swing.text.Element |
getCurTableCell()
get the table cell at the current caret position |
java.lang.String |
getTableCellHTML(javax.swing.text.Element srcCell)
build an HTML string copying from an existing table cell |
java.lang.String |
getTableRowHTML(javax.swing.text.Element srcRow)
build an HTML string copying from an existing table row. |
void |
goNextCell(javax.swing.text.Element cell)
|
void |
goPrevCell(javax.swing.text.Element cell)
|
void |
initDnd()
Initialize the drag and drop implementation for this component. |
void |
insertAnchor(java.lang.String anchorName)
apply a new anchor to the currently selected text |
void |
insertBreak()
insert a line break (i.e. |
void |
insertTable(int colCount)
insert a table |
void |
insertTableColumn()
insert a table column before the current column (if any) |
void |
insertTableRow()
insert a row to a table assuming the caret currently is inside a table |
void |
paste()
Transfers the contents of the system clipboard into the associated text model. |
void |
removeAnchor(java.lang.String anchorName)
remove an anchor with a given name |
void |
replaceSelection(HTMLText content)
Replaces the currently selected content with new content represented by the given HTMLText . |
void |
setLink(java.lang.String linkText,
java.lang.String href,
java.lang.String className)
set a text link at the current selection replacing the selection with a given text. |
void |
setLink(java.lang.String linkText,
java.lang.String href,
java.lang.String className,
java.lang.String linkImage,
java.awt.Dimension size)
set a link at the current selection replacing the selection with the given text or image. |
void |
toggleList(java.lang.String listTag,
javax.swing.text.AttributeSet a,
boolean forceOff)
toggle list formatting on or off for the currently selected text portion. |
Methods inherited from class javax.swing.JEditorPane |
---|
addHyperlinkListener, createDefaultEditorKit, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getStream, getText, getUIClassID, paramString, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, replaceSelection, scrollToReference, setContentType, setEditorKit, setEditorKitForContentType, setPage, setPage, setText |
Methods inherited from class javax.swing.text.JTextComponent |
---|
addCaretListener, addInputMethodListener, addKeymap, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDocument, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write |
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, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, 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, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, 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, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int THIS_CELL
public static final int THIS_COLUMN
public static final int THIS_ROW
public static final int ALL_CELLS
public static final java.lang.String DEFAULT_TABLE_WIDTH
public static final java.lang.String DEFAULT_VERTICAL_ALIGN
public static final java.lang.String newListItemAction
Constructor Detail |
---|
public SHTMLEditorPane()
SHTMLEditorPane
Method Detail |
---|
public void applyListAttributes(javax.swing.text.AttributeSet a)
a
- the set of attributes to applypublic void toggleList(java.lang.String listTag, javax.swing.text.AttributeSet a, boolean forceOff)
Switches list display on for the given type, if the selection contains parts not formatted as list or parts formatted as list of another type.
Switches list formatting off, if the selection contains only parts formatted as list of the given type.
listTag
- the list tag type to toggle on or off (UL or OL)a
- the attributes to use for the list to toggle toforceOff
- indicator for toggle operation. If true, possibly
exisiting list formatting inside the selected parts always is switched
off. If false, the method decides, if list formatting for the parts
inside the selection needs to be switched on or off.public void insertTable(int colCount)
colCount
- the number of columns the new table shall havepublic void insertAnchor(java.lang.String anchorName)
If nothing is selected, this method does nothing
anchorName
- the name of the new anchorpublic void insertBreak()
public void setLink(java.lang.String linkText, java.lang.String href, java.lang.String className)
If nothing is selected, but the caret is inside a link, this will replace the existing link. If nothing is selected and the caret is not inside a link, this method does nothing.
linkText
- the text that shall appear as link at the current selectionhref
- the target this link shall refer toclassName
- the style class to be usedpublic void setLink(java.lang.String linkText, java.lang.String href, java.lang.String className, java.lang.String linkImage, java.awt.Dimension size)
linkText
- the text to show as link (or null, if an image shall appear instead)href
- the link referenceclassName
- the style name to be used for the linklinkImage
- the file name of the image be used for the link (or null, if a text link is to be set instead)size
- the size of the image or nullpublic void removeAnchor(java.lang.String anchorName)
anchorName
- the name of the anchor to removepublic void insertTableColumn()
public void appendTableColumn()
public void appendTableRow()
public void insertTableRow()
public java.lang.String getTableRowHTML(javax.swing.text.Element srcRow)
srcRow
- the table row Element to copy frominsert
- indicates if a row is inserted before another row
public java.lang.String getTableCellHTML(javax.swing.text.Element srcCell)
srcCell
- the cell to get the HTML fora
- set of attributes to copy if we are inserting first table columninsertFirst
- indicates if we are inserting first table columnrNum
- number of row a cell is to be inserted to
(can be any value if insertFirst is false)
public void deleteTableRow()
public void deleteTableCol()
width of adjacent column is adjusted, if there is more than one column in the table. Width adjustment only works, if width attributes of both the column to remove and its adjacent column have the same unit (pt or %).
If there is only one cell or if the caret is not in a table, this method does nothing
Smart border handling automatically sets the left border of a cell to zero, if the cell on the left of that cell has a right border and both cells have no margin. In that case removing the first column will cause all cells of the new first column to have no left border.
public void applyTableAttributes(javax.swing.text.AttributeSet a)
a
- the set of attributes to applypublic void applyCellAttributes(javax.swing.text.AttributeSet a, int range)
a
- the set of attributes to applyrange
- the range of cells to apply attributes toadjustColWidths
public void goNextCell(javax.swing.text.Element cell)
public void goPrevCell(javax.swing.text.Element cell)
public javax.swing.text.Element getCurTableCell()
public void replaceSelection(HTMLText content)
HTMLText
. If there is no selection
this amounts to an insert of the given text. If there
is no replacement text this amounts to a removal of the
current selection.
content
- the content to replace the selection withpublic void initDnd()
DropTarget, DragSource and DragGestureRecognizer are instantiated and a MouseListener is established to track the selection in drag operations
this ideally is called in the constructor of a class which would like to implement drag and drop
public void dragGestureRecognized(java.awt.dnd.DragGestureEvent event)
dragGestureRecognized
in interface java.awt.dnd.DragGestureListener
public void dragDropEnd(java.awt.dnd.DragSourceDropEvent event)
dragDropEnd
in interface java.awt.dnd.DragSourceListener
public void dragOver(java.awt.dnd.DropTargetDragEvent event)
dragOver
in interface java.awt.dnd.DropTargetListener
public void drop(java.awt.dnd.DropTargetDropEvent event)
DataFlavor
, do the drop.
drop
in interface java.awt.dnd.DropTargetListener
event
- - the event specifiying the drop operationDataFlavor
,
de.calcom.cclib.text.StyledText
,
de.calcom.cclib.text.StyledTextSelection
public void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
dropActionChanged
in interface java.awt.dnd.DropTargetListener
public void dropActionChanged(java.awt.dnd.DragSourceDragEvent event)
dropActionChanged
in interface java.awt.dnd.DragSourceListener
public void dragEnter(java.awt.dnd.DropTargetDragEvent event)
dragEnter
in interface java.awt.dnd.DropTargetListener
public void dragExit(java.awt.dnd.DropTargetEvent event)
dragExit
in interface java.awt.dnd.DropTargetListener
public void dragEnter(java.awt.dnd.DragSourceDragEvent event)
dragEnter
in interface java.awt.dnd.DragSourceListener
public void dragExit(java.awt.dnd.DragSourceEvent event)
dragExit
in interface java.awt.dnd.DragSourceListener
public void dragOver(java.awt.dnd.DragSourceDragEvent event)
dragOver
in interface java.awt.dnd.DragSourceListener
public void cut()
cut
in class javax.swing.text.JTextComponent
replaceSelection(com.lightdev.app.shtm.HTMLText)
public void copy()
copy
in class javax.swing.text.JTextComponent
public void paste()
paste
in class javax.swing.text.JTextComponent
replaceSelection(com.lightdev.app.shtm.HTMLText)
public void applyAttributes(javax.swing.text.AttributeSet a, boolean para)
public void applyAttributes(javax.swing.text.AttributeSet a, boolean para, boolean replace)
a
- the set of attributes to applypara
- true, if the attributes shall be applied to the whole
paragraph, false, if only the selected range of characters shall have themreplace
- true, if existing attribtes are to be replaced, false if notpublic void applyTag(java.lang.String tag, java.util.Vector allowedTags)
tag
- the tag name to switche elements toallowedTags
- tags that may be switched
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |