CCM NG/ccm-cms: Renaming folders
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4595 8810af33-2d31-482b-a856-94f89814c4df
Former-commit-id: 82f51a1d70
pull/2/head
parent
7b50e1b830
commit
468a4b9473
|
|
@ -22,44 +22,52 @@ import com.arsdigita.bebop.FormData;
|
|||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
|
||||
|
||||
/**
|
||||
* Implements functionality for renaming a folder. Most code taken from FolderCreator. Need to refactor out base
|
||||
* functionality of FolderEditor & Creator.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens >Pelzetter</a>
|
||||
* @author <a href="mailto:jorris@arsdigita.com">Jon Orris</a>
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens >Pelzetter</a>
|
||||
*
|
||||
*/
|
||||
|
||||
public class FolderEditor extends FolderForm {
|
||||
|
||||
public FolderEditor(String name, FolderSelectionModel folder) {
|
||||
public FolderEditor(final String name, final FolderSelectionModel folder) {
|
||||
super(name, folder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the form with name & label of folder being edited.
|
||||
* @param e
|
||||
* @param event
|
||||
* @throws com.arsdigita.bebop.FormProcessException
|
||||
*/
|
||||
@Override
|
||||
public void init(FormSectionEvent e) throws FormProcessException {
|
||||
PageState s = e.getPageState();
|
||||
FormData data = e.getFormData();
|
||||
Category folder = getCurrentFolder(s);
|
||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
final FormData data = event.getFormData();
|
||||
final Category folder = getCurrentFolder(state);
|
||||
data.put(NAME, folder.getName());
|
||||
data.put(TITLE, folder.getDisplayName());
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final ConfigurationManager confManager = cdiUtil.findBean(ConfigurationManager.class);
|
||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||
KernelConfig.class);
|
||||
data.put(TITLE,
|
||||
folder.getTitle().getValue(kernelConfig.getDefaultLocale()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent e) throws FormProcessException {
|
||||
PageState s = e.getPageState();
|
||||
FormData data = e.getFormData();
|
||||
Category folder = getCurrentFolder(s);
|
||||
public void process(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
final FormData data = event.getFormData();
|
||||
final Category folder = getCurrentFolder(state);
|
||||
|
||||
updateFolder(folder, (String)data.get(NAME), (String)data.get(TITLE));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import com.arsdigita.bebop.parameters.TrimmedStringParameter;
|
|||
import com.arsdigita.bebop.parameters.URLTokenValidationListener;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
|
@ -46,6 +47,8 @@ import org.apache.logging.log4j.Logger;
|
|||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.categorization.CategoryRepository;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
import org.librecms.CmsConstants;
|
||||
|
||||
/**
|
||||
|
|
@ -366,10 +369,15 @@ public abstract class FolderForm extends FormSection
|
|||
final protected void updateFolder(final Category folder,
|
||||
final String name,
|
||||
final String label) {
|
||||
folder.setName(name);
|
||||
folder.setDisplayName(label);
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final ConfigurationManager confManager = cdiUtil.findBean(ConfigurationManager.class);
|
||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||
KernelConfig.class);
|
||||
|
||||
folder.setName(name);
|
||||
folder.setDisplayName(name);
|
||||
folder.getTitle().addValue(kernelConfig.getDefaultLocale(), label);
|
||||
|
||||
final CategoryRepository categoryRepo = cdiUtil.findBean(
|
||||
CategoryRepository.class);
|
||||
categoryRepo.save(folder);
|
||||
|
|
@ -378,10 +386,9 @@ public abstract class FolderForm extends FormSection
|
|||
/**
|
||||
* Returns the current folder being operated on.
|
||||
*
|
||||
* @param state
|
||||
* @return The current folder
|
||||
*
|
||||
* @pre state != null
|
||||
* @post return != null
|
||||
*/
|
||||
final protected Category getCurrentFolder(final PageState state) {
|
||||
final Category folder = (Category) currentFolder
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.arsdigita.bebop.tree.TreeModel;
|
|||
import com.arsdigita.bebop.tree.TreeModelBuilder;
|
||||
import com.arsdigita.bebop.tree.TreeNode;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceTreeNode;
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
|
||||
|
|
@ -40,6 +40,7 @@ import org.librecms.contentsection.Folder;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
|
||||
/**
|
||||
* A {@link com.arsdigita.bebop.tree.TreeModelBuilder} that produces trees
|
||||
|
|
@ -115,8 +116,6 @@ public class FolderTreeModelBuilder extends LockableImpl
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*return new DataQueryTreeModel(getRoot(state).getID(),
|
||||
"com.arsdigita.cms.getRootFolder",
|
||||
"com.arsdigita.cms.getSubFolders") {
|
||||
|
|
@ -199,7 +198,12 @@ public class FolderTreeModelBuilder extends LockableImpl
|
|||
if (folder.getTitle().hasValue(locale)) {
|
||||
return folder.getTitle().getValue(locale);
|
||||
} else {
|
||||
final String value = folder.getTitle().getValue();
|
||||
final ConfigurationManager confManager = cdiUtil.findBean(
|
||||
ConfigurationManager.class);
|
||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||
KernelConfig.class);
|
||||
final String value = folder.getTitle().getValue(kernelConfig.
|
||||
getDefaultLocale());
|
||||
if (value == null) {
|
||||
return folder.getName();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -118,3 +118,5 @@ cms.ui.edit_folder=Rename the current folder
|
|||
cms.ui.authoring.create_new=Create new
|
||||
cms.ui.authoring.go=Go
|
||||
empty_text=
|
||||
cms.contenttypes.ui.title=Title
|
||||
cms.contenttypes.ui.name=Name (URL fragment)
|
||||
|
|
|
|||
|
|
@ -117,3 +117,5 @@ cms.ui.edit_folder=Aktuellen Ordner umbenennen
|
|||
cms.ui.authoring.create_new=Neuer Inhalt
|
||||
cms.ui.authoring.go=Anlegen
|
||||
empty_text=
|
||||
cms.contenttypes.ui.title=Titel
|
||||
cms.contenttypes.ui.name=Name (URL-Fragment)
|
||||
|
|
|
|||
|
|
@ -86,3 +86,5 @@ cms.ui.edit_folder=Rename the current folder
|
|||
cms.ui.authoring.create_new=Create new
|
||||
cms.ui.authoring.go=Go
|
||||
empty_text=
|
||||
cms.contenttypes.ui.title=Title
|
||||
cms.contenttypes.ui.name=Name (URL fragment)
|
||||
|
|
|
|||
Loading…
Reference in New Issue