com.tecnick.jxhtmledit
Class JXHTMLedit

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by com.tecnick.jxhtmledit.JXHTMLedit
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer

public class JXHTMLedit
extends javax.swing.JApplet

WYSIWYG XHTML Editor
Java Applet to edit XHTML in WYSIWYG mode.
Copyright (c) 2002-2006 Tecnick.com S.r.l (www.tecnick.com) Via Ugo Foscolo n.19 - 09045 Quartu Sant'Elena (CA) - ITALY - www.tecnick.com - info@tecnick.com
Project homepage: http://jxhtmledit.sourceforge.net
License: http://www.gnu.org/copyleft/gpl.html GPL 2

Version:
4.0.005
Author:
Nicola Asuni [www.tecnick.com].
See Also:
Serialized Form

Nested Class Summary
(package private)  class JXHTMLedit.RedoAction
          class to handle REDO action
(package private)  class JXHTMLedit.tableIndex
          Class to store caret position of table elements
(package private)  class JXHTMLedit.TabListener
          Listener Class to switch between WYISWIG and HTML SOURCE tab editors
(package private)  class JXHTMLedit.UndoAction
          class to handle UNDO action
 
Nested classes/interfaces inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  java.lang.String[] attribute_string_array
          the following will contain the string attribute to attach on tag
private  boolean auto_li_enabled
          enable auto
private  javax.swing.JCheckBox autobreak
          checkbox to enable/disable the auto
mode
private  javax.swing.JCheckBox autoListItem
          checkbox to enable/disable the auto mode
private  boolean br_state_editor
          remember auto
settings for editor
private  boolean br_state_source
          remember auto
settings for source editor
private  java.util.ArrayList buttonActionListener
          ActionListener array for buttons
private  java.lang.String buttons_images_path
          Applet parameter (param_buttons_images_path): path to buttons images directory (relative to document base)
private  java.lang.String config_files_path
          Applet parameter (param_config_files_path): path configuration files directory (relative to document base)
private  JXHTMLConfig configuration
          Configuration data.
private  javax.swing.JEditorPane current_editor
          Selected Editor
(package private)  java.lang.String current_html_code
          HTML source code to edit
private  javax.swing.JEditorPane editor
          WYSIWYG editor pane
private  javax.swing.JEditorPane editsource
          Source editor pane
private  java.lang.String encoding_in
          Applet parameter (param_page_encoding): input page charset encoding
private  java.lang.String encoding_out
          Applet parameter (param_encoding): charset encoding
private  java.lang.String images_list
          Applet parameter (param_images_list): list of images in images_path directory separted by ":"
private  java.lang.String images_path
          Applet parameter (param_images_path): absolute URI of images directory
(package private)  boolean isStandalone
          This is an applet
private  java.lang.String jarpath
          path to jar file
private  java.lang.String jxhtmledit_version
          Software Version
private  java.awt.event.ActionListener openManufacturerSite
          open manufacturer site on a new browser window
private  java.lang.String param_callingfield
          Applet parameter (param_callingfield): name of the calling html textarea form field
private  java.lang.String param_callingform
          Applet parameter (param_callingform): name of the calling html form
private  boolean param_entities_off
          Applet parameter (param_entities_off): when true convert htmlentities to extended chars
private  boolean param_hide_source
          Applet parameter (param_hide_source): if true hide source edit panel
private  boolean param_indent
          Applet parameter (param_indent): when true indent XHTML output code
private  java.lang.String param_lang
          ISO 639 language identifier (a two- or three-letter code) used on TMX files
private  boolean param_separate_window
          Applet parameter (param_separate_window): true if applet is loaded in a separate browser window respect one containing the calling form field
private  java.lang.String param_stylesheet
          Applet parameter (param_stylesheet): name of the default CSS stylesheet file
private  boolean param_xhtml
          Applet parameter (param_xhtml): if true export (save) as XHTML instead of HTML
private  java.util.Stack redo_stack
          Redo stack
private  JXHTMLedit.RedoAction redoAction
          redo action
private static long serialVersionUID
          serialVersionUID
private  boolean source_mode
          Set current edit mode: WYSIWYG/source
private  java.lang.String text_to_search
          remember last search
(package private)  java.applet.Applet this_applet
          "this" applet
private static int undo_size
          max undo operation size
private  java.util.Stack undo_stack
          Undo stack
private  JXHTMLedit.UndoAction undoAction
          undo action
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
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
JXHTMLedit()
           
 
Method Summary
 void about_this_applet()
          display this software information dialog window
private  javax.swing.JComponent attribute_input_component(int input_type, int attribute_index, java.lang.String attribute_name, java.lang.String attribute_values, java.lang.String default_value, javax.swing.ImageIcon attribute_icon, javax.swing.JTextField parent_component)
          return input component for tag attributes
private  javax.swing.JComponent attribute_input_component2(int input_type, int attribute_index, java.lang.String attribute_name, java.lang.String attribute_start, java.lang.String attribute_end, java.lang.String attribute_values, java.lang.String default_value, javax.swing.ImageIcon attribute_icon, javax.swing.JTextField parent_component)
          return input component for tag attributes
private  javax.swing.JLabel attribute_label_component(java.lang.String attribute_name, java.lang.String attribute_description, int attribute_status, java.lang.String status_name, java.lang.String status_description)
          create label for attribute input
private  JXHTMLedit.tableIndex createTableIndex()
          Create table index (find caret start positions of each table element)
private  javax.swing.JButton customButton(java.lang.String name, java.lang.String description, java.lang.String icon, java.lang.String intag, java.lang.String outtag, int action_id, int keystroke, int keymodifier)
          Create a custom TAG button
 java.lang.String getCode()
          Convenience method to get html code from javascript.
private  java.lang.String getCodeOnForm()
          Get HTML code from calling form
private  javax.swing.ImageIcon getImageIcon(java.lang.String imgpath)
          Get the ImageIcon object from file.
private  java.lang.String getParameter(java.lang.String key, java.lang.String def)
          Get the applet parameters from applet call and set default values for void parameters
private  void getParameters()
          set the applet parameters (param)
private  javax.swing.JPanel info_panel()
          Create a JButton that display JXHTMLEDIT infos and open tecnick.com site
 void init()
          Initialize applet
private  javax.swing.JLabel input_label_component(java.lang.String name, java.lang.String description)
          create a formatted label with tooltip
private  void insertTag(java.lang.String intag, java.lang.String outtag)
          Insert open and close tag around selection or at caret position
private  void removeTag()
          Remove selected or adjacent tag
private  void replaceTag(java.lang.String search_tag, java.lang.String replace_tag)
          Replace HTML tag on selection
private  void searchText(java.lang.String text_to_search)
          find first occurence of specified text from current caret position
 void setCode(java.lang.String code)
          Convenience method to set html code from javascript.
private  void setHTMLCode(java.lang.String html, boolean update_source, boolean update_undo)
          Set the HTML code in the current editor pane
private  void setRedo(java.lang.String txt)
          Add text objects to redo stack.
private  void setUndo(java.lang.String txt)
          Add text objects to undo stack.
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, 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

serialVersionUID

private static final long serialVersionUID
serialVersionUID

See Also:
Constant Field Values

jxhtmledit_version

private java.lang.String jxhtmledit_version
Software Version


configuration

private JXHTMLConfig configuration
Configuration data.


isStandalone

boolean isStandalone
This is an applet


this_applet

java.applet.Applet this_applet
"this" applet


undo_size

private static final int undo_size
max undo operation size

See Also:
Constant Field Values

undo_stack

private java.util.Stack undo_stack
Undo stack


redo_stack

private java.util.Stack redo_stack
Redo stack


jarpath

private java.lang.String jarpath
path to jar file


editor

private javax.swing.JEditorPane editor
WYSIWYG editor pane


editsource

private javax.swing.JEditorPane editsource
Source editor pane


current_editor

private javax.swing.JEditorPane current_editor
Selected Editor


encoding_out

private java.lang.String encoding_out
Applet parameter (param_encoding): charset encoding


encoding_in

private java.lang.String encoding_in
Applet parameter (param_page_encoding): input page charset encoding


param_lang

private java.lang.String param_lang
ISO 639 language identifier (a two- or three-letter code) used on TMX files


param_callingform

private java.lang.String param_callingform
Applet parameter (param_callingform): name of the calling html form


param_callingfield

private java.lang.String param_callingfield
Applet parameter (param_callingfield): name of the calling html textarea form field


param_stylesheet

private java.lang.String param_stylesheet
Applet parameter (param_stylesheet): name of the default CSS stylesheet file


param_hide_source

private boolean param_hide_source
Applet parameter (param_hide_source): if true hide source edit panel


param_xhtml

private boolean param_xhtml
Applet parameter (param_xhtml): if true export (save) as XHTML instead of HTML


param_indent

private boolean param_indent
Applet parameter (param_indent): when true indent XHTML output code


param_entities_off

private boolean param_entities_off
Applet parameter (param_entities_off): when true convert htmlentities to extended chars


buttons_images_path

private java.lang.String buttons_images_path
Applet parameter (param_buttons_images_path): path to buttons images directory (relative to document base)


config_files_path

private java.lang.String config_files_path
Applet parameter (param_config_files_path): path configuration files directory (relative to document base)


images_path

private java.lang.String images_path
Applet parameter (param_images_path): absolute URI of images directory


images_list

private java.lang.String images_list
Applet parameter (param_images_list): list of images in images_path directory separted by ":"


param_separate_window

private boolean param_separate_window
Applet parameter (param_separate_window): true if applet is loaded in a separate browser window respect one containing the calling form field


current_html_code

java.lang.String current_html_code
HTML source code to edit


undoAction

private JXHTMLedit.UndoAction undoAction
undo action


redoAction

private JXHTMLedit.RedoAction redoAction
redo action


source_mode

private boolean source_mode
Set current edit mode: WYSIWYG/source


attribute_string_array

private java.lang.String[] attribute_string_array
the following will contain the string attribute to attach on tag


br_state_editor

private boolean br_state_editor
remember auto
settings for editor


br_state_source

private boolean br_state_source
remember auto
settings for source editor


text_to_search

private java.lang.String text_to_search
remember last search


auto_li_enabled

private boolean auto_li_enabled
enable auto

  • autoListItem

    private javax.swing.JCheckBox autoListItem
    checkbox to enable/disable the auto
  • mode


  • autobreak

    private javax.swing.JCheckBox autobreak
    checkbox to enable/disable the auto
    mode


    buttonActionListener

    private java.util.ArrayList buttonActionListener
    ActionListener array for buttons


    openManufacturerSite

    private java.awt.event.ActionListener openManufacturerSite
    open manufacturer site on a new browser window

    Constructor Detail

    JXHTMLedit

    public JXHTMLedit()
    Method Detail

    getParameter

    private java.lang.String getParameter(java.lang.String key,
                                          java.lang.String def)
    Get the applet parameters from applet call and set default values for void parameters

    Parameters:
    key - name of param to get
    def - default value for void param
    Returns:
    param value

    getParameters

    private void getParameters()
    set the applet parameters (param)


    setHTMLCode

    private void setHTMLCode(java.lang.String html,
                             boolean update_source,
                             boolean update_undo)
    Set the HTML code in the current editor pane

    Parameters:
    html - HTML source code to write on document
    update_source - if true, then update source editor

    setCode

    public void setCode(java.lang.String code)
    Convenience method to set html code from javascript.

    Parameters:
    code -

    getCode

    public java.lang.String getCode()
    Convenience method to get html code from javascript.

    Returns:
    html code

    insertTag

    private void insertTag(java.lang.String intag,
                           java.lang.String outtag)
    Insert open and close tag around selection or at caret position

    Parameters:
    intag - open tag <tagname> or ""
    outtag - close tag </tagname> or ""

    removeTag

    private void removeTag()
    Remove selected or adjacent tag


    replaceTag

    private void replaceTag(java.lang.String search_tag,
                            java.lang.String replace_tag)
    Replace HTML tag on selection

    Parameters:
    search_tag - tag to replace
    replace_tag - new tag

    createTableIndex

    private JXHTMLedit.tableIndex createTableIndex()
    Create table index (find caret start positions of each table element)

    Returns:
    table data

    searchText

    private void searchText(java.lang.String text_to_search)
    find first occurence of specified text from current caret position

    Parameters:
    text_to_search - text to search

    getCodeOnForm

    private java.lang.String getCodeOnForm()
    Get HTML code from calling form

    Returns:
    code from calling form

    info_panel

    private javax.swing.JPanel info_panel()
    Create a JButton that display JXHTMLEDIT infos and open tecnick.com site

    Returns:
    JButton

    about_this_applet

    public void about_this_applet()
    display this software information dialog window


    getImageIcon

    private javax.swing.ImageIcon getImageIcon(java.lang.String imgpath)
    Get the ImageIcon object from file.

    Parameters:
    imgpath - image file path (inside jar or external URL)
    Returns:
    ImageIcon object

    init

    public void init()
    Initialize applet

    Overrides:
    init in class java.applet.Applet

    setUndo

    private void setUndo(java.lang.String txt)
    Add text objects to undo stack.

    Parameters:
    txt - text to add.

    setRedo

    private void setRedo(java.lang.String txt)
    Add text objects to redo stack.

    Parameters:
    txt - text to add.

    attribute_label_component

    private javax.swing.JLabel attribute_label_component(java.lang.String attribute_name,
                                                         java.lang.String attribute_description,
                                                         int attribute_status,
                                                         java.lang.String status_name,
                                                         java.lang.String status_description)
    create label for attribute input

    Parameters:
    attribute_name - attribute name
    attribute_description - attribute description
    attribute_status - status of attribute (0-4) for displaying different colors
    status_name - status name
    status_description - status description
    Returns:
    label

    attribute_input_component

    private javax.swing.JComponent attribute_input_component(int input_type,
                                                             int attribute_index,
                                                             java.lang.String attribute_name,
                                                             java.lang.String attribute_values,
                                                             java.lang.String default_value,
                                                             javax.swing.ImageIcon attribute_icon,
                                                             javax.swing.JTextField parent_component)
    return input component for tag attributes

    Parameters:
    input_type - type of input: 0=inputttext; 1=checkbox; 2=textarea; 3=combobox; 4=colorchooser;
    attribute_index - this attribute number
    attribute_name - this attribute name
    attribute_values - list of values separated by ":" for combobox (type 3)
    default_value - default value
    attribute_icon - ImageIcon for colorchooser button (only for type 4)
    parent_component - inputtext component where to store the colorchooser value (only for type 4)
    Returns:
    input component

    attribute_input_component2

    private javax.swing.JComponent attribute_input_component2(int input_type,
                                                              int attribute_index,
                                                              java.lang.String attribute_name,
                                                              java.lang.String attribute_start,
                                                              java.lang.String attribute_end,
                                                              java.lang.String attribute_values,
                                                              java.lang.String default_value,
                                                              javax.swing.ImageIcon attribute_icon,
                                                              javax.swing.JTextField parent_component)
    return input component for tag attributes

    Parameters:
    input_type - type of input: 0=inputttext; 1=checkbox; 2=textarea; 3=combobox; 4=colorchooser;
    attribute_index - this attribute number
    attribute_name - this attribute name
    attribute_start - this attribute start string (e.g: style=")
    attribute_end - this attribute end string (e.g: ")
    attribute_values - list of values separated by ":" for combobox (type 3)
    default_value - default value
    attribute_icon - ImageIcon for colorchooser button (only for type 4)
    parent_component - inputtext component where to store the colorchooser value (only for type 4)
    Returns:
    input component

    input_label_component

    private javax.swing.JLabel input_label_component(java.lang.String name,
                                                     java.lang.String description)
    create a formatted label with tooltip

    Parameters:
    name - name of label
    description - text for tooltip
    Returns:
    label

    customButton

    private javax.swing.JButton customButton(java.lang.String name,
                                             java.lang.String description,
                                             java.lang.String icon,
                                             java.lang.String intag,
                                             java.lang.String outtag,
                                             int action_id,
                                             int keystroke,
                                             int keymodifier)
    Create a custom TAG button

    Parameters:
    name - String button name (used if icon is null)
    description - String description for tooltip
    icon - String image filename (must be located inside the buttons_images_path)
    intag - String the opening tag (e.g.: <h1>)
    outtag - String the closing tag (e.g.: </h1>)
    action_id - int ID of buttonsActionListener
    keystroke - int keyboard key for KeyboardAction
    keymodifier - int keyboard modifier key for KeyboardAction
    Returns:
    JButton