org.eclipse.epf.richtext
Class RichText

java.lang.Object
  extended byorg.eclipse.epf.richtext.RichText
All Implemented Interfaces:
IRichText
Direct Known Subclasses:
MethodRichText

public class RichText
extends java.lang.Object
implements IRichText

The default rich text control implementation.

The default rich text editor uses XHTML as the underlying markup language for the rich text content. It is implemented using a SWT Browser control and DHTML (HTML, CSS and JavaScript).

Since:
1.0
Author:
Kelvin Low

Field Summary
 
Fields inherited from interface org.eclipse.epf.richtext.IRichText
PROPERTY_NAME
 
Constructor Summary
RichText(org.eclipse.swt.widgets.Composite parent, int style)
          Creates a new instance.
RichText(org.eclipse.swt.widgets.Composite parent, int style, java.lang.String basePath)
          Creates a new instance.
 
Method Summary
 void addDisposeListener(org.eclipse.swt.events.DisposeListener listener)
          Adds the listener to the collection of listeners who will be notifed when this control is disposed.
 void addHelpListener(org.eclipse.swt.events.HelpListener listener)
          Adds a listener to the collection of listeners who will be notified when help events are generated for this control.
 void addKeyListener(org.eclipse.swt.events.KeyListener listener)
          Adds a listener to the collection of listeners who will be notified when keys are pressed and released within this control.
 void addListener(int eventType, org.eclipse.swt.widgets.Listener listener)
          Adds the listener to the collection of listeners who will be notifed when an event of the given type occurs within this control.
 void addModifyListener(org.eclipse.swt.events.ModifyListener listener)
          Adds a listener to the collection of listeners who will be notified when the content of this control is modified.
 void dispose()
          Disposes the operating system resources allocated by the control.
 int executeCommand(java.lang.String command)
          Executes the given rich text command.
 int executeCommand(java.lang.String command, java.lang.String param)
          Executes the given rich text command with a single parameter.
 int executeCommand(java.lang.String command, java.lang.String[] params)
          Executes the given rich text command with an array of parameters.
 java.lang.String getBasePath()
          Returns the base path used for resolving text and image links.
 org.eclipse.swt.widgets.Control getControl()
          Returns this rich text control.
 java.lang.Object getData(java.lang.String key)
          Returns an application specific property value.
 boolean getEditable()
          Returns the editable state.
 java.lang.Object getLayoutData()
          Returns the layout data.
 java.util.Iterator getListeners()
          Returns the event listeners attached to this control.
 boolean getModified()
          Checks whether the content has been modified.
 java.util.Iterator getModifyListeners()
          Returns the modify listeners attached to this control.
 java.lang.String getSelectedText()
          Returns the currently selected text.
 java.lang.String getText()
          Returns the rich text content.
 boolean hasFocus()
          Checks whether this control has focus.
 boolean isDisposed()
          Checks whether this control has been disposed.
 void notifyModifyListeners()
          Notifies the modify listeners that the rich text editor content has changed.
 void removeDisposeListener(org.eclipse.swt.events.DisposeListener listener)
          Removes a listener from the collection of listeners who will be notified when this control is disposed.
 void removeHelpListener(org.eclipse.swt.events.HelpListener listener)
          Removes a listener from the collection of listeners who will be notified when help events are generated for this control.
 void removeKeyListener(org.eclipse.swt.events.KeyListener listener)
          Removes a listener from the collection of listeners who will be notified when keys are pressed and released within this control.
 void removeListener(int eventType, org.eclipse.swt.widgets.Listener listener)
          Removes the listener from the collection of listeners who will be notifed when an event of the given type occurs within this control.
 void removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
          Removes a listener from the collection of listeners who will be notified when the content of this control is modified.
 void restoreText()
          Restores the rich text content back to the initial value.
 void setData(java.lang.String key, java.lang.Object value)
          Sets an application specific property name and value.
 void setEditable(boolean editable)
          Sets the editable state.
 void setFocus()
          Sets focus to this control.
 void setLayoutData(java.lang.Object layoutData)
          Sets the layout data.
 void setModified(boolean modified)
          Sets the modified state.
 void setText(java.lang.String text)
          Sets the rich text content.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RichText

public RichText(org.eclipse.swt.widgets.Composite parent,
                int style,
                java.lang.String basePath)
Creates a new instance.

Parameters:
parent - the parent composite
style - the style for this control
basePath - the path used for resolving links

RichText

public RichText(org.eclipse.swt.widgets.Composite parent,
                int style)
Creates a new instance.

Parameters:
parent - the parent composite
style - the style for this control
Method Detail

getControl

public org.eclipse.swt.widgets.Control getControl()
Returns this rich text control.

Specified by:
getControl in interface IRichText
Returns:
this rich text control

setLayoutData

public void setLayoutData(java.lang.Object layoutData)
Sets the layout data.

Specified by:
setLayoutData in interface IRichText
Parameters:
layoutData - the layout data to set

getLayoutData

public java.lang.Object getLayoutData()
Returns the layout data.

Specified by:
getLayoutData in interface IRichText
Returns:
this control's layout data

setFocus

public void setFocus()
Sets focus to this control.

Specified by:
setFocus in interface IRichText

hasFocus

public boolean hasFocus()
Checks whether this control has focus.

Specified by:
hasFocus in interface IRichText
Returns:
true if this control has the user-interface focus

getBasePath

public java.lang.String getBasePath()
Returns the base path used for resolving text and image links.

Specified by:
getBasePath in interface IRichText
Returns:
the base path used for resolving links in this control

getEditable

public boolean getEditable()
Returns the editable state.

Specified by:
getEditable in interface IRichText
Returns:
true if the content is ediatble

setEditable

public void setEditable(boolean editable)
Sets the editable state.

Specified by:
setEditable in interface IRichText
Parameters:
editable - the editable state

getModified

public boolean getModified()
Checks whether the content has been modified.

Specified by:
getModified in interface IRichText
Returns:
true if the content has been modified

setModified

public void setModified(boolean modified)
Sets the modified state.

Specified by:
setModified in interface IRichText
Parameters:
modified - the modified state

getText

public java.lang.String getText()
Returns the rich text content.

Specified by:
getText in interface IRichText
Returns:
the rich text content formatted in a markup language

setText

public void setText(java.lang.String text)
Sets the rich text content.

Specified by:
setText in interface IRichText
Parameters:
text - the rich text content formatted in a markup language

restoreText

public void restoreText()
Restores the rich text content back to the initial value.

Specified by:
restoreText in interface IRichText

getSelectedText

public java.lang.String getSelectedText()
Returns the currently selected text.

Specified by:
getSelectedText in interface IRichText
Returns:
the selected text or "" if there is no selection

getData

public java.lang.Object getData(java.lang.String key)
Returns an application specific property value.

Specified by:
getData in interface IRichText
Parameters:
key - the name of the property
Returns:
the value of the property or null if it has not been set

setData

public void setData(java.lang.String key,
                    java.lang.Object value)
Sets an application specific property name and value.

Specified by:
setData in interface IRichText
Parameters:
key - the name of the property
value - the property value

executeCommand

public int executeCommand(java.lang.String command)
Executes the given rich text command. The supported command strings are defined in RichTextCommand.

Specified by:
executeCommand in interface IRichText
Parameters:
command - a rich text command string.
Returns:
a status code returned by the executed command

executeCommand

public int executeCommand(java.lang.String command,
                          java.lang.String param)
Executes the given rich text command with a single parameter. The supported command strings are defined in RichTextCommand.

Specified by:
executeCommand in interface IRichText
Parameters:
command - a rich text command string
param - a parameter for the command or null
Returns:
a status code returned by the executed command

executeCommand

public int executeCommand(java.lang.String command,
                          java.lang.String[] params)
Executes the given rich text command with an array of parameters. The supported command strings are defined in RichTextCommand.

Specified by:
executeCommand in interface IRichText
Parameters:
command - a rich text command string
params - an array of parameters for the command or null
Returns:
a status code returned by the executed command

dispose

public void dispose()
Disposes the operating system resources allocated by the control.

Specified by:
dispose in interface IRichText

isDisposed

public boolean isDisposed()
Checks whether this control has been disposed.

Specified by:
isDisposed in interface IRichText
Returns:
true if this control is disposed successfully

getModifyListeners

public java.util.Iterator getModifyListeners()
Returns the modify listeners attached to this control.

Specified by:
getModifyListeners in interface IRichText
Returns:
an iterator for retrieving the modify listeners

addKeyListener

public void addKeyListener(org.eclipse.swt.events.KeyListener listener)
Adds a listener to the collection of listeners who will be notified when keys are pressed and released within this control.

Specified by:
addKeyListener in interface IRichText
Parameters:
listener - the listener which should be notified

removeKeyListener

public void removeKeyListener(org.eclipse.swt.events.KeyListener listener)
Removes a listener from the collection of listeners who will be notified when keys are pressed and released within this control.

Specified by:
removeKeyListener in interface IRichText
Parameters:
listener - the listener which should no longer be notified

addModifyListener

public void addModifyListener(org.eclipse.swt.events.ModifyListener listener)
Adds a listener to the collection of listeners who will be notified when the content of this control is modified.

Specified by:
addModifyListener in interface IRichText
Parameters:
listener - the listener which should be notified

removeModifyListener

public void removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
Removes a listener from the collection of listeners who will be notified when the content of this control is modified.

Specified by:
removeModifyListener in interface IRichText
Parameters:
listener - the listener which should no longer be notified

addDisposeListener

public void addDisposeListener(org.eclipse.swt.events.DisposeListener listener)
Adds the listener to the collection of listeners who will be notifed when this control is disposed.

Specified by:
addDisposeListener in interface IRichText
Parameters:
listener - the listener which should be notified

removeDisposeListener

public void removeDisposeListener(org.eclipse.swt.events.DisposeListener listener)
Removes a listener from the collection of listeners who will be notified when this control is disposed.

Specified by:
removeDisposeListener in interface IRichText
Parameters:
listener - the listener which should no longer be notified

addHelpListener

public void addHelpListener(org.eclipse.swt.events.HelpListener listener)
Adds a listener to the collection of listeners who will be notified when help events are generated for this control.

Specified by:
addHelpListener in interface IRichText
Parameters:
listener - the listener which should be notified

removeHelpListener

public void removeHelpListener(org.eclipse.swt.events.HelpListener listener)
Removes a listener from the collection of listeners who will be notified when help events are generated for this control.

Specified by:
removeHelpListener in interface IRichText
Parameters:
listener - the listener which should no longer be notified

addListener

public void addListener(int eventType,
                        org.eclipse.swt.widgets.Listener listener)
Adds the listener to the collection of listeners who will be notifed when an event of the given type occurs within this control.

Specified by:
addListener in interface IRichText
Parameters:
eventType - the type of event to listen for
listener - the listener which should be notified when the event occurs

removeListener

public void removeListener(int eventType,
                           org.eclipse.swt.widgets.Listener listener)
Removes the listener from the collection of listeners who will be notifed when an event of the given type occurs within this control.

Specified by:
removeListener in interface IRichText
Parameters:
eventType - the type of event to listen for
listener - the listener which should no longer be notified when the event occurs

getListeners

public java.util.Iterator getListeners()
Returns the event listeners attached to this control.

Specified by:
getListeners in interface IRichText
Returns:
an iterator for retrieving the event listeners attached to this control

notifyModifyListeners

public void notifyModifyListeners()
Notifies the modify listeners that the rich text editor content has changed.