Skip to content

Commit

Permalink
#5401 fix TreeView
Browse files Browse the repository at this point in the history
  • Loading branch information
pnatashap committed May 3, 2024
1 parent c418ebc commit b32c0b9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ public class TreeView extends UIBaseElement<TreeViewAssert> implements
ISetup, IsLoading, ISelector, IsDense {

protected static final String HOVERABLE_CORE_CLASS = "v-treeview--hoverable";
protected static String nodesInCoreLocator = "./*[contains(@class, 'v-treeview-node')]";
protected static String nodesAllLocator = ".v-treeview-node";
protected static String checkboxFullyMarkedClass = "mdi-checkbox-marked";
protected static String checkboxNotMarkedClass = "mdi-checkbox-blank-outline";

protected static String nodesInNodeLocator =
protected String nodesInCoreLocator = "./*[contains(@class, 'v-treeview-node')]";
protected String nodesAllLocator = ".v-treeview-node";
protected String checkboxFullyMarkedClass = "mdi-checkbox-marked";
protected String checkboxNotMarkedClass = "mdi-checkbox-blank-outline";
protected String nodesInNodeLocator =
"./*[contains(@class, 'v-treeview-node__children')]/*[contains(@class, 'v-treeview-node')]";
protected static String rootInNodeLocator = "./*[contains(@class, 'v-treeview-node__root')]";
protected int startIndex = ELEMENT.startIndex;
Expand All @@ -48,8 +47,6 @@ public void setup(Field field) {
thisParent = true;
}

// @todo #5322 New locator affects all classes, as they change static values
// Should be fixed to use instance variables
private void initializeLocators(JDITreeView annotation) {
if (!annotation.core().isEmpty()) {
setCore(TreeView.class, $(annotation.core()));
Expand Down Expand Up @@ -97,8 +94,10 @@ public TreeViewNode node(int index) {
@JDIAction("Get '{name}' list of nodes")
public List<TreeViewNode> treeViewNodes() {
return childNodes().stream()
.map(webElement -> new TreeViewNode().setCore(TreeViewNode.class, webElement))
.collect(Collectors.toList());
.map(webElement ->
new TreeViewNode(checkboxFullyMarkedClass, checkboxNotMarkedClass, nodesInNodeLocator)
.setCore(TreeViewNode.class, webElement)
).collect(Collectors.toList());
}

@JDIAction("Get if '{name}' is hoverable")
Expand All @@ -111,11 +110,12 @@ public int size() {
return childNodes().size();
}

@JDIAction("Get '{name}' size")
@JDIAction("Get '{name}' count of all nodes (children, grandchildrens, ...)")
public int fullSize() {
return allNodes().size();
}

// @todo #5401 Check that implementation is optimal
@JDIAction("Expand all nodes in '{name}'")
public void expandAllNodes() {
treeViewNodes().forEach(TreeViewNode::expand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,36 @@ public class TreeViewNode extends UIBaseElement<TreeViewNodeAssert> implements
protected static final String DISABLED_NODE_CLASS = "v-treeview-node--disabled";
protected static final String ACTIVE_ROOT_CLASS = "v-treeview-node--active";

protected static String toggleLocator = ".v-treeview-node__toggle";
protected static String checkboxLocator = ".v-treeview-node__checkbox";
protected static String contentLocator = ".v-treeview-node__content";
protected String toggleLocator = ".v-treeview-node__toggle";
protected String checkboxLocator = ".v-treeview-node__checkbox";
protected String contentLocator = ".v-treeview-node__content";

// can be changed in Ctor
protected String checkboxFullyMarkedClass = "mdi-checkbox-marked";
protected String checkboxNotMarkedClass = "mdi-checkbox-blank-outline";
protected String nodesInNodeLocator =
"./*[contains(@class, 'v-treeview-node__children')]/*[contains(@class, 'v-treeview-node')]";


protected final String delimiter = "/";
protected int startIndex = ELEMENT.startIndex;

public TreeViewNode() {
super();
}

public TreeViewNode(String full, String empty, String nodesInNode) {
super();
if (full != null && !full.isEmpty()) {
this.checkboxFullyMarkedClass = full;
}
if (empty != null && !empty.isEmpty()) {
this.checkboxNotMarkedClass = empty;
}
if (nodesInNode != null && !nodesInNode.isEmpty()) {
this.nodesInNodeLocator = nodesInNode;
}
}


@JDIAction("Get if '{name}' is a leaf")
public boolean isLeaf() {
Expand All @@ -60,12 +83,12 @@ public boolean isActive() {

@JDIAction("Get if '{name}' is fully marked")
public boolean isFullyMarked() {
return checkbox().hasClass(TreeView.checkboxFullyMarkedClass);
return checkbox().hasClass(this.checkboxFullyMarkedClass);
}

@JDIAction("Get if '{name}' is not marked")
public boolean isNotMarked() {
return checkbox().hasClass(TreeView.checkboxNotMarkedClass);
return checkbox().hasClass(this.checkboxNotMarkedClass);
}

@Override
Expand Down Expand Up @@ -144,7 +167,7 @@ public WebList list() {
return checkList();
}
expand();
return core().finds(TreeView.nodesInNodeLocator);
return core().finds(this.nodesInNodeLocator);
}

@JDIAction("Get '{name}' list of nodes")
Expand Down

0 comments on commit b32c0b9

Please sign in to comment.