danny.robinson
19 May 2009, 7:14 AM
I have a Tree and it correctly loads a set of BaseTreeModel objects at startup. However, when I try at allow the user to further change the tree by adding/removing items, then these changes don't seem to be reflected when I call store.getModels().get(0)
I setup the tree/store as follows:
store = new TreeStore<FormTreeModel>();
TreeBinder<FormTreeModel> binder = new TreeBinder<FormTreeModel>(tree, store);
binder.setDisplayProperty("id");
binder.setAutoLoad(true);
binder.init();
store.setMonitorChanges(true);
tree.getRootItem().getItem(0).setExpanded(true);
tree.setContextMenu(new BuilderContextMenu(tree, store));
store.add(someBaseTreeModelSubClassAlreadyLoaded, true);
Then through a context menu, I add an item using the following code (or even remove something), it is correctly displayed in the tree on screen.
store.add(item.getModel(), new Section("SECTION"), false);
tree.getSelectionModel().getSelectedItem().setExpanded(true);
However, when I try and retrieve the model from the store and inspect the children
store.getModels().get(0).getChildren()Then the object returned (which is derived from BaseTreeModel) doesn't contain any changes made during editing of the tree. I'm assuming this problem relates to the following javadoc entry, but the doc doesn't indicate how to handle this.
The parent child relationshiops are handled internally by the store. It is important to note that the store does not use the the parent and children of any TreeModel instances added to the store.
I setup the tree/store as follows:
store = new TreeStore<FormTreeModel>();
TreeBinder<FormTreeModel> binder = new TreeBinder<FormTreeModel>(tree, store);
binder.setDisplayProperty("id");
binder.setAutoLoad(true);
binder.init();
store.setMonitorChanges(true);
tree.getRootItem().getItem(0).setExpanded(true);
tree.setContextMenu(new BuilderContextMenu(tree, store));
store.add(someBaseTreeModelSubClassAlreadyLoaded, true);
Then through a context menu, I add an item using the following code (or even remove something), it is correctly displayed in the tree on screen.
store.add(item.getModel(), new Section("SECTION"), false);
tree.getSelectionModel().getSelectedItem().setExpanded(true);
However, when I try and retrieve the model from the store and inspect the children
store.getModels().get(0).getChildren()Then the object returned (which is derived from BaseTreeModel) doesn't contain any changes made during editing of the tree. I'm assuming this problem relates to the following javadoc entry, but the doc doesn't indicate how to handle this.
The parent child relationshiops are handled internally by the store. It is important to note that the store does not use the the parent and children of any TreeModel instances added to the store.