nameTreecell.appendChild(nameLabel);
treerow.appendChild(nameTreecell);
Treecell operationsTreecell = new Treecell();
Button createDerivedButton = new Button();
createDerivedButton.setTooltiptext(_("Create derived"));
createDerivedButton.setSclass("icono");
createDerivedButton.setImage("/common/img/ico_derived1.png");
createDerivedButton.setHoverImage("/common/img/ico_derived.png");
createDerivedButton.addEventListener(Events.ON_CLICK,
new EventListener() {
@Override
public void onEvent(Event event) {
goToCreateDerivedForm(scenario);
}
});
operationsTreecell.appendChild(createDerivedButton);
Button editButton = Util.createEditButton(new EventListener() {
@Override
public void onEvent(Event event) {
goToEditForm(scenario);
}
});
operationsTreecell.appendChild(editButton);
Button removeButton = Util.createRemoveButton(new EventListener() {
@Override
public void onEvent(Event event) {
confirmDelete(scenario);
}
});
boolean isMainScenario = PredefinedScenarios.MASTER.getScenario()
.getId().equals(scenario.getId());
List<Scenario> derivedScenarios = scenarioModel
.getDerivedScenarios(scenario);
if (isCurrentScenario || isMainScenario
|| !derivedScenarios.isEmpty()) {
removeButton.setDisabled(true);
}
operationsTreecell.appendChild(removeButton);
Button connectButton = new Button(_("Connect"));
connectButton.addEventListener(Events.ON_CLICK,
new EventListener() {
@Override
public void onEvent(Event event) {
connectTo(scenario);
}
private void connectTo(Scenario scenario) {
templateModel.setScenario(SecurityUtils
.getSessionUserLoginName(),
scenario,
new IOnFinished() {
@Override
public void onWithoutErrorFinish() {
Executions
.sendRedirect("/scenarios/scenarios.zul");
}
@Override
public void errorHappened(
Exception exceptionHappened) {
errorHappenedDoingReassignation(exceptionHappened);
}
});
}
});
if (isCurrentScenario) {
connectButton.setDisabled(true);
}
operationsTreecell.appendChild(connectButton);
treerow.appendChild(operationsTreecell);