001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS <http://nuxeo.com> and others
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Jean-Marc Orliaguet, Chalmers
011 *
012 * $Id$
013 */
014
015package org.nuxeo.theme.resources;
016
017import org.nuxeo.common.xmap.annotation.XNode;
018import org.nuxeo.common.xmap.annotation.XNodeList;
019import org.nuxeo.common.xmap.annotation.XObject;
020import org.nuxeo.runtime.api.Framework;
021import org.nuxeo.theme.types.Type;
022import org.nuxeo.theme.types.TypeFamily;
023
024@XObject("resource")
025public final class ResourceType implements Type {
026
027    @XNode("@name")
028    public String name;
029
030    @XNode("path")
031    public String path;
032
033    @XNode("url")
034    public String url;
035
036    public String contextPath;
037
038    @XNode("shrinkable")
039    public boolean shrinkable = true;
040
041    @XNodeList(value = "require", type = String[].class, componentType = String.class)
042    public String[] dependencies;
043
044    public ResourceType() {
045    }
046
047    public ResourceType(String name, String path, String[] dependencies) {
048        this.name = name;
049        this.path = path;
050        this.dependencies = dependencies;
051    }
052
053    @Override
054    public TypeFamily getTypeFamily() {
055        return TypeFamily.RESOURCE;
056    }
057
058    @Override
059    public String getTypeName() {
060        return name;
061    }
062
063    @XNode("context-path")
064    public void setContextPath(String contextPath) {
065        this.contextPath = Framework.expandVars(contextPath);
066    }
067
068    public String[] getDependencies() {
069        return dependencies;
070    }
071
072    public String getName() {
073        return name;
074    }
075
076    public String getPath() {
077        return path;
078    }
079
080    public boolean isShrinkable() {
081        return shrinkable;
082    }
083
084    public String getUrl() {
085        return url;
086    }
087
088    public void setName(String name) {
089        this.name = name;
090    }
091
092    public void setPath(String path) {
093        this.path = path;
094    }
095
096    public void setUrl(String url) {
097        this.url = url;
098    }
099
100    public String getContextPath() {
101        return contextPath;
102    }
103
104    public void setShrinkable(boolean shrinkable) {
105        this.shrinkable = shrinkable;
106    }
107
108    public void setDependencies(String[] dependencies) {
109        this.dependencies = dependencies;
110    }
111
112}