com.github.fge.grappa.debugger.javafx.parsetree.ParseTreeItem Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grappa-debugger Show documentation
Show all versions of grappa-debugger Show documentation
GUI application to debug grappa parsers
The newest version!
package com.github.fge.grappa.debugger.javafx.parsetree;
import com.github.fge.grappa.debugger.csvtrace.tabs.tree.TreeTabDisplay;
import com.github.fge.grappa.debugger.model.ParseTreeNode;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.TreeItem;
public final class ParseTreeItem
extends TreeItem
{
private final BooleanProperty loadingProperty
= new SimpleBooleanProperty(false);
private final boolean leaf;
public ParseTreeItem(final TreeTabDisplay display,
final ParseTreeNode value)
{
super(value);
leaf = !value.hasChildren();
expandedProperty().addListener(new ChangeListener()
{
@Override
public void changed(
final ObservableValue extends Boolean> observable,
final Boolean oldValue, final Boolean newValue)
{
if (!newValue) {
getChildren().clear();
return;
}
display.needChildrenEvent(ParseTreeItem.this);
}
});
}
public BooleanProperty loadingProperty()
{
return loadingProperty;
}
@Override
public boolean isLeaf()
{
return leaf;
}
}