View Javadoc

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.Collections;
20  import java.util.List;
21  
22  import org.eclipse.swt.widgets.Tree;
23  import org.seasar.uruma.annotation.ComponentAttribute;
24  import org.seasar.uruma.annotation.ComponentElement;
25  import org.seasar.uruma.annotation.FieldDescription;
26  import org.seasar.uruma.annotation.RenderingPolicy;
27  import org.seasar.uruma.annotation.RenderingPolicy.ConversionType;
28  import org.seasar.uruma.annotation.RenderingPolicy.TargetType;
29  
30  /**
31   * {@link Tree} を表すコンポーネントです。<br />
32   * 
33   * @author y-komori
34   */
35  @ComponentElement
36  public class TreeComponent extends CompositeComponent {
37      /**
38       * ヘッダの表示状態です。<br />
39       */
40      @RenderingPolicy(conversionType = ConversionType.BOOLEAN)
41      @ComponentAttribute
42      @FieldDescription("ヘッダの表示状態")
43      public String headerVisible;
44  
45      /**
46       * ラインの表示状態です。<br />
47       */
48      @RenderingPolicy(conversionType = ConversionType.BOOLEAN)
49      @ComponentAttribute
50      @FieldDescription("ラインの表示状態")
51      public String linesVisible;
52  
53      /**
54       * デフォルトでツリーを展開する階層です。<br /> 【例】2を指定した場合、常に2階層目まで展開されます。<br />
55       */
56      @RenderingPolicy(targetType = TargetType.NONE)
57      @ComponentAttribute
58      @FieldDescription("デフォルトでツリー展開する階層")
59      public String autoExpandLevel = "1";
60  
61      private List<TreeItemComponent> children = new ArrayList<TreeItemComponent>();
62  
63      /**
64       * ツリー項目を追加します。<br />
65       * 
66       * @param child
67       *      ツリー項目
68       */
69      public void addTreeItem(final TreeItemComponent child) {
70          children.add(child);
71      }
72  
73      /**
74       * ツリー項目のリストを取得します。<br />
75       * 
76       * @return ツリー項目のリスト
77       */
78      public List<TreeItemComponent> getTreeItems() {
79          return Collections.unmodifiableList(children);
80      }
81  }