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

com.extjs.gxt.ui.client.widget.treegrid.WidgetTreeGridCellRenderer Maven / Gradle / Ivy

/*
 * 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.store.ListStore;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel.Joint;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Widget;

/**
 * A TreeGridCellRenderer that adds widget support.
 * 
 * @param  the model type
 */
public abstract class WidgetTreeGridCellRenderer extends TreeGridCellRenderer {

  @SuppressWarnings({"unchecked", "rawtypes"})
  public Object render(M model, String property, ColumnData config, int rowIndex, int colIndex, ListStore store,
      Grid grid) {
    config.css = "x-treegrid-column";

    assert grid instanceof TreeGrid : "TreeGridCellRenderer can only be used in a TreeGrid";

    TreeGrid tree = (TreeGrid) grid;
    TreeStore ts = tree.getTreeStore();

    int level = ts.getDepth(model);

    String id = getId(tree, model, property, rowIndex, colIndex);
    String text = getText(tree, model, property, rowIndex, colIndex);
    AbstractImagePrototype icon = calculateIconStyle(tree, model, property, rowIndex, colIndex);
    Joint j = calcualteJoint(tree, model, property, rowIndex, colIndex);

    return tree.getTreeView().getWidgetTemplate(model, id, text, icon, false, j, level - 1);
  }

  public abstract Widget getWidget(M model, String property, ColumnData config, int rowIndex, int colIndex,
      ListStore store, Grid grid);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy