com.extjs.gxt.ui.client.widget.treegrid.EditorTreeGrid Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gxt Show documentation
Show all versions of gxt Show documentation
Rich Internet Application Framework for GWT
/*
* Sencha GXT 2.3.1a - Sencha for GWT
* Copyright(c) 2007-2013, Sencha, Inc.
* [email protected]
*
* http://www.sencha.com/products/gxt/license/
*/
package com.extjs.gxt.ui.client.widget.treegrid;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.EditorGrid.ClicksToEdit;
import com.google.gwt.user.client.Element;
/**
* Adds editing capabilities to TreeGrid.
*
*
* - Events:
*
* - BeforeEdit : GridEvent(grid, record, property, value, rowIndex,
* colIndex)
* Fires before cell editing is triggered. Listeners can cancel the action
* by calling {@link BaseEvent#setCancelled(boolean)}.
*
* - grid : this
* - record : the record being edited
* - property : the property being edited
* - value : the value being edited
* - rowIndex : the current row
* - colIndex : the current column
*
*
*
* - AfterEdit : GridEvent(grid, record, property, value, startValue,
* rowIndex, colIndex)
* Fires after a cell is edited.
*
* - grid : this
* - record : the record being edited
* - property : the property being edited
* - value : the value being set
* - startValue : the value before the edit
* - rowIndex : the current row
* - colIndex : the current column
*
*
*
* - ValidateEdit : GridEvent(grid, record, property, value,
* startValue, rowIndex, colIndex)
* Fires right before the record is updated. Listeners can cancel the
* action by calling {@link BaseEvent#setCancelled(boolean)}.
*
* - grid : this
* - record : the record being edited
* - property : the property being edited
* - value : the value being set
* - startValue : the value before the edit
* - rowIndex : the current row
* - colIndex : the current column
*
*
*
*
*/
public class EditorTreeGrid extends TreeGrid {
@SuppressWarnings("rawtypes")
public EditorTreeGrid(TreeStore store, ColumnModel cm) {
super(store, cm);
setSelectionModel(new CellTreeGridSelectionModel());
setTrackMouseOver(false);
editSupport = getEditSupport();
editSupport.bind(this);
}
/**
* Returns the active editor.
*
* @return the active editor
*/
public CellEditor getActiveEditor() {
return editSupport.getActiveEditor();
}
/**
* Returns the clicks to edit.
*
* @return the clicks to edit
*/
public ClicksToEdit getClicksToEdit() {
return editSupport.getClicksToEdit();
}
/**
* Returns true if editing is active.
*
* @return the editing state
*/
public boolean isEditing() {
return editSupport.isEditing();
}
@Override
public void reconfigure(TreeStore store, ColumnModel cm) {
super.reconfigure(store, cm);
editSupport.bind(this);
}
/**
* Sets the number of clicks to edit (defaults to ONE).
*
* @param clicksToEdit the clicks to edit
*/
public void setClicksToEdit(ClicksToEdit clicksToEdit) {
editSupport.setClicksToEdit(clicksToEdit);
}
/**
* Starts editing the specified for the specified row/column.
*
* @param row the row index
* @param col the column index
*/
public void startEditing(final int row, final int col) {
editSupport.startEditing(row, col);
}
/**
* Stops any active editing.
*/
public void stopEditing() {
editSupport.stopEditing();
}
/**
* Stops any active editing.
*
* @param cancel true to cancel, false to complete
*/
public void stopEditing(boolean cancel) {
editSupport.stopEditing(cancel);
}
@Override
protected void onDoubleClick(GridEvent e) {
if (editSupport.onDoubleClick(e)) {
return;
}
super.onDoubleClick(e);
}
@Override
protected void onRender(Element target, int index) {
super.onRender(target, index);
editSupport.doRender();
}
}