View Javadoc
1   /*
2    * Copyright (C) 2003-2008 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.wcm.webui.selector.content;
18  
19  import javax.jcr.Node;
20  
21  import org.exoplatform.ecm.webui.tree.UIBaseNodeTreeSelector;
22  import org.exoplatform.webui.config.annotation.ComponentConfig;
23  import org.exoplatform.webui.config.annotation.EventConfig;
24  import org.exoplatform.webui.core.lifecycle.Lifecycle;
25  import org.exoplatform.webui.event.Event;
26  import org.exoplatform.webui.event.EventListener;
27  
28  /**
29   * Created by The eXo Platform SAS.
30   *
31   * @author : Hoa.Pham hoa.pham@exoplatform.com Jun 23, 2008
32   */
33  
34  @ComponentConfig(
35    lifecycle = Lifecycle.class,
36    events = {
37    @EventConfig(listeners = UIContentBrowsePanel.ChangeContentTypeActionListener.class)
38    }
39  )
40  
41  public abstract class UIContentBrowsePanel extends UIBaseNodeTreeSelector {
42  
43    public static final String WEBCONTENT = "Web Contents";
44  
45    public static final String DMSDOCUMENT = "DMS Documents";
46  
47    public static final String MEDIA = "Medias";
48  
49    private String contentType = WEBCONTENT;
50  
51    public String getContentType() {
52    return contentType;
53    }
54  
55    public void setContentType(String contentType) {
56    this.contentType = contentType;
57    }
58  
59    public void onChange(Node node, Object context) throws Exception {}
60  
61    public static class ChangeContentTypeActionListener extends EventListener<UIContentBrowsePanel> {
62    public void execute(Event<UIContentBrowsePanel> event) throws Exception {
63      UIContentBrowsePanel contentBrowsePanel = event.getSource();
64      contentBrowsePanel.contentType = event.getRequestContext().getRequestParameter(OBJECTID);
65        event.getRequestContext()
66             .addUIComponentToUpdateByAjax(contentBrowsePanel.getAncestorOfType(UIContentSelector.class)
67                                                             .getChild(UIContentSearchForm.class));
68    }
69    }
70  }