Search in sources :

Example 1 with ImprovedCellTreeGridSelectionModel

use of org.activityinfo.client.page.common.grid.ImprovedCellTreeGridSelectionModel in project activityinfo by bedatadriven.

the class DesignView method createGridAndAddToContainer.

@Override
protected Grid<ModelData> createGridAndAddToContainer(Store store) {
    final TreeStore treeStore = (TreeStore) store;
    tree = new EditorTreeGrid<ModelData>(treeStore, createColumnModel());
    tree.setSelectionModel(new ImprovedCellTreeGridSelectionModel<ModelData>());
    tree.setClicksToEdit(EditorGrid.ClicksToEdit.TWO);
    tree.setAutoExpandColumn("name");
    tree.setHideHeaders(true);
    tree.setLoadMask(true);
    // tree.setContextMenu(createContextMenu());
    tree.setIconProvider(new ModelIconProvider<ModelData>() {

        @Override
        public AbstractImagePrototype getIcon(ModelData model) {
            if (model instanceof ActivityDTO) {
                return IconImageBundle.ICONS.activity();
            } else if (model instanceof Folder) {
                return GXT.IMAGES.tree_folder_closed();
            } else if (model instanceof AttributeGroupDTO) {
                return IconImageBundle.ICONS.attributeGroup();
            } else if (model instanceof AttributeDTO) {
                return IconImageBundle.ICONS.attribute();
            } else if (model instanceof IndicatorDTO) {
                return IconImageBundle.ICONS.indicator();
            } else {
                return null;
            }
        }
    });
    tree.addListener(Events.CellClick, new Listener<GridEvent>() {

        @Override
        public void handleEvent(GridEvent ge) {
            showForm(tree.getStore().getAt(ge.getRowIndex()));
        }
    });
    add(tree, new BorderLayoutData(Style.LayoutRegion.CENTER));
    TreeGridDragSource source = new TreeGridDragSource(tree);
    source.addDNDListener(new DNDListener() {

        @Override
        public void dragStart(DNDEvent e) {
            ModelData sel = ((CellTreeGridSelectionModel) tree.getSelectionModel()).getSelectCell().model;
            if (!db.isDesignAllowed() || sel == null || sel instanceof Folder) {
                e.setCancelled(true);
                e.getStatus().setStatus(false);
                return;
            }
            super.dragStart(e);
        }
    });
    TreeGridDropTarget target = new TreeGridDropTarget(tree);
    target.setAllowSelfAsSource(true);
    target.setFeedback(DND.Feedback.BOTH);
    target.setAutoExpand(false);
    target.addDNDListener(new DragDropListener(treeStore));
    return tree;
}
Also used : AbstractImagePrototype(com.google.gwt.user.client.ui.AbstractImagePrototype) TreeGridDragSource(com.extjs.gxt.ui.client.dnd.TreeGridDragSource) ModelData(com.extjs.gxt.ui.client.data.ModelData) AttributeGroupDTO(org.activityinfo.shared.dto.AttributeGroupDTO) GridEvent(com.extjs.gxt.ui.client.event.GridEvent) DNDEvent(com.extjs.gxt.ui.client.event.DNDEvent) BorderLayoutData(com.extjs.gxt.ui.client.widget.layout.BorderLayoutData) DNDListener(com.extjs.gxt.ui.client.event.DNDListener) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) TreeGridDropTarget(com.extjs.gxt.ui.client.dnd.TreeGridDropTarget) AttributeDTO(org.activityinfo.shared.dto.AttributeDTO) TreeStore(com.extjs.gxt.ui.client.store.TreeStore) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) CellTreeGridSelectionModel(com.extjs.gxt.ui.client.widget.treegrid.CellTreeGridSelectionModel) ImprovedCellTreeGridSelectionModel(org.activityinfo.client.page.common.grid.ImprovedCellTreeGridSelectionModel)

Aggregations

ModelData (com.extjs.gxt.ui.client.data.ModelData)1 TreeGridDragSource (com.extjs.gxt.ui.client.dnd.TreeGridDragSource)1 TreeGridDropTarget (com.extjs.gxt.ui.client.dnd.TreeGridDropTarget)1 DNDEvent (com.extjs.gxt.ui.client.event.DNDEvent)1 DNDListener (com.extjs.gxt.ui.client.event.DNDListener)1 GridEvent (com.extjs.gxt.ui.client.event.GridEvent)1 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)1 BorderLayoutData (com.extjs.gxt.ui.client.widget.layout.BorderLayoutData)1 CellTreeGridSelectionModel (com.extjs.gxt.ui.client.widget.treegrid.CellTreeGridSelectionModel)1 AbstractImagePrototype (com.google.gwt.user.client.ui.AbstractImagePrototype)1 ImprovedCellTreeGridSelectionModel (org.activityinfo.client.page.common.grid.ImprovedCellTreeGridSelectionModel)1 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)1 AttributeDTO (org.activityinfo.shared.dto.AttributeDTO)1 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)1 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)1