/* * Smart GWT (GWT for SmartClient) * Copyright 2008 and beyond, Isomorphic Software, Inc. * * Smart GWT is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. Smart GWT is also * available under typical commercial license terms - see * http://smartclient.com/license * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package com.smartgwt.client.widgets.tile; import com.smartgwt.client.event.*; import com.smartgwt.client.core.*; import com.smartgwt.client.types.*; import com.smartgwt.client.data.*; import com.smartgwt.client.data.events.*; import com.smartgwt.client.rpc.*; import com.smartgwt.client.widgets.*; import com.smartgwt.client.widgets.events.*; import com.smartgwt.client.widgets.form.*; import com.smartgwt.client.widgets.form.validator.*; import com.smartgwt.client.widgets.form.fields.*; import com.smartgwt.client.widgets.tile.*; import com.smartgwt.client.widgets.tile.events.*; import com.smartgwt.client.widgets.grid.*; import com.smartgwt.client.widgets.grid.events.*; import com.smartgwt.client.widgets.chart.*; import com.smartgwt.client.widgets.layout.*; import com.smartgwt.client.widgets.layout.events.*; import com.smartgwt.client.widgets.menu.*; import com.smartgwt.client.widgets.tab.*; import com.smartgwt.client.widgets.toolbar.*; import com.smartgwt.client.widgets.tree.*; import com.smartgwt.client.widgets.tree.events.*; import com.smartgwt.client.widgets.viewer.*; import com.smartgwt.client.widgets.calendar.*; import com.smartgwt.client.widgets.calendar.events.*; import com.smartgwt.client.widgets.cube.*; import java.util.Date; import java.util.List; import java.util.Map; import java.util.HashMap; import com.google.gwt.user.client.ui.Widget; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.user.client.Element; import com.smartgwt.client.util.*; import com.google.gwt.event.shared.*; /** * A TileGrid is a {@link com.smartgwt.client.widgets.DataBoundComponent} that displays a list of objects as a set of * "tiles", where each tile represents one object, and the tiles are laid out in a grid with multiple tiles per row. Each * tile displays one or more properties of the object it represents. */ public class TileGrid extends TileLayout implements DataBoundComponent, com.smartgwt.client.widgets.tile.events.HasRecordClickHandlers, com.smartgwt.client.widgets.tile.events.HasRecordDoubleClickHandlers, com.smartgwt.client.widgets.tile.events.HasRecordContextClickHandlers, com.smartgwt.client.widgets.tile.events.HasSelectionChangedHandlers { public static TileGrid getOrCreateRef(JavaScriptObject jsObj) { if(jsObj == null) return null; BaseWidget obj = BaseWidget.getRef(jsObj); if(obj != null) { return (TileGrid) obj; } else { return new TileGrid(jsObj); } } public TileGrid(){ scClassName = "TileGrid"; } public TileGrid(JavaScriptObject jsObj){ super(jsObj); } protected native JavaScriptObject create()/*-{ var config = this.@com.smartgwt.client.widgets.BaseWidget::getConfig()(); var scClassName = this.@com.smartgwt.client.widgets.BaseWidget::scClassName; var widget = $wnd.isc[scClassName].create(config); this.@com.smartgwt.client.widgets.BaseWidget::doInit()(); return widget; }-*/; // ********************* Properties / Attributes *********************** /** * If set, when the dataset changes due to filtering, sorting or other actions, any tiles that were showing before and * after the change will animate from their old positions to their new positions. * <p><b>Note : </b> This is an advanced setting</p> * * @param animateTileChange animateTileChange Default value is true * @see com.smartgwt.client.docs.Appearance Appearance overview and related methods */ public void setAnimateTileChange(Boolean animateTileChange) { setAttribute("animateTileChange", animateTileChange, true); } /** * If set, when the dataset changes due to filtering, sorting or other actions, any tiles that were showing before and * after the change will animate from their old positions to their new positions. * * * @return Boolean * @see com.smartgwt.client.docs.Appearance Appearance overview and related methods */ public Boolean getAnimateTileChange() { return getAttributeAsBoolean("animateTileChange"); } /** * If {@link com.smartgwt.client.widgets.tile.TileGrid#getAutoFetchData autoFetchData} is <code>true</code>, this attribute * allows the developer to specify a textMatchStyle for the initial {@link * com.smartgwt.client.widgets.tile.TileGrid#fetchData TileGrid.fetchData} call. * * @param autoFetchTextMatchStyle autoFetchTextMatchStyle Default value is "substring" * @throws IllegalStateException this property cannot be changed after the component has been created * @see com.smartgwt.client.docs.Databinding Databinding overview and related methods */ public void setAutoFetchTextMatchStyle(TextMatchStyle autoFetchTextMatchStyle) throws IllegalStateException { setAttribute("autoFetchTextMatchStyle", autoFetchTextMatchStyle == null ? null : autoFetchTextMatchStyle.getValue(), false); } /** * If {@link com.smartgwt.client.widgets.tile.TileGrid#getAutoFetchData autoFetchData} is <code>true</code>, this attribute * allows the developer to specify a textMatchStyle for the initial {@link * com.smartgwt.client.widgets.tile.TileGrid#fetchData TileGrid.fetchData} call. * * * @return TextMatchStyle * @see com.smartgwt.client.docs.Databinding Databinding overview and related methods */ public TextMatchStyle getAutoFetchTextMatchStyle() { return EnumUtil.getEnum(TextMatchStyle.values(), getAttribute("autoFetchTextMatchStyle")); } /** * Indicates whether records can be dropped into this TileGrid. * * @param canAcceptDroppedRecords canAcceptDroppedRecords Default value is false * @see <a href="http://www.smartclient.com/smartgwt/showcase/#effects_dd_move_list" target="examples">Drag list (move) Example</a> */ public void setCanAcceptDroppedRecords(Boolean canAcceptDroppedRecords) { setAttribute("canAcceptDroppedRecords", canAcceptDroppedRecords, true); } /** * Indicates whether records can be dropped into this TileGrid. * * * @return Boolean * @see <a href="http://www.smartclient.com/smartgwt/showcase/#effects_dd_move_list" target="examples">Drag list (move) Example</a> */ public Boolean getCanAcceptDroppedRecords() { return getAttributeAsBoolean("canAcceptDroppedRecords"); } /** * Indicates whether tiles can be dragged from this tileGrid and dropped elsewhere. * * @param canDragTilesOut canDragTilesOut Default value is false */ public void setCanDragTilesOut(Boolean canDragTilesOut) { setAttribute("canDragTilesOut", canDragTilesOut, true); } /** * Indicates whether tiles can be dragged from this tileGrid and dropped elsewhere. * * * @return Boolean */ public Boolean getCanDragTilesOut() { return getAttributeAsBoolean("canDragTilesOut"); } /** * Indicates whether tiles can be reordered by dragging within this tileGrid. * * @param canReorderTiles canReorderTiles Default value is false */ public void setCanReorderTiles(Boolean canReorderTiles) { setAttribute("canReorderTiles", canReorderTiles, true); } /** * Indicates whether tiles can be reordered by dragging within this tileGrid. * * * @return Boolean */ public Boolean getCanReorderTiles() { return getAttributeAsBoolean("canReorderTiles"); } /** * How to fetch and manage records retrieve from the server. See {@link com.smartgwt.client.types.FetchMode}. <P> This * setting only applies to the {@link com.smartgwt.client.data.ResultSet} automatically created by calling {@link * com.smartgwt.client.widgets.tile.TileGrid#fetchData TileGrid.fetchData}. If a pre-existing ResultSet is passed to * setData() instead, it's existing setting for {@link com.smartgwt.client.data.ResultSet#getFetchMode fetchMode} applies. * * @param dataFetchMode dataFetchMode Default value is "paged" * @see com.smartgwt.client.docs.Databinding Databinding overview and related methods */ public void setDataFetchMode(FetchMode dataFetchMode) { setAttribute("dataFetchMode", dataFetchMode == null ? null : dataFetchMode.getValue(), true); } /** * How to fetch and manage records retrieve from the server. See {@link com.smartgwt.client.types.FetchMode}. <P> This * setting only applies to the {@link com.smartgwt.client.data.ResultSet} automatically created by calling {@link * com.smartgwt.client.widgets.tile.TileGrid#fetchData TileGrid.fetchData}. If a pre-existing ResultSet is passed to * setData() instead, it's existing setting for {@link com.smartgwt.client.data.ResultSet#getFetchMode fetchMode} applies. * * * @return FetchMode * @see com.smartgwt.client.docs.Databinding Databinding overview and related methods */ public FetchMode getDataFetchMode() { return EnumUtil.getEnum(FetchMode.values(), getAttribute("dataFetchMode")); } /** * Properties for the {@link com.smartgwt.client.widgets.viewer.DetailViewer} that is automatically created to render the * contents of tiles by default. * * @param detailViewerProperties detailViewerProperties Default value is null * @throws IllegalStateException this property cannot be changed after the component has been created */ public void setDetailViewerProperties(DetailViewer detailViewerProperties) throws IllegalStateException { setAttribute("detailViewerProperties", detailViewerProperties == null ? null : detailViewerProperties.getOrCreateJsObj(), false); } /** * Properties for the {@link com.smartgwt.client.widgets.viewer.DetailViewer} that is automatically created to render the * contents of tiles by default. * * * @return DetailViewer */ public DetailViewer getDetailViewerProperties() { return DetailViewer.getOrCreateRef(getAttributeAsJavaScriptObject("detailViewerProperties")); } /** * How many tiles should be present in a line when printing? * * @param printTilesPerLine printTilesPerLine Default value is null * @throws IllegalStateException this property cannot be changed after the component has been created */ public void setPrintTilesPerLine(Integer printTilesPerLine) throws IllegalStateException { setAttribute("printTilesPerLine", printTilesPerLine, false); } /** * How many tiles should be present in a line when printing? * * * @return Integer */ public Integer getPrintTilesPerLine() { return getAttributeAsInt("printTilesPerLine"); } /** * Defines a tileGrid's clickable-selection behavior. * * @param selectionType selectionType Default value is Selection.MULTIPLE * @see com.smartgwt.client.types.SelectionStyle * @see com.smartgwt.client.docs.Appearance Appearance overview and related methods * @see <a href="http://www.smartclient.com/smartgwt/showcase/#grid_editing_category" target="examples">Editing Example</a> */ public void setSelectionType(SelectionStyle selectionType) { setAttribute("selectionType", selectionType == null ? null : selectionType.getValue(), true); } /** * Defines a tileGrid's clickable-selection behavior. * * * @return SelectionStyle * @see com.smartgwt.client.types.SelectionStyle * @see com.smartgwt.client.docs.Appearance Appearance overview and related methods * @see <a href="http://www.smartclient.com/smartgwt/showcase/#grid_editing_category" target="examples">Editing Example</a> */ public SelectionStyle getSelectionType() { return EnumUtil.getEnum(SelectionStyle.values(), getAttribute("selectionType")); } /** * Whether tiles are created and drawn for all records, or only for those currently visible. * * @param showAllRecords showAllRecords Default value is false * @throws IllegalStateException this property cannot be changed after the component has been created * @see com.smartgwt.client.docs.Basics Basics overview and related methods */ public void setShowAllRecords(Boolean showAllRecords) throws IllegalStateException { setAttribute("showAllRecords", showAllRecords, false); } /** * Whether tiles are created and drawn for all records, or only for those currently visible. * * * @return Boolean * @see com.smartgwt.client.docs.Basics Basics overview and related methods */ public Boolean getShowAllRecords() { return getAttributeAsBoolean("showAllRecords"); } /** * By default, TileGrids will not show fields marked {@link com.smartgwt.client.data.DataSourceField#getDetail detail:true} * in the DataSource. See also {@link com.smartgwt.client.widgets.tile.TileGrid#getFields fields}. * * @param showDetailFields showDetailFields Default value is false * @throws IllegalStateException this property cannot be changed after the component has been created */ public void setShowDetailFields(Boolean showDetailFields) throws IllegalStateException { setAttribute("showDetailFields", showDetailFields, false); } /** * By default, TileGrids will not show fields marked {@link com.smartgwt.client.data.DataSourceField#getDetail detail:true} * in the DataSource. See also {@link com.smartgwt.client.widgets.tile.TileGrid#getFields fields}. * * * @return Boolean */ public Boolean getShowDetailFields() { return getAttributeAsBoolean("showDetailFields"); } /** * Style for the overall TileGrid component. * * @param styleName styleName Default value is "tileGrid" * @throws IllegalStateException this property cannot be changed after the component has been created * @see com.smartgwt.client.docs.Appearance Appearance overview and related methods */ public void setStyleName(String styleName) throws IllegalStateException { setAttribute("styleName", styleName, false); } /** * Style for the overall TileGrid component. * * * @return String * @see com.smartgwt.client.docs.Appearance Appearance overview and related methods */ public String getStyleName() { return getAttributeAsString("styleName"); } /** * Visual appearance to show when the tile is being dragged. * <p><b>Note : </b> This is an advanced setting</p> * * @param tileDragAppearance tileDragAppearance Default value is EventHandler.TRACKER * @see com.smartgwt.client.widgets.Canvas#setDragAppearance * @see com.smartgwt.client.docs.Dragdrop Dragdrop overview and related methods */ public void setTileDragAppearance(DragAppearance tileDragAppearance) { setAttribute("tileDragAppearance", tileDragAppearance == null ? null : tileDragAppearance.getValue(), true); } /** * Visual appearance to show when the tile is being dragged. * * * @return DragAppearance * @see com.smartgwt.client.widgets.Canvas#getDragAppearance * @see com.smartgwt.client.docs.Dragdrop Dragdrop overview and related methods */ public DragAppearance getTileDragAppearance() { return EnumUtil.getEnum(DragAppearance.values(), getAttribute("tileDragAppearance")); } /** * Common properties to use when creating every tile. * * @param tileProperties tileProperties Default value is null * @throws IllegalStateException this property cannot be changed after the component has been created */ public void setTileProperties(Canvas tileProperties) throws IllegalStateException { setAttribute("tileProperties", tileProperties == null ? null : tileProperties.getOrCreateJsObj(), false); } /** * Common properties to use when creating every tile. * * * @return Canvas */ public Canvas getTileProperties() { return Canvas.getOrCreateRef(getAttributeAsJavaScriptObject("tileProperties")); } /** * Horizontal alignment for tile values: "left", "right" or "center". * * @param tileValueAlign tileValueAlign Default value is "center" * @throws IllegalStateException this property cannot be changed after the component has been created */ public void setTileValueAlign(String tileValueAlign) throws IllegalStateException { setAttribute("tileValueAlign", tileValueAlign, false); } /** * Horizontal alignment for tile values: "left", "right" or "center". * * * @return String */ public String getTileValueAlign() { return getAttributeAsString("tileValueAlign"); } /** * When using the default SimpleTile, CSS style for each value shown within a tile. * * @param tileValueStyle tileValueStyle Default value is "tileValue" * @throws IllegalStateException this property cannot be changed after the component has been created */ public void setTileValueStyle(String tileValueStyle) throws IllegalStateException { setAttribute("tileValueStyle", tileValueStyle, false); } /** * When using the default SimpleTile, CSS style for each value shown within a tile. * * * @return String */ public String getTileValueStyle() { return getAttributeAsString("tileValueStyle"); } /** * Whether values should be allowed to wrap by default, or should be shown on one line regardless of length. * * @param wrapValues wrapValues Default value is false * @throws IllegalStateException this property cannot be changed after the component has been created */ public void setWrapValues(Boolean wrapValues) throws IllegalStateException { setAttribute("wrapValues", wrapValues, false); } /** * Whether values should be allowed to wrap by default, or should be shown on one line regardless of length. * * * @return Boolean */ public Boolean getWrapValues() { return getAttributeAsBoolean("wrapValues"); } // ********************* Methods *********************** /** * This is not allowed for tileGrid. Instead, use {@link com.smartgwt.client.widgets.tile.TileGrid#addData * TileGrid.addData}. */ public native void addTile() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.addTile(); }-*/; /** * Notification method fired when new data arrives from the server to be displayed in this tileGrid, (for example in * response to the user scrolling a new set of tiles into view). Only applies to databound tileGrid where the {@link * com.smartgwt.client.widgets.tile.TileGrid#getData data} attribute is a {@link com.smartgwt.client.data.ResultSet}. This * method is fired directly in response to {@link com.smartgwt.client.data.ResultSet#addDataArrivedHandler dataArrived()} * firing on the data object. * @param startRecord starting index of the newly loaded set of records * @param endRecord ending index of the newly loaded set of records (non inclusive). */ public native void dataArrived(int startRecord, int endRecord) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.dataArrived(startRecord, endRecord); }-*/; /** * Return "title" HTML to display as a drag tracker when the user drags some record.<br> Default implementation will * display the cell value for the title field (see {@link com.smartgwt.client.widgets.grid.ListGrid#getTitleField * ListGrid.getTitleField}) for the record(s) being dragged (including any icons / custom formatting / styling, etc). <p> * Note: Only called if {@link com.smartgwt.client.widgets.grid.ListGrid#getDragTrackerMode dragTrackerMode} is set to * <code>"title"</code>. * @param record First selected record being dragged * @param rowNum row index of first record being dragged * * @return Title for the row. Default implementation looks at the value of the title-field cell for the row. */ public native String getDragTrackerTitle(ListGridRecord record, int rowNum) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); return self.getDragTrackerTitle(record.@com.smartgwt.client.core.DataClass::getJsObj()(), rowNum); }-*/; /** * Returns a snapshot of the current presentation of this grid's fields as a String object. <P> This object can be passed * to {@link com.smartgwt.client.widgets.tile.TileGrid#setFieldState TileGrid.setFieldState} to reset this grid's fields to * the current state. <P> Note that the information stored includes the current width and visibility of each of this * grid's fields. * * @return current state of this grid's fields. * @see com.smartgwt.client.widgets.tile.TileGrid#setFieldState */ public native String getFieldState() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); return self.getFieldState(); }-*/; /** * Return the first selected record in this component * * @return first selected record, or null if nothing selected * @see com.smartgwt.client.docs.Selection Selection overview and related methods * @see <a href="http://www.smartclient.com/smartgwt/showcase/#grid_dataoperations_remove" target="examples">Databound remove Example</a> */ public native TileRecord getSelectedRecord() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var ret = self.getSelectedRecord(); if(ret == null || ret === undefined) return null; var retVal = @com.smartgwt.client.core.RefDataClass::getRef(Lcom/google/gwt/core/client/JavaScriptObject;)(ret); if(retVal == null) { retVal = @com.smartgwt.client.widgets.tile.TileRecord::new(Lcom/google/gwt/core/client/JavaScriptObject;)(ret); } return retVal; }-*/; /** * Add a recordClick handler. * <p> * Executed when the tileGrid receives a 'click' event on a tile. The default implementation does nothing -- override to * perform some action when any record is clicked.<br> A record event handler can be specified either as a function to * execute, or as a string of script to evaluate. If the handler is defined as a string of script, all the parameters below * will be available as variables for use in the script.<br> If you want to cancel the click based on the parameters, * Call {@link com.smartgwt.client.widgets.tile.events.RecordClickEvent#cancel()} from within {@link RecordClickHandler#onRecordClick}. Otherwise, return true so that the click event be registered with the tile. * * @param handler the recordClick handler * @return {@link HandlerRegistration} used to remove this handler */ public HandlerRegistration addRecordClickHandler(com.smartgwt.client.widgets.tile.events.RecordClickHandler handler) { if(getHandlerCount(com.smartgwt.client.widgets.tile.events.RecordClickEvent.getType()) == 0) setupRecordClickEvent(); return doAddHandler(handler, com.smartgwt.client.widgets.tile.events.RecordClickEvent.getType()); } private native void setupRecordClickEvent() /*-{ var obj = null; var selfJ = this; if(this.@com.smartgwt.client.widgets.BaseWidget::isCreated()()) { obj = this.@com.smartgwt.client.widgets.BaseWidget::getJsObj()(); obj.addProperties({recordClick:$entry(function(){ var param = {"viewer" : arguments[0], "tile" : arguments[1], "record" : arguments[2]}; var event = @com.smartgwt.client.widgets.tile.events.RecordClickEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); }) }); } else { obj = this.@com.smartgwt.client.widgets.BaseWidget::getConfig()(); obj.recordClick = $entry(function(){ var param = {"viewer" : arguments[0], "tile" : arguments[1], "record" : arguments[2]}; var event = @com.smartgwt.client.widgets.tile.events.RecordClickEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); }); } }-*/; /** * Add a recordContextClick handler. * <p> * Executed when the tileGrid receives a context-click (right mouse button) event on a tile. The default implementation * does nothing -- override to perform some action when any record is right-clicked.<br> Cancel the event to suppress the * native browser context menu. <P> A record event handler can be specified either as a function to execute, or as a string * of script to evaluate. If the handler is defined as a string of script, all the parameters below will be available as * variables for use in the script.<br> If you want to cancel the click based on the parameters, Call {@link com.smartgwt.client.widgets.tile.events.RecordContextClickEvent#cancel()} from within {@link RecordContextClickHandler#onRecordContextClick}. Otherwise, * return true so that the click event be registered with the tile. * * @param handler the recordContextClick handler * @return {@link HandlerRegistration} used to remove this handler */ public HandlerRegistration addRecordContextClickHandler(com.smartgwt.client.widgets.tile.events.RecordContextClickHandler handler) { if(getHandlerCount(com.smartgwt.client.widgets.tile.events.RecordContextClickEvent.getType()) == 0) setupRecordContextClickEvent(); return doAddHandler(handler, com.smartgwt.client.widgets.tile.events.RecordContextClickEvent.getType()); } private native void setupRecordContextClickEvent() /*-{ var obj = null; var selfJ = this; if(this.@com.smartgwt.client.widgets.BaseWidget::isCreated()()) { obj = this.@com.smartgwt.client.widgets.BaseWidget::getJsObj()(); obj.addProperties({recordContextClick:$debox($entry(function(){ var param = {"viewer" : arguments[0], "tile" : arguments[1], "record" : arguments[2]}; var event = @com.smartgwt.client.widgets.tile.events.RecordContextClickEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); var ret = event.@com.smartgwt.client.event.Cancellable::isCancelled()(); return !ret; })) }); } else { obj = this.@com.smartgwt.client.widgets.BaseWidget::getConfig()(); obj.recordContextClick = $debox($entry(function(){ var param = {"viewer" : arguments[0], "tile" : arguments[1], "record" : arguments[2]}; var event = @com.smartgwt.client.widgets.tile.events.RecordContextClickEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); var ret = event.@com.smartgwt.client.event.Cancellable::isCancelled()(); return !ret; })); } }-*/; /** * Add a recordDoubleClick handler. * <p> * Executed when the tileGrid receives a 'doubleclick' event on a tile. The default implementation does nothing -- override * to perform some action when any record is doubleclicked.<br> A record event handler can be specified either as a * function to execute, or as a string of script to evaluate. If the handler is defined as a string of script, all the * parameters below will be available as variables for use in the script.<br> If you want to cancel the doubleclick based * on the parameters, Call {@link com.smartgwt.client.widgets.tile.events.RecordDoubleClickEvent#cancel()} from within {@link RecordDoubleClickHandler#onRecordDoubleClick}. Otherwise, return true so that the doubleclick event be registered with the tile. * * @param handler the recordDoubleClick handler * @return {@link HandlerRegistration} used to remove this handler */ public HandlerRegistration addRecordDoubleClickHandler(com.smartgwt.client.widgets.tile.events.RecordDoubleClickHandler handler) { if(getHandlerCount(com.smartgwt.client.widgets.tile.events.RecordDoubleClickEvent.getType()) == 0) setupRecordDoubleClickEvent(); return doAddHandler(handler, com.smartgwt.client.widgets.tile.events.RecordDoubleClickEvent.getType()); } private native void setupRecordDoubleClickEvent() /*-{ var obj = null; var selfJ = this; if(this.@com.smartgwt.client.widgets.BaseWidget::isCreated()()) { obj = this.@com.smartgwt.client.widgets.BaseWidget::getJsObj()(); obj.addProperties({recordDoubleClick:$entry(function(){ var param = {"viewer" : arguments[0], "tile" : arguments[1], "record" : arguments[2]}; var event = @com.smartgwt.client.widgets.tile.events.RecordDoubleClickEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); }) }); } else { obj = this.@com.smartgwt.client.widgets.BaseWidget::getConfig()(); obj.recordDoubleClick = $entry(function(){ var param = {"viewer" : arguments[0], "tile" : arguments[1], "record" : arguments[2]}; var event = @com.smartgwt.client.widgets.tile.events.RecordDoubleClickEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); }); } }-*/; /** * This is not allowed for tileGrid. Instead, use {@link com.smartgwt.client.widgets.tile.TileGrid#removeData * TileGrid.removeData}. */ public native void removeTile() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.removeTile(); }-*/; /** * Add a selectionChanged handler. * <p> * Called when selection changes within this tileGrid. Note this method fires for each record for which selection is * modified - so when a user clicks inside a tileGrid this method will typically fire twice (once for the old record being * deselected, and once for the new record being selected). * * @param handler the selectionChanged handler * @return {@link HandlerRegistration} used to remove this handler */ public HandlerRegistration addSelectionChangedHandler(com.smartgwt.client.widgets.tile.events.SelectionChangedHandler handler) { if(getHandlerCount(com.smartgwt.client.widgets.tile.events.SelectionChangedEvent.getType()) == 0) setupSelectionChangedEvent(); return doAddHandler(handler, com.smartgwt.client.widgets.tile.events.SelectionChangedEvent.getType()); } private native void setupSelectionChangedEvent() /*-{ var obj = null; var selfJ = this; if(this.@com.smartgwt.client.widgets.BaseWidget::isCreated()()) { obj = this.@com.smartgwt.client.widgets.BaseWidget::getJsObj()(); obj.addProperties({selectionChanged:$entry(function(){ var param = {"record" : arguments[0], "state" : arguments[1]}; var event = @com.smartgwt.client.widgets.tile.events.SelectionChangedEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); }) }); } else { obj = this.@com.smartgwt.client.widgets.BaseWidget::getConfig()(); obj.selectionChanged = $entry(function(){ var param = {"record" : arguments[0], "state" : arguments[1]}; var event = @com.smartgwt.client.widgets.tile.events.SelectionChangedEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); }); } }-*/; /** * Sets some presentation properties (visibility, width, userFormula and userSummary) of the grid fields based on the * String object passed in.<br> Used to restore previous state retrieved from the grid by a call to {@link * com.smartgwt.client.widgets.tile.TileGrid#getFieldState TileGrid.getFieldState}. * @param fieldState state to apply to the grid's fields. */ public native void setFieldState(String fieldState) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.setFieldState(fieldState); }-*/; // ********************* Static Methods *********************** /** * Class level method to set the default properties of this class. If set, then all subsequent instances of this * class will automatically have the default properties that were set when this method was called. This is a powerful * feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default * properties of this class. Can also be used for skinning / styling purposes. * <P> * <b>Note:</b> This method is intended for setting default attributes only and will effect all instances of the * underlying class (including those automatically generated in JavaScript). * This method should not be used to apply standard EventHandlers or override methods for * a class - use a custom subclass instead. * * @param tileGridProperties properties that should be used as new defaults when instances of this class are created */ public static native void setDefaultProperties(TileGrid tileGridProperties) /*-{ var properties = $wnd.isc.addProperties({},tileGridProperties.@com.smartgwt.client.widgets.BaseWidget::getConfig()()); delete properties.ID; $wnd.isc.TileGrid.addProperties(properties); }-*/; // *********************************************************** protected void onInit () { super.onInit(); onInit_TileGrid(); } protected native void onInit_TileGrid() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self._getTileHTML = self.getTileHTML; self.getTileHTML = $debox($entry(function(record) { var jObj = this.__ref; var recordJ = @com.smartgwt.client.data.Record::getOrCreateRef(Lcom/google/gwt/core/client/JavaScriptObject;)(record); return jObj.@com.smartgwt.client.widgets.tile.TileGrid::getTileHTML(Lcom/smartgwt/client/data/Record;)(recordJ); })); self._getTile = self.getTile; self.getTile = $debox($entry(function(record) { var jObj = this.__ref; if(!$wnd.isc.isA.Number(record)) { var recordJ = @com.smartgwt.client.data.Record::getOrCreateRef(Lcom/google/gwt/core/client/JavaScriptObject;)(record); var tile = jObj.@com.smartgwt.client.widgets.tile.TileGrid::getTile(Lcom/smartgwt/client/data/Record;)(recordJ); return tile == null ? null : tile.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); } else { var tile = jObj.@com.smartgwt.client.widgets.tile.TileGrid::getTile(I)(record); return tile == null ? null : tile.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); } })); }-*/; /** * This method provides the HTML to * be displayed within each tile. See {@link com.smartgwt.client.widgets.tile.TileGrid#getTile tile}. * <p/> * <b>This is an override point.</b> * * @param record the tile for which HTML should be retrieved * @return HTML contents for the tile, as a String */ protected native String getTileHTML(Record record) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); return self._getTileHTML(record.@com.smartgwt.client.core.DataClass::getJsObj()()); }-*/; public native Canvas getTile(Record record) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var canvasJS = self._getTile(record.@com.smartgwt.client.core.DataClass::getJsObj()()); if(canvasJS == null) return null; var canvas = @com.smartgwt.client.widgets.Canvas::getOrCreateRef(Lcom/google/gwt/core/client/JavaScriptObject;)(canvasJS); return canvas; }-*/; /** * This is an override point */ public native Canvas getTile(int recordNum) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var canvasJS = self._getTile(recordNum); if(canvasJS == null) return null; var canvas = @com.smartgwt.client.widgets.Canvas::getOrCreateRef(Lcom/google/gwt/core/client/JavaScriptObject;)(canvasJS); return canvas; }-*/; /** * Array of field definitions to control the default rendering of tiles. <P> If not specified, if the DataSource has * an {@link com.smartgwt.client.data.DataSource#getIconField iconField}, only the <code>iconField</code> and {@link * com.smartgwt.client.data.DataSource#getTitleField titleField} will be shown. Otherwise, all non-{@link * com.smartgwt.client.data.DataSourceField#getHidden hidden} non-{@link com.smartgwt.client.data.DataSourceField#getDetail * detail} fields will be shown, similar to the default set of fields shown by a {@link * com.smartgwt.client.widgets.grid.ListGrid}. <P> Only applicable if using the default {@link * com.smartgwt.client..SimpleTile} class for tiles. <P> For SimpleTiles, it is possible to use {@link * com.smartgwt.client.widgets.viewer.DetailViewerField#getCellStyle} and {@link * com.smartgwt.client.widgets.StatefulCanvas#getStateSuffix} to make a single field statefully styled: <pre> * isc.TileGrid.create({ fields:[ {name:'animalName' getCellStyle : function (value, field, * record, viewer) { if (value == "Tiger") return "tigerStyle" + * viewer.currentTile.getStateSuffix(); else return view.tileGrid.tileValueStyle + * viewer.currentTile.getStateSuffix(); } } ] }); </pre> * * @param fields fields Default value is null * @throws IllegalStateException this property cannot be changed after the component has been created */ public void setFields(DetailViewerField... fields) throws IllegalStateException { setAttribute("fields", fields, false); } /** * A List of TileRecord objects, specifying the data to be used to create the tiles. <p> This property will * typically not be explicitly specified for databound TileGrids, where the data is returned from the server via * databound component methods such as {@link com.smartgwt.client.widgets.tile.TileGrid#fetchData}. In this case the * data objects will be set to a {@link com.smartgwt.client.data.ResultSet} rather than a simple array. * * @param data data Default value is null */ public void setData(TileRecord[] data) { setAttribute("data", data, true); } /** * An array of Record objects, specifying the data to be used to populate the DataBoundComponent. Note that not * all DataBoundComponents observe the changes to the data to redraw themselves. Refer to the version of setData * that accepts component specific records. * * @param data array of Record objects. * @see #setData(TileRecord[]) */ public void setData(Record[] data) { setAttribute("data", data, true); } /** * An List of Record objects, specifying the data to be used to populate the DataBoundComponent. Note that not * all DataBoundComponents observe the changes to the data to redraw themselves. Refer to the version of setData * that accepts component specific records. * * @param data List of Records */ public void setData(RecordList data) { setAttribute("data", data == null ? null : data.getOrCreateJsObj(), true); } /** * A List of TileRecord objects, specifying the data to be used to create the tiles. * * @return the records in the TileGrid */ public Record[] getData() { JavaScriptObject dataJS = getAttributeAsJavaScriptObject("data"); Record[] data = Record.convertToRecordArray(dataJS); return data; } /** * Return the tileGrid data as a {@link com.smartgwt.client.data.RecordList}. If the component is * bound to a DataSource, * the actual type of the RecordList instance will be a {@link com.smartgwt.client.data.ResultSet}. * * @return the data */ public RecordList getDataAsRecordList() { return getRecordList(); } /** * Perform a DataSource "add" operation to add new records to this component's DataSource. * * @param record new record */ public native void addData(Record record) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordJS = record.@com.smartgwt.client.data.Record::getJsObj()(); self.addData(recordJS); }-*/; /** * Perform a DataSource "add" operation to add new records to this component's DataSource. * * @param record new record * @param callback method to call on operation completion */ public native void addData(Record record, DSCallback callback) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordJS = record.@com.smartgwt.client.data.Record::getJsObj()(); self.addData(recordJS, $entry(function (dsResponse, data, dsRequest) { var responseJ = @com.smartgwt.client.data.DSResponse::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsResponse); var requestJ = @com.smartgwt.client.data.DSRequest::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsRequest); if(callback != null) callback.@com.smartgwt.client.data.DSCallback::execute(Lcom/smartgwt/client/data/DSResponse;Ljava/lang/Object;Lcom/smartgwt/client/data/DSRequest;)(responseJ, data, requestJ); })); }-*/; /** * Perform a DataSource "add" operation to add new records to this component's DataSource. * * @param record new record * @param callback method to call on operation completion * @param requestProperties additional properties to set on the DSRequest * that will be issued */ public native void addData(Record record, DSCallback callback, DSRequest requestProperties) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordJS = record.@com.smartgwt.client.data.Record::getJsObj()(); var requestPropertiesJS = requestProperties == null ? null : requestProperties.@com.smartgwt.client.core.DataClass::getJsObj()(); self.addData(recordJS, $entry(function (dsResponse, data, dsRequest) { var responseJ = @com.smartgwt.client.data.DSResponse::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsResponse); var requestJ = @com.smartgwt.client.data.DSRequest::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsRequest); if(callback != null) callback.@com.smartgwt.client.data.DSCallback::execute(Lcom/smartgwt/client/data/DSResponse;Ljava/lang/Object;Lcom/smartgwt/client/data/DSRequest;)(responseJ, data, requestJ); }), requestPropertiesJS); }-*/; /** * Perform a DataSource "remove" operation to remove records from this component's DataSource. * * @param record primary key values of record to delete, (or complete * record) */ public native void removeData(Record record) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordJS = record.@com.smartgwt.client.data.Record::getJsObj()(); self.removeData(recordJS); }-*/; /** * Perform a DataSource "remove" operation to remove records from this component's DataSource. * * @param record primary key values of record to delete, (or complete * record) * @param callback method to call on operation completion */ public native void removeData(Record record, DSCallback callback) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordJS = record.@com.smartgwt.client.data.Record::getJsObj()(); self.removeData(recordJS, $entry(function (dsResponse, data, dsRequest) { var responseJ = @com.smartgwt.client.data.DSResponse::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsResponse); var requestJ = @com.smartgwt.client.data.DSRequest::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsRequest); if(callback != null) callback.@com.smartgwt.client.data.DSCallback::execute(Lcom/smartgwt/client/data/DSResponse;Ljava/lang/Object;Lcom/smartgwt/client/data/DSRequest;)(responseJ, data, requestJ); })); }-*/; /** * Perform a DataSource "remove" operation to remove records from this component's DataSource. * * @param record primary key values of record to delete, (or * complete record) * @param callback method to call on operation completion * @param requestProperties additional properties to set on the DSRequest * that will be issued */ public native void removeData(Record record, DSCallback callback, DSRequest requestProperties) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordJS = record.@com.smartgwt.client.data.Record::getJsObj()(); var requestPropertiesJS = requestProperties == null ? null : requestProperties.@com.smartgwt.client.core.DataClass::getJsObj()(); self.removeData(recordJS, $entry(function (dsResponse, data, dsRequest) { var responseJ = @com.smartgwt.client.data.DSResponse::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsResponse); var requestJ = @com.smartgwt.client.data.DSRequest::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsRequest); if(callback != null) callback.@com.smartgwt.client.data.DSCallback::execute(Lcom/smartgwt/client/data/DSResponse;Ljava/lang/Object;Lcom/smartgwt/client/data/DSRequest;)(responseJ, data, requestJ); }), requestPropertiesJS); }-*/; /** * Sort data by property. * * @param property property * @param ascending direction */ public native void sortByProperty(String property, boolean ascending) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.data.sortByProperty(property, ascending); }-*/; /** * Remove the currently selected records from this component. If this is a databound grid, the records will be removed directly from the DataSource. <P> If no records are selected, no action is taken. The grid will automatically be updated if the record deletion succeeds. */ public native void removeSelectedData() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.removeSelectedData(); }-*/; /** * Returns all selected records, as an Array. * * @return list of records, empty list if nothing selected */ public native Record[] getSelection() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var selection = self.getSelection(); return @com.smartgwt.client.data.Record::convertToRecordArray(Lcom/google/gwt/core/client/JavaScriptObject;)(selection); }-*/; // ********************* DataBoundComponent Properties / Attributes *********************** public void setDataPageSize(int dataPageSize) { setAttribute("dataPageSize", dataPageSize, true); } public int getDataPageSize() { return getAttributeAsInt("dataPageSize"); } public void setUseAllDataSourceFields(Boolean useAllDataSourceFields) { setAttribute("useAllDataSourceFields", useAllDataSourceFields, true); } public Boolean getUseAllDataSourceFields() { return getAttributeAsBoolean("useAllDataSourceFields"); } public void setShowHiddenFields(Boolean showHiddenFields) { setAttribute("showHiddenFields", showHiddenFields, true); } public Boolean getShowHiddenFields() { return getAttributeAsBoolean("showHiddenFields"); } public void setShowComplexFields(Boolean showComplexFields) { setAttribute("showComplexFields", showComplexFields, true); } public Boolean getShowComplexFields() { return getAttributeAsBoolean("showComplexFields"); } public void setFetchOperation(String fetchOperation) { setAttribute("fetchOperation", fetchOperation, true); } public String getFetchOperation() { return getAttributeAsString("fetchOperation"); } public void setUpdateOperation(String updateOperation) { setAttribute("updateOperation", updateOperation, true); } public String getUpdateOperation() { return getAttributeAsString("updateOperation"); } public void setAddOperation(String addOperation) { setAttribute("addOperation", addOperation, true); } public String getAddOperation() { return getAttributeAsString("addOperation"); } public void setRemoveOperation(String removeOperation) { setAttribute("removeOperation", removeOperation, true); } public String getRemoveOperation() { return getAttributeAsString("removeOperation"); } public void setExportFields(String[] exportFields) { setAttribute("exportFields", exportFields, true); } public String[] getExportFields() { return getAttributeAsStringArray("exportFields"); } public void setExportAll(Boolean exportAll) { setAttribute("exportAll", exportAll, true); } public Boolean getExportAll() { return getAttributeAsBoolean("exportAll"); } public void setPreventDuplicates(Boolean preventDuplicates) throws IllegalStateException { setAttribute("preventDuplicates", preventDuplicates, false); } public Boolean getPreventDuplicates() { return getAttributeAsBoolean("preventDuplicates"); } public void setDuplicateDragMessage(String duplicateDragMessage) throws IllegalStateException { setAttribute("duplicateDragMessage", duplicateDragMessage, false); } public String getDuplicateDragMessage() { return getAttributeAsString("duplicateDragMessage"); } public void setAddDropValues(Boolean addDropValues) { setAttribute("addDropValues", addDropValues, true); } public Boolean getAddDropValues() { return getAttributeAsBoolean("addDropValues"); } public void setDropValues(Map dropValues) { setAttribute("dropValues", dropValues, true); } public Map getDropValues() { return getAttributeAsMap("dropValues"); } public void setUseFlatFields(Boolean useFlatFields) throws IllegalStateException { setAttribute("useFlatFields", useFlatFields, false); } public Boolean getUseFlatFields() { return getAttributeAsBoolean("useFlatFields"); } public void setHiliteProperty(String hiliteProperty) { setAttribute("hiliteProperty", hiliteProperty, true); } public String getHiliteProperty() { return getAttributeAsString("hiliteProperty"); } /** * Shows a HiliteEditor interface allowing end-users to edit the data-hilites currently in use by this DataBoundComponent. */ public native void editHilites() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.editHilites(); }-*/; /** * Get the current hilites encoded as a String, for saving. * * @return the hilite state */ public native String getHiliteState() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); return self.getHiliteState(); }-*/; /** * Set the current hilites based on a hiliteState String previously returned from getHilitesState. * * @param hiliteState hilites state encoded as a String */ public native void setHiliteState(String hiliteState) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); return self.setHiliteState(hiliteState); }-*/; /** * Accepts an array of hilite objects and applies them to this DataBoundComponent. See also {@link #getHilites() getHilites} for a method of * retrieving the hilite array for storage, including hilites manually added by the user. * * @param hilites array of hilite objects */ public native void setHilites(Hilite[] hilites)/*-{ var isCreated = this.@com.smartgwt.client.widgets.BaseWidget::isCreated()(); var hilitesJS = @com.smartgwt.client.util.JSOHelper::convertToJavaScriptArray([Ljava/lang/Object;)(hilites); if (isCreated) { var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.setHilites(hilitesJS); } else { var obj = this.@com.smartgwt.client.widgets.BaseWidget::getConfig()(); obj.hilites = hilitesJS; } }-*/; /** * Return the set of hilite-objects currently applied to this DataBoundComponent. These can be saved for * storage and then restored to a component later via setHilites(). * * @return array of hilite objects */ public native Hilite[] getHilites()/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var hilitesJS = self.getHilites(); return @com.smartgwt.client.data.Hilite::convertToHiliteArray(Lcom/google/gwt/core/client/JavaScriptObject;)(hilitesJS); }-*/; public void setDragDataAction(DragDataAction dragDataAction) { setAttribute("dragDataAction", dragDataAction.getValue(), true); } public DragDataAction getDragDataAction() { return EnumUtil.getEnum(DragDataAction.values(), getAttribute("dragDataAction")); } public void setDragTrackerStyle(String dragTrackerStyle) { setAttribute("dragTrackerStyle", dragTrackerStyle, true); } public String getDragTrackerStyle() { return getAttributeAsString("dragTrackerStyle"); } public void setCanAddFormulaFields(Boolean canAddFormulaFields) { setAttribute("canAddFormulaFields", canAddFormulaFields, true); } public native void addSummaryField() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.addSummaryField(); }-*/; public native void addFormulaField() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.addFormulaField(); }-*/; public Boolean getCanAddFormulaFields() { return getAttributeAsBoolean("canAddFormulaFields"); } public void setAddFormulaFieldText(String addFormulaFieldText) { setAttribute("addFormulaFieldText", addFormulaFieldText, true); } public String getAddFormulaFieldText() { return getAttributeAsString("addFormulaFieldText"); } public void setEditFormulaFieldText(String editFormulaFieldText) { setAttribute("editFormulaFieldText", editFormulaFieldText, true); } public String getEditFormulaFieldText() { return getAttributeAsString("editFormulaFieldText"); } public void setCanAddSummaryFields(Boolean canAddSummaryFields) { setAttribute("canAddSummaryFields", canAddSummaryFields, true); } public Boolean getCanAddSummaryFields() { return getAttributeAsBoolean("canAddSummaryFields"); } public void setAddSummaryFieldText(String addSummaryFieldText) { setAttribute("addSummaryFieldText", addSummaryFieldText, true); } public String getAddSummaryFieldText() { return getAttributeAsString("addSummaryFieldText"); } public void setEditSummaryFieldText(String editSummaryFieldText) { setAttribute("editSummaryFieldText", editSummaryFieldText, true); } public String getEditSummaryFieldText() { return getAttributeAsString("editSummaryFieldText"); } // ********************* Methods *********************** public native void selectRecord(Record record)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordJS = record.@com.smartgwt.client.data.Record::getJsObj()(); self.selectRecord(recordJS); }-*/; public native void selectRecord(int record)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.selectRecord(record); }-*/; public native void selectRecord(int record, boolean newState)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.selectRecord(record, newState); }-*/; public native void selectRecord(Record record, boolean newState)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordJS = record.@com.smartgwt.client.data.Record::getJsObj()(); self.selectRecord(recordJS, newState); }-*/; public native void selectRecords(int[] records)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordsJS = @com.smartgwt.client.util.JSOHelper::convertToJavaScriptArray([I)(records); self.selectRecord(recordsJS); }-*/; public native void selectRecords(int[] records, boolean newState)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordsJS = @com.smartgwt.client.util.JSOHelper::convertToJavaScriptArray([I)(records); self.selectRecords(recordsJS, newState); }-*/; public native void selectRecords(Record[] records)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordsJS = @com.smartgwt.client.util.JSOHelper::convertToJavaScriptArray([Ljava/lang/Object;)(records); self.selectRecords(recordsJS); }-*/; public native void selectRecords(Record[] records, boolean newState)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordsJS = @com.smartgwt.client.util.JSOHelper::convertToJavaScriptArray([Ljava/lang/Object;)(records); self.selectRecords(recordsJS, newState); }-*/; public native void deselectRecord(Record record)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordJS = record.@com.smartgwt.client.data.Record::getJsObj()(); self.deselectRecord(recordJS); }-*/; public native void deselectRecord(int record)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.deselectRecord(record); }-*/; public native void deselectRecords(int[] records)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordsJS = @com.smartgwt.client.util.JSOHelper::convertToJavaScriptArray([I)(records); self.deselectRecords(recordsJS); }-*/; public native void deselectRecords(Record[] records)/*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordsJS = @com.smartgwt.client.util.JSOHelper::convertToJavaScriptArray([Ljava/lang/Object;)(records); self.deselectRecords(recordsJS); }-*/; public native void selectAllRecords() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.selectAllRecords(); }-*/; public native void deselectAllRecords() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.deselectAllRecords(); }-*/; public native Boolean anySelected() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var retVal =self.anySelected(); if(retVal == null || retVal === undefined) { return null; } else { return @com.smartgwt.client.util.JSOHelper::toBoolean(Z)(retVal); } }-*/; public native void enableHilite(String hiliteID) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.enableHilite(hiliteID); }-*/; public native void enableHilite(String hiliteID, boolean enable) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.enableHilite(hiliteID, enable); }-*/; public native void disableHilite(String hiliteID) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.disableHilite(hiliteID); }-*/; public native void enableHiliting() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.enableHiliting(); }-*/; public native void enableHiliting(boolean enable) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.enableHiliting(enable); }-*/; public native void disableHiliting() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.disableHiliting(); }-*/; public native Record[] getDragData() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var recordsJS = self.getDragData(); return @com.smartgwt.client.data.Record::convertToRecordArray(Lcom/google/gwt/core/client/JavaScriptObject;)(recordsJS); }-*/; public native void transferSelectedData(DataBoundComponent source) /*-{ var self = this.@com.smartgwt.client.widgets.DataBoundComponent::getOrCreateJsObj()(); self.transferSelectedData(source.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()()); }-*/; public native void transferSelectedData(DataBoundComponent source, int index) /*-{ var self = this.@com.smartgwt.client.widgets.DataBoundComponent::getOrCreateJsObj()(); self.transferSelectedData(source.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(), index); }-*/; public native int getRecordIndex(Record record) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); return self.getRecordIndex(record.@com.smartgwt.client.core.DataClass::getJsObj()()); }-*/; public native String getTitleFieldValue(Record record) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); return self.getTitleFieldValue(record); }-*/; public void setTitleField(String titleField) { setAttribute("titleField", titleField, true); } public String getTitleField() { return getAttributeAsString("titleField"); } public void setDataSource(DataSource dataSource) { setAttribute("dataSource", dataSource.getOrCreateJsObj(), true); } public DataSource getDataSource() { return DataSource.getOrCreateRef(getAttributeAsJavaScriptObject("dataSource")); } public void setAutoFetchData(Boolean autoFetchData) throws IllegalStateException { setAttribute("autoFetchData", autoFetchData, false); } public Boolean getAutoFetchData() { return getAttributeAsBoolean("autoFetchData"); } public void setAutoFetchAsFilter(Boolean autoFetchAsFilter) throws IllegalStateException { setAttribute("autoFetchAsFilter", autoFetchAsFilter, false); } public Boolean getAutoFetchAsFilter() { return getAttributeAsBoolean("autoFetchAsFilter"); } public void setInitialCriteria(Criteria initialCriteria) throws IllegalStateException { setAttribute("initialCriteria", initialCriteria.getJsObj(), false); } public Criteria getInitialCriteria() { return new Criteria(getAttributeAsJavaScriptObject("initialCriteria")); } public native void fetchData() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.fetchData(); }-*/; public native void fetchData(Criteria criteria) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.fetchData(criteria == null ? null : criteria.@com.smartgwt.client.data.Criteria::getJsObj()()); }-*/; public native void fetchData(Criteria criteria, DSCallback callback) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var critJS = criteria == null ? null : criteria.@com.smartgwt.client.data.Criteria::getJsObj()(); self.fetchData(critJS, $entry(function (dsResponse, data, dsRequest) { var responseJ = @com.smartgwt.client.data.DSResponse::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsResponse); var requestJ = @com.smartgwt.client.data.DSRequest::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsRequest); if(callback != null) callback.@com.smartgwt.client.data.DSCallback::execute(Lcom/smartgwt/client/data/DSResponse;Ljava/lang/Object;Lcom/smartgwt/client/data/DSRequest;)(responseJ, data, requestJ); })); }-*/; public native void fetchData(Criteria criteria, DSCallback callback, DSRequest requestProperties) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var critJS = criteria == null ? null : criteria.@com.smartgwt.client.data.Criteria::getJsObj()(); var requestPropertiesJS = requestProperties == null ? null : requestProperties.@com.smartgwt.client.core.DataClass::getJsObj()(); self.fetchData(critJS, $entry(function (dsResponse, data, dsRequest) { var responseJ = @com.smartgwt.client.data.DSResponse::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsResponse); var requestJ = @com.smartgwt.client.data.DSRequest::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsRequest); if(callback != null) callback.@com.smartgwt.client.data.DSCallback::execute(Lcom/smartgwt/client/data/DSResponse;Ljava/lang/Object;Lcom/smartgwt/client/data/DSRequest;)(responseJ, data, requestJ); }), requestPropertiesJS); }-*/; public native void filterData() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.filterData(); }-*/; public native void filterData(Criteria criteria) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.filterData(criteria == null ? null : criteria.@com.smartgwt.client.data.Criteria::getJsObj()()); }-*/; public native void filterData(Criteria criteria, DSCallback callback) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var critJS = criteria == null ? null : criteria.@com.smartgwt.client.data.Criteria::getJsObj()(); self.filterData(critJS, $entry(function (dsResponse, data, dsRequest) { var responseJ = @com.smartgwt.client.data.DSResponse::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsResponse); var requestJ = @com.smartgwt.client.data.DSRequest::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsRequest); if(callback != null) callback.@com.smartgwt.client.data.DSCallback::execute(Lcom/smartgwt/client/data/DSResponse;Ljava/lang/Object;Lcom/smartgwt/client/data/DSRequest;)(responseJ, data, requestJ); })); }-*/; public native void filterData(Criteria criteria, DSCallback callback, DSRequest requestProperties) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); var critJS = criteria == null ? null : criteria.@com.smartgwt.client.data.Criteria::getJsObj()(); var requestPropertiesJS = requestProperties == null ? null : requestProperties.@com.smartgwt.client.core.DataClass::getJsObj()(); self.filterData(critJS, $entry(function (dsResponse, data, dsRequest) { var responseJ = @com.smartgwt.client.data.DSResponse::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsResponse); var requestJ = @com.smartgwt.client.data.DSRequest::new(Lcom/google/gwt/core/client/JavaScriptObject;)(dsRequest); if(callback != null) callback.@com.smartgwt.client.data.DSCallback::execute(Lcom/smartgwt/client/data/DSResponse;Ljava/lang/Object;Lcom/smartgwt/client/data/DSRequest;)(responseJ, data, requestJ); }), requestPropertiesJS); }-*/; public native void invalidateCache() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.invalidateCache(); }-*/; public ResultSet getResultSet() { JavaScriptObject dataJS = getAttributeAsJavaScriptObject("data"); if(dataJS == null) return null; if(!ResultSet.isResultSet(dataJS)) { SC.logWarn("getResultSet(): data is not a ResultSet; returning null " + "(if grouped, use getOriginalResultSet(); if unbound, use getRecordList(); " + "can only be called on DataBoundComponents after initial data has been fetched)"); return null; } return new ResultSet(dataJS); } public RecordList getRecordList() { JavaScriptObject dataJS = getAttributeAsJavaScriptObject("data"); if(dataJS == null) return null; if(ResultSet.isResultSet(dataJS)) { return getResultSet(); } return new RecordList(dataJS); } /** * Uses a "fetch" operation on the current {@link com.smartgwt.client.widgets.DataBoundComponent#getDataSource DataSource} * to retrieve data that matches the current filter and sort criteria for this component, then exports the resulting data * to a file or window in the requested format. <P> A variety of DSRequest settings, such as {@link * com.smartgwt.client.data.DSRequest#getExportAs exportAs} and {@link com.smartgwt.client.data.DSRequest#getExportFilename * exportFilename}, affect the exporting process: see {@link com.smartgwt.client.data.DSRequest#getExportResults * exportResults} for further detail. <P> Note that data exported via this method does not include any client-side * formatting and relies on both the Smart GWT server and server-side DataSources. To export client-data with formatters * applied, see {@link com.smartgwt.client.widgets.DataBoundComponent#exportClientData exportClientData}, which still * requires the Smart GWT server but does not rely on server-side DataSources. <P> For more information on exporting data, * see {@link com.smartgwt.client.data.DataSource#exportData DataSource.exportData}. */ public native void exportData() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.exportData(); }-*/; /** * Uses a "fetch" operation on the current {@link com.smartgwt.client.widgets.DataBoundComponent#getDataSource DataSource} * to retrieve data that matches the current filter and sort criteria for this component, then exports the resulting data * to a file or window in the requested format. <P> A variety of DSRequest settings, such as {@link * com.smartgwt.client.data.DSRequest#getExportAs exportAs} and {@link com.smartgwt.client.data.DSRequest#getExportFilename * exportFilename}, affect the exporting process: see {@link com.smartgwt.client.data.DSRequest#getExportResults * exportResults} for further detail. <P> Note that data exported via this method does not include any client-side * formatting and relies on both the Smart GWT server and server-side DataSources. To export client-data with formatters * applied, see {@link com.smartgwt.client.widgets.DataBoundComponent#exportClientData exportClientData}, which still * requires the Smart GWT server but does not rely on server-side DataSources. <P> For more information on exporting data, * see {@link com.smartgwt.client.data.DataSource#exportData DataSource.exportData}. * @param requestProperties additional properties to set on the DSRequest that will be issued * @see com.smartgwt.client.docs.DataBoundComponentMethods DataBoundComponentMethods overview and related methods */ public native void exportData(DSRequest requestProperties) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.exportData(requestProperties.@com.smartgwt.client.core.DataClass::getJsObj()()); }-*/; /** * Exports this component's data with client-side formatters applied, so is suitable for * direct display to users. This feature requires the SmartClient server, but does not * rely on any server-side DataSources. * <P>To export unformatted data from this component's dataSource, see * {@link com.smartgwt.client.widgets.DataBoundComponent#exportData exportData} * which does not include client-side formatters, * but relies on both the SmartClient server and server-side DataSources. * @see com.smartgwt.client.data.DataSource#exportClientData */ public native void exportClientData() /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.exportClientData(); }-*/; /** * Exports this component's data with client-side formatters applied, so is suitable for * direct display to users. This feature requires the SmartClient server, but does not * rely on any server-side DataSources. * <P>To export unformatted data from this component's dataSource, see * {@link com.smartgwt.client.widgets.DataBoundComponent#exportData exportData} * which does not include client-side formatters, * but relies on both the SmartClient server and server-side DataSources. * @param requestProperties Request properties for the export * @see com.smartgwt.client.data.DataSource#exportClientData */ public native void exportClientData(DSRequest requestProperties) /*-{ var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()(); self.exportClientData(requestProperties.@com.smartgwt.client.core.DataClass::getJsObj()()); }-*/; /** * Add a fetchData handler. * <p> * Notification function fired on fetchData() or filterData() * * @param handler the filterData handler * @return {@link com.google.gwt.event.shared.HandlerRegistration} used to remove this handler */ public HandlerRegistration addFetchDataHandler(FetchDataHandler handler) { if(getHandlerCount(FetchDataEvent.getType()) == 0) setupFetchDataEvent(); return doAddHandler(handler, FetchDataEvent.getType()); } private native void setupFetchDataEvent() /*-{ var obj = null; var selfJ = this; if(this.@com.smartgwt.client.widgets.BaseWidget::isCreated()()) { obj = this.@com.smartgwt.client.widgets.BaseWidget::getJsObj()(); obj.addProperties({onFetchData:$debox($entry(function(){ var param = {"criteria" : arguments[0], "requestProperties" : arguments[1]}; var event = @com.smartgwt.client.widgets.events.FetchDataEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); })) }); } else { obj = this.@com.smartgwt.client.widgets.BaseWidget::getConfig()(); obj.onFetchData = $debox($entry(function(){ var param = {"criteria" : arguments[0], "requestProperties" : arguments[1]}; var event = @com.smartgwt.client.widgets.events.FetchDataEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); })); } }-*/; /** * Add a {@link com.smartgwt.client.widgets.DropCompleteHandler}. See that class's documentation for a definition of "drop complete", * and how it differs from "drag complete" ({@link com.smartgwt.client.widgets.DragCompleteHandler}). * * @param handler the DropCompleteHandler * @return {@link com.google.gwt.event.shared.HandlerRegistration} used to remove this handler */ public HandlerRegistration addDropCompleteHandler(DropCompleteHandler handler) { if(getHandlerCount(DropCompleteEvent.getType()) == 0) setupDropCompleteEvent(); return doAddHandler(handler, DropCompleteEvent.getType()); } private native void setupDropCompleteEvent() /*-{ var obj = null; var selfJ = this; if(this.@com.smartgwt.client.widgets.BaseWidget::isCreated()()) { obj = this.@com.smartgwt.client.widgets.BaseWidget::getJsObj()(); obj.addProperties({dropComplete:$debox($entry(function(){ var param = {"transferredRecords" : arguments[0]}; var event = @com.smartgwt.client.widgets.events.DropCompleteEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); })) }); } else { obj = this.@com.smartgwt.client.widgets.BaseWidget::getConfig()(); obj.dropComplete = $debox($entry(function(){ var param = {"transferredRecords" : arguments[0]}; var event = @com.smartgwt.client.widgets.events.DropCompleteEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(param); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); })); } }-*/; /** * Add a {@link com.smartgwt.client.widgets.DragCompleteHandler}. See that class's documentation for a definition of "drag complete", * and how it differs from "drop complete" ({@link com.smartgwt.client.widgets.DropCompleteHandler}). * * @param handler the DropCompleteHandler * @return {@link com.google.gwt.event.shared.HandlerRegistration} used to remove this handler */ public HandlerRegistration addDragCompleteHandler(DragCompleteHandler handler) { if(getHandlerCount(DragCompleteEvent.getType()) == 0) setupDragCompleteEvent(); return doAddHandler(handler, DragCompleteEvent.getType()); } private native void setupDragCompleteEvent() /*-{ var obj = null; var selfJ = this; if(this.@com.smartgwt.client.widgets.BaseWidget::isCreated()()) { obj = this.@com.smartgwt.client.widgets.BaseWidget::getJsObj()(); obj.addProperties({dragComplete:$debox($entry(function(){ var event = @com.smartgwt.client.widgets.events.DragCompleteEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); })) }); } else { obj = this.@com.smartgwt.client.widgets.BaseWidget::getConfig()(); obj.dragComplete = $debox($entry(function(){ var event = @com.smartgwt.client.widgets.events.DragCompleteEvent::new(Lcom/google/gwt/core/client/JavaScriptObject;)(); selfJ.@com.smartgwt.client.widgets.BaseWidget::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event); })); } }-*/; }