org.xwiki.gwt.wysiwyg.client.plugin.style.exec
Class InlineStyleNameExecutable

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.user.client.ui.rta.cmd.internal.InlineStyleExecutable
              extended by org.xwiki.gwt.wysiwyg.client.plugin.style.exec.InlineStyleNameExecutable
All Implemented Interfaces:
Executable

public class InlineStyleNameExecutable
extends org.xwiki.gwt.user.client.ui.rta.cmd.internal.InlineStyleExecutable

Applies a given style name to each of the text nodes from the current text selection.

Version:
$Id: f35df9a9fa7ed4809c858f364c483dd6a5d9aa90 $

Field Summary
 
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
InlineStyleNameExecutable(RichTextArea rta)
          Creates a new instance.
 
Method Summary
protected  void addStyle(Element element, String parameter)
          
 boolean execute(String parameter)
          
protected  TextFragment execute(Text text, int startIndex, int endIndex, String parameter)
          
 String getParameter()
          
protected  Set<String> getStyleNames(com.google.gwt.dom.client.Node node)
           
protected  Set<String> getStyleNames(Range range)
           
protected  Set<String> getStyleNames(Selection selection)
           
 boolean isExecuted()
          
protected  boolean matchesStyleName(Text text, String parameter)
           
protected  TextFragment removeStyleName(Text text, int startIndex, int endIndex, String styleName)
          Removes the give style name from all the in-line element ancestors of the given text node, making sure no other nodes are affected by this change (by isolating the nodes while iterating the ancestors).
 
Methods inherited from class org.xwiki.gwt.user.client.ui.rta.cmd.internal.InlineStyleExecutable
execute, getNonEmptyTextNodes, getParameter, getParameter, getParameter, getProperty
 
Methods inherited from class org.xwiki.gwt.user.client.ui.rta.cmd.internal.AbstractSelectionExecutable
hasValidSelection, isEnabled
 
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
 

Constructor Detail

InlineStyleNameExecutable

public InlineStyleNameExecutable(RichTextArea rta)
Creates a new instance.

Parameters:
rta - the execution target
Method Detail

execute

public boolean execute(String parameter)

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

execute

protected TextFragment execute(Text text,
                               int startIndex,
                               int endIndex,
                               String parameter)

Overrides:
execute in class org.xwiki.gwt.user.client.ui.rta.cmd.internal.InlineStyleExecutable
See Also:
InlineStyleExecutable.execute(Text, int, int, String)

addStyle

protected void addStyle(Element element,
                        String parameter)

Overrides:
addStyle in class org.xwiki.gwt.user.client.ui.rta.cmd.internal.InlineStyleExecutable
See Also:
InlineStyleExecutable.addStyle(Element, String)

matchesStyleName

protected boolean matchesStyleName(Text text,
                                   String parameter)
Parameters:
text - a text node
parameter - a style name
Returns:
true if any of the in-line ancestors of the given text node has the specified style name, false otherwise

removeStyleName

protected TextFragment removeStyleName(Text text,
                                       int startIndex,
                                       int endIndex,
                                       String styleName)
Removes the give style name from all the in-line element ancestors of the given text node, making sure no other nodes are affected by this change (by isolating the nodes while iterating the ancestors).

Parameters:
text - the target text node
startIndex - the first character on which we remove the style name
endIndex - the last character on which we remove the style name
styleName - the style name to be removed
Returns:
the text fragment where the given style name doesn't apply anymore

getParameter

public String getParameter()

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

getStyleNames

protected Set<String> getStyleNames(Selection selection)
Parameters:
selection - a text selection
Returns:
the set of style names that affect all the text nodes touched by the given text selection

getStyleNames

protected Set<String> getStyleNames(Range range)
Parameters:
range - a text range
Returns:
the set of style names that affect all the text nodes touched by the given text range

getStyleNames

protected Set<String> getStyleNames(com.google.gwt.dom.client.Node node)
Parameters:
node - a DOM node
Returns:
the set of style names that affect the given DOM node

isExecuted

public boolean isExecuted()

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


Copyright © 2004–2015 XWiki. All rights reserved.