cmssearchindexlist.java
来自「找了很久才找到到源代码」· Java 代码 · 共 710 行 · 第 1/3 页
JAVA
710 行
projectCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
projectCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_PROJECT_0));
projectCol.setWidth("30%");
metadata.addColumn(projectCol);
// add column for locale
CmsListColumnDefinition localeCol = new CmsListColumnDefinition(LIST_COLUMN_LOCALE);
localeCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
localeCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_LOCALE_0));
localeCol.setWidth("10%");
metadata.addColumn(localeCol);
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
*/
protected void setIndependentActions(CmsListMetadata metadata) {
// add index source details
CmsListItemDetails indexDetails = new CmsListItemDetails(LIST_DETAIL_INDEXSOURCE);
indexDetails.setAtColumn(LIST_COLUMN_NAME);
indexDetails.setVisible(false);
indexDetails.setShowActionName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_SHOW_0));
indexDetails.setShowActionHelpText(Messages.get().container(
Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_SHOW_HELP_0));
indexDetails.setHideActionName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_HIDE_0));
indexDetails.setHideActionHelpText(Messages.get().container(
Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_HIDE_HELP_0));
indexDetails.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_NAME_0));
indexDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
Messages.GUI_LIST_SEARCHINDEX_DETAIL_INDEXSOURCE_NAME_0)));
metadata.addItemDetails(indexDetails);
// add field configuration details
CmsListItemDetails configDetails = new CmsListItemDetails(LIST_DETAIL_FIELDCONFIGURATION);
configDetails.setAtColumn(LIST_COLUMN_NAME);
configDetails.setVisible(false);
configDetails.setShowActionName(Messages.get().container(
Messages.GUI_LIST_SEARCHINDEX_DETAIL_FIELDCONFIGURATION_SHOW_0));
configDetails.setShowActionHelpText(Messages.get().container(
Messages.GUI_LIST_SEARCHINDEX_DETAIL_FIELDCONFIGURATION_SHOW_HELP_0));
configDetails.setHideActionName(Messages.get().container(
Messages.GUI_LIST_SEARCHINDEX_DETAIL_FIELDCONFIGURATION_HIDE_0));
configDetails.setHideActionHelpText(Messages.get().container(
Messages.GUI_LIST_SEARCHINDEX_DETAIL_FIELDCONFIGURATION_HIDE_HELP_0));
configDetails.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_DETAIL_FIELDCONFIGURATION_NAME_0));
configDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
Messages.GUI_LIST_SEARCHINDEX_DETAIL_FIELDCONFIGURATION_NAME_0)));
metadata.addItemDetails(configDetails);
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
*/
protected void setMultiActions(CmsListMetadata metadata) {
// add delete multi action
CmsListMultiAction deleteMultiAction = new CmsListMultiAction(LIST_MACTION_DELETE);
deleteMultiAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_MACTION_DELETE_NAME_0));
deleteMultiAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_MACTION_DELETE_HELP_0));
deleteMultiAction.setConfirmationMessage(Messages.get().container(
Messages.GUI_LIST_SEARCHINDEX_MACTION_DELETE_CONF_0));
deleteMultiAction.setIconPath(ICON_MULTI_DELETE);
metadata.addMultiAction(deleteMultiAction);
// add rebuild multi action
CmsListMultiAction rebuildMultiAction = new CmsListMultiAction(LIST_MACTION_REBUILD);
rebuildMultiAction.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_MACTION_REBUILD_NAME_0));
rebuildMultiAction.setHelpText(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_MACTION_REBUILD_HELP_0));
rebuildMultiAction.setConfirmationMessage(Messages.get().container(
Messages.GUI_LIST_SEARCHINDEX_MACTION_REBUILD_CONF_0));
rebuildMultiAction.setIconPath(LIST_ICON_REBUILD_MULTI);
metadata.addMultiAction(rebuildMultiAction);
}
/**
* Writes the updated search configuration back to the XML
* configuration file and refreshes the complete list.<p>
*
* @param refresh if true, the list items are refreshed
*/
protected void writeConfiguration(boolean refresh) {
// update the XML configuration
OpenCms.writeConfiguration(CmsSearchConfiguration.class);
if (refresh) {
refreshList();
}
}
/**
* Fills details of the field configuration into the given item. <p>
*
* @param item the list item to fill
* @param detailId the id for the detail to fill
*/
private void fillDetailFieldConfiguration(CmsListItem item, String detailId) {
StringBuffer html = new StringBuffer();
// search for the corresponding CmsSearchIndex:
String idxName = (String)item.get(LIST_COLUMN_NAME);
CmsSearchIndex idx = OpenCms.getSearchManager().getIndex(idxName);
CmsSearchFieldConfiguration idxFieldConfiguration = idx.getFieldConfiguration();
List fields = idxFieldConfiguration.getFields();
html.append("<ul>\n");
html.append(" <li>\n").append(" ").append("name : ").append(idxFieldConfiguration.getName()).append(
"\n");
html.append(" </li>");
html.append(" <li>\n").append(" ").append("fields : ").append("\n");
html.append(" <ul>\n");
Iterator itFields = fields.iterator();
while (itFields.hasNext()) {
CmsSearchField field = (CmsSearchField)itFields.next();
String fieldName = field.getName();
boolean fieldStore = field.isStored();
String fieldIndex = field.getIndexed();
boolean fieldExcerpt = field.isInExcerpt();
float fieldBoost = field.getBoost();
String fieldDefault = field.getDefaultValue();
html.append(" <li>\n").append(" ");
html.append("name=").append(fieldName);
if (fieldStore) {
html.append(", ").append("store=").append(fieldStore);
}
if (!fieldIndex.equals("false")) {
html.append(", ").append("index=").append(fieldIndex);
}
if (fieldExcerpt) {
html.append(", ").append("excerpt=").append(fieldExcerpt);
}
if (fieldBoost != CmsSearchField.BOOST_DEFAULT) {
html.append(", ").append("boost=").append(fieldBoost);
}
if (fieldDefault != null) {
html.append(", ").append("default=").append(field.getDefaultValue());
}
html.append("\n").append(" <ul>\n");
Iterator itMappings = field.getMappings().iterator();
while (itMappings.hasNext()) {
CmsSearchFieldMapping mapping = (CmsSearchFieldMapping)itMappings.next();
html.append(" <li>\n").append(" ");
html.append(mapping.getType().toString());
if (CmsStringUtil.isNotEmpty(mapping.getParam())) {
html.append("=").append(mapping.getParam()).append("\n");
}
html.append(" </li>");
}
html.append(" </ul>\n");
html.append(" </li>");
}
html.append(" </ul>\n");
html.append(" </li>");
html.append("</ul>\n");
item.set(detailId, html.toString());
}
/**
* Fills details of the index source into the given item. <p>
*
* @param item the list item to fill
* @param detailId the id for the detail to fill
*
*/
private void fillDetailIndexSource(CmsListItem item, String detailId) {
CmsSearchManager searchManager = OpenCms.getSearchManager();
StringBuffer html = new StringBuffer();
// search for the corresponding CmsSearchIndex:
String idxName = (String)item.get(LIST_COLUMN_NAME);
CmsSearchIndex idx = OpenCms.getSearchManager().getIndex(idxName);
// get the index sources (nice API)
List idxSources = new LinkedList();
Iterator itIdxSrcNames = idx.getSourceNames().iterator();
while (itIdxSrcNames.hasNext()) {
idxSources.add(searchManager.getIndexSource((String)itIdxSrcNames.next()));
}
// output of found index sources
Iterator itIdxSources = idxSources.iterator();
CmsSearchIndexSource idxSource;
List resources;
html.append("<ul>\n");
while (itIdxSources.hasNext()) {
idxSource = (CmsSearchIndexSource)itIdxSources.next();
html.append(" <li>\n").append(" ").append("name : ").append(idxSource.getName()).append("\n");
html.append(" </li>");
html.append(" <li>\n").append(" ").append("indexer : ").append(idxSource.getIndexerClassName()).append(
"\n");
html.append(" </li>");
html.append(" <li>\n").append(" ").append("resources : ").append("\n");
html.append(" <ul>\n");
resources = idxSource.getResourcesNames();
Iterator itResources = resources.iterator();
while (itResources.hasNext()) {
html.append(" <li>\n").append(" ").append((String)itResources.next()).append("\n");
html.append(" </li>\n");
}
html.append(" </ul>\n");
html.append(" </li>");
html.append(" <li>\n").append(" ").append("doctypes : ").append("\n");
html.append(" <ul>\n");
resources = idxSource.getDocumentTypes();
itResources = resources.iterator();
while (itResources.hasNext()) {
html.append(" <li>\n").append(" ").append((String)itResources.next()).append("\n");
html.append(" </li>\n");
}
html.append(" </ul>\n");
html.append(" </li>");
}
html.append("</ul>\n");
item.set(detailId, html.toString());
}
/**
* Returns the available search indexes of this installation.
*
* @return the available search indexes of this installation
*/
private List searchIndexes() {
CmsSearchManager manager = OpenCms.getSearchManager();
return manager.getSearchIndexes();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?