001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.extensions.markup.html.repeater.tree;
018
019import java.util.Set;
020
021import org.apache.wicket.Component;
022import org.apache.wicket.extensions.markup.html.repeater.tree.content.Folder;
023import org.apache.wicket.extensions.markup.html.repeater.tree.theme.WindowsTheme;
024import org.apache.wicket.model.IModel;
025
026/**
027 * An implementation of the NestedTree that aims to solve the 90% usecase by using {@link Folder}s
028 * on a standard {@link NestedTree}.
029 * 
030 * @param <T>
031 *            The node type
032 * @author svenmeier
033 */
034public class DefaultNestedTree<T> extends NestedTree<T>
035{
036        private static final long serialVersionUID = 1L;
037
038        /**
039         * Construct.
040         * 
041         * @param id
042         *            component id
043         * @param provider
044         *            provider of the tree
045         */
046        public DefaultNestedTree(String id, ITreeProvider<T> provider)
047        {
048                this(id, provider, null);
049        }
050
051        /**
052         * Construct.
053         * 
054         * @param id
055         *            component id
056         * @param provider
057         *            provider of the tree
058         * @param state
059         *            expansion state
060         */
061        public DefaultNestedTree(String id, ITreeProvider<T> provider, IModel<? extends Set<T>> state)
062        {
063                super(id, provider, state);
064
065                add(new WindowsTheme());
066        }
067
068        /**
069         * Creates {@link Folder} for each node.
070         * 
071         * @param id
072         *            component id
073         * @param node
074         *            the node model
075         */
076        @Override
077        protected Component newContentComponent(String id, IModel<T> node)
078        {
079                return new Folder<>(id, this, node);
080        }
081}