com.ecyrd.jspwiki.ui
Class EditorManager

java.lang.Object
  extended by com.ecyrd.jspwiki.modules.ModuleManager
      extended by com.ecyrd.jspwiki.ui.EditorManager

public class EditorManager
extends ModuleManager

Defines an editor manager. An editor can be added by adding a suitable JSP file under templates/default/editors If you want your editor to include any scripts or something, you can simply request it by adding the following in your ini/jspwiki_module.xml:

  
   
       Janne Jalkanen
       
       foo.css
       editors/myeditor.jsp
   
  
  

Since:
2.4
Author:
jalkanen, Christoph Sauer, Chuck Smith

Field Summary
static String ATTR_EDITEDTEXT
          Known attribute name for storing the user edited text inside a session or a page context
static String EDITOR_PLAIN
          Known name for the plain wikimarkup editor.
static String EDITOR_PREVIEW
          Known name for the preview editor component.
static String PARA_EDITOR
          Parameter for changing editors at run-time
static String PROP_EDITORTYPE
          The property name for setting the editor.
static String REQ_EDITEDTEXT
          Known attribute name for storing the user edited text inside a HTTP parameter.
 
Fields inherited from class com.ecyrd.jspwiki.modules.ModuleManager
PLUGIN_RESOURCE_LOCATION
 
Constructor Summary
EditorManager()
           
 
Method Summary
static String getEditedText(javax.servlet.jsp.PageContext ctx)
          Convenience function which examines the current context and attempts to figure out whether the edited text is in the HTTP request parameters or somewhere in the session.
 String[] getEditorList()
          Returns a list of editors as Strings of editor names.
 String getEditorName(WikiContext context)
          Returns an editor for the current context.
 String getEditorPath(WikiContext context)
          Convenience method for getting the path to the editor JSP file.
 void initialize(WikiEngine engine, Properties props)
          Initializes the EditorManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_EDITORTYPE

public static final String PROP_EDITORTYPE
The property name for setting the editor. Current value is "jspwiki.editor"

See Also:
Constant Field Values

PARA_EDITOR

public static final String PARA_EDITOR
Parameter for changing editors at run-time

See Also:
Constant Field Values

EDITOR_PLAIN

public static final String EDITOR_PLAIN
Known name for the plain wikimarkup editor.

See Also:
Constant Field Values

EDITOR_PREVIEW

public static final String EDITOR_PREVIEW
Known name for the preview editor component.

See Also:
Constant Field Values

REQ_EDITEDTEXT

public static final String REQ_EDITEDTEXT
Known attribute name for storing the user edited text inside a HTTP parameter.

See Also:
Constant Field Values

ATTR_EDITEDTEXT

public static final String ATTR_EDITEDTEXT
Known attribute name for storing the user edited text inside a session or a page context

See Also:
Constant Field Values
Constructor Detail

EditorManager

public EditorManager()
Method Detail

initialize

public void initialize(WikiEngine engine,
                       Properties props)
Initializes the EditorManager. It also registers any editors it can find.

Parameters:
engine - The WikiEngine we're attached to.
props - Properties for setup.

getEditorName

public String getEditorName(WikiContext context)
Returns an editor for the current context. The editor names are matched in a case insensitive manner. At the moment, the only place that this method looks in is the property file, but in the future this will also look at user preferences.

Determines the editor to use by the following order of conditions: 1. Attribute in HttpSession: used when an alternative editor has been chosen 2. Editor set in User Preferences (not yet implemented) 3. Default Editor set in jspwiki.properties

For the PREVIEW context, this method returns the "preview" editor.

Parameters:
context - The context that is chosen.
Returns:
The name of the chosen editor. If no match could be found, will revert to the default "plain" editor.

getEditorList

public String[] getEditorList()
Returns a list of editors as Strings of editor names.

Returns:
the list of available editors

getEditorPath

public String getEditorPath(WikiContext context)
Convenience method for getting the path to the editor JSP file.

Parameters:
context -
Returns:
e.g. "editors/plain.jsp"

getEditedText

public static String getEditedText(javax.servlet.jsp.PageContext ctx)
Convenience function which examines the current context and attempts to figure out whether the edited text is in the HTTP request parameters or somewhere in the session.

Parameters:
ctx - the JSP page context
Returns:
the edited text, if present in the session page context or as a parameter