protected void walk(ItemTreeModel model, Group gr, Object o) { int cc = model.getChildCount(o); for (int i = 0; i < cc; i++) { ActivableMutableTreeNode child = (ActivableMutableTreeNode) model.getChild(o, i); if (child.isActive()) { final Item userObject = (Item) child.getUserObject(); if (userObject instanceof Group) { final Group item = new Group(userObject.getId()); item.setLocalHint(new LayoutHints(userObject.getLocalHint())); gr.add(item); walk(model, item, child); } else { final Item item = new Item(userObject.getId()); item.setLocalHint(new LayoutHints(userObject.getLocalHint())); final SQLTable table = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(n.getTable()); if (table.contains(userObject.getId())) { SQLField field = table.getField(userObject.getId()); if (!field.isPrimaryKey() && !field.getName().endsWith("ORDRE") && !field.getName().endsWith("ARCHIVE")) { gr.add(item); } } } } } }
public Group getFilteredGroup() { // Parcours du Tree Group filteredGroup = new Group(n.getId()); if (n.getTable() == null) { throw new IllegalStateException("Not table defined for " + n); } walk(newModel, filteredGroup, newModel.getRoot()); filteredGroup = (Group) filteredGroup.getItem(0); return filteredGroup; }