PDA

View Full Version : Unable to drag & drop into EditorTreeGrid after removing elements



shroom
11 Sep 2009, 1:30 AM
I have two components on my panel: ListView containing elements to drag and EditorTreeGrid to create tree structure from elements dragged from ListView. You can also remove elements from EditorTreeGrid and they go back to list. But when I remove parent element, I can no longer drag new elements into the TreeGrid. Everything works fine when I delete only leaves.
Here's the code I use to create list:

this.view = new ListView<ModelData>();
view.setBorders(false);
view.setStore(listStore);
view.setDisplayProperty("displayName");
view.disable();
new ListViewDragSource(view);
And here's the code I use to create EditorTreeGrid:

this.treeStore = new TreeStore<ModelData>();
this.treeStore.addListener(Store.Remove, new Listener<TreeStoreEvent<ModelData>>() {

public void handleEvent(TreeStoreEvent<ModelData> be) {
listStore.add(be.getModel());
for (ModelData m : be.getChildren()) {
listStore.add(m);
}
listStore.commitChanges();
}
});
ComboBox<PositionDTO> comboPosition = new ComboBox<PositionDTO>();
comboPosition.setTriggerAction(TriggerAction.ALL);
comboPosition.setStore(listPositions);
comboPosition.setDisplayField("name");
comboPosition.setEditable(false);

ColumnConfig name = new ColumnConfig("displayName", "Structure", 184);
ColumnConfig position = new ColumnConfig("position", "Position", 184);
ColumnConfig button = new ColumnConfig("id", "", 32);
final ColumnModel cm = new ColumnModel(Arrays.asList(name, position, button));
GridCellRenderer<ModelData> buttonRenderer = new GridCellRenderer<ModelData>() {

public Object render(final ModelData model, String property,
com.extjs.gxt.ui.client.widget.grid.ColumnData config, final int rowIndex,
int colIndex, final ListStore<ModelData> store, Grid<ModelData> grid) {
IconButton buttonRemove = new IconButton("icon-delete");
buttonRemove.addSelectionListener(new SelectionListener<IconButtonEvent>() {

@Override
public void componentSelected(IconButtonEvent ce) {
treeStore.remove(model);
treeStore.commitChanges();
}

});

return buttonRemove;
}
};
name.setRenderer(new TreeGridCellRenderer<ModelData>());
position.setEditor(new CellEditor(comboPosition));
button.setRenderer(buttonRenderer);

tree = new EditorTreeGrid<ModelData>(treeStore, cm) {
@Override
protected boolean hasChildren(ModelData model) {
return true;
}
};
tree.setBorders(false);
tree.setSize(400, 400);
tree.setAutoExpandColumn("displayName");
tree.setTrackMouseOver(false);
tree.getView().setShowDirtyCells(false);

new TreeGridDropTarget(tree);

Here's how it looks (the tooltip doesn't change and I'm unable to drop the element into TreeGrid - as soon as the cursor enters the TreeGrid area the tooltip stops, sorry for the erased user data I hope it doesn't make this unreadable):
http://imgur.com/cMDp0.png

I tried to look into it and here's what I've found out:
1. OnDragEnter is fired as usual in TreeGridDropTarget.
2. OnDragMove ia also fired as usual and after that I get series of invocations of other methods which end in showFeedback in class TreeGridDropTarget.
3. And that's where I get the exception... Sort of... Because this exception isn't displayed in console or in server log, I found it during debug:


com.google.gwt.core.client.JavaScriptException: (TypeError): Result of expression 'dom' [null] is not an object.
line: 1941
sourceId: 1027880400
sourceURL: jar:file:/Users/Mat/Documents/Projects/Testee/war/WEB-INF/lib/gxt.jar!/com/extjs/gxt/ui/client/core/El.java
expressionBeginOffset: 280
expressionCaretOffset: 283
expressionEndOffset: 293


TypeError: Result of expression 'dom' [null] is not an object.
com.extjs.gxt.ui.client.core.El.removeStyleName(Native Method), com.extjs.gxt.ui.client.dnd.TreeGridDropTarget.clearStyle(TreeGridDropTarget.java:160), com.extjs.gxt.ui.client.dnd.TreeGridDropTarget.showFeedback(TreeGridDropTarget.java:336), com.extjs.gxt.ui.client.dnd.DNDManager.handleDragMove(DNDManager.java:69), com.extjs.gxt.ui.client.dnd.DragSource.onDraggableDragMove(DragSource.java:290), com.extjs.gxt.ui.client.dnd.DragSource.access$2(DragSource.java:281), com.extjs.gxt.ui.client.dnd.DragSource$1.dragMove(DragSource.java:104), com.extjs.gxt.ui.client.event.DragListener.handleEvent(DragListener.java:23), com.extjs.gxt.ui.client.event.DragListener.handleEvent(DragListener.java:1), com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:176), com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:96), com.extjs.gxt.ui.client.fx.Draggable.onMouseMove(Draggable.java:594), com.extjs.gxt.ui.client.fx.Draggable$2.onPreview(Draggable.java:147), com.extjs.gxt.ui.client.util.BaseEventPreview.onPreviewNativeEvent(BaseEventPreview.java:145), com.google.gwt.user.client.Event$NativePreviewEvent.dispatch(Event.java:181), com.google.gwt.user.client.Event$NativePreviewEvent.dispatch(Event.java:1), com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:60), com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53), com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178), com.google.gwt.user.client.Event$NativePreviewEvent.fire(Event.java:80), com.google.gwt.user.client.Event$NativePreviewEvent.access$4(Event.java:73), com.google.gwt.user.client.Event$.fireNativePreviewEvent(Event.java:412), com.google.gwt.user.client.DOM.previewEvent(DOM.java:1284)

I think I'm doing everything right because it works fine until I delete something with children (it doesn't have to be a root node). Thanks for your help.

shroom
16 Sep 2009, 5:41 AM
Fixed it myself. I don't know whether it's a good solution but it works. I release TreeGridDropTarget after user removes something from the tree and then I create a new one.

sven
16 Sep 2009, 5:44 AM
This issue got alreadz fixed in SVN and is part of the next release.

mariusz.pala
16 Sep 2009, 5:45 AM
I had similar issue, it's fixed in SVN.
http://www.extjs.com/forum/showthread.php?t=80357