use of org.opencms.ui.apps.search.CmsSearchReplaceSettings in project opencms-core by alkacon.
the class CmsResourceTypeStatResultList method getLayoutFromResult.
/**
* Creates a result row.<p>
*
* @param statResult result to be displayed
* @return a row with information about result
*/
private HorizontalLayout getLayoutFromResult(final CmsResourceTypeStatResult statResult) {
HorizontalLayout hLayout = new HorizontalLayout();
hLayout.setWidth("100%");
hLayout.setHeight("60px");
hLayout.addStyleName("o-report");
Label result = new Label();
result.setContentMode(ContentMode.HTML);
result.addStyleName("v-scrollable");
// result.addStyleName("o-report");
result.setValue(statResult.getResult());
Label type = new Label();
type.setWidth("200px");
type.setContentMode(ContentMode.HTML);
type.addStyleName("v-scrollable");
// type.addStyleName("o-report");
type.setValue(statResult.getTypeTitle());
Label time = new Label();
time.setWidth("180px");
time.setContentMode(ContentMode.HTML);
time.addStyleName("v-scrollable");
// time.addStyleName("o-report");
time.setValue(CmsDateUtil.getDateTime(new Date(statResult.getTimestamp()), java.text.DateFormat.DATE_FIELD, A_CmsUI.get().getLocale()));
Button showList = new Button(CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_STATS_LIST_0));
showList.setWidth("100px");
showList.addClickListener(new Button.ClickListener() {
private static final long serialVersionUID = 2665235403970750534L;
public void buttonClick(ClickEvent event) {
CmsSearchReplaceSettings settings = new CmsSearchReplaceSettings();
settings.setPaths(Collections.singletonList("/"));
settings.setSiteRoot(statResult.getSiteRoot());
settings.setSearchpattern(".*");
if (statResult.getType() != null) {
settings.setTypes(statResult.getType().getTypeName());
}
settings.setType(SearchType.fullText);
CmsAppWorkplaceUi.get().showApp(CmsSourceSearchAppConfiguration.APP_ID, CmsSourceSearchApp.generateState(settings));
}
});
hLayout.addComponent(type);
hLayout.addComponent(result);
hLayout.addComponent(time);
hLayout.addComponent(showList);
hLayout.setExpandRatio(result, 1);
hLayout.setData(statResult);
hLayout.setSpacing(true);
hLayout.setComponentAlignment(showList, Alignment.MIDDLE_CENTER);
hLayout.setComponentAlignment(time, Alignment.MIDDLE_CENTER);
hLayout.setComponentAlignment(result, Alignment.MIDDLE_CENTER);
hLayout.setComponentAlignment(type, Alignment.MIDDLE_CENTER);
return hLayout;
}
use of org.opencms.ui.apps.search.CmsSearchReplaceSettings in project opencms-core by alkacon.
the class CmsShellCommands method replaceElementsInPages.
/**
* Replaces elements on container pages.<p>
*
* @param elementPath to be found in container pages
* @param targetElementPath new elements in pages
* @param project project to replace in
* @param basePath basePath to find resources
* @param ignoreSubSites ignore subsites?
*/
public void replaceElementsInPages(String elementPath, String targetElementPath, String project, String basePath, boolean ignoreSubSites) {
try {
CmsObject cms = OpenCms.initCmsObject(m_cms);
cms.getRequestContext().setCurrentProject(cms.readProject(project));
cms.getRequestContext().setSiteRoot("");
CmsResource resource = cms.readResource(elementPath);
CmsResource targetResource = cms.readResource(targetElementPath);
CmsSearchReplaceSettings settings = new CmsSearchReplaceSettings();
settings.setType(SearchType.resourcetype);
settings.setSearchpattern(CmsSearchReplaceSettings.searchElementInPagePattern(resource));
settings.setReplacepattern(CmsSearchReplaceSettings.replaceElementInPagePattern(targetResource));
String siteRoot = OpenCms.getSiteManager().getSiteRoot(basePath);
if (siteRoot != null) {
settings.setSiteRoot(siteRoot);
settings.setPaths(Collections.singletonList(basePath.substring(siteRoot.length())));
} else {
settings.setSiteRoot("");
settings.setPaths(Collections.singletonList(basePath));
}
settings.setIgnoreSubSites(ignoreSubSites);
settings.setProject(project);
settings.setTypes(CmsResourceTypeXmlContainerPage.RESOURCE_TYPE_NAME + "," + CmsResourceTypeXmlContainerPage.MODEL_GROUP_TYPE_NAME);
CmsSearchReplaceThread thread = new CmsSearchReplaceThread(null, cms, settings, new CmsShellLogReport(m_cms.getRequestContext().getLocale()));
thread.run();
} catch (CmsException e) {
LOG.error("test", e);
}
}
use of org.opencms.ui.apps.search.CmsSearchReplaceSettings in project opencms-core by alkacon.
the class CmsShellCommands method renameNestedContainers.
/**
* Replaces elements on container pages.<p>
*
* @param elementPath to be found in container pages
* @param oldName to replace
* @param newName new name
* @param project project to replace in
* @param basePath basePath to find resources
* @param ignoreSubSites ignore subsites?
*/
public void renameNestedContainers(String elementPath, String oldName, String newName, String project, String basePath, boolean ignoreSubSites) {
try {
CmsObject cms = OpenCms.initCmsObject(m_cms);
cms.getRequestContext().setCurrentProject(cms.readProject(project));
cms.getRequestContext().setSiteRoot("");
CmsResource resource = cms.readResource(elementPath);
CmsSearchReplaceSettings settings = new CmsSearchReplaceSettings();
settings.setType(SearchType.renameContainer);
settings.setSearchpattern(CmsSearchReplaceSettings.searchElementInPagePattern(resource));
settings.setElementResource(resource);
settings.setReplacepattern(oldName + ";" + newName);
String siteRoot = OpenCms.getSiteManager().getSiteRoot(basePath);
if (siteRoot != null) {
settings.setSiteRoot(siteRoot);
settings.setPaths(Collections.singletonList(basePath.substring(siteRoot.length())));
} else {
settings.setSiteRoot("");
settings.setPaths(Collections.singletonList(basePath));
}
settings.setIgnoreSubSites(ignoreSubSites);
settings.setProject(project);
settings.setTypes(CmsResourceTypeXmlContainerPage.RESOURCE_TYPE_NAME + "," + CmsResourceTypeXmlContainerPage.MODEL_GROUP_TYPE_NAME);
CmsSearchReplaceThread thread = new CmsSearchReplaceThread(null, cms, settings, new CmsShellLogReport(m_cms.getRequestContext().getLocale()));
thread.run();
} catch (CmsException e) {
//
}
}
use of org.opencms.ui.apps.search.CmsSearchReplaceSettings in project opencms-core by alkacon.
the class CmsPropertyTable method showResources.
/**
* Change to source search for showing resources for property definition.<p>
*
* @param propertyName to search resources for
*/
protected void showResources(String propertyName) {
CmsSearchReplaceSettings settings = new CmsSearchReplaceSettings();
settings.setPaths(Collections.singletonList("/"));
settings.setSiteRoot("");
settings.setSearchpattern(".*");
settings.setType(SearchType.properties);
try {
settings.setProperty(A_CmsUI.getCmsObject().readPropertyDefinition(propertyName));
} catch (CmsException e) {
//
}
CmsAppWorkplaceUi.get().showApp(CmsSourceSearchAppConfiguration.APP_ID, CmsSourceSearchApp.generateState(settings));
}
Aggregations