package org.vaadin.grid.cellrenderers;

import com.vaadin.data.Item;
import com.vaadin.event.ConnectorEventListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.Grid;
import com.vaadin.ui.renderers.ClickableRenderer;
import com.vaadin.util.ReflectTools;

import java.lang.reflect.Method;

/**
 * @author Mikael Grankvist - Vaadin
 */
public class EditableRenderer<T> extends ClickableRenderer<T> {

    protected EditableRenderer(Class<T> presentationType) {
        super(presentationType);
    }


    public interface ItemEditListener extends ConnectorEventListener {

        Method ITEM_EDIT_METHOD = ReflectTools.findMethod(
                ItemEditListener.class, "itemEdited", ItemEditEvent.class);

        void itemEdited(ItemEditEvent event);
    }

    public static class ItemEditEvent<T> extends Component.Event {

        private final Object itemId;
        private final Item item;
        private final Object columnPropertyId;
        private final T newValue;

        public ItemEditEvent(Grid grid, Object itemId, Item item, Object columnPropertyId, T newValue) {
            super(grid);
        this.itemId = itemId;
            this.item = item;
            this.columnPropertyId = columnPropertyId;
            this.newValue = newValue;
        }

        public Object getItemId() {
            return itemId;
        }

        public Item getItem() {
            return item;
        }

        public Object getColumnPropertyId() {
            return columnPropertyId;
        }

        public T getNewValue() {
            return newValue;
        }
    }

    public void addItemEditListener(ItemEditListener listener) {
        addListener(ItemEditEvent.class, listener,
                ItemEditListener.ITEM_EDIT_METHOD);
    }

    public void removeItemEditListener(ItemEditListener listener) {
        removeListener(ItemEditListener.class, listener);
    }

    /**
     * Fires a event to all listeners without any event details.
     *
     */
    public void fireItemEditEvent(Object itemId, Item item, Object columnPropertyId, T newValue) {
        fireEvent(new ItemEditEvent(getParentGrid(), itemId, item, columnPropertyId, newValue));
    }
}

@@ -501,16 +501,159 @@
 %0A    %7D%0A%0A
+    public EditableRenderer(Class%3CT%3E presentationType, String nullRepresentation) %7B%0A        super(presentationType, nullRepresentation);%0A    %7D%0A
 %0A    pub

Add constructor.