View Javadoc
1   /*
2    * Copyright (C) 2003-2010 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.ecm.webui.component.explorer.optionblocks;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import org.exoplatform.webui.config.annotation.ComponentConfig;
23  import org.exoplatform.webui.core.UIComponent;
24  import org.exoplatform.webui.core.UIContainer;
25  import org.exoplatform.webui.ext.UIExtension;
26  import org.exoplatform.webui.ext.UIExtensionManager;
27  
28  /**
29   * Created by The eXo Platform SAS
30   * Author : Khuong.Van.Dung
31   *          dung.khuong@exoplatform.com
32   * Jul 22, 2010
33   */
34  
35  @ComponentConfig(
36      template  = "app:/groovy/webui/component/explorer/optionblocks/UIOptionBlockPanel.gtmpl"
37  )
38  public class UIOptionBlockPanel extends UIContainer {
39  
40    private String OPTION_BLOCK_EXTENSION_TYPE = "org.exoplatform.ecm.dms.UIOptionBlocks";
41    private List<UIComponent> listExtenstions = new ArrayList<UIComponent>();
42  
43    public UIOptionBlockPanel() throws Exception {
44  
45    }
46    /*
47     * This method checks and returns true if there is at least one extension, otherwise it returns false
48     * */
49    public boolean isHasOptionBlockExtension() {
50      UIExtensionManager manager = getApplicationComponent(UIExtensionManager.class);
51       List<UIExtension> extensions = manager.getUIExtensions(OPTION_BLOCK_EXTENSION_TYPE);
52       if(extensions != null) {
53         return true;
54       }
55      return false;
56    }
57    public void addOptionBlockExtension() throws Exception {
58      UIExtensionManager manager = getApplicationComponent(UIExtensionManager.class);
59      List<UIExtension> extensions = manager.getUIExtensions(OPTION_BLOCK_EXTENSION_TYPE);
60  
61      if(extensions != null ) {
62        for (UIExtension extension : extensions) {
63  
64          UIComponent uicomp = manager.addUIExtension(extension, null, this);
65          //uicomp.setRendered(false);
66         listExtenstions.add(uicomp);
67        }
68      }
69    }
70    public void setDisplayOptionExtensions(boolean display) {
71      for(UIComponent uicomp : listExtenstions) {
72        uicomp.setRendered(display);
73      }
74    }
75  }