Class AttributedResult
- Object
-
- AttributedResult
-
public class AttributedResult extends Object
Provides means for output elements' formatting.The usage is simple, instead of returning the output value, create a new
AttributedResultinstance like this:api.attributedResult(plain value), customize it by calling its various methods, and return it finally.Example:
def cost = api.getElement("MarginPct") def myOptions = ["A" , "B" , "C" ] return api.attributedResult(cost) .withBackgroundColor(cost < 0.30 ? "red" : "#0101DF") .withSuffix(cost < 0.30 ? "!!!" : null) .withTextColor(cost < 0.30 ? "white" : null) .withTextDecoration(cost < 0.30 ? "underline" : null) .withManualOverrideValueOptions(myOptions)
-
-
Constructor Summary
Constructors Constructor Description AttributedResult(Object result)AttributedResult(Object result, Map<String,Object> attrs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TclearAttribute(String name)booleancontainsAttribute(String name)<T> TgetAttribute(String name)Map<String,Object>getAttributes()ObjectgetResult()<T> TsetAttribute(String name, Object value)AttributedResultwithBackgroundColor(String cssColor)Sets the background color.AttributedResultwithManualOverrideAllowEmpty(Boolean allow)In case the result element is overridable, this method defines if the selection box shows also the "empty value" option.AttributedResultwithManualOverrideValueOptions(List<Object> options)In case the result element is overridable, this method defines a set (list) of values tha the user can pick from (vs.AttributedResultwithRawCSS(String css)Adds any valid CSS style to the cell.AttributedResultwithSuffix(String suffix)Sets a suffix to be appended to the result.AttributedResultwithTextColor(String cssColor)Sets the text (foreground) color.AttributedResultwithTextDecoration(String textDecoration)Sets the decoration to be added to the resulting text.
-
-
-
Method Detail
-
getResult
public Object getResult()
-
getAttribute
public <T> T getAttribute(String name)
-
clearAttribute
public <T> T clearAttribute(String name)
-
containsAttribute
public boolean containsAttribute(String name)
-
withRawCSS
public AttributedResult withRawCSS(String css)
Adds any valid CSS style to the cell. Note: There is no check if the CSS is actually valid, the values are just passed through as-is- Parameters:
css- The full CSS style parameter in the form of "property:value;"- See Also:
- CSS Reference
-
withSuffix
public AttributedResult withSuffix(String suffix)
Sets a suffix to be appended to the result.
-
withTextColor
public AttributedResult withTextColor(String cssColor)
Sets the text (foreground) color.- See Also:
- CSS Legal Color Values
-
withTextDecoration
public AttributedResult withTextDecoration(String textDecoration)
Sets the decoration to be added to the resulting text.Valid options are
underline,line-through, andoverline.- See Also:
- CSS text-decoration Property
-
withBackgroundColor
public AttributedResult withBackgroundColor(String cssColor)
Sets the background color.- See Also:
- CSS Legal Color Values
-
withManualOverrideValueOptions
public AttributedResult withManualOverrideValueOptions(List<Object> options)
In case the result element is overridable, this method defines a set (list) of values tha the user can pick from (vs. default free-style data entry) IMPORTANT NOTE: This is meant to list a few options only. Not a large list of choices! There is not a hard limitation here, but if this is used widely in a particular configuration and the list of options is long the browser may not be able to render it anymore and/or the data transfer speeds may suffer.- Parameters:
options- The list of valid options in the UI- Returns:
-
withManualOverrideAllowEmpty
public AttributedResult withManualOverrideAllowEmpty(Boolean allow)
In case the result element is overridable, this method defines if the selection box shows also the "empty value" option. Default is true- Returns:
-
-