View Javadoc
1   /*
2    * Copyright (C) 2003-2013 eXo Platform SAS.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU Affero General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (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 Affero General Public License for more details.
13   *
14   * You should have received a copy of the GNU Affero 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.lifecycle;
18  
19  import org.apache.commons.lang.StringUtils;
20  import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea;
21  import org.exoplatform.ecm.webui.component.explorer.control.UIActionBar;
22  import org.exoplatform.webui.application.WebuiRequestContext;
23  import org.exoplatform.webui.core.UIContainer;
24  import org.exoplatform.webui.core.lifecycle.Lifecycle;
25  
26  /**
27   * Created by The eXo Platform SAS
28   *  Author : eXoPlatform exo@exoplatform.com Apr
29   * 4, 2013
30   */
31  public class UIDocumentWorkspaceLifeCycle extends Lifecycle<UIContainer> {
32    public void processRender(UIContainer uicomponent, WebuiRequestContext context) throws Exception {
33      UIWorkingArea uiWorkingArea = uicomponent.getAncestorOfType(UIWorkingArea.class);
34      UIActionBar uiActionBar = uiWorkingArea.getChild(UIActionBar.class);
35      boolean isUISelectDocumentTemplateTitleRendered =
36          uiWorkingArea.isUISelectDocumentTemplateTitleRendered();
37      context.getWriter()
38             .append("<div class=\"")
39             .append(uicomponent.getId())
40             .append(isUISelectDocumentTemplateTitleRendered || uiActionBar.isRendered()
41                     ? StringUtils.EMPTY : " uiDocumentWorkspaceBox") 
42             .append("\" id=\"")
43             .append(uicomponent.getId())
44             .append("\">");
45      uicomponent.renderChildren(context);
46      context.getWriter().append("</div>");
47    }
48  }