View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag;
21  
22  import org.apache.myfaces.tobago.component.Attributes;
23  import org.apache.myfaces.tobago.config.Configurable;
24  import org.apache.myfaces.tobago.layout.LayoutContainer;
25  import org.apache.myfaces.tobago.layout.Measure;
26  import org.apache.myfaces.tobago.renderkit.MarginValues;
27  import org.apache.myfaces.tobago.renderkit.RendererBase;
28  import org.apache.myfaces.tobago.renderkit.SpacingValues;
29  import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
30  import org.slf4j.Logger;
31  import org.slf4j.LoggerFactory;
32  
33  import javax.faces.component.UIComponent;
34  import javax.faces.context.FacesContext;
35  import java.io.IOException;
36  
37  public class GridLayoutRenderer extends RendererBase implements SpacingValues, MarginValues {
38  
39    private static final Logger LOG = LoggerFactory.getLogger(GridLayoutRenderer.class);
40  
41    @Override
42    public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
43  //    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
44  //    UIGridLayout gridLayout = (UIGridLayout) component;
45  //    writer.startElement(HtmlElements.DIV, gridLayout);
46  //    writer.writeClassAttribute();
47    }
48  
49    @Override
50    public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
51      UIComponent container = component.getParent();
52      if (container instanceof LayoutContainer && !((LayoutContainer) container).isLayoutChildren()) {
53        return;
54      }
55      RenderUtils.encodeChildren(facesContext, container);
56    }
57  
58    @Override
59    public void encodeEnd(
60        FacesContext facesContext,
61        UIComponent component) throws IOException {
62  //    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
63  //    writer.endElement(HtmlElements.DIV);
64    }
65  
66    public Measure getColumnSpacing(FacesContext facesContext, Configurable component) {
67      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.COLUMN_SPACING);
68    }
69  
70    public Measure getRowSpacing(FacesContext facesContext, Configurable component) {
71      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.ROW_SPACING);
72    }
73  
74    public Measure getMarginLeft(FacesContext facesContext, Configurable component) {
75      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_LEFT);
76    }
77  
78    public Measure getMarginRight(FacesContext facesContext, Configurable component) {
79      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_RIGHT);
80    }
81  
82    public Measure getMarginTop(FacesContext facesContext, Configurable component) {
83      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_TOP);
84    }
85  
86    public Measure getMarginBottom(FacesContext facesContext, Configurable component) {
87      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_BOTTOM);
88    }
89  }