*/
@Override
public void render(Treeitem ti, Object node) {
final MaterialCategory materialCategory = (MaterialCategory) node;
final Textbox tb = new Textbox(materialCategory.getName());
tb.setWidth("90%");
tb.addEventListener("onChange", new EventListener() {
@Override
public void onEvent(Event event) {
final InputEvent ie = (InputEvent) event;
materialCategory.setName(ie.getValue());
}
});
tb.addEventListener("onFocus", new EventListener() {
@Override
public void onEvent(Event event) {
((Treeitem)tb.getParent().getParent().getParent()).setSelected(true);
refreshMaterials();
}
});
Treecell tc = new Treecell();
Treerow tr = null;
ti.setValue(node);
if (ti.getTreerow() == null) {
tr = new Treerow();
tr.setParent(ti);
ti.setOpen(true); // Expand node
} else {
tr = ti.getTreerow();
tr.getChildren().clear();
}
tb.setParent(tc);
tc.setParent(tr);
final Textbox codeTb = new Textbox(materialCategory.getCode());
codeTb.setWidth("95%");
codeTb.setDisabled(materialCategory.isCodeAutogenerated());
codeTb.addEventListener("onChange", new EventListener() {
@Override
public void onEvent(Event event) {
final InputEvent ie = (InputEvent) event;
materialCategory.setCode(ie.getValue());
}
});
codeTb.addEventListener("onFocus", new EventListener() {
@Override
public void onEvent(Event event) {
((Treeitem)codeTb.getParent().getParent().getParent()).setSelected(true);
refreshMaterials();
}
});
Treecell codeTc = new Treecell();
codeTb.setParent(codeTc);
codeTc.setParent(tr);
final Checkbox cb = new Checkbox();
cb.setChecked(materialCategory.isCodeAutogenerated());
cb.addEventListener("onCheck", new EventListener() {
@Override
public void onEvent(Event event) {
final CheckEvent ce = (CheckEvent) event;
materialCategory.setCodeAutogenerated(ce.isChecked());
if (ce.isChecked()) {
try {
materialsModel.setCodeAutogenerated(ce.isChecked(),
materialCategory);
} catch (ConcurrentModificationException err) {
messagesForUser.showMessage(Level.ERROR, err
.getMessage());
}
}
codeTb.setValue(materialCategory.getCode());
codeTb.setDisabled(ce.isChecked());
Util.reloadBindings(codeTb);
Util.reloadBindings(gridMaterials);
}
});
Treecell generateCodeTc = new Treecell();