Package com.vaadin.browserless.internal
Class PrettyPrintTree
java.lang.Object
com.vaadin.browserless.internal.PrettyPrintTree
Utility class to create a pretty-printed ASCII tree of arbitrary nodes that
can be printed to the console. You can build the tree out of any tree
structure, just fill in this node
name and its
children.
To create a pretty tree dump of a Vaadin component, just use
ofVaadin(Component).
For internal use only. May be renamed or removed in a future release.
-
Constructor Summary
ConstructorsConstructorDescriptionPrettyPrintTree(String name, List<PrettyPrintTree> children) Creates a tree node. -
Method Summary
Modifier and TypeMethodDescriptionReturns the node children.Never dump these attributes intoPrettyString(Component).getName()Returns the node name.static booleanstatic BiConsumer<Component, LinkedList<String>> Invoked bytoPrettyString(Component)to add additional properties for your custom component.static PrettyPrintTreeCreates a tree out of the given Vaadin component and all of its descendants, as provided byTestingLifecycleHook.getAllChildren(Component).print()Prints this tree.static voidsetDontDumpAttributes(Set<String> dontDumpAttributes) Sets the attributes never dumped bytoPrettyString(Component), seegetDontDumpAttributes().static voidsetPrettyPrintUseAscii(boolean prettyPrintUseAscii) Sets whetherPrettyPrintTreeuses ASCII characters only.static voidsetPrettyStringHook(BiConsumer<Component, LinkedList<String>> prettyStringHook) Sets the hook invoked bytoPrettyString(Component), seegetPrettyStringHook().static StringtoPrettyString(Component component) Returns the most basic properties of the component, formatted as a concise string: The component class TheComponent.getId()Whether the component isComponent.isVisible()Whether it is aHasValuethat is read-only the styles The label and text TheHasValue.getValue()static StringtoPrettyTree(Component component) Returns a pretty-printed tree of the given component and its descendants.
-
Constructor Details
-
PrettyPrintTree
Creates a tree node.- Parameters:
name- the node name.children- the node children, mutable.
-
-
Method Details
-
getName
Returns the node name.- Returns:
- the node name.
-
getChildren
Returns the node children.- Returns:
- the mutable list of children.
-
print
Prints this tree.- Returns:
- the pretty-printed tree.
-
ofVaadin
Creates a tree out of the given Vaadin component and all of its descendants, as provided byTestingLifecycleHook.getAllChildren(Component).- Parameters:
root- the root component.- Returns:
- the tree.
-
getPrettyPrintUseAscii
public static boolean getPrettyPrintUseAscii()- Returns:
- whether ASCII characters are used.
-
setPrettyPrintUseAscii
public static void setPrettyPrintUseAscii(boolean prettyPrintUseAscii) Sets whetherPrettyPrintTreeuses ASCII characters only.- Parameters:
prettyPrintUseAscii- true to use ASCII characters only.
-
toPrettyTree
Returns a pretty-printed tree of the given component and its descendants.- Parameters:
component- the root component.- Returns:
- the pretty-printed tree.
-
toPrettyString
Returns the most basic properties of the component, formatted as a concise string:- The component class
- The
Component.getId() - Whether the component is
Component.isVisible() - Whether it is a
HasValuethat is read-only - the styles
- The label and text
- The
HasValue.getValue()
- Parameters:
component- the component.- Returns:
- the component properties as a concise string.
-
getPrettyStringHook
Invoked bytoPrettyString(Component)to add additional properties for your custom component. Add additional properties to thelistprovided, e.g.list.add("icon='" + icon + "'").By default does nothing.
- Returns:
- the hook.
-
setPrettyStringHook
Sets the hook invoked bytoPrettyString(Component), seegetPrettyStringHook().- Parameters:
prettyStringHook- the hook, not null.
-
getDontDumpAttributes
Never dump these attributes intoPrettyString(Component). By default these attributes are ignored:disabled- dumped separately as "DISABLED" string.id- dumped as Component.idhref- dumped separately for any component that has anhrefmember.
- Returns:
- the mutable set of attribute names.
-
setDontDumpAttributes
Sets the attributes never dumped bytoPrettyString(Component), seegetDontDumpAttributes().- Parameters:
dontDumpAttributes- the set of attribute names, not null.
-