View Javadoc
1   /**
2   /**
3    * This file Copyright (c) 2011-2015 Magnolia International
4    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
5    *
6    *
7    * This file is dual-licensed under both the Magnolia
8    * Network Agreement and the GNU General Public License.
9    * You may elect to use one or the other of these licenses.
10   *
11   * This file is distributed in the hope that it will be
12   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
13   * implied warranty of MERCHANTABILITY or FITNESS FOR A
14   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
15   * Redistribution, except as permitted by whichever of the GPL
16   * or MNA you select, is prohibited.
17   *
18   * 1. For the GPL license (GPL), you can redistribute and/or
19   * modify this file under the terms of the GNU General
20   * Public License, Version 3, as published by the Free Software
21   * Foundation.  You should have received a copy of the GNU
22   * General Public License, Version 3 along with this program;
23   * if not, write to the Free Software Foundation, Inc., 51
24   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25   *
26   * 2. For the Magnolia Network Agreement (MNA), this file
27   * and the accompanying materials are made available under the
28   * terms of the MNA which accompanies this distribution, and
29   * is available at http://www.magnolia-cms.com/mna.html
30   *
31   * Any modifications to this file must keep this entire header
32   * intact.
33   *
34   */
35  package info.magnolia.rendering.template.configured;
36  
37  import info.magnolia.rendering.template.AreaDefinition;
38  import info.magnolia.rendering.template.ComponentAvailability;
39  import info.magnolia.rendering.template.InheritanceConfiguration;
40  import info.magnolia.rendering.template.TemplateAvailability;
41  
42  import java.util.LinkedHashMap;
43  import java.util.Map;
44  
45  import com.google.inject.Inject;
46  
47  /**
48   * A {@link AreaDefinition} configured in the configuration workspace.
49   */
50  public class ConfiguredAreaDefinition extends ConfiguredTemplateDefinition implements AreaDefinition {
51  
52      private Map<String, ComponentAvailability> availableComponents = new LinkedHashMap<String, ComponentAvailability>();
53  
54      // default value is undefined to allow for merging with possibly defined values by parents
55      private Boolean enabled;
56      private Boolean optional;
57      private String type;
58      private String contentStructure;
59      private InheritanceConfiguration inheritance;
60      private Integer maxComponents;
61      private Boolean createAreaNode;
62  
63      /**
64       * @deprecated since 5.3.3 use {@link #ConfiguredAreaDefinition(TemplateAvailability templateAvailability)}
65       */
66      public ConfiguredAreaDefinition() {
67      }
68  
69      @Inject
70      public ConfiguredAreaDefinition(TemplateAvailability templateAvailability) {
71          super(templateAvailability);
72      }
73  
74      @Override
75      public Map<String, ComponentAvailability> getAvailableComponents() {
76          return availableComponents;
77      }
78  
79      public void setAvailableComponents(Map<String, ComponentAvailability> availableComponents) {
80          this.availableComponents = availableComponents;
81      }
82  
83      public void addAvailableComponent(String name, ComponentAvailability configuredComponentAvailability) {
84          this.availableComponents.put(name, configuredComponentAvailability);
85      }
86  
87      @Override
88      public Boolean getEnabled() {
89          return enabled;
90      }
91  
92      public void setEnabled(Boolean enabled) {
93          this.enabled = enabled;
94      }
95  
96      @Override
97      public String getType() {
98          return type;
99      }
100 
101     @Override
102     public void setType(String type) {
103         this.type = type;
104     }
105 
106     @Override
107     public String getContentStructure() {
108         return contentStructure;
109     }
110 
111     public void setContentStructure(String contentStructure) {
112         this.contentStructure = contentStructure;
113     }
114 
115     @Override
116     public InheritanceConfiguration getInheritance() {
117         return inheritance;
118     }
119 
120     public void setInheritance(InheritanceConfiguration inheritanceConfiguration) {
121         this.inheritance = inheritanceConfiguration;
122     }
123 
124     @Override
125     public Boolean isOptional() {
126         return optional;
127     }
128 
129     @Override
130     public Boolean isEnabled() {
131         return enabled;
132     }
133 
134     @Override
135     public Boolean getOptional() {
136         return optional;
137     }
138 
139     public void setOptional(Boolean optional) {
140         this.optional = optional;
141     }
142 
143     @Override
144     public Integer getMaxComponents() {
145         return maxComponents;
146     }
147 
148 
149     public void setCreateAreaNode(Boolean createAreaNode) {
150         this.createAreaNode = createAreaNode;
151     }
152 
153     @Override
154     public Boolean getCreateAreaNode() {
155         return createAreaNode;
156     }
157 
158     public void setMaxComponents(Integer maxComponents) {
159         this.maxComponents = maxComponents;
160     }
161 
162 }