org.xwiki.gwt.wysiwyg.client.plugin.indent.exec
Class AbstractListExecutable

java.lang.Object
  extended by org.xwiki.gwt.user.client.ui.rta.cmd.internal.AbstractRichTextAreaExecutable
      extended by org.xwiki.gwt.user.client.ui.rta.cmd.internal.AbstractSelectionExecutable
          extended by org.xwiki.gwt.wysiwyg.client.plugin.indent.exec.AbstractListExecutable
All Implemented Interfaces:
Executable
Direct Known Subclasses:
IndentExecutable, OutdentExecutable

public abstract class AbstractListExecutable
extends org.xwiki.gwt.user.client.ui.rta.cmd.internal.AbstractSelectionExecutable

Superclass for all the list executables, such as indent and outdent executables, to handle frequent list operations.

Version:
$Id: 0c2e7d219e707fd6a2d7e883e75c1300b21c9f63 $

Field Summary
protected static String LIST_ITEM_TAG
          List item element name.
protected static String ORDERED_LIST_TAG
          Ordered list element name.
protected static String UNORDERED_LIST_TAG
          Unordered list element name.
 
Fields inherited from class org.xwiki.gwt.user.client.ui.rta.cmd.internal.AbstractSelectionExecutable
cache, domUtils
 
Fields inherited from class org.xwiki.gwt.user.client.ui.rta.cmd.internal.AbstractRichTextAreaExecutable
rta
 
Constructor Summary
AbstractListExecutable(RichTextArea rta)
          Creates a new executable to be executed on the specified rich text area.
 
Method Summary
protected  boolean canExecute(Element listItem)
          Checks if this command can be executed on a single list item.
protected abstract  void execute(Element listItem)
          Actually executes the operation on a single list item.
 boolean execute(String param)
          
protected abstract  boolean executeOnMultipleItems(Range range, boolean perform)
          Executes this list operation on all items in the non-collapsed selection.
protected  Element getListItem(Range range)
           
 boolean isEnabled()
          
protected  boolean isList(com.google.gwt.dom.client.Node node)
          Checks if the passed node is a list node: either an ordered list or an unordered one.
 
Methods inherited from class org.xwiki.gwt.user.client.ui.rta.cmd.internal.AbstractSelectionExecutable
getParameter, hasValidSelection, isExecuted
 
Methods inherited from class org.xwiki.gwt.user.client.ui.rta.cmd.internal.AbstractRichTextAreaExecutable
isSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIST_ITEM_TAG

protected static final String LIST_ITEM_TAG
List item element name.

See Also:
Constant Field Values

UNORDERED_LIST_TAG

protected static final String UNORDERED_LIST_TAG
Unordered list element name.

See Also:
Constant Field Values

ORDERED_LIST_TAG

protected static final String ORDERED_LIST_TAG
Ordered list element name.

See Also:
Constant Field Values
Constructor Detail

AbstractListExecutable

public AbstractListExecutable(RichTextArea rta)
Creates a new executable to be executed on the specified rich text area.

Parameters:
rta - the execution target
Method Detail

getListItem

protected Element getListItem(Range range)
Parameters:
range - a DOM range
Returns:
the list item in which the given range is positioned, or null if no such thing exists

isList

protected boolean isList(com.google.gwt.dom.client.Node node)
Checks if the passed node is a list node: either an ordered list or an unordered one. If the passed node is null, false is returned.

Parameters:
node - the node to check if it's a list or not
Returns:
true if the passed node is a list node, false otherwise (including the case when the node is null).

execute

public boolean execute(String param)


execute

protected abstract void execute(Element listItem)
Actually executes the operation on a single list item. This should be called only after canExecute(Element) on the same list item returns true.

Parameters:
listItem - the list item to execute the operation on

canExecute

protected boolean canExecute(Element listItem)
Checks if this command can be executed on a single list item.

Parameters:
listItem - the list item to check if the command can be executed on
Returns:
true if the command can be executed, false otherwise

executeOnMultipleItems

protected abstract boolean executeOnMultipleItems(Range range,
                                                  boolean perform)
Executes this list operation on all items in the non-collapsed selection. The perform parameter specifies if the operation is actually performed or just checked to be possible (while this kind of parameters are not good practice, it's the best way right now to make sure we use the same detection algorithm in the #execute(RichTextArea, String) and #isEnabled(RichTextArea) functions).

Parameters:
range - the current range to execute the operation on
perform - true if the operation is to be actually executed, false if it's only to be checked
Returns:
true if at least one of the items in the selection was affected, false otherwise.

isEnabled

public boolean isEnabled()

Specified by:
isEnabled in interface Executable
Overrides:
isEnabled in class org.xwiki.gwt.user.client.ui.rta.cmd.internal.AbstractSelectionExecutable
See Also:
isEnabled()


Copyright © 2004–2014 XWiki. All rights reserved.