Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hierarchy pane not being scrollable #747

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading