Coverage Report - org.seasar.uruma.renderer.layout.LayoutSupportFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
LayoutSupportFactory
89%
8/9
N/A
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.renderer.layout;
 17  
 
 18  
 import java.util.HashMap;
 19  
 import java.util.Map;
 20  
 
 21  
 import org.eclipse.swt.layout.FillLayout;
 22  
 import org.eclipse.swt.layout.GridData;
 23  
 import org.eclipse.swt.layout.GridLayout;
 24  
 import org.eclipse.swt.layout.RowData;
 25  
 import org.eclipse.swt.layout.RowLayout;
 26  
 import org.seasar.uruma.component.LayoutInfo;
 27  
 import org.seasar.uruma.component.jface.FillLayoutInfo;
 28  
 import org.seasar.uruma.component.jface.GridLayoutInfo;
 29  
 import org.seasar.uruma.component.jface.RowLayoutInfo;
 30  
 import org.seasar.uruma.renderer.layout.impl.GenericLayoutSupport;
 31  
 
 32  
 /**
 33  
  * {@link LayoutSupport} の実装クラスを取得するためのファクトリです。</br>
 34  
  * 
 35  
  * @author y-komori
 36  
  */
 37  0
 public class LayoutSupportFactory {
 38  4
     private static final Map<Class<? extends LayoutInfo<?>>, LayoutSupport> LAYOUT_SUPPORT_MAP = new HashMap<Class<? extends LayoutInfo<?>>, LayoutSupport>();
 39  
 
 40  
     static {
 41  4
         addLayoutSupport(FillLayoutInfo.class, new GenericLayoutSupport(
 42  
                 FillLayout.class, null));
 43  4
         addLayoutSupport(RowLayoutInfo.class, new GenericLayoutSupport(
 44  
                 RowLayout.class, RowData.class));
 45  4
         addLayoutSupport(GridLayoutInfo.class, new GenericLayoutSupport(
 46  
                 GridLayout.class, GridData.class));
 47  4
     }
 48  
 
 49  
     /**
 50  
      * {@link LayoutInfo} クラスをキーにして、レイアウトサポートクラスを取得します。<br />
 51  
      * 
 52  
      * @param layoutInfo
 53  
      *            {@link LayoutInfo} クラス。
 54  
      * @return レイアウトサポートクラス。見つからない場合は <code>null</code>
 55  
      */
 56  
     public static LayoutSupport getLayoutSupport(
 57  
             final Class<? extends LayoutInfo<?>> layoutInfo) {
 58  1456
         return LAYOUT_SUPPORT_MAP.get(layoutInfo);
 59  
     }
 60  
 
 61  
     /**
 62  
      * レイアウトサポートクラスを追加します</br>
 63  
      * 
 64  
      * @param layoutSupport
 65  
      *            レイアウトサポートクラス
 66  
      */
 67  
     public static void addLayoutSupport(
 68  
             final Class<? extends LayoutInfo<?>> layoutInfo,
 69  
             final LayoutSupport layoutSupport) {
 70  12
         LAYOUT_SUPPORT_MAP.put(layoutInfo, layoutSupport);
 71  12
     }
 72  
 }