it.amattioli.guidate.editing.EditorGridComposer Maven / Gradle / Ivy
package it.amattioli.guidate.editing;
import it.amattioli.applicate.commands.ListEditor;
import it.amattioli.guidate.collections.PrototypeRowRenderer;
import it.amattioli.guidate.containers.BackBeans;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.SelectEvent;
import org.zkoss.zk.ui.util.GenericComposer;
import org.zkoss.zul.Grid;
import org.zkoss.zul.Rows;
public class EditorGridComposer extends GenericComposer {
private ListEditor> editor;
public void onCreate(Event evt) {
Grid grid = (Grid)evt.getTarget();
this.editor = (ListEditor>)BackBeans.findBackBean(grid);
grid.setRowRenderer(new PrototypeRowRenderer(grid));
grid.setModel(new ListEditorModel(editor));
}
public void onSelect(SelectEvent evt) {
Rows rows = ((Grid)evt.getTarget()).getRows();
for (Object curr:evt.getSelectedItems()) {
int idx = rows.getChildren().lastIndexOf(curr);
editor.select(idx);
}
}
}