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 GmbH & Co. KG, 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.workplace.tools.modules; 029 030import org.opencms.jsp.CmsJspActionElement; 031import org.opencms.main.CmsRuntimeException; 032import org.opencms.widgets.CmsVfsFileWidget; 033import org.opencms.workplace.CmsWidgetDialogParameter; 034 035import javax.servlet.http.HttpServletRequest; 036import javax.servlet.http.HttpServletResponse; 037import javax.servlet.jsp.PageContext; 038 039/** 040 * Edit class to edit an exiting module.<p> 041 * 042 * @since 6.0.0 043 */ 044public class CmsModulesEditResources extends CmsModulesEditBase { 045 046 /** 047 * Public constructor with JSP action element.<p> 048 * 049 * @param jsp an initialized JSP action element 050 */ 051 public CmsModulesEditResources(CmsJspActionElement jsp) { 052 053 super(jsp); 054 } 055 056 /** 057 * Public constructor with JSP variables.<p> 058 * 059 * @param context the JSP page context 060 * @param req the JSP request 061 * @param res the JSP response 062 */ 063 public CmsModulesEditResources(PageContext context, HttpServletRequest req, HttpServletResponse res) { 064 065 this(new CmsJspActionElement(context, req, res)); 066 } 067 068 /** 069 * @see org.opencms.workplace.tools.modules.CmsModulesEditBase#actionCommit() 070 */ 071 @Override 072 public void actionCommit() { 073 074 try { 075 // validate the module reouces 076 m_module.checkResources(getCms()); 077 } catch (CmsRuntimeException e) { 078 addCommitError(e); 079 } 080 081 // now do the committing in the base class 082 super.actionCommit(); 083 } 084 085 /** 086 * Creates the dialog HTML for all defined widgets of the named dialog (page).<p> 087 * 088 * @param dialog the dialog (page) to get the HTML for 089 * @return the dialog HTML for all defined widgets of the named dialog (page) 090 */ 091 @Override 092 protected String createDialogHtml(String dialog) { 093 094 StringBuffer result = new StringBuffer(1024); 095 096 // create table 097 result.append(createWidgetTableStart()); 098 099 // show error header once if there were validation errors 100 result.append(createWidgetErrorHeader()); 101 102 if (dialog.equals(PAGES[0])) { 103 result.append(dialogBlockStart(key("label.resource"))); 104 result.append(createWidgetTableStart()); 105 result.append(createDialogRowsHtml(0, 0)); 106 result.append(createWidgetTableEnd()); 107 result.append(dialogBlockEnd()); 108 } 109 110 if (dialog.equals(PAGES[0])) { 111 result.append(dialogBlockStart(key("label.excluderesource"))); 112 result.append(createWidgetTableStart()); 113 result.append(createDialogRowsHtml(1, 1)); 114 result.append(createWidgetTableEnd()); 115 result.append(dialogBlockEnd()); 116 } 117 // close table 118 result.append(createWidgetTableEnd()); 119 120 return result.toString(); 121 } 122 123 /** 124 * Creates the list of widgets for this dialog.<p> 125 */ 126 @Override 127 protected void defineWidgets() { 128 129 super.defineWidgets(); 130 131 addWidget(new CmsWidgetDialogParameter(m_module, "resources", PAGES[0], new CmsVfsFileWidget())); 132 addWidget(new CmsWidgetDialogParameter(m_module, "excludeResources", PAGES[0], new CmsVfsFileWidget())); 133 } 134}