/** * Adds the icon and content components to the panel. You can override this method if you want * custom components to be added * * @param model * model that can be used to retrieve the TreeNode * * @param tree */ protected void addComponents(IModel<Object> model, BaseTree tree) { add(newImageComponent("icon", tree, model)); add(newContentComponent("content", tree, model)); }
/** * Constructs the panel. * * @param id * component id * @param model * model that is used to access the TreeNode * @param tree */ public LabelIconPanel(String id, IModel<Object> model, BaseTree tree) { super(id, model); addComponents(model, tree); }
@Override protected ResourceReference getImageResourceReference() { return LabelIconPanel.this.getImageResourceReference(tree, model.getObject()); }
/** * Returns the image resource reference based on the give tree node type. * * @param tree * @param node * @return image resource reference */ protected ResourceReference getImageResourceReference(BaseTree tree, Object node) { TreeModel model = (TreeModel)tree.getDefaultModelObject(); if (model.isLeaf(node)) { return getResourceItemLeaf(node); } else { if (tree.getTreeState().isNodeExpanded(node)) { return getResourceFolderOpen(node); } else { return getResourceFolderClosed(node); } } }
@Override protected Component newContentComponent(String componentId, BaseTree tree, IModel<?> model) { return super.newContentComponent(componentId, tree, getNodeTextModel(model)); } };