public class AttributedResult extends Object
The usage is simple, instead of returning the output value, create a new AttributedResult
instance 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 and Description |
---|
AttributedResult(Object result) |
AttributedResult(Object result,
Map<String,Object> attrs) |
Modifier and Type | Method and Description |
---|---|
<T> T |
clearAttribute(String name) |
boolean |
containsAttribute(String name) |
<T> T |
getAttribute(String name) |
Map<String,Object> |
getAttributes() |
Object |
getResult() |
<T> T |
setAttribute(String name,
Object value) |
AttributedResult |
withBackgroundColor(String cssColor)
Sets the background color.
|
AttributedResult |
withManualOverrideAllowEmpty(Boolean allow)
In case the result element is overridable, this method defines if the selection box shows also the "empty value" option.
|
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.
|
AttributedResult |
withRawCSS(String css)
Adds any valid CSS style to the cell.
|
AttributedResult |
withSuffix(String suffix)
Sets a suffix to be appended to the result.
|
AttributedResult |
withTextColor(String cssColor)
Sets the text (foreground) color.
|
AttributedResult |
withTextDecoration(String textDecoration)
Sets the decoration to be added to the resulting text.
|
public AttributedResult(Object result)
public Object getResult()
public <T> T getAttribute(String name)
public <T> T clearAttribute(String name)
public boolean containsAttribute(String name)
public AttributedResult withRawCSS(String css)
css
- The full CSS style parameter in the form of "property:value;"public AttributedResult withSuffix(String suffix)
public AttributedResult withTextColor(String cssColor)
public AttributedResult withTextDecoration(String textDecoration)
Valid options are underline
, line-through
, and overline
.
public AttributedResult withBackgroundColor(String cssColor)
public AttributedResult withManualOverrideValueOptions(List<Object> options)
options
- The list of valid options in the UIpublic AttributedResult withManualOverrideAllowEmpty(Boolean allow)
Copyright © 2019. All rights reserved.