Got it :) The root is a class member and not created in the getObject(..) each time. The TreeModel is class member as well. I also had to removeChildren from the root at the begining of the method.
Eyal Golan egola...@gmail.com Visit: http://jvdrums.sourceforge.net/ LinkedIn: http://www.linkedin.com/in/egolan74 P Save a tree. Please don't print this e-mail unless it's really necessary On Tue, Aug 18, 2009 at 4:55 PM, Eyal Golan <egola...@gmail.com> wrote: > Hello, > I have a wizard that in the last step I show a tree with the selections > made in the previous steps. > The wizard uses static steps so actually the last step is built in advance. > The problem is that the tree is not updated. > > For debugging purposes I have in the last step tables that show the same > selections. > The tables are updated (the DataProvider calls the iterator). I use > DetachableModel for the tables. > > So in short, > How can I updated the model of the tree. > Below is the code of creating the tree that is made in the constructor: > private TreeModel createTreeModel() { > final Profile profile = (Profile) getModelObject(); > final DefaultMutableTreeNode rootNode = new > DefaultMutableTreeNode(); > final ConfigurationsNode configurationsNode = new > ConfigurationsNode(profile, > > getString("extract.rdb.profile.view.section.configurations")); > configurationsNode.addToParentNode(profile, rootNode); > > final CampaignsNode campaignsNode = new CampaignsNode(profile, > getString("extract.rdb.profile.view.section.campaigns")); > campaignsNode.addToParentNode(profile, rootNode); > > final UniverseNode universesNode = new UniverseNode(profile, > getString("extract.rdb.profile.view.section.universes")); > universesNode.addToParentNode(profile, rootNode); > > final BprsNode bprsNode = new BprsNode(profile, > getString("extract.rdb.profile.view.section.bprs")); > bprsNode.addToParentNode(profile, rootNode); > > final AuditCardsNode auditCardsNode = new AuditCardsNode(profile, > getString("extract.rdb.profile.view.section.audits")); > auditCardsNode.addToParentNode(profile, rootNode); > > final AllTicketsNode allTicketsNode = new AllTicketsNode( > getString("extract.rdb.profile.view.section.allTickets")); > allTicketsNode.addToParentNode(profile, rootNode); > > final TreeModel treeModel = new DefaultTreeModel(rootNode); > return treeModel; > } > > Here's one of the nodes: > public final class ConfigurationsNode extends AbstractProfileDataNode { > private static final long serialVersionUID = 3306972776261689364L; > public ConfigurationsNode(final Profile profile, String title) { > super(title); > final List<Configuration> configurations = > profile.getConfigurations(); > for (final Configuration configuration : configurations) { > final DefaultMutableTreeNode configurationNode = new > DefaultMutableTreeNode() { > private static final long serialVersionUID = 1L; > @Override > public Object getUserObject() { > return configuration.getConfigurationName(); > } > }; > add(configurationNode); > } > } > > @Override > protected boolean isVisible(Profile profile) { > return CollectionUtils.isNotEmpty(profile.getConfigurations()); > } > } > > @SuppressWarnings("serial") > abstract class AbstractProfileDataNode extends DefaultMutableTreeNode { > private final String title; > > AbstractProfileDataNode(String title) { > this.title = title; > } > > @Override > public final Object getUserObject() { > return title; > } > > public final void addToParentNode(Profile profile, final > DefaultMutableTreeNode parentNode) { > if (isVisible(profile)) { > parentNode.add(this); > } > } > > protected abstract boolean isVisible(Profile profile); > } > > Thanks, > > Eyal Golan > egola...@gmail.com > > Visit: http://jvdrums.sourceforge.net/ > LinkedIn: http://www.linkedin.com/in/egolan74 > > P Save a tree. Please don't print this e-mail unless it's really necessary >