--- /dev/null
+package com.itmill.toolkit.event;
+
+import java.lang.reflect.Method;
+
+import com.itmill.toolkit.data.Container;
+import com.itmill.toolkit.data.Item;
+import com.itmill.toolkit.data.Property;
+import com.itmill.toolkit.terminal.gwt.client.MouseEventDetails;
+import com.itmill.toolkit.ui.Component;
+import com.itmill.toolkit.ui.Component.Event;
+
+/**
+ *
+ * Click event fired by a {@link Component} implementing
+ * {@link com.itmill.toolkit.data.Container} interface. ItemClickEvents happens
+ * on an {@link Item} rendered somehow on terminal. Event may also contain a
+ * specific {@link Property} on which the click event happened.
+ *
+ * ClickEvents are rather terminal dependent events. Correct values in event
+ * details cannot be guaranteed.
+ *
+ * EXPERIMENTAL FEATURE, user input is welcome
+ *
+ * @since 5.3
+ *
+ * TODO extract generic super class/interfaces if we implement some other click
+ * events.
+ */
+public class ItemClickEvent extends Event {
+ public static final int BUTTON_LEFT = MouseEventDetails.BUTTON_LEFT;
+ public static final int BUTTON_MIDDLE = MouseEventDetails.BUTTON_MIDDLE;
+ public static final int BUTTON_RIGHT = MouseEventDetails.BUTTON_RIGHT;
+
+ private MouseEventDetails details;
+ private Item item;
+ private Object itemId;
+ private Object propertyId;
+
+ public ItemClickEvent(Component source, Item item, Object itemId,
+ Object propertyId, MouseEventDetails details) {
+ super(source);
+ this.details = details;
+ this.item = item;
+ this.itemId = itemId;
+ this.propertyId = propertyId;
+ }
+
+ /**
+ * Gets the item on which the click event occurred.
+ *
+ * @return item which was clicked
+ */
+ public Item getItem() {
+ return item;
+ }
+
+ /**
+ * Gets a possible identifier in source for clicked Item
+ *
+ * @return
+ */
+ public Object getItemId() {
+ return itemId;
+ }
+
+ /**
+ * Returns property on which click event occurred. Returns null if source
+ * cannot be resolved at property leve. For example if clicked a cell in
+ * table, the "column id" is returned.
+ *
+ * @return a property id of clicked property or null if click didn't occur
+ * on any distinct property.
+ */
+ public Object getPropertyId() {
+ return propertyId;
+ }
+
+ public int getButton() {
+ return details.getButton();
+ }
+
+ public int getClientX() {
+ return details.getClientX();
+ }
+
+ public int getClientY() {
+ return details.getClientY();
+ }
+
+ public boolean isDoubleClick() {
+ return details.isDoubleClick();
+ }
+
+ public boolean isAltKey() {
+ return details.isAltKey();
+ }
+
+ public boolean isCtrlKey() {
+ return details.isCtrlKey();
+ }
+
+ public boolean isMetaKey() {
+ return details.isMetaKey();
+ }
+
+ public boolean isShiftKey() {
+ return details.isShiftKey();
+ }
+
+ /**
+ * Serial generated by eclipse
+ */
+ private static final long serialVersionUID = 3576399524236787971L;
+
+ public static final Method ITEM_CLICK_METHOD;
+
+ static {
+ try {
+ ITEM_CLICK_METHOD = ItemClickListener.class.getDeclaredMethod(
+ "itemClick", new Class[] { ItemClickEvent.class });
+ } catch (final java.lang.NoSuchMethodException e) {
+ // This should never happen
+ throw new java.lang.RuntimeException();
+ }
+ }
+
+ public interface ItemClickListener {
+ public void itemClick(ItemClickEvent event);
+ }
+
+ /**
+ * Components implementing
+ *
+ * @link {@link Container} interface may support emitting
+ * {@link ItemClickEvent}s.
+ */
+ public interface ItemClickSource {
+ /**
+ * Register listener to handle ItemClickEvents.
+ *
+ * Note! Click listeners are rather terminal dependent features.
+ *
+ * This feature is EXPERIMENTAL
+ *
+ * @param listener
+ * ItemClickListener to be registered
+ */
+ public void addListener(ItemClickListener listener);
+
+ /**
+ * Removes ItemClickListener.
+ *
+ * @param listener
+ */
+ public void removeListener(ItemClickListener listener);
+ }
+
+}
--- /dev/null
+package com.itmill.toolkit.tests.tickets;\r
+\r
+import com.itmill.toolkit.data.Container;\r
+import com.itmill.toolkit.event.ItemClickEvent;\r
+import com.itmill.toolkit.tests.TestForTablesInitialColumnWidthLogicRendering;\r
+import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.Label;\r
+import com.itmill.toolkit.ui.OrderedLayout;\r
+import com.itmill.toolkit.ui.Panel;\r
+import com.itmill.toolkit.ui.Table;\r
+import com.itmill.toolkit.ui.TextField;\r
+import com.itmill.toolkit.ui.Tree;\r
+import com.itmill.toolkit.ui.Window;\r
+import com.itmill.toolkit.ui.Button.ClickEvent;\r
+\r
+public class Ticket2009 extends com.itmill.toolkit.Application {\r
+\r
+ TextField f = new TextField();\r
+\r
+ public void init() {\r
+ final Window main = new Window(getClass().getName().substring(\r
+ getClass().getName().lastIndexOf(".") + 1));\r
+ setMainWindow(main);\r
+\r
+ OrderedLayout ol = new OrderedLayout(\r
+ OrderedLayout.ORIENTATION_HORIZONTAL);\r
+ main.setLayout(ol);\r
+ ol.setSizeFull();\r
+\r
+ Panel p = new Panel("Tree test");\r
+ p.setSizeFull();\r
+\r
+ Tree t = new Tree();\r
+\r
+ t.addItem("Foo");\r
+ t.addItem("Bar");\r
+\r
+ final OrderedLayout events = new OrderedLayout();\r
+\r
+ t.addListener(new ItemClickEvent.ItemClickListener() {\r
+ public void itemClick(ItemClickEvent event) {\r
+ events.addComponent(new Label(new Label("Click:"\r
+ + (event.isDoubleClick() ? "double" : "single")\r
+ + " button:" + event.getButton() + " propertyId:"\r
+ + event.getPropertyId() + " itemID:"\r
+ + event.getItemId() + " item:" + event.getItem())));\r
+\r
+ }\r
+ });\r
+\r
+ main.addComponent(p);\r
+ p.addComponent(t);\r
+ p.addComponent(events);\r
+\r
+ Panel p2 = new Panel("Table test (try dbl click also)");\r
+ p2.setSizeFull();\r
+\r
+ final OrderedLayout events2 = new OrderedLayout();\r
+ Table table = TestForTablesInitialColumnWidthLogicRendering\r
+ .getTestTable(5, 100);\r
+ table.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);\r
+ table.addListener(new ItemClickEvent.ItemClickListener() {\r
+ public void itemClick(ItemClickEvent event) {\r
+ events2.addComponent(new Label("Click:"\r
+ + (event.isDoubleClick() ? "double" : "single")\r
+ + " button:" + event.getButton() + " propertyId:"\r
+ + event.getPropertyId() + " itemID:"\r
+ + event.getItemId() + " item:" + event.getItem()));\r
+ if (event.isDoubleClick()) {\r
+ new PropertyEditor(event);\r
+ }\r
+\r
+ }\r
+ });\r
+ p2.addComponent(table);\r
+ p2.addComponent(events2);\r
+\r
+ main.addComponent(p2);\r
+\r
+ }\r
+\r
+ class PropertyEditor extends Window {\r
+\r
+ private static final int W = 300;\r
+ private static final int H = 150;\r
+\r
+ private Container c;\r
+ private Object itemid;\r
+ private Object propertyid;\r
+\r
+ TextField editor = new TextField();\r
+ Button done = new Button("Done");\r
+\r
+ PropertyEditor(ItemClickEvent event) {\r
+ c = (Container) event.getSource();\r
+\r
+ propertyid = event.getPropertyId();\r
+ itemid = event.getItemId();\r
+\r
+ setCaption("Editing " + itemid + " : " + propertyid);\r
+\r
+ editor.setPropertyDataSource(c.getContainerProperty(itemid,\r
+ propertyid));\r
+ addComponent(editor);\r
+ addComponent(done);\r
+\r
+ setWidth(W);\r
+ setHeight(H);\r
+\r
+ setPositionX(event.getClientX() - W / 2);\r
+ setPositionY(event.getClientY() - H / 2);\r
+\r
+ getMainWindow().addWindow(this);\r
+\r
+ done.addListener(new Button.ClickListener() {\r
+ public void buttonClick(ClickEvent event) {\r
+ getMainWindow().removeWindow(PropertyEditor.this);\r
+ }\r
+ });\r
+\r
+ }\r
+\r
+ }\r
+\r
+}
\ No newline at end of file
import com.itmill.toolkit.data.util.ContainerOrderedWrapper;
import com.itmill.toolkit.data.util.IndexedContainer;
import com.itmill.toolkit.event.Action;
+import com.itmill.toolkit.event.ItemClickEvent;
+import com.itmill.toolkit.event.ItemClickEvent.ItemClickListener;
+import com.itmill.toolkit.event.ItemClickEvent.ItemClickSource;
import com.itmill.toolkit.terminal.KeyMapper;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.Resource;
+import com.itmill.toolkit.terminal.gwt.client.MouseEventDetails;
/**
* <p>
* @since 3.0
*/
public class Table extends AbstractSelect implements Action.Container,
- Container.Ordered, Container.Sortable {
+ Container.Ordered, Container.Sortable, ItemClickSource {
private static final int CELL_KEY = 0;
*/
private CellStyleGenerator cellStyleGenerator = null;
+ private int clickListenerCount;
+
/* Table constructors */
/**
* </p>
*
* @param visibleColumns
- * the Array of shown property id:s.
+ * the Array of shown property id:s.
*/
public void setVisibleColumns(Object[] visibleColumns) {
* </p>
*
* @param columnHeaders
- * the Array of column headers that match the
- * <code>getVisibleColumns</code> method.
+ * the Array of column headers that match the
+ * <code>getVisibleColumns</code> method.
*/
public void setColumnHeaders(String[] columnHeaders) {
* </p>
*
* @param columnIcons
- * the Array of icons that match the
- * <code>getVisibleColumns</code>.
+ * the Array of icons that match the
+ * <code>getVisibleColumns</code>.
*/
public void setColumnIcons(Resource[] columnIcons) {
*
* <p>
* The items in the array must match the properties identified by
- * <code>getVisibleColumns()</code>. The possible values for the alignments
- * include:
+ * <code>getVisibleColumns()</code>. The possible values for the
+ * alignments include:
* <ul>
* <li><code>ALIGN_LEFT</code>: Left alignment</li>
* <li><code>ALIGN_CENTER</code>: Centered</li>
*
* <p>
* The items in the array must match the properties identified by
- * <code>getVisibleColumns()</code>. The possible values for the alignments
- * include:
+ * <code>getVisibleColumns()</code>. The possible values for the
+ * alignments include:
* <ul>
* <li><code>ALIGN_LEFT</code>: Left alignment</li>
* <li><code>ALIGN_CENTER</code>: Centered</li>
* </p>
*
* @param columnAlignments
- * the Column alignments array.
+ * the Column alignments array.
*/
public void setColumnAlignments(String[] columnAlignments) {
* will make decision of width.
*
* @param columnId
- * colunmns property id
+ * colunmns property id
* @param width
- * width to be reserved for colunmns content
+ * width to be reserved for colunmns content
* @since 4.0.3
*/
public void setColumnWidth(Object columnId, int width) {
* </p>
*
* @param pageLength
- * the Length of one page.
+ * the Length of one page.
*/
public void setPageLength(int pageLength) {
if (pageLength >= 0 && this.pageLength != pageLength) {
* Setter for property currentPageFirstItemId.
*
* @param currentPageFirstItemId
- * the New value of property currentPageFirstItemId.
+ * the New value of property currentPageFirstItemId.
*/
public void setCurrentPageFirstItemId(Object currentPageFirstItemId) {
* Gets the icon Resource for the specified column.
*
* @param propertyId
- * the propertyId indentifying the column.
+ * the propertyId indentifying the column.
* @return the icon for the specified column; null if the column has no icon
* set, or if the column is not visible.
*/
* </p>
*
* @param propertyId
- * the propertyId identifying the column.
+ * the propertyId identifying the column.
* @param icon
- * the icon Resource to set.
+ * the icon Resource to set.
*/
public void setColumnIcon(Object propertyId, Resource icon) {
* Gets the header for the specified column.
*
* @param propertyId
- * the propertyId indentifying the column.
+ * the propertyId indentifying the column.
* @return the header for the specifed column if it has one.
*/
public String getColumnHeader(Object propertyId) {
* Sets the column header for the specified column;
*
* @param propertyId
- * the propertyId indentifying the column.
+ * the propertyId indentifying the column.
* @param header
- * the header to set.
+ * the header to set.
*/
public void setColumnHeader(Object propertyId, String header) {
* Gets the specified column's alignment.
*
* @param propertyId
- * the propertyID identifying the column.
+ * the propertyID identifying the column.
* @return the specified column's alignment if it as one; null otherwise.
*/
public String getColumnAlignment(Object propertyId) {
* </p>
*
* @param propertyId
- * the propertyID identifying the column.
+ * the propertyID identifying the column.
* @param alignment
- * the desired alignment.
+ * the desired alignment.
*/
public void setColumnAlignment(Object propertyId, String alignment) {
* Checks if the specified column is collapsed.
*
* @param propertyId
- * the propertyID identifying the column.
+ * the propertyID identifying the column.
* @return true if the column is collapsed; false otherwise;
*/
public boolean isColumnCollapsed(Object propertyId) {
*
*
* @param propertyId
- * the propertyID identifying the column.
+ * the propertyID identifying the column.
* @param collapsed
- * the desired collapsedness.
+ * the desired collapsedness.
* @throws IllegalAccessException
*/
public void setColumnCollapsed(Object propertyId, boolean collapsed)
* Sets whether column collapsing is allowed or not.
*
* @param collapsingAllowed
- * specifies whether column collapsing is allowed.
+ * specifies whether column collapsing is allowed.
*/
public void setColumnCollapsingAllowed(boolean collapsingAllowed) {
columnCollapsingAllowed = collapsingAllowed;
* Sets whether column reordering is allowed or not.
*
* @param reorderingAllowed
- * specifies whether column reordering is allowed.
+ * specifies whether column reordering is allowed.
*/
public void setColumnReorderingAllowed(boolean reorderingAllowed) {
columnReorderingAllowed = reorderingAllowed;
* Setter for property currentPageFirstItem.
*
* @param newIndex
- * the New value of property currentPageFirstItem.
+ * the New value of property currentPageFirstItem.
*/
public void setCurrentPageFirstItemIndex(int newIndex) {
setCurrentPageFirstItemIndex(newIndex, true);
* @deprecated functionality is not needed in ajax rendering model
*
* @param pageBuffering
- * the New value of property pageBuffering.
+ * the New value of property pageBuffering.
*/
public void setPageBufferingEnabled(boolean pageBuffering) {
* </p>
*
* @param selectable
- * the New value of property selectable.
+ * the New value of property selectable.
*/
public void setSelectable(boolean selectable) {
if (this.selectable != selectable) {
* Setter for property columnHeaderMode.
*
* @param columnHeaderMode
- * the New value of property columnHeaderMode.
+ * the New value of property columnHeaderMode.
*/
public void setColumnHeaderMode(int columnHeaderMode) {
if (columnHeaderMode >= COLUMN_HEADER_MODE_HIDDEN
* <code>toString()</code> is used as row caption.
* <li><code>ROW_HEADER_MODE_PROPERTY</code>: Property set with
* <code>setItemCaptionPropertyId()</code> is used as row header.
- * <li><code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code>: Items Id-objects
- * <code>toString()</code> is used as row header. If caption is explicitly
- * specified, it overrides the id-caption.
+ * <li><code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code>: Items
+ * Id-objects <code>toString()</code> is used as row header. If caption is
+ * explicitly specified, it overrides the id-caption.
* <li><code>ROW_HEADER_MODE_EXPLICIT</code>: The row headers must be
* explicitly specified.</li>
- * <li><code>ROW_HEADER_MODE_INDEX</code>: The index of the item is used as
- * row caption. The index mode can only be used with the containers
+ * <li><code>ROW_HEADER_MODE_INDEX</code>: The index of the item is used
+ * as row caption. The index mode can only be used with the containers
* implementing <code>Container.Indexed</code> interface.</li>
* </ul>
* The default value is <code>ROW_HEADER_MODE_HIDDEN</code>
* </p>
*
* @param mode
- * the One of the modes listed above.
+ * the One of the modes listed above.
*/
public void setRowHeaderMode(int mode) {
if (ROW_HEADER_MODE_HIDDEN == mode) {
* columns) with given values.
*
* @param cells
- * the Object array that is used for filling the visible cells
- * new row. The types must be settable to visible column property
- * types.
+ * the Object array that is used for filling the visible
+ * cells new row. The types must be settable to visible
+ * column property types.
* @param itemId
- * the Id the new row. If null, a new id is automatically
- * assigned. If given, the table cant already have a item with
- * given id.
+ * the Id the new row. If null, a new id is automatically
+ * assigned. If given, the table cant already have a item
+ * with given id.
* @return Returns item id for the new row. Returns null if operation fails.
*/
public Object addItem(Object[] cells, Object itemId)
}
}
- enableContentRefreshing(clientNeedsContentRefresh);
+ // handle clicks before content refresh if content is refreshed anyway
+ if (clientNeedsContentRefresh) {
+ handleClickEvent(variables);
+ enableContentRefreshing(clientNeedsContentRefresh);
+ } else {
+ enableContentRefreshing(clientNeedsContentRefresh);
+ handleClickEvent(variables);
+ }
+ }
+
+ /**
+ * Handles click event
+ *
+ * @param variables
+ */
+ private void handleClickEvent(Map variables) {
+ if (clickListenerCount > 0) {
+ if (variables.containsKey("clickEvent")) {
+ String key = (String) variables.get("clickedKey");
+ Object itemId = itemIdMapper.get(key);
+ Object propertyId = null;
+ String colkey = (String) variables.get("clickedColKey");
+ // click is not necessary on a property
+ if (colkey != null) {
+ propertyId = columnIdMap.get(colkey);
+ }
+ MouseEventDetails evt = MouseEventDetails
+ .deSerialize((String) variables.get("clickEvent"));
+ fireEvent(new ItemClickEvent(this, getItem(itemId), itemId,
+ propertyId, evt));
+ }
+ }
}
/**
* Go to mode where content content refreshing has effect.
*
* @param refreshContent
- * true if content refresh needs to be done
+ * true if content refresh needs to be done
*/
protected void enableContentRefreshing(boolean refreshContent) {
isContentRefreshesEnabled = true;
/*
* (non-Javadoc)
*
- * @see
- * com.itmill.toolkit.ui.AbstractSelect#paintContent(com.itmill.toolkit.
- * terminal.PaintTarget)
+ * @see com.itmill.toolkit.ui.AbstractSelect#paintContent(com.itmill.toolkit.
+ * terminal.PaintTarget)
*/
public void paintContent(PaintTarget target) throws PaintException {
} else {
target.addAttribute("selectmode", "none");
}
+
+ if (clickListenerCount > 0) {
+ target.addAttribute("listenClicks", true);
+ }
+
target.addAttribute("cols", cols);
target.addAttribute("rows", rows);
* the value representation.
*
* @param rowId
- * the Id of the row (same as item Id).
+ * the Id of the row (same as item Id).
* @param colId
- * the Id of the column.
+ * the Id of the column.
* @param property
- * the Property to be presented.
+ * the Property to be presented.
* @return Object Either formatted value or Component for field.
* @see #setFieldFactory(FieldFactory)
*/
* and return a empty string for null properties.
*
* @param rowId
- * the Id of the row (same as item Id).
+ * the Id of the row (same as item Id).
* @param colId
- * the Id of the column.
+ * the Id of the column.
* @param property
- * the Property to be formatted.
+ * the Property to be formatted.
* @return the String representation of property and its value.
* @since 3.1
*/
* Adds a new property to the table and show it as a visible column.
*
* @param propertyId
- * the Id of the proprty.
+ * the Id of the proprty.
* @param type
- * the class of the property.
+ * the class of the property.
* @param defaultValue
- * the default value given for all existing items.
+ * the default value given for all existing items.
* @see com.itmill.toolkit.data.Container#addContainerProperty(Object,
* Class, Object)
*/
* Adds a new property to the table and show it as a visible column.
*
* @param propertyId
- * the Id of the proprty
+ * the Id of the proprty
* @param type
- * the class of the property
+ * the class of the property
* @param defaultValue
- * the default value given for all existing items
+ * the default value given for all existing items
* @param columnHeader
- * the Explicit header of the column. If explicit header is not
- * needed, this should be set null.
+ * the Explicit header of the column. If explicit header is
+ * not needed, this should be set null.
* @param columnIcon
- * the Icon of the column. If icon is not needed, this should be
- * set null.
+ * the Icon of the column. If icon is not needed, this should
+ * be set null.
* @param columnAlignment
- * the Alignment of the column. Null implies align left.
+ * the Alignment of the column. Null implies align left.
* @throws UnsupportedOperationException
- * if the operation is not supported.
+ * if the operation is not supported.
* @see com.itmill.toolkit.data.Container#addContainerProperty(Object,
* Class, Object)
*/
* </p>
*
* @param id
- * the id of the column to be added
+ * the id of the column to be added
* @param generatedColumn
- * the {@link ColumnGenerator} to use for this column
+ * the {@link ColumnGenerator} to use for this column
*/
public void addGeneratedColumn(Object id, ColumnGenerator generatedColumn) {
if (generatedColumn == null) {
* Removes a generated column previously added with addGeneratedColumn.
*
* @param id
- * id of the generated column to remove
+ * id of the generated column to remove
* @return true if the column could be removed (existed in the Table)
*/
public boolean removeGeneratedColumn(Object id) {
* Adding new items is not supported.
*
* @throws UnsupportedOperationException
- * if set to true.
+ * if set to true.
* @see com.itmill.toolkit.ui.Select#setNewItemsAllowed(boolean)
*/
public void setNewItemsAllowed(boolean allowNewOptions)
* Focusing to this component is not supported.
*
* @throws UnsupportedOperationException
- * if invoked.
+ * if invoked.
* @see com.itmill.toolkit.ui.AbstractField#focus()
*/
public void focus() throws UnsupportedOperationException {
* BaseFieldFactory is used.
*
* @param fieldFactory
- * the field factory to set.
+ * the field factory to set.
* @see #isEditable
* @see BaseFieldFactory
*
* property to true.
*
* @param editable
- * true if table should be editable by user.
+ * true if table should be editable by user.
* @see Field
* @see FieldFactory
*
* Sorts the table.
*
* @throws UnsupportedOperationException
- * if the container data source does not implement
- * Container.Sortable
+ * if the container data source does not implement
+ * Container.Sortable
* @see com.itmill.toolkit.data.Container.Sortable#sort(java.lang.Object[],
* boolean[])
*
* Sorts the table by currently selected sorting column.
*
* @throws UnsupportedOperationException
- * if the container data source does not implement
- * Container.Sortable
+ * if the container data source does not implement
+ * Container.Sortable
*/
public void sort() {
if (getSortContainerPropertyId() == null) {
* Sets the currently sorted column property id.
*
* @param propertyId
- * the Container property id of the currently sorted column.
+ * the Container property id of the currently sorted column.
*/
public void setSortContainerPropertyId(Object propertyId) {
setSortContainerPropertyId(propertyId, true);
/**
* Is the table currently sorted in ascending order.
*
- * @return <code>true</code> if ascending, <code>false</code> if descending.
+ * @return <code>true</code> if ascending, <code>false</code> if
+ * descending.
*/
public boolean isSortAscending() {
return sortAscending;
* Sets the table in ascending order.
*
* @param ascending
- * <code>true</code> if ascending, <code>false</code> if
- * descending.
+ * <code>true</code> if ascending, <code>false</code> if
+ * descending.
*/
public void setSortAscending(boolean ascending) {
setSortAscending(ascending, true);
* columns are given even in the case where datasource would support this.
*
* @param sortDisabled
- * True iff sorting is disabled.
+ * True iff sorting is disabled.
*/
public void setSortDisabled(boolean sortDisabled) {
if (this.sortDisabled != sortDisabled) {
* generated.
*
* @param source
- * the source Table
+ * the source Table
* @param itemId
- * the itemId (aka rowId) for the of the cell to be generated
+ * the itemId (aka rowId) for the of the cell to be
+ * generated
* @param columnId
- * the id for the generated column (as specified in
- * addGeneratedColumn)
+ * the id for the generated column (as specified in
+ * addGeneratedColumn)
* @return
*/
public abstract Component generateCell(Table source, Object itemId,
* Set cell style generator for Table.
*
* @param cellStyleGenerator
- * New cell style generator or null to remove generator.
+ * New cell style generator or null to remove generator.
*/
public void setCellStyleGenerator(CellStyleGenerator cellStyleGenerator) {
this.cellStyleGenerator = cellStyleGenerator;
* Called by Table when a cell (and row) is painted.
*
* @param itemId
- * The itemId of the painted cell
+ * The itemId of the painted cell
* @param propertyId
- * The propertyId of the cell, null when getting row style
+ * The propertyId of the cell, null when getting row
+ * style
* @return The style name to add to this cell or row. (the CSS class
* name will be i-table-cell-content-[style name], or
* i-table-row-[style name] for rows)
*/
public abstract String getStyle(Object itemId, Object propertyId);
}
+
+ public void addListener(ItemClickListener listener) {
+ addListener(ItemClickEvent.class, listener,
+ ItemClickEvent.ITEM_CLICK_METHOD);
+ clickListenerCount++;
+ // repaint needed only if click listening became necessary
+ if (clickListenerCount == 1) {
+ requestRepaint();
+ }
+
+ }
+
+ public void removeListener(ItemClickListener listener) {
+ removeListener(ItemClickEvent.class, listener,
+ ItemClickEvent.ITEM_CLICK_METHOD);
+ clickListenerCount++;
+ // repaint needed only if click listening is not needed in client
+ // anymore
+ if (clickListenerCount == 0) {
+ requestRepaint();
+ }
+ }
}