1 31 32 package org.opencms.workplace.tools.searchindex; 33 34 import org.opencms.file.CmsProject; 35 import org.opencms.jsp.CmsJspActionElement; 36 import org.opencms.main.CmsException; 37 import org.opencms.widgets.CmsDisplayWidget; 38 import org.opencms.widgets.CmsInputWidget; 39 import org.opencms.widgets.CmsSelectWidget; 40 import org.opencms.widgets.CmsSelectWidgetOption; 41 import org.opencms.workplace.CmsWidgetDialogParameter; 42 43 import java.util.Iterator ; 44 import java.util.LinkedList ; 45 import java.util.List ; 46 import java.util.Set ; 47 import java.util.TreeSet ; 48 49 import javax.servlet.http.HttpServletRequest ; 50 import javax.servlet.http.HttpServletResponse ; 51 import javax.servlet.jsp.PageContext ; 52 53 63 public class CmsEditSearchIndexDialog extends A_CmsEditSearchIndexDialog { 64 65 70 public CmsEditSearchIndexDialog(CmsJspActionElement jsp) { 71 72 super(jsp); 73 } 74 75 82 public CmsEditSearchIndexDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) { 83 84 this(new CmsJspActionElement(context, req, res)); 85 } 86 87 95 protected String createDialogHtml(String dialog) { 96 97 StringBuffer result = new StringBuffer (1024); 98 99 result.append(createWidgetTableStart()); 100 result.append(createWidgetErrorHeader()); 102 103 if (dialog.equals(PAGES[0])) { 104 result.append(dialogBlockStart(key(Messages.GUI_LABEL_SEARCHINDEX_BLOCK_SETTINGS_0))); 106 result.append(createWidgetTableStart()); 107 result.append(createDialogRowsHtml(0, 3)); 108 result.append(createWidgetTableEnd()); 109 result.append(dialogBlockEnd()); 110 } 111 112 result.append(createWidgetTableEnd()); 113 return result.toString(); 114 } 115 116 119 protected void defineWidgets() { 120 121 super.defineWidgets(); 122 123 if (m_index == null || m_index.getName() == null) { 125 addWidget(new CmsWidgetDialogParameter(m_index, "name", PAGES[0], new CmsInputWidget())); 126 } else { 127 addWidget(new CmsWidgetDialogParameter(m_index, "name", PAGES[0], new CmsDisplayWidget())); 128 } 129 addWidget(new CmsWidgetDialogParameter(m_index, "rebuildMode", "", PAGES[0], new CmsSelectWidget( 130 getRebuildModeWidgetConfiguration()), 0, 1)); 131 addWidget(new CmsWidgetDialogParameter(m_index, "locale", "", PAGES[0], new CmsSelectWidget( 132 getLocaleWidgetConfiguration()), 0, 1)); 133 addWidget(new CmsWidgetDialogParameter(m_index, "project", "", PAGES[0], new CmsSelectWidget( 134 getProjectWidgetConfiguration()), 0, 1)); 135 } 136 137 private List getLocaleWidgetConfiguration() { 138 139 List result = new LinkedList (); 140 String locale = m_index.getLocale(); 141 Iterator itAnalyzerLocales = m_searchManager.getAnalyzers().keySet().iterator(); 143 Set distinctLocales = new TreeSet (); 144 while (itAnalyzerLocales.hasNext()) { 145 distinctLocales.add(itAnalyzerLocales.next()); 146 } 147 148 itAnalyzerLocales = distinctLocales.iterator(); 150 String curLocale; 151 CmsSelectWidgetOption option; 152 while (itAnalyzerLocales.hasNext()) { 153 curLocale = (String )itAnalyzerLocales.next(); 154 option = new CmsSelectWidgetOption(curLocale, curLocale.equals(locale)); 155 result.add(option); 156 } 157 return result; 158 } 159 160 private List getProjectWidgetConfiguration() { 161 162 List result = new LinkedList (); 163 List projects; 164 try { 165 projects = getCms().getAllManageableProjects(); 166 projects.add(getCms().readProject(CmsProject.ONLINE_PROJECT_ID)); 168 Iterator itProjects = projects.iterator(); 169 String project = m_index.getProject(); 170 String curProject; 171 CmsSelectWidgetOption option; 172 while (itProjects.hasNext()) { 173 curProject = ((CmsProject)itProjects.next()).getName(); 174 option = new CmsSelectWidgetOption(curProject, curProject.equals(project)); 175 result.add(option); 176 } 177 } catch (CmsException e) { 178 } 180 return result; 181 } 182 183 private List getRebuildModeWidgetConfiguration() { 184 185 List result = new LinkedList (); 186 String rebuildMode = m_index.getRebuildMode(); 187 CmsSelectWidgetOption option = new CmsSelectWidgetOption("auto", "auto".equals(rebuildMode)); 188 result.add(option); 189 option = new CmsSelectWidgetOption("manual", "manual".equals(rebuildMode)); 190 result.add(option); 191 return result; 192 } 193 194 } | Popular Tags |