Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
Add title prefix to tree nodes with field name
Browse files Browse the repository at this point in the history
  • Loading branch information
Rauks committed Nov 20, 2013
1 parent 3c4e17e commit f268f9d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,38 @@ public TreeChartTask(ObservableClass rootClasse){
}

/**
* Build a node with informations of a {@link ObservableClass}.
* Build a node with informations of a {@link ObservableClass} with a custom title prefix.
*
* @param classe The classe used to build the node.
* @param titlePrefix The title prefix.
* @return A Node with class informations.
*/
private Node loadTreeNode(ObservableClass classe){
private Node loadTreeNode(ObservableClass classe, String titlePrefix){
Node element = null;
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("TreeNode.fxml"));
element = (Node) fxmlLoader.load();
TreeNodeController elementController = fxmlLoader.<TreeNodeController>getController();
elementController.setObservation(classe);
if(titlePrefix != null){
elementController.setTitlePrefix(titlePrefix);
}
} catch (IOException ex) {
Logger.getLogger(BigBrotherGuiController.class.getName()).log(Level.SEVERE, null, ex);
}
return element;
}

/**
* Build a node with informations of a {@link ObservableClass}.
*
* @param classe The classe used to build the node.
* @return A Node with class informations.
*/
private Node loadTreeNode(ObservableClass classe){
return loadTreeNode(classe, null);
}

/**
* Build a ellipsis node.
*
Expand Down Expand Up @@ -131,7 +145,7 @@ private void loadTreeNodeChildren(ObservableClass classe, TreePane treePane, Nod
}
else{
ObservableClass fieldType = field.getType();
final Node node = this.loadTreeNode(fieldType);
final Node node = this.loadTreeNode(fieldType, field.getName().concat(" : "));
treePane.addChild(node, position);
this.loadTreeNodeChildren(fieldType, treePane, position, maxChildren, maxLevel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class TreeNodeController implements Initializable {
private ObservableList<ObservableField> observablesFields;
private ObservableList<ObservableMethod> observablesMethods;
private SimpleStringProperty title;
private SimpleStringProperty titlePre;

/**
* Initializes the controller class.
Expand Down Expand Up @@ -123,8 +124,9 @@ public void updateItem(ObservableField item, boolean empty){
}
});

this.title = new SimpleStringProperty("Element");
this.titlePane.textProperty().bind(this.title);
this.title = new SimpleStringProperty("");
this.titlePre = new SimpleStringProperty("");
this.titlePane.textProperty().bind(this.titlePre.concat(this.title));
}

/**
Expand All @@ -150,4 +152,8 @@ public void setObservation(ObservableClass classe){
this.fieldsList.setDisable(true);
}
}

public void setTitlePrefix(String prefix){
this.titlePre.set(prefix);
}
}

0 comments on commit f268f9d

Please sign in to comment.