001/*
002 * (C) Copyright 2006-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Thierry Delprat
016 */
017package org.nuxeo.apidoc.tree;
018
019import org.nuxeo.apidoc.snapshot.DistributionSnapshot;
020import org.nuxeo.ecm.webengine.model.WebContext;
021import org.nuxeo.ecm.webengine.ui.tree.ContentProvider;
022import org.nuxeo.ecm.webengine.ui.tree.JSonTree;
023import org.nuxeo.ecm.webengine.ui.tree.JSonTreeSerializer;
024import org.nuxeo.ecm.webengine.ui.tree.TreeModelImpl;
025
026public class NuxeoArtifactTree extends JSonTree {
027
028    protected DistributionSnapshot ds;
029
030    public NuxeoArtifactTree(WebContext ctx, DistributionSnapshot ds) {
031        tree = new TreeModelImpl();
032        this.ds = ds;
033        tree.setContentProvider(getProvider(ctx));
034        tree.setInput(ds);
035    }
036
037    public void setDs(DistributionSnapshot ds) {
038        this.ds = ds;
039        tree.setContentProvider(new NuxeoArtifactContentProvider(ds));
040    }
041
042    @Override
043    protected Object getInput(WebContext ctx) {
044        return ds;
045    }
046
047    @Override
048    protected ContentProvider getProvider(WebContext ctx) {
049        return new NuxeoArtifactContentProvider(ds);
050    }
051
052    @Override
053    protected JSonTreeSerializer getSerializer(WebContext ctx) {
054        return new NuxeoArtifactSerializer(ctx, ds);
055    }
056
057}