if (snapshotOfOpenedNodes != null) {
snapshotOfOpenedNodes.openIfRequired(item);
}
Treecell cellForName = new Treecell();
Textbox textboxName= new Textbox();
textboxName.setWidth("400px");
cellForName.appendChild(Util.bind(textboxName,
new Util.Getter<String>() {
@Override
public String get() {
return criterionForThisRow.getName();
}
}, new Util.Setter<String>() {
@Override
public void set(String value) {
criterionForThisRow.setName(value);
}
}));
String message = _("cannot be empty");
textboxName
.setConstraint("no empty:"+message);
Treecell cellForActive = new Treecell();
cellForActive.setStyle("center");
Checkbox checkboxActive = new Checkbox();
cellForActive.appendChild(Util.bind(checkboxActive,
new Util.Getter<Boolean>() {
@Override
public Boolean get() {
return criterionForThisRow.isActive();
}
}, new Util.Setter<Boolean>() {
@Override
public void set(Boolean value) {
criterionForThisRow.setActive(value);
}
}));
checkboxActive.addEventListener(Events.ON_CHECK,new EventListener() {
@Override
public void onEvent(Event event) {
getModel().updateEnabledCriterions(criterionForThisRow.isActive(),criterionForThisRow);
reloadTree();
}
});
Treerow tr = null;
/*
* Since only one treerow is allowed, if treerow is not null, append
* treecells to it. If treerow is null, contruct a new treerow and
* attach it to item.
*/
if (item.getTreerow() == null) {
tr = new Treerow();
tr.setParent(item);
} else {
tr = item.getTreerow();
tr.getChildren().clear();
}
// Attach treecells to treerow
tr.setDraggable("true");
tr.setDroppable("true");
// Treecell with the cost category of the Criterion
Treecell cellForCostCategory = new Treecell();
criterionForThisRow.getCriterion().getCostCategory();
cellForCostCategory.appendChild(appendAutocompleteType(item));
// Treecell with the code of the Criterion
Treecell cellForCode = new Treecell();
cellForCode.setStyle("center");
Textbox codeLabel = new Textbox();
codeLabel.setDisabled(codeEditionDisabled);
cellForCode.appendChild(Util.bind(codeLabel,
new Util.Getter<String>() {
@Override
public String get() {
return criterionForThisRow.getCriterion().getCode();
}
}, new Util.Setter<String>() {
@Override
public void set(String value) {
criterionForThisRow.getCriterion().setCode(value);
}
}));
cellForName.setParent(tr);
cellForCostCategory.setParent(tr);
cellForCode.setParent(tr);
cellForActive.setParent(tr);
Treecell tcOperations = new Treecell();
Button upbutton = new Button("", "/common/img/ico_bajar1.png");
upbutton.setHoverImage("/common/img/ico_bajar.png");
upbutton.setParent(tcOperations);
upbutton.setSclass("icono");
upbutton.addEventListener(Events.ON_CLICK, new EventListener() {
@Override
public void onEvent(Event event) {
getModel().down(criterionForThisRow);
reloadTree();
}
});
Button downbutton = new Button("", "/common/img/ico_subir1.png");
downbutton.setHoverImage("/common/img/ico_subir.png");
downbutton.setParent(tcOperations);
downbutton.setSclass("icono");
downbutton.addEventListener(Events.ON_CLICK, new EventListener() {
@Override
public void onEvent(Event event) {
getModel().up(criterionForThisRow);
reloadTree();
}
});
Button indentbutton = createButtonIndent();
indentbutton.setParent(tcOperations);
if(getModel().getCriterionType().allowHierarchy()){
indentbutton.addEventListener(Events.ON_CLICK, new EventListener() {
@Override
public void onEvent(Event event) {
getModel().indent(criterionForThisRow);
reloadTree();
}
});
}
Button unindentbutton = createButtonUnindent();
unindentbutton.setParent(tcOperations);
if(getModel().getCriterionType().allowHierarchy()){
unindentbutton.addEventListener(Events.ON_CLICK,
new EventListener() {
@Override
public void onEvent(Event event) {
getModel().unindent(criterionForThisRow);
reloadTree();
}
});
}
Button removebutton = createButtonRemove(criterionForThisRow);
removebutton.setParent(tcOperations);
if (criterionsModel.isDeletable(criterionForThisRow.getCriterion())) {
removebutton.addEventListener(Events.ON_CLICK, new EventListener() {
@Override
public void onEvent(Event event) {
getModel().removeNode(criterionForThisRow);
if (!criterionForThisRow.isNewObject()) {
criterionsModel
.addForRemoval(criterionForThisRow
.getCriterion());
}
reloadTree();
}
});
}
tcOperations.setParent(tr);
tr.addEventListener("onDrop", new EventListener() {
@Override
public void onEvent(org.zkoss.zk.ui.event.Event arg0)
{