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.rcp.configuration.extension;
17  
18  import java.util.List;
19  
20  import org.seasar.uruma.component.Template;
21  import org.seasar.uruma.component.rcp.ViewPartComponent;
22  import org.seasar.uruma.core.TemplateManager;
23  import org.seasar.uruma.rcp.configuration.Extension;
24  import org.seasar.uruma.rcp.configuration.ExtensionBuilder;
25  import org.seasar.uruma.rcp.configuration.ExtensionFactory;
26  import org.seasar.uruma.rcp.configuration.ExtensionPoints;
27  import org.seasar.uruma.rcp.configuration.elements.ViewElement;
28  
29  /**
30   * <code>views</code> 拡張ポイントを生成するための {@link ExtensionBuilder} です。<br />
31   * 
32   * @author y-komori
33   */
34  public class ViewsBuilder extends AbstractExtensionBuilder {
35  
36      /*
37       * @see org.seasar.uruma.rcp.configuration.ExtensionBuilder#buildExtension()
38       */
39      public Extension[] buildExtension() {
40          TemplateManager templateManager = (TemplateManager) service
41                  .getContainer().getComponent(TemplateManager.class);
42          List<Template> viewTemplates = templateManager
43                  .getTemplates(ViewPartComponent.class);
44  
45          Extension extension = ExtensionFactory
46                  .createExtension(ExtensionPoints.VIEWS);
47          for (Template template : viewTemplates) {
48              ViewPartComponent component = (ViewPartComponent) template
49                      .getRootComponent();
50              ViewElement element = new ViewElement(component);
51              extension.addElement(element);
52          }
53  
54          return new Extension[] { extension };
55      }
56  }