Skip to content

Commit

Permalink
fix: hierarchy pane not being scrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jydett committed Dec 1, 2023
1 parent 0c37490 commit cbb7f78
Showing 1 changed file with 5 additions and 35 deletions.
40 changes: 5 additions & 35 deletions recaf-ui/src/main/java/me/coley/recaf/ui/pane/HierarchyPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import me.coley.recaf.util.threading.FxThreadUtil;
import org.slf4j.Logger;

import java.util.Objects;


/**
* Visualization of the class hierarchy for children and parent relations.
Expand Down Expand Up @@ -116,7 +114,7 @@ private HierarchyTree() {
@Override
public void onUpdate(CommonClassInfo newValue) {
InheritanceGraph graph = RecafUI.getController().getServices().getInheritanceGraph();
HierarchyItem root = new HierarchyItem(newValue);
TreeItem<CommonClassInfo> root = new TreeItem<>(newValue);
String name = newValue.getName();
InheritanceVertex vertex = graph.getVertex(name);
if (vertex != null) {
Expand All @@ -131,23 +129,23 @@ public void onUpdate(CommonClassInfo newValue) {
FxThreadUtil.run(() -> setRoot(root));
}

private void createParents(HierarchyItem root, InheritanceVertex rootVertex) {
private void createParents(TreeItem<CommonClassInfo> root, InheritanceVertex rootVertex) {
root.setExpanded(true);
for (InheritanceVertex parentVertex : rootVertex.getParents()) {
if (parentVertex.getName().equals("java/lang/Object"))
continue;
HierarchyItem subItem = new HierarchyItem(parentVertex.getValue());
TreeItem<CommonClassInfo> subItem = new TreeItem<>(parentVertex.getValue());
if (noLoops(root, subItem)) {
root.getChildren().add(subItem);
createParents(subItem, parentVertex);
}
}
}

private void createChildren(HierarchyItem root, InheritanceVertex rootVertex) {
private void createChildren(TreeItem<CommonClassInfo> root, InheritanceVertex rootVertex) {
root.setExpanded(true);
for (InheritanceVertex childVertex : rootVertex.getChildren()) {
HierarchyItem subItem = new HierarchyItem(childVertex.getValue());
TreeItem<CommonClassInfo> subItem = new TreeItem<>(childVertex.getValue());
if (noLoops(root, subItem)) {
root.getChildren().add(subItem);
createChildren(subItem, childVertex);
Expand All @@ -166,34 +164,6 @@ private boolean noLoops(TreeItem<?> root, TreeItem<?> child) {
}
}

/**
* Item of a class in the hierarchy.
*/
static class HierarchyItem extends TreeItem<CommonClassInfo> {
private HierarchyItem(CommonClassInfo info) {
super(info);
}

@Override
public int hashCode() {
CommonClassInfo value = getValue();
if (value == null)
return -1;
int result = value.getName().hashCode();
result = 31 * result + (value.getSuperName().hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (obj instanceof HierarchyItem) {
HierarchyItem other = (HierarchyItem) obj;
return Objects.equals(getValue(), other.getValue());
}
return false;
}
}

/**
* Cell of a class in the hierarchy.
*/
Expand Down

0 comments on commit cbb7f78

Please sign in to comment.