com.ephox.editlive.custom
Class CustomTagController

java.lang.Object
  extended by com.ephox.editlive.custom.CustomTagController

public class CustomTagController
extends Object

This class provides methods for registering additional views and view rendering to be used in conjunction with the ELJBean. Changing values via this class must be done before loading content into the editor, which means an early loading plugin (or before init() for Swing SDK users).

Instance available via ELJBean.getCustomTagController().

Since:
7.0

Constructor Summary
CustomTagController()
           
 
Method Summary
 void addCustomView(String tagName, int type, Class<?> viewClass, Object extraData)
          Registers a new custom tag with a specific view.
 void clear()
          Clears all custom tags, custom views, and view annotations
 CustomTagBehaviour getCustomTagBehaviour(String tagName)
          Returns the behaviour object for a previously defined tag.
 Map<String,String> getCustomTags()
          Returns the map of custom tag ids to custom tags.
 Map<HTML.Tag,com.ephox.editlive.common.CustomTagData> getCustomViews()
          Returns the map of tag names to CustomTagData objects for all currently registered custom tags.
 HTML.Tag getDeclaredCustomTag(String tagName)
          Finds an object reference to a previously declared custom tag.
 Object getUnregisteredCustomTagExtraData()
          Returns the Unregistered Custom Tag Extra Data previously set by setUnregisteredCustomTagView(Class, Object)
 Class<?> getUnregisteredCustomTagView()
          Returns the Unregistered Custom Tag View previously set by setUnregisteredCustomTagView(Class, Object)
 List<com.ephox.editlive.common.CustomTagData> getViewAnnotationsForTag(String tagName)
          Retrieves the list of ViewAnnotation registered against the specified tag.
 void registerCustomBlockTag(String tagName, Icon startIcon, String startLabel, Icon endIcon, String endLabel, ViewClickListener listener)
          Registers a custom block tag.
 void registerCustomBlockView(String tagName, Class<?> viewClass, Object extraData)
          Registers a custom view for the specified block tag.
 void registerCustomCollapsedView(String tagName, Class<?> viewName, Object extraData)
          Registers a custom view for the specified inline tag.
 void registerCustomEmptyTag(String tagName, Icon icon, String label, ViewClickListener listener)
          Registers a custom empty tag.
 void registerCustomEmptyView(String tagName, Class<?> viewClass, Object extraData)
          Registers a custom view for the specified empty tag.
 void registerCustomInlineTag(String tagName, Icon startIcon, String startLabel, Icon endIcon, String endLabel, ViewClickListener listener)
          Registers a custom inline tag.
 void registerCustomInlineView(String tagName, Class<?> viewClass, Object extraData)
          Registers a custom view for the specified inline tag.
 void registerViewAnnotation(String tagName, Class<?> clazz, Object extraData)
          Registers a class implementing ViewAnnotation to create additional rendering for a specified HTML tag.
 void setUnregisteredCustomTagView(Class<?> viewClass, Object extraData)
          Sets the view to use for unregistered custom tags.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomTagController

public CustomTagController()
Method Detail

getDeclaredCustomTag

public HTML.Tag getDeclaredCustomTag(String tagName)
Finds an object reference to a previously declared custom tag.

Parameters:
tagName - name of a custom tag
Returns:
HTML.Tag reference for the custom tag, or null if it hasn't been declared.

registerCustomBlockTag

public void registerCustomBlockTag(String tagName,
                                   Icon startIcon,
                                   String startLabel,
                                   Icon endIcon,
                                   String endLabel,
                                   ViewClickListener listener)
Registers a custom block tag. The tag will be displayed with the given icons and labels at the start and end of the block. The ViewClickListener will be notified when a mouse click is detected on the view.

Parameters:
tagName - the name of the custom block tag.
startIcon - the icon to display at the start of the block, or null for no icon.
startLabel - the label to display at the start of the block, or null for no label.
endIcon - the icon to display at the end of the block, or null for no icon.
endLabel - the label to display at the end of the block, or null for no label.
listener - the listener to notify of mouse click events, or null if no notification is required.

registerCustomInlineTag

public void registerCustomInlineTag(String tagName,
                                    Icon startIcon,
                                    String startLabel,
                                    Icon endIcon,
                                    String endLabel,
                                    ViewClickListener listener)
Registers a custom inline tag. The tag will be displayed with the given icons and labels at the start and end of the tag. The ViewClickListener will be notified when a mouse click is detected on the view.

Parameters:
tagName - the name of the custom inline tag.
startIcon - the icon to display at the start of the tag, or null for no icon.
startLabel - the label to display at the start of the tag, or null for no label.
endIcon - the icon to display at the end of the tag, or null for no icon.
endLabel - the label to display at the end of the tag, or null for no label.
listener - the listener to notify of mouse click events, or null if no notification is required.

registerCustomEmptyTag

public void registerCustomEmptyTag(String tagName,
                                   Icon icon,
                                   String label,
                                   ViewClickListener listener)
Registers a custom empty tag. The tag will be displayed with the given icon and label. The ViewClickListener will be notified when a mouse click is detected on the view.

Parameters:
tagName - the name of the custom inline tag.
icon - the icon to display for the tag, or null for no icon.
label - the label to display for the tag, or null for no label.
listener - the listener to notify of mouse click events, or null if no notification is required.

registerCustomBlockView

public void registerCustomBlockView(String tagName,
                                    Class<?> viewClass,
                                    Object extraData)
Registers a custom view for the specified block tag.

Parameters:
tagName - the name of the tag to use the view for.
viewClass - the fully qualify class name for the Viewfor the tag.
extraData - this can be any object (or null) and is passed into the constructor for viewClass if it has a constructor that takes both an element and an object.

registerCustomInlineView

public void registerCustomInlineView(String tagName,
                                     Class<?> viewClass,
                                     Object extraData)
Registers a custom view for the specified inline tag.

Parameters:
tagName - the name of the tag to use the view for.
viewClass - the fully qualify class name for the Viewfor the tag.
extraData - this can be any object (or null) and is passed into the constructor for viewClass if it has a constructor that takes both an element and an object.

registerCustomEmptyView

public void registerCustomEmptyView(String tagName,
                                    Class<?> viewClass,
                                    Object extraData)
Registers a custom view for the specified empty tag.

Parameters:
tagName - the name of the tag to use the view for.
viewClass - the fully qualify class name for the View for the tag.
extraData - this can be any object (or null) and is passed into the constructor for viewClass if it has a constructor that takes both an element and an object.

registerCustomCollapsedView

public void registerCustomCollapsedView(String tagName,
                                        Class<?> viewName,
                                        Object extraData)
Registers a custom view for the specified inline tag. Unlike registerCustomInlineView(String, Class, Object), the contents of the tag will not be loaded and the element loaded into the document will appear as an empty tag. When the document is retrieved the original contents of the tag will be reinserted.

The contents of the tag is available as an URL encoded string in the eljcontent attribute of the parsed tag.

Parameters:
tagName - the name of the tag.
viewName - the fully qualified class name for the View for the tag.
extraData - this can be any object (or null) and is passed into the constructor for viewClass if it has a constructor that takes both an element and an object.

setUnregisteredCustomTagView

public void setUnregisteredCustomTagView(Class<?> viewClass,
                                         Object extraData)
Sets the view to use for unregistered custom tags. A new instance of this class is used for every unregistered custom tag in the editor. The view should act as an empty tag as a separate view will be created for any start and end tags found. The original contents of the custom tag can be retrieved via the ELJBean.getCustomTagContent(String) method. The ID for the custom tag can be retrieved from the HTML.Attribute.ID attribute.

Parameters:
viewClass - the class to use for unregistered custom tag views. This class must have a constructor that takes either just a Element or an Element and an Object.
extraData - this can be any object (or null) and is passed into the constructor for viewClass if it has a constructor that takes both an element and an object.

getUnregisteredCustomTagView

public Class<?> getUnregisteredCustomTagView()
Returns the Unregistered Custom Tag View previously set by setUnregisteredCustomTagView(Class, Object)


getUnregisteredCustomTagExtraData

public Object getUnregisteredCustomTagExtraData()
Returns the Unregistered Custom Tag Extra Data previously set by setUnregisteredCustomTagView(Class, Object)


registerViewAnnotation

public void registerViewAnnotation(String tagName,
                                   Class<?> clazz,
                                   Object extraData)
Registers a class implementing ViewAnnotation to create additional rendering for a specified HTML tag.

Parameters:
tagName - HTML tag for which additional rendering will be generated
clazz - fully qualified class name for the ViewAnnotation

getViewAnnotationsForTag

public List<com.ephox.editlive.common.CustomTagData> getViewAnnotationsForTag(String tagName)
Retrieves the list of ViewAnnotation registered against the specified tag.

Returns:
List of ViewAnnotation

getCustomViews

public Map<HTML.Tag,com.ephox.editlive.common.CustomTagData> getCustomViews()
Returns the map of tag names to CustomTagData objects for all currently registered custom tags.

Returns:
a Map mapping tag names to CustomTagData objects.

getCustomTags

public Map<String,String> getCustomTags()
Returns the map of custom tag ids to custom tags.

Returns:
a map of custom tag ids to custom tags.

getCustomTagBehaviour

public CustomTagBehaviour getCustomTagBehaviour(String tagName)
Returns the behaviour object for a previously defined tag. This can be used to

Parameters:
tagName - A valid tag (either in HTML.Tag or a custom tag previously registered)
Returns:
Custom Tag Behaviour definition for the specified custom tag, or null if the tag is not valid

addCustomView

public void addCustomView(String tagName,
                          int type,
                          Class<?> viewClass,
                          Object extraData)
Registers a new custom tag with a specific view.

The type must be one of:

Parameters:
tagName - the name of the custom tag.
type - the type of the custom tag.
viewClass - the full class name of the view to use for this custom tag.
extraData - the extra data to provide to the views for this tag type.

clear

public void clear()
Clears all custom tags, custom views, and view annotations


Copyright (c) 2005-2012 Ephox Pty Ltd. All rights reserved.