1 31 32 package org.opencms.workplace.tools.content; 33 34 import org.opencms.jsp.CmsJspActionElement; 35 import org.opencms.main.CmsIllegalArgumentException; 36 import org.opencms.util.CmsStringUtil; 37 import org.opencms.widgets.CmsInputWidget; 38 import org.opencms.widgets.CmsVfsFileWidget; 39 import org.opencms.workplace.CmsWidgetDialog; 40 import org.opencms.workplace.CmsWidgetDialogParameter; 41 import org.opencms.workplace.CmsWorkplaceSettings; 42 import org.opencms.workplace.tools.CmsToolDialog; 43 import org.opencms.workplace.tools.CmsToolManager; 44 45 import java.io.IOException ; 46 import java.util.ArrayList ; 47 import java.util.HashMap ; 48 import java.util.List ; 49 import java.util.Map ; 50 51 import javax.servlet.ServletException ; 52 import javax.servlet.http.HttpServletRequest ; 53 import javax.servlet.http.HttpServletResponse ; 54 import javax.servlet.jsp.PageContext ; 55 56 66 public class CmsTagReplaceDialog extends CmsWidgetDialog { 67 68 69 public static final String KEY_PREFIX = "tagreplace"; 70 71 72 public static final String [] PAGES = {"page1"}; 73 74 75 protected static final String TAGREPLACE_ACTION_REPORT = PATH_WORKPLACE 76 + "admin/contenttools/reports/tagreplace.jsp"; 77 78 79 private CmsTagReplaceSettings m_settings; 80 81 87 public CmsTagReplaceDialog(CmsJspActionElement jsp) { 88 89 super(jsp); 90 } 91 92 100 public CmsTagReplaceDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) { 101 102 this(new CmsJspActionElement(context, req, res)); 103 } 104 105 108 public void actionCommit() throws IOException , ServletException { 109 110 List errors = new ArrayList (); 111 setDialogObject(m_settings); 112 113 try { 114 115 Map params = new HashMap (); 116 params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW); 118 params.put(PARAM_CLOSELINK, CmsToolManager.linkForToolPath(getJsp(), "/contenttools")); 120 getToolManager().jspForwardPage(this, TAGREPLACE_ACTION_REPORT, params); 122 123 } catch (CmsIllegalArgumentException e) { 124 errors.add(e); 125 } 126 setCommitErrors(errors); 128 } 129 130 133 protected String createDialogHtml(String dialog) { 134 135 StringBuffer result = new StringBuffer (1024); 136 137 result.append(createWidgetTableStart()); 139 140 result.append(createWidgetErrorHeader()); 142 143 result.append(createWidgetBlockStart(Messages.get().getBundle(getLocale()).key( 145 Messages.GUI_TAGREPLACE_DIALOG_BLOCK_SETTINGS_0))); 146 result.append(createDialogRowsHtml(0, 2)); 147 result.append(createWidgetBlockEnd()); 148 149 result.append(createWidgetTableEnd()); 151 152 return result.toString(); 153 } 154 155 158 protected void defineWidgets() { 159 160 initSettingsObject(); 162 163 setKeyPrefix(KEY_PREFIX); 165 addWidget(new CmsWidgetDialogParameter(m_settings, "replacements", PAGES[0], new CmsInputWidget())); 166 addWidget(new CmsWidgetDialogParameter(m_settings, "workPath", "/", PAGES[0], new CmsVfsFileWidget( 167 false, 168 getCms().getRequestContext().getSiteRoot()), 1, 1)); 169 170 addWidget(new CmsWidgetDialogParameter( 171 m_settings, 172 "propertyValueTagReplaceID", 173 PAGES[0], 174 new CmsInputWidget(""))); 175 } 176 177 180 protected String [] getPageArray() { 181 182 return PAGES; 183 } 184 185 188 protected void initMessages() { 189 190 addMessages(Messages.get().getBundleName()); 192 addMessages("org.opencms.workplace.workplace"); 194 super.initMessages(); 196 } 197 198 203 protected void initSettingsObject() { 204 205 Object o; 206 if (CmsStringUtil.isEmpty(getParamAction())) { 207 o = new CmsTagReplaceSettings(getCms()); 208 } else { 209 o = getDialogObject(); 211 } 212 213 if (o == null) { 214 m_settings = new CmsTagReplaceSettings(getCms()); 216 } else { 217 m_settings = (CmsTagReplaceSettings)o; 219 } 220 221 } 222 223 227 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 228 229 super.initWorkplaceRequestValues(settings, request); 231 232 setDialogObject(m_settings); 235 } 236 } | Popular Tags |