use of org.drools.workbench.models.guided.dtree.shared.model.nodes.BoundNode in project drools-wb by kiegroup.
the class EditActionRetractPopup method initialiseBoundTypes.
private void initialiseBoundTypes() {
// Extract all bindings available on the path to the root
final Map<String, TypeNode> bindings = new TreeMap<String, TypeNode>();
Node parent = clone.getParent();
while (parent != null) {
if (parent instanceof TypeNode) {
final TypeNode tn = (TypeNode) parent;
if (tn.isBound()) {
bindings.put(tn.getBinding(), tn);
}
}
parent = parent.getParent();
}
bindingListBox.setEnabled(!bindings.isEmpty());
if (bindings.isEmpty()) {
bindingListBox.addItem(GuidedDecisionTreeConstants.INSTANCE.noBindings());
return;
}
// Add them to the ListBox
int selectedIndex = 0;
final BoundNode boundNode = clone.getBoundNode();
for (String binding : bindings.keySet()) {
bindingListBox.addItem(binding);
if (boundNode != null) {
if (binding.equals(boundNode.getBinding())) {
selectedIndex = bindingListBox.getItemCount() - 1;
}
}
}
// Attach event handler before we set the selected index in case we're selecting the first item
bindingListBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(final ChangeEvent event) {
final String binding = bindingListBox.getItemText(bindingListBox.getSelectedIndex());
clone.setBoundNode(bindings.get(binding));
}
});
bindingListBox.setSelectedIndex(selectedIndex);
}
use of org.drools.workbench.models.guided.dtree.shared.model.nodes.BoundNode in project drools-wb by kiegroup.
the class EditActionUpdatePopup method initialiseBoundTypes.
private void initialiseBoundTypes() {
// Extract all bindings available on the path to the root
final Map<String, TypeNode> bindings = new TreeMap<String, TypeNode>();
Node parent = clone.getParent();
while (parent != null) {
if (parent instanceof TypeNode) {
final TypeNode tn = (TypeNode) parent;
if (tn.isBound()) {
bindings.put(tn.getBinding(), tn);
}
}
parent = parent.getParent();
}
bindingListBox.setEnabled(!bindings.isEmpty());
if (bindings.isEmpty()) {
bindingListBox.addItem(GuidedDecisionTreeConstants.INSTANCE.noBindings());
return;
}
// Add them to the ListBox
int selectedIndex = 0;
final BoundNode boundNode = clone.getBoundNode();
for (String binding : bindings.keySet()) {
bindingListBox.addItem(binding);
if (boundNode != null) {
if (binding.equals(boundNode.getBinding())) {
selectedIndex = bindingListBox.getItemCount() - 1;
}
}
}
// Attach event handler before we set the selected index in case we're selecting the first item
bindingListBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(final ChangeEvent event) {
final String binding = bindingListBox.getItemText(bindingListBox.getSelectedIndex());
clone.setBoundNode(bindings.get(binding));
clone.getFieldValues().clear();
initialiseFieldValues();
}
});
bindingListBox.setSelectedIndex(selectedIndex);
}
Aggregations