private void removeSelectedItems( TreeGrid<DefaultTreeModel, DefaultMutableTreeNode, String> grid) { Collection<IModel<DefaultMutableTreeNode>> selected = grid.getSelectedItems(); for (IModel<DefaultMutableTreeNode> model : selected) { DefaultMutableTreeNode node = model.getObject(); treeModel.removeNodeFromParent(node); Page3EO page3EO = (Page3EO) node.getUserObject(); LOG.debug(".removeSelectedItems page3 node: " + page3EO.getCustomer()); } }
private void addGrid() { List<IGridColumn<DefaultTreeModel, DefaultMutableTreeNode, String>> columns = new ArrayList<>(); PropertyColumn id = new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String, String>( Model.of("ID"), "userObject.Id"); id.setInitialSize(100); columns.add(id); PropertyColumn customer = new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String, String>( Model.of("Customer"), "userObject.Customer"); customer.setInitialSize(200); columns.add(customer); PropertyColumn attrG = new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String, String>( Model.of("Attribute G"), "userObject.Attr_g"); attrG.setInitialSize(200); columns.add(attrG); PropertyColumn attrH = new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String, String>( Model.of("Attribute H"), "userObject.Attr_h"); attrH.setInitialSize(200); columns.add(attrH); PropertyColumn attrI = new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String, String>( Model.of("Attribute I"), "userObject.Attr_i"); attrI.setInitialSize(200); columns.add(attrI); List<Page3EO> page3EOs = (List<Page3EO>) getDefaultModel().getObject(); treeModel = createTreeModel(page3EOs); grid = new TreeGrid<DefaultTreeModel, DefaultMutableTreeNode, String>( "page3treegrid", treeModel, columns) { @Override public void selectItem(IModel itemModel, boolean selected) { node = (DefaultMutableTreeNode) itemModel.getObject(); if (!node.isRoot()) { Page3EO page3EO = (Page3EO) node.getUserObject(); LOG.debug("TreeGrid.addGrid.selectItem selected customer =" + page3EO.getCustomer()); if (super.isItemSelected(itemModel)) { LOG.debug("TreeGrid.addGrid.selectItem item is selected"); super.selectItem(itemModel, false); } else { super.selectItem(itemModel, true); LOG.info("Page3 List Entity Customer: " + page3EO.getCustomer()); SelectModelEvent.send(getPage(), this, page3EO); } } } }; grid.setContentHeight(10, SizeUnit.EM); grid.setAllowSelectMultiple(false); grid.setClickRowToSelect(true); grid.setClickRowToDeselect(false); grid.setSelectToEdit(false); // expand the root node grid.getTreeState().expandNode((TreeNode) treeModel.getRoot()); this.add(grid); grid.setOutputMarkupId(true); }