All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.amattioli.guidate.editing.EditorGridComposer Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
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);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy