Coverage Report - org.seasar.uruma.component.jface.CompositeComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
CompositeComponent
83%
25/30
70%
7/10
0
 
 1  
 /*
 2  
  * Copyright 2004-2008 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.uruma.component.jface;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import org.eclipse.swt.widgets.Composite;
 22  
 import org.seasar.uruma.annotation.ComponentElement;
 23  
 import org.seasar.uruma.component.CommonAttributes;
 24  
 import org.seasar.uruma.component.LayoutDataInfo;
 25  
 import org.seasar.uruma.component.LayoutInfo;
 26  
 import org.seasar.uruma.component.UIComponent;
 27  
 import org.seasar.uruma.component.UICompositeComponent;
 28  
 import org.seasar.uruma.component.UIElement;
 29  
 import org.seasar.uruma.component.UIElementVisitor;
 30  
 import org.seasar.uruma.context.PartContext;
 31  
 import org.seasar.uruma.context.WidgetHandle;
 32  
 import org.seasar.uruma.context.WindowContext;
 33  
 
 34  
 /**
 35  
  * {@link Composite} に対応するコンポーネントです。<br />
 36  
  * 
 37  
  * @author y-komori
 38  
  */
 39  
 @ComponentElement
 40  524
 public class CompositeComponent extends ControlComponent implements
 41  
         UICompositeComponent {
 42  
     private LayoutInfo<?> layoutInfo;
 43  
 
 44  
     private LayoutDataInfo childLayoutDataInfo;
 45  
 
 46  
     private CommonAttributes commonAttributes;
 47  
 
 48  524
     private List<UIElement> children = new ArrayList<UIElement>();
 49  
 
 50  
     /*
 51  
      * @see org.seasar.uruma.component.UICompositeComponent#getLayoutInfo()
 52  
      */
 53  
     public LayoutInfo<?> getLayoutInfo() {
 54  3188
         return this.layoutInfo;
 55  
     }
 56  
 
 57  
     /*
 58  
      * @see org.seasar.uruma.component.UICompositeComponent#setLayoutInfo(org.seasar.uruma.component.LayoutInfo)
 59  
      */
 60  
     public void setLayoutInfo(final LayoutInfo<?> layoutInfo) {
 61  368
         this.layoutInfo = layoutInfo;
 62  368
     }
 63  
 
 64  
     /**
 65  
      * 子コンポーネントの {@link LayoutDataInfo} を取得します。<br />
 66  
      * 
 67  
      * @return 子コンポーネントの {@link LayoutDataInfo}
 68  
      */
 69  
     public LayoutDataInfo getChildLayoutDataInfo() {
 70  0
         return this.childLayoutDataInfo;
 71  
     }
 72  
 
 73  
     /**
 74  
      * 子コンポーネントの {@link LayoutDataInfo} を設定します。<br />
 75  
      * 
 76  
      * @param childLayoutDataInfo
 77  
      *            子コンポーネントの {@link LayoutDataInfo}
 78  
      */
 79  
     public void setChildLayoutDataInfo(final LayoutDataInfo childLayoutDataInfo) {
 80  0
         this.childLayoutDataInfo = childLayoutDataInfo;
 81  0
     }
 82  
 
 83  
     /*
 84  
      * @see org.seasar.uruma.component.UICompositeComponent#getCommonAttributes()
 85  
      */
 86  
     public CommonAttributes getCommonAttributes() {
 87  1644
         return commonAttributes;
 88  
     }
 89  
 
 90  
     /*
 91  
      * @see org.seasar.uruma.component.UICompositeComponent#setCommonAttributes(org.seasar.uruma.component.CommonAttributes)
 92  
      */
 93  
     public void setCommonAttributes(final CommonAttributes commonAttributes) {
 94  204
         this.commonAttributes = commonAttributes;
 95  204
     }
 96  
 
 97  
     /*
 98  
      * @see org.seasar.uruma.component.UIElementContainer#addChild(org.seasar.uruma.component.UIElement)
 99  
      */
 100  
     public void addChild(final UIElement child) {
 101  1528
         this.children.add(child);
 102  
 
 103  1528
         if (child instanceof UIComponent) {
 104  1528
             ((UIComponent) child).setParent(this);
 105  
         }
 106  1528
     }
 107  
 
 108  
     /*
 109  
      * @see org.seasar.uruma.component.UIElementContainer#getChildren()
 110  
      */
 111  
     public List<UIElement> getChildren() {
 112  52
         return children;
 113  
     }
 114  
 
 115  
     /*
 116  
      * @see org.seasar.uruma.component.jface.AbstractUIComponent#doPreRender(org.seasar.uruma.context.WidgetHandle,
 117  
      *      org.seasar.uruma.context.WindowContext)
 118  
      */
 119  
     @Override
 120  
     protected void doPreRender(final WidgetHandle parent,
 121  
             final WindowContext context) {
 122  496
         preRenderChild(context.getWidgetHandle(getId()), context);
 123  496
     }
 124  
 
 125  
     /*
 126  
      * @see org.seasar.uruma.component.jface.AbstractUIComponent#doRender(org.seasar.uruma.context.WidgetHandle,
 127  
      *      org.seasar.uruma.context.PartContext)
 128  
      */
 129  
     @Override
 130  
     protected void doRender(final WidgetHandle parent, final PartContext context) {
 131  508
         renderChild(context.getWidgetHandle(getId()), context);
 132  508
     }
 133  
 
 134  
     /*
 135  
      * @see org.seasar.uruma.component.base.AbstractUIElement#accept(org.seasar.uruma.component.UIElementVisitor)
 136  
      */
 137  
     @Override
 138  
     public void accept(final UIElementVisitor visitor) {
 139  0
         visitor.visit(this);
 140  0
     }
 141  
 
 142  
     /**
 143  
      * 子コンポーネントのプリレンダリングを行います。<br />
 144  
      * 
 145  
      * @param parent
 146  
      *            親 {@link WidgetHandle}
 147  
      * @param context
 148  
      *            {@link WindowContext} オブジェクト
 149  
      */
 150  
     protected void preRenderChild(final WidgetHandle parent,
 151  
             final WindowContext context) {
 152  496
         for (UIElement child : children) {
 153  1448
             if (child instanceof UIComponent) {
 154  1448
                 ((UIComponent) child).preRender(parent, context);
 155  
             }
 156  
         }
 157  496
     }
 158  
 
 159  
     /**
 160  
      * 子コンポーネントのレンダリングを行います。<br />
 161  
      * 
 162  
      * @param parent
 163  
      *            親 {@link WidgetHandle}
 164  
      * @param context
 165  
      *            {@link PartContext} オブジェクト
 166  
      */
 167  
     protected void renderChild(final WidgetHandle parent,
 168  
             final PartContext context) {
 169  508
         for (UIElement child : children) {
 170  1472
             if (child instanceof UIComponent) {
 171  1472
                 ((UIComponent) child).render(parent, context);
 172  
             }
 173  
         }
 174  508
     }
 175  
 }