001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.ui.apps; 029 030import org.opencms.main.OpenCms; 031import org.opencms.ui.A_CmsUI; 032import org.opencms.workplace.CmsWorkplace; 033import org.opencms.workplace.CmsWorkplaceSettings; 034import org.opencms.workplace.tools.I_CmsToolHandler; 035 036import javax.servlet.http.HttpServletRequest; 037 038import com.vaadin.server.ExternalResource; 039import com.vaadin.ui.BrowserFrame; 040import com.vaadin.ui.JavaScript; 041 042/** 043 * App for legacy admin tools. Renders the tool in an iframe.<p> 044 */ 045public class CmsLegacyApp extends BrowserFrame implements I_CmsWorkplaceApp { 046 047 /** Name of Javascript variable used to indicate whether we are currently showing a legacy app. */ 048 public static final String VAR_IS_LEGACY_APP = "cmsIsLegacyApp"; 049 050 /** The serial version id. */ 051 private static final long serialVersionUID = -2857100593142358027L; 052 053 /** The tool handler. */ 054 private I_CmsToolHandler m_toolHandler; 055 056 /** 057 * Constructor.<p> 058 * 059 * @param toolHandler the tool handler 060 */ 061 public CmsLegacyApp(I_CmsToolHandler toolHandler) { 062 063 m_toolHandler = toolHandler; 064 addAttachListener(new AttachListener() { 065 066 private static final long serialVersionUID = 1L; 067 068 public void attach(AttachEvent event) { 069 070 JavaScript.eval(VAR_IS_LEGACY_APP + " = true;"); 071 072 } 073 }); 074 addDetachListener(new DetachListener() { 075 076 private static final long serialVersionUID = 1L; 077 078 public void detach(DetachEvent event) { 079 080 JavaScript.eval(VAR_IS_LEGACY_APP + " = false;"); 081 } 082 }); 083 setSizeFull(); 084 } 085 086 /** 087 * @see org.opencms.ui.apps.I_CmsWorkplaceApp#initUI(org.opencms.ui.apps.I_CmsAppUIContext) 088 */ 089 public void initUI(I_CmsAppUIContext context) { 090 091 context.setAppContent(this); 092 context.showInfoArea(false); 093 } 094 095 /** 096 * @see org.opencms.ui.apps.I_CmsWorkplaceApp#onStateChange(java.lang.String) 097 */ 098 public void onStateChange(String state) { 099 100 // only act on initial state change 101 if (getSource() == null) { 102 CmsWorkplace wp = new CmsWorkplace(A_CmsUI.getCmsObject(), CmsAppWorkplaceUi.get().getHttpSession()) { 103 104 @Override 105 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 106 107 // nothing to do 108 } 109 }; 110 111 OpenCms.getWorkplaceManager().getToolManager().setCurrentToolPath(wp, m_toolHandler.getPath()); 112 113 String url = OpenCms.getLinkManager().substituteLink(A_CmsUI.getCmsObject(), m_toolHandler.getLink()); 114 setSource(new ExternalResource(url)); 115 setSizeFull(); 116 } 117 } 118}