Skip to content

Instantly share code, notes, and snippets.

@dariusf
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dariusf/80c3657fcdfa1c0bc3a2 to your computer and use it in GitHub Desktop.
Save dariusf/80c3657fcdfa1c0bc3a2 to your computer and use it in GitHub Desktop.
package ui;
import javafx.scene.Node;
import javafx.scene.control.ListView;
import ui.components.FilterTextField;
import ui.issuecolumn.ColumnControl;
import ui.issuepanel.IssuePanel;
import ui.issuepanel.IssuePanelCard;
public class UITraversal {
private final ColumnControl columns;
public UITraversal(ColumnControl columns) {
this.columns = columns;
}
public ColumnControl panels() {
return columns;
}
/**
* A bit of reflection to factor out the pattern of checking that a Node is
* of a specific type, then casting to that type.
*/
private static <T> T check(Node node, Class<T> type) {
assert type.isInstance(node) : String.format("%s is not of type %s!" +
"The traversal library is probably out of date!",
node, type.getSimpleName());
return type.cast(node);
}
public IssuePanel panel(int index) {
return check(columns.getChildren().get(index), IssuePanel.class);
}
public FilterTextField filterField(int panelIndex) {
// TODO doesn't actually work (there's a HBox in the way), but this is the idea
return check(panel(panelIndex).getChildren().get(0), FilterTextField.class);
}
public IssuePanelCard issueCard(int panelIndex, int issueId) {
ListView<?> listView = check(panel(panelIndex).getChildren().get(1), ListView.class);
// TODO go into the listview to find cells, cards, etc.
assert false : "not yet implemented";
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment