diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AbstractAssetForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AbstractAssetForm.java index b8595be24..d10414413 100644 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AbstractAssetForm.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/AbstractAssetForm.java @@ -116,8 +116,7 @@ public abstract class AbstractAssetForm } } - } - ); + }); showLocaleSelect = new SingleSelect("selected-locale"); try { showLocaleSelect.addPrintListener(new PrintListener() { @@ -139,9 +138,8 @@ public abstract class AbstractAssetForm final List availableLocales = new ArrayList<>( l10nManager.availableLocales(selectedAsset.get())); availableLocales.sort((locale1, locale2) -> { - return locale1 - .toString() - .compareTo(locale2.toString()); + return locale1.toString().compareTo(locale2 + .toString()); }); availableLocales.forEach(locale -> target.addOption( new Option(locale.toString(), @@ -301,10 +299,7 @@ public abstract class AbstractAssetForm if (selectedAsset.isPresent()) { showLocaleSelect.setValue(state, - KernelConfig - .getConfig() - .getDefaultLocale() - .toString()); + getSelectedLocale(state)); title.setValue(state, selectedAsset diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/AttachmentListSelectionModel.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/AttachmentListSelectionModel.java new file mode 100644 index 000000000..8a576d784 --- /dev/null +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/AttachmentListSelectionModel.java @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2017 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.arsdigita.cms.ui.authoring.assets; + +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.ParameterSingleSelectionModel; +import com.arsdigita.bebop.SingleSelectionModel; +import com.arsdigita.bebop.event.ChangeListener; +import com.arsdigita.bebop.parameters.LongParameter; +import com.arsdigita.bebop.parameters.ParameterModel; + +import org.libreccm.cdi.utils.CdiUtil; +import org.librecms.contentsection.AttachmentList; +import org.librecms.contentsection.AttachmentListManager; + +/** + * + * @author Jens Pelzetter + */ +public class AttachmentListSelectionModel implements + SingleSelectionModel { + + private final SingleSelectionModel model; + + public AttachmentListSelectionModel(final LongParameter parameter) { + this.model = new ParameterSingleSelectionModel<>(parameter); + } + + public AttachmentListSelectionModel(final String parameterName) { + this(new LongParameter(parameterName)); + } + + @Override + public boolean isSelected(final PageState state) { + return model.isSelected(state); + } + + @Override + public Long getSelectedKey(final PageState state) { + final Object key = model.getSelectedKey(state); + if (key == null) { + return null; + } else if (key instanceof Long) { + return (Long) key; + } else if (key instanceof String) { + return Long.parseLong((String) key); + } else { + return Long.parseLong(key.toString()); + } + } + + @Override + public void setSelectedKey(final PageState state, + final Long key) { + model.setSelectedKey(state, key); + } + + public AttachmentList getSelectedAttachmentList(final PageState state) { + final Long key = getSelectedKey(state); + if (key == null) { + return null; + } else { + final AttachmentListManager manager = CdiUtil + .createCdiUtil() + .findBean(AttachmentListManager.class); + return manager.getAttachmentList(key).get(); + } + } + + @Override + public void clearSelection(final PageState state) { + model.clearSelection(state); + } + + @Override + public void addChangeListener(final ChangeListener changeListener) { + model.addChangeListener(changeListener); + } + + @Override + public void removeChangeListener(final ChangeListener changeListener) { + model.removeChangeListener(changeListener); + } + + @Override + public ParameterModel getStateParameter() { + return model.getStateParameter(); + } + +} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListForm.java new file mode 100644 index 000000000..4473a272b --- /dev/null +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListForm.java @@ -0,0 +1,377 @@ +/* + * Copyright (C) 2017 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.arsdigita.cms.ui.authoring.assets.relatedinfo; + +import com.arsdigita.bebop.BoxPanel; +import com.arsdigita.bebop.Form; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.SaveCancelSection; +import com.arsdigita.bebop.Text; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.FormSubmissionListener; +import com.arsdigita.bebop.form.Option; +import com.arsdigita.bebop.form.SingleSelect; +import com.arsdigita.bebop.form.Submit; +import com.arsdigita.bebop.form.TextArea; +import com.arsdigita.bebop.form.TextField; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel; +import com.arsdigita.globalization.GlobalizedMessage; +import com.arsdigita.kernel.KernelConfig; + +import org.libreccm.cdi.utils.CdiUtil; +import org.libreccm.core.UnexpectedErrorException; +import org.librecms.CmsConstants; +import org.librecms.contentsection.AttachmentList; +import org.librecms.contentsection.AttachmentListL10NManager; +import org.librecms.contentsection.AttachmentListManager; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import java.util.TooManyListenersException; + +/** + * + * @author Jens Pelzetter + */ +class RelatedInfoListForm + extends Form + implements FormInitListener, + FormProcessListener, + FormSubmissionListener { + + private final RelatedInfoStep relatedInfoStep; + private final ItemSelectionModel itemSelectionModel; + private final AttachmentListSelectionModel listSelectionModel; + private final StringParameter selectedLanguage; + + private BoxPanel showLocalePanel; + private SingleSelect showLocaleSelect; + private Submit showLocaleSubmit; + + private BoxPanel addLocalePanel; + private SingleSelect addLocaleSelect; + private Submit addLocaleSubmit; + + private TextField nameField; + private TextField titleField; + private TextArea descriptionArea; + + private SaveCancelSection saveCancelSection; + + public RelatedInfoListForm( + final RelatedInfoStep relatedInfoStep, + final ItemSelectionModel itemSelectionModel, + final AttachmentListSelectionModel listSelectionModel, + final StringParameter selectedLanguageParam) { + + super("relatedinfo-list-form", new BoxPanel(BoxPanel.VERTICAL)); + + this.relatedInfoStep = relatedInfoStep; + this.itemSelectionModel = itemSelectionModel; + this.listSelectionModel = listSelectionModel; + this.selectedLanguage = selectedLanguageParam; + + showLocalePanel = new BoxPanel(BoxPanel.HORIZONTAL); + final Label showLocaleLabel = new Label(event -> { + + final PageState state = event.getPageState(); + final Optional selectedList = getSelectedList(state); + final Label target = (Label) event.getTarget(); + if (selectedList.isPresent()) { + target.setLabel(new GlobalizedMessage( + "cms.ui.assetlist.show_locale", + CmsConstants.CMS_BUNDLE)); + } else { + target.setLabel(new GlobalizedMessage( + "cms.ui.assetlist.initial_locale", + CmsConstants.CMS_BUNDLE)); + } + }); + showLocaleSelect = new SingleSelect("selected-locale"); + try { + showLocaleSelect.addPrintListener(event -> { + + final PageState state = event.getPageState(); + + final Optional selectedList = getSelectedList( + state); + if (selectedList.isPresent()) { + final SingleSelect target = (SingleSelect) event.getTarget(); + + target.clearOptions();; + + final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); + final AttachmentListL10NManager l10NManager = cdiUtil + .findBean(AttachmentListL10NManager.class); + final List availableLocales = new ArrayList<>( + l10NManager.availableLocales(selectedList.get())); + availableLocales.sort((locale1, locale2) -> { + return locale1.toString().compareTo(locale2.toString()); + }); + availableLocales.forEach(locale -> target.addOption( + new Option(locale.toString(), + new Text(locale.toString())))); + } else { + final SingleSelect target = (SingleSelect) event + .getTarget(); + + target.clearOptions(); + + final List langs = new ArrayList<>( + KernelConfig.getConfig().getSupportedLanguages()); + langs.sort((lang1, lang2) -> lang1.compareTo(lang2)); + + langs.forEach(lang -> { + target.addOption(new Option(lang, new Text(lang))); + }); + + } + + }); + } catch (TooManyListenersException ex) { + throw new UnexpectedErrorException(ex); + } + showLocaleSubmit = new Submit(new GlobalizedMessage( + "cms.ui.assetlist.show_locale", + CmsConstants.CMS_BUNDLE)) { + + @Override + public boolean isVisible(final PageState state) { + return getSelectedList(state).isPresent(); + } + + }; + showLocalePanel.add(showLocaleLabel); + showLocalePanel.add(showLocaleSelect); + showLocalePanel.add(showLocaleSubmit); + super.add(showLocalePanel); + + addLocalePanel = new BoxPanel(BoxPanel.HORIZONTAL) { + + @Override + public boolean isVisible(final PageState state) { + return getSelectedList(state).isPresent(); + } + + }; + final Label addLocaleLabel = new Label( + new GlobalizedMessage("cms.ui.assetlist.add_locale", + CmsConstants.CMS_BUNDLE)); + addLocaleSelect = new SingleSelect("add-locale-select"); + try { + addLocaleSelect.addPrintListener(event -> { + + final PageState state = event.getPageState(); + final Optional selectedList = getSelectedList( + state); + if (selectedList.isPresent()) { + final SingleSelect target = (SingleSelect) event.getTarget(); + + target.clearOptions(); + + final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); + final AttachmentListL10NManager l10nManager = cdiUtil + .findBean(AttachmentListL10NManager.class); + final List creatableLocales = new ArrayList<>( + l10nManager.creatableLocales(selectedList.get())); + creatableLocales.sort((locale1, locale2) -> { + return locale1 + .toString() + .compareTo(locale2.toString()); + }); + creatableLocales.forEach(locale -> target.addOption( + new Option(locale.toString(), + new Text(locale.toString())))); + + } + + }); + } catch (TooManyListenersException ex) { + throw new UnexpectedErrorException(ex); + } + addLocaleSubmit = new Submit(new GlobalizedMessage( + "cms.ui.assetlist.add_locale", + CmsConstants.CMS_BUNDLE)); + addLocalePanel.add(addLocaleLabel); + addLocalePanel.add(addLocaleSelect); + addLocalePanel.add(addLocaleSubmit); + super.add(addLocalePanel); + + super.add(new Label(new GlobalizedMessage("cms.ui.assetlist.name", + CmsConstants.CMS_BUNDLE))); + nameField = new TextField("attachmentListName"); + super.add(nameField); + + super.add(new Label(new GlobalizedMessage("cms.ui.assetlist.title", + CmsConstants.CMS_BUNDLE))); + titleField = new TextField("attachmentListTitle"); + super.add(titleField); + + super.add(new Label( + new GlobalizedMessage("cms.ui.assetlist.description", + CmsConstants.CMS_BUNDLE))); + descriptionArea = new TextArea("attachmentListDesc"); + super.add(descriptionArea); + + saveCancelSection = new SaveCancelSection(); + super.add(saveCancelSection); + + super.addInitListener(this); + super.addProcessListener(this); + super.addSubmissionListener(this); + } + + protected Optional getSelectedList(final PageState state) { + + if (listSelectionModel.getSelectedKey(state) == null) { + return Optional.empty(); + } else { + final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); + final AttachmentListManager manager = cdiUtil + .findBean(AttachmentListManager.class); + final AttachmentList list = manager + .getAttachmentList(listSelectionModel.getSelectedKey(state)) + .orElseThrow(() -> new IllegalArgumentException(String + .format("No AttachmentList with ID %d in the database.", + listSelectionModel.getSelectedKey(state)))); + return Optional.of(list); + } + } + + @Override + public void init(final FormSectionEvent event) throws FormProcessException { + + final PageState state = event.getPageState(); + + final Optional selectedList = getSelectedList(state); + + if (selectedList.isPresent()) { + + nameField.setValue(state, selectedList.get().getName()); + + showLocaleSelect.setValue(state, + KernelConfig + .getConfig() + .getDefaultLocale() + .toString()); + + titleField.setValue(state, + selectedList + .get() + .getTitle() + .getValue(getSelectedLocale(state))); + + descriptionArea.setValue(state, + selectedList + .get() + .getTitle() + .getValue(getSelectedLocale(state))); + } else { + showLocaleSelect.setValue(state, + KernelConfig + .getConfig() + .getDefaultLocale() + .toString()); + } + } + + protected Locale getSelectedLocale(final PageState state) { + final String selected = (String) showLocaleSelect.getValue(state); + if (selected == null) { + return KernelConfig.getConfig().getDefaultLocale(); + } else { + return new Locale(selected); + } + } + + @Override + public void process(final FormSectionEvent event) + throws FormProcessException { + + final PageState state = event.getPageState(); + + final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); + + if (showLocaleSubmit.isSelected(state)) { + + return; + } + + if (addLocaleSubmit.isSelected(state)) { + final AttachmentListL10NManager l10nManager = cdiUtil + .findBean(AttachmentListL10NManager.class); + final Locale add = new Locale((String) addLocaleSelect + .getValue(state)); + final Optional selectedList = getSelectedList(state); + l10nManager.addLanguage(selectedList.get(), add); + } + + if (saveCancelSection.getSaveButton().isSelected(state)) { + + final RelatedInfoStepController controller = cdiUtil + .findBean(RelatedInfoStepController.class); + final AttachmentListManager attachmentListManager = cdiUtil + .findBean(AttachmentListManager.class); + + final Optional selectedList = getSelectedList(state); + final AttachmentList attachmentList; + if (selectedList.isPresent()) { + attachmentList = selectedList.get(); + } else { + attachmentList = attachmentListManager + .createAttachmentList(itemSelectionModel + .getSelectedItem(state), + (String) nameField.getValue(state)); + } + + attachmentList.setName((String) nameField.getValue(state)); + attachmentList + .getTitle() + .addValue(getSelectedLocale(state), + (String) titleField.getValue(state)); + attachmentList + .getDescription() + .addValue(getSelectedLocale(state), + (String) descriptionArea.getValue(state)); + + controller.saveAttachmentList(attachmentList); + } + } + + @Override + public void submitted(final FormSectionEvent event) + throws FormProcessException { + + final PageState state = event.getPageState(); + + if (saveCancelSection.getCancelButton().isSelected(state)) { + listSelectionModel.clearSelection(state); + relatedInfoStep.showAttachmentList(state); + } + } + +} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/RelatedInfoStep.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStep.java similarity index 90% rename from ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/RelatedInfoStep.java rename to ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStep.java index ec452c0fc..570fa6c2b 100644 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/RelatedInfoStep.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStep.java @@ -16,8 +16,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ -package com.arsdigita.cms.ui.authoring.assets; +package com.arsdigita.cms.ui.authoring.assets.relatedinfo; +import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.Text; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.ItemSelectionModel; @@ -47,4 +48,8 @@ public class RelatedInfoStep extends ResettableContainer { super.add(new Text("Related Info Step placeholder")); } + protected void showAttachmentList(final PageState state) { + + } + } diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStepController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStepController.java new file mode 100644 index 000000000..ea5ade23e --- /dev/null +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStepController.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2017 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.arsdigita.cms.ui.authoring.assets.relatedinfo; + +import org.librecms.contentsection.AttachmentList; +import org.librecms.contentsection.AttachmentListManager; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.persistence.EntityManager; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +class RelatedInfoStepController { + + @Inject + private AttachmentListManager attachmentListManager; + + @Inject + private EntityManager entityManager; + + protected void saveAttachmentList(final AttachmentList attachmentList) { + + if (attachmentList.getListId() == 0) { + entityManager.persist(attachmentList); + } else { + entityManager.merge(attachmentList); + } + } +} diff --git a/ccm-cms/src/main/java/org/librecms/assets/AssetL10NManager.java b/ccm-cms/src/main/java/org/librecms/assets/AssetL10NManager.java index 028fc43ef..46c9f2b25 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/AssetL10NManager.java +++ b/ccm-cms/src/main/java/org/librecms/assets/AssetL10NManager.java @@ -51,7 +51,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; /** - * Manages the language versions of an asset. + * Manages the language variants of an asset. * * @author Jens Pelzetter */ @@ -159,7 +159,7 @@ public class AssetL10NManager { * @param asset The asset to check. * @param locale The locale to check for. * - * @return {@link true} if the item has data for the language, {@code false} + * @return {@link true} if the asset has data for the language, {@code false} * if not. */ @AuthorizationRequired @@ -184,7 +184,7 @@ public class AssetL10NManager { * * @param asset The asset. * - * @return A {@link Set} with the locales for which the item does not have a + * @return A {@link Set} with the locales for which the asset does not have a * variant. */ @Transactional(Transactional.TxType.REQUIRED) diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/AttachmentListL10NManager.java b/ccm-cms/src/main/java/org/librecms/contentsection/AttachmentListL10NManager.java new file mode 100644 index 000000000..ff743f91f --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/contentsection/AttachmentListL10NManager.java @@ -0,0 +1,334 @@ +/* + * Copyright (C) 2017 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.contentsection; + +import com.arsdigita.kernel.KernelConfig; + +import org.libreccm.configuration.ConfigurationManager; +import org.libreccm.core.UnexpectedErrorException; +import org.libreccm.l10n.LocalizedString; +import org.libreccm.security.AuthorizationRequired; +import org.libreccm.security.RequiresPrivilege; +import org.librecms.contentsection.privileges.AssetPrivileges; + +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.annotation.PostConstruct; +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.persistence.EntityManager; +import javax.transaction.Transactional; + +/** + * Manages the language variants of an {@link AttachmentList}. + * + * @author Jens Pelzetter + */ +@RequestScoped +public class AttachmentListL10NManager { + + @Inject + private ConfigurationManager confManager; + + @Inject + private AttachmentListManager listManager; + + @Inject + private EntityManager entityManager; + + private Locale defaultLocale; + private List supportedLocales; + + @PostConstruct + private void init() { + final KernelConfig kernelConfig = confManager.findConfiguration( + KernelConfig.class); + defaultLocale = kernelConfig.getDefaultLocale(); + supportedLocales = kernelConfig.getSupportedLanguages() + .stream() + .map(language -> new Locale(language)) + .collect(Collectors.toList()); + } + + private List findLocalizedStringProperties( + final AttachmentList attachmentList) { + + try { + final PropertyDescriptor[] properties = Introspector + .getBeanInfo(attachmentList.getClass()) + .getPropertyDescriptors(); + + return Arrays.stream(properties) + .filter(property -> { + return property + .getPropertyType() + .isAssignableFrom(LocalizedString.class); + }) + .collect(Collectors.toList()); + } catch (IntrospectionException ex) { + throw new UnexpectedErrorException(ex); + } + + } + + private LocalizedString readLocalizedString( + final AttachmentList attachmentList, + final Method readMethod) { + + try { + return (LocalizedString) readMethod.invoke(attachmentList); + } catch (IllegalAccessException + | IllegalArgumentException + | InvocationTargetException ex) { + throw new UnexpectedErrorException(ex); + } + } + + private Set collectLanguages(final AttachmentList attachmentList) { + + final Set locales = new HashSet<>(); + + findLocalizedStringProperties(attachmentList) + .stream() + .map(property -> property.getReadMethod()) + .map(readMethod -> readLocalizedString(attachmentList, readMethod)) + .forEach(str -> locales.addAll(str.getAvailableLocales())); + + return locales; + } + + /** + * Retrieves all languages in which the describing properties of an {@link AttachmentList) are available. + * + * @param attachmentList The {@link AttachmentList} + * + * @return An (unmodifiable) {@link Set} containing all languages in which + * the attachment list is available. + */ + @Transactional(Transactional.TxType.REQUIRED) + public Set availableLocales(final AttachmentList attachmentList) { + + return Collections.unmodifiableSet(collectLanguages(attachmentList)); + } + + /** + * Checks if an {@link AttachmentList} has data for the particular language. + * + * @param attachmentList The AttachmentList to check. + * @param locale The locale to check for. + * + * @return {@link true} if the attachment list has data for the language, + * {@code false} if not. + */ + public boolean hasLanguage(final AttachmentList attachmentList, + final Locale locale) { + + Objects.requireNonNull( + attachmentList, + "Can't check if AttachmentList null has a specific locale."); + Objects.requireNonNull(locale, "Can't check for locale null."); + + return collectLanguages(attachmentList).contains(locale); + } + + /** + * Returns a {@link Set} containing the locales for which the + * {@link AttachmentList} does not yet have a variant. + * + * @param attachmentList The {@link AttachmentList}. + * + * @return A {@link Set} with the locales for which the + * {@link AttachmentList} does not have a variant. + */ + @Transactional(Transactional.TxType.REQUIRED) + public Set creatableLocales(final AttachmentList attachmentList) { + + return supportedLocales.stream() + .filter(locale -> !hasLanguage(attachmentList, locale)) + .collect(Collectors.toSet()); + } + + /** + * Adds a language to an {@link AttachmentList}. The method will retrieve + * all fields of the type {@link LocalizedString} from the + * {@link AttachmentList} and add a new entry for the provided locale by + * coping the value for the default language configured in + * {@link KernelConfig}. If a field does not have an entry for the default + * language the first value found is used. + * + * @param attachmentList The {@link AttachmentList} to which the language + * variant is added. + * @param locale The locale of the language to add. + */ + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public void addLanguage( + @RequiresPrivilege(AssetPrivileges.EDIT) + final AttachmentList attachmentList, + final Locale locale) { + + Objects.requireNonNull(attachmentList, + "Can't add language to asset null."); + Objects.requireNonNull(attachmentList, + "Cant't add language null to an asset."); + + findLocalizedStringProperties(attachmentList) + .forEach(property -> addLanguage(attachmentList, locale, property)); + + entityManager.merge(attachmentList); + } + + private void addLanguage(final AttachmentList attachmentList, + final Locale locale, + final PropertyDescriptor property) { + + final Method readMethod = property.getReadMethod(); + final LocalizedString localizedStr = readLocalizedString(attachmentList, + readMethod); + addLanguage(localizedStr, locale); + } + + private void addLanguage(final LocalizedString localizedString, + final Locale locale) { + if (localizedString.hasValue(locale)) { + //Nothing to do + return; + } + + final String value; + if (localizedString.hasValue(defaultLocale)) { + value = localizedString.getValue(defaultLocale); + } else { + value = findValue(localizedString); + } + + localizedString.addValue(locale, value); + } + + private String findValue(final LocalizedString localizedStr) { + final Optional locale = supportedLocales + .stream() + .filter(current -> localizedStr.hasValue(current)) + .findAny(); + + if (locale.isPresent()) { + return localizedStr.getValue(locale.get()); + } else { + return "Lorem ipsum"; + } + } + + /** + * Removes a language variant from an {@link AttachmentList}. This method + * will retrieve all fields of the type {@link LocalizedString} from the + * {@link AttachmentList} and remove the entry for the provided locale if + * the field has an entry for that locale. + * + * @param attachmentList + * @param locale + */ + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public void removeLanguage( + @RequiresPrivilege(AssetPrivileges.EDIT) + final AttachmentList attachmentList, + final Locale locale) { + + Objects.requireNonNull(attachmentList, + "Can't remove language to attachmentList null."); + Objects + .requireNonNull(attachmentList, + "Cant't remove language null to an attachmentList."); + + findLocalizedStringProperties(attachmentList) + .forEach( + property -> removeLanguage(attachmentList, locale, property)); + + entityManager.merge(attachmentList); + } + + private void removeLanguage(final AttachmentList attachmentList, + final Locale locale, + final PropertyDescriptor property) { + + final Method readMethod = property.getReadMethod(); + + final LocalizedString localizedStr = readLocalizedString(attachmentList, + readMethod); + if (localizedStr.hasValue(locale)) { + localizedStr.removeValue(locale); + } + } + + /** + * This method normalises the values of the fields of type + * {@link LocalizedString} of an {@link AttachmentList}. The method will + * first retrieve all fields of the type {@link LocalizedString} from the + * {@link AttachmentList} and than build a set with all locales provided by + * any of the fields. After that the method will iterate over all + * {@link LocalizedString} fields and check if the {@link LocalizedString} + * has an entry for every language in the set. If not an entry for the + * language is added. + * + * @param attachmentList The attachmentList to normalise. + */ + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public void normalizeLanguages( + final AttachmentList attachmentList) { + + Objects.requireNonNull(attachmentList, + "Can't normalise attachmentList null"); + + final Set languages = collectLanguages(attachmentList); + + findLocalizedStringProperties(attachmentList) + .stream() + .map(property -> property.getReadMethod()) + .map(readMethod -> readLocalizedString(attachmentList, readMethod)) + .forEach(str -> normalize(str, languages)); + } + + private void normalize(final LocalizedString localizedString, + final Set languages) { + + final List missingLangs = languages.stream() + .filter(lang -> !localizedString.hasValue(lang)) + .collect(Collectors.toList()); + + if (!missingLangs.isEmpty()) { + missingLangs.stream() + .forEach(lang -> addLanguage(localizedString, lang)); + } + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionConfig.java b/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionConfig.java index bb24c4183..08d12639a 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionConfig.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionConfig.java @@ -18,7 +18,7 @@ */ package org.librecms.contentsection; -import com.arsdigita.cms.ui.authoring.assets.RelatedInfoStep; +import com.arsdigita.cms.ui.authoring.assets.relatedinfo.RelatedInfoStep; import com.arsdigita.cms.ui.authoring.assets.images.ImageStep; import org.libreccm.cdi.utils.CdiUtil; diff --git a/ccm-cms/src/main/resources/org/librecms/CmsResources.properties b/ccm-cms/src/main/resources/org/librecms/CmsResources.properties index ca9a562c8..2e846a740 100644 --- a/ccm-cms/src/main/resources/org/librecms/CmsResources.properties +++ b/ccm-cms/src/main/resources/org/librecms/CmsResources.properties @@ -414,3 +414,9 @@ cms.ui.authoring.assets.imagestep.available_images.title_header=Title cms.ui.authoring.assets.imagestep.available_images.add=Add cms.ui.authoring.assets.imagestep.assigned_images.title_header=Title cms.ui.authoring.assets.imagestep.assigned_images.remove=Remove +cms.ui.assetlist.show_locale=Show data for locale +cms.ui.assetlist.initial_locale=Language +cms.ui.assetlist.add_locale=Add data for language +cms.ui.assetlist.name=Name +cms.ui.assetlist.title=Title +cms.ui.assetlist.description=Description diff --git a/ccm-cms/src/main/resources/org/librecms/CmsResources_de.properties b/ccm-cms/src/main/resources/org/librecms/CmsResources_de.properties index 6b835619b..1ef8fdb99 100644 --- a/ccm-cms/src/main/resources/org/librecms/CmsResources_de.properties +++ b/ccm-cms/src/main/resources/org/librecms/CmsResources_de.properties @@ -411,3 +411,9 @@ cms.ui.authoring.assets.imagestep.available_images.title_header=Titel cms.ui.authoring.assets.imagestep.available_images.add=Hinzuf\u00fcgen cms.ui.authoring.assets.imagestep.assigned_images.title_header=Titel cms.ui.authoring.assets.imagestep.assigned_images.remove=Entfernen +cms.ui.assetlist.show_locale=Zeige Daten f\u00fcr Sprache +cms.ui.assetlist.initial_locale=Sprache +cms.ui.assetlist.add_locale=Daten f\u00fcr folgende Sprache hinzuf\u00fcgen +cms.ui.assetlist.name=Name +cms.ui.assetlist.title=Titel +cms.ui.assetlist.description=Beschreibung diff --git a/ccm-cms/src/main/resources/org/librecms/CmsResources_fr.properties b/ccm-cms/src/main/resources/org/librecms/CmsResources_fr.properties index 53c217805..8f57e02a7 100644 --- a/ccm-cms/src/main/resources/org/librecms/CmsResources_fr.properties +++ b/ccm-cms/src/main/resources/org/librecms/CmsResources_fr.properties @@ -370,3 +370,9 @@ cms.ui.authoring.assets.imagestep.available_images.title_header=Title cms.ui.authoring.assets.imagestep.available_images.add=Add cms.ui.authoring.assets.imagestep.assigned_images.title_header=Title cms.ui.authoring.assets.imagestep.assigned_images.remove=Remove +cms.ui.assetlist.show_locale=Show data for locale +cms.ui.assetlist.initial_locale=Language +cms.ui.assetlist.add_locale=Add data for language +cms.ui.assetlist.name=Name +cms.ui.assetlist.title=Title +cms.ui.assetlist.description=Description diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/roles/RoleMembersTable.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/roles/RoleMembersTable.java index 0cac42e45..26180ff4c 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/roles/RoleMembersTable.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/roles/RoleMembersTable.java @@ -34,7 +34,7 @@ import com.arsdigita.bebop.table.TableModelBuilder; import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.util.LockableImpl; -import org.libreccm.admin.ui.UsersGroupsRoles; +import org.libreccm.admin.ui.UsersGroupsRolesTab; import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.security.Group; import org.libreccm.security.Party; diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/AdminView.java b/ccm-core/src/main/java/org/libreccm/admin/ui/AdminView.java index edf427e14..325fd2a10 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/AdminView.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/AdminView.java @@ -23,18 +23,11 @@ import com.arsdigita.ui.admin.AdminUiConstants; import com.vaadin.cdi.CDIView; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; -import com.vaadin.server.ClassResource; import com.vaadin.server.VaadinServlet; -import com.vaadin.shared.ui.MarginInfo; -import com.vaadin.ui.Alignment; import com.vaadin.ui.CssLayout; import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Image; -import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.themes.ValoTheme; import org.apache.shiro.subject.Subject; import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.security.GroupManager; @@ -107,7 +100,7 @@ public class AdminView extends CustomComponent implements View { private final TabSheet tabSheet; // private final Grid usersTable; private final TabSheet.Tab tabUsersGroupsRoles; - private final UsersGroupsRoles usersGroupsRoles; + private final UsersGroupsRolesTab usersGroupsRoles; private final JpqlConsole jpqlConsole; @@ -115,7 +108,7 @@ public class AdminView extends CustomComponent implements View { tabSheet = new TabSheet(); - usersGroupsRoles = new UsersGroupsRoles(this); + usersGroupsRoles = new UsersGroupsRolesTab(this); tabUsersGroupsRoles = tabSheet.addTab(usersGroupsRoles, "Users/Groups/Roles"); diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/ConfigurationTab.java b/ccm-core/src/main/java/org/libreccm/admin/ui/ConfigurationTab.java new file mode 100644 index 000000000..c108c049d --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/ConfigurationTab.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2017 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.admin.ui; + +import com.vaadin.ui.CustomComponent; + +/** + * + * @author Jens Pelzetter + */ +public class ConfigurationTab extends CustomComponent { + + private static final long serialVersionUID = 7642627611731762410L; + + + + public ConfigurationTab(final AdminView adminView) { + + } + + +} diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/ConfigurationsTabController.java b/ccm-core/src/main/java/org/libreccm/admin/ui/ConfigurationsTabController.java new file mode 100644 index 000000000..0f0acd260 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/ConfigurationsTabController.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2017 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.admin.ui; + +import com.vaadin.cdi.ViewScoped; + +/** + * + * @author Jens Pelzetter + */ +@ViewScoped +public class ConfigurationsTabController { + + + +} diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/ConfigurationsTableDataProvider.java b/ccm-core/src/main/java/org/libreccm/admin/ui/ConfigurationsTableDataProvider.java new file mode 100644 index 000000000..c8dacfb82 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/ConfigurationsTableDataProvider.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2017 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.admin.ui; + +import com.vaadin.cdi.ViewScoped; +import com.vaadin.data.provider.AbstractDataProvider; +import com.vaadin.data.provider.Query; +import org.libreccm.configuration.ConfigurationInfo; +import org.libreccm.configuration.ConfigurationManager; +import org.libreccm.l10n.GlobalizationHelper; + +import java.util.SortedSet; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.inject.Inject; + +/** + * + * @author Jens Pelzetter + */ +@ViewScoped +public class ConfigurationsTableDataProvider extends AbstractDataProvider, String> { + + private static final long serialVersionUID = -7001151229931864885L; + + private String filter; + + @Inject + private ConfigurationManager confManager; + + @Inject + private GlobalizationHelper globalizationHelper; + + @Override + public boolean isInMemory() { + return false; + } + + @Override + public int size(final Query, String> query) { + if (filter == null || filter.trim().isEmpty()) { + return confManager.findAllConfigurations().size(); + } else { + return (int) confManager + .findAllConfigurations() + .stream() + .filter(conf -> { + final ConfigurationInfo info = confManager + .getConfigurationInfo(conf); +// return c.getName().startsWith(filterTerm); + if (filter == null || filter.isEmpty()) { + return true; + } else { + return info + .getTitle(globalizationHelper.getNegotiatedLocale()) + .startsWith( + filter); + } + }) + .count(); + } + } + + @Override + public Stream> fetch(final Query, String> query) { + if (filter == null || filter.trim().isEmpty()) { + return confManager.findAllConfigurations().stream(); + } else { + return confManager + .findAllConfigurations() + .stream() + .filter(conf -> { + final ConfigurationInfo info = confManager + .getConfigurationInfo(conf); +// return c.getName().startsWith(filterTerm); + if (filter == null || filter.isEmpty()) { + return true; + } else { + return info + .getTitle(globalizationHelper.getNegotiatedLocale()) + .startsWith( + filter); + } + }) + .collect(Collectors.toList()) + .subList(query.getOffset(), query.getOffset() + query.getLimit()) + .stream(); + } + } + + public void setFilter(final String filter) { + this.filter = filter; + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/GroupDetails.java b/ccm-core/src/main/java/org/libreccm/admin/ui/GroupDetails.java index eefa97979..78ea5e375 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/GroupDetails.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/GroupDetails.java @@ -68,7 +68,7 @@ public class GroupDetails extends Window { private static final String COL_ROLE_NAME = "role_name"; private static final String COL_ROLE_REMOVE = "remove"; - private final UsersGroupsRoles usersGroupsRoles; + private final UsersGroupsRolesTab usersGroupsRoles; private final Group group; private final GroupRepository groupRepo; @@ -80,7 +80,7 @@ public class GroupDetails extends Window { private HorizontalLayout saveCancelButtons; public GroupDetails(final Group group, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final GroupRepository groupRepo) { super(String.format("Edit group %s", group.getName())); diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/GroupEditor.java b/ccm-core/src/main/java/org/libreccm/admin/ui/GroupEditor.java index d28419049..0c9d9acfe 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/GroupEditor.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/GroupEditor.java @@ -47,7 +47,7 @@ public class GroupEditor extends Window { private static final long serialVersionUID = -5834095844674226692L; - private final UsersGroupsRoles usersGroupsRoles; + private final UsersGroupsRolesTab usersGroupsRoles; private final Group group; private final GroupRepository groupRepo; private final GroupManager groupManager; @@ -56,7 +56,7 @@ public class GroupEditor extends Window { private TextField groupName; - public GroupEditor(final UsersGroupsRoles usersGroupsRoles, + public GroupEditor(final UsersGroupsRolesTab usersGroupsRoles, final GroupRepository groupRepo, final GroupManager groupManager) { @@ -71,7 +71,7 @@ public class GroupEditor extends Window { } public GroupEditor(final Group group, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final GroupRepository groupRepo, final GroupManager groupManager) { diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/GroupSelector.java b/ccm-core/src/main/java/org/libreccm/admin/ui/GroupSelector.java index 73efd8a00..7ef637572 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/GroupSelector.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/GroupSelector.java @@ -43,7 +43,7 @@ public class GroupSelector extends Window { public GroupSelector(final String caption, final String actionLabel, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final List excludedGroups, final GroupSelectionAction action) { diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/GroupsTable.java b/ccm-core/src/main/java/org/libreccm/admin/ui/GroupsTable.java index d1148d992..d7435e0f1 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/GroupsTable.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/GroupsTable.java @@ -57,7 +57,7 @@ public class GroupsTable extends Grid { private final Button createGroupButton; public GroupsTable(final AdminView view, - final UsersGroupsRoles usersGroupsRoles) { + final UsersGroupsRolesTab usersGroupsRoles) { super(); @@ -158,11 +158,11 @@ public class GroupsTable extends Grid { private static final long serialVersionUID = -1168912882249598278L; private final Group group; - private final UsersGroupsRoles usersGroupsRoles; + private final UsersGroupsRolesTab usersGroupsRoles; private final GroupRepository groupRepo; public ConfirmDeleteDialog(final Group group, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final GroupRepository groupRepo) { this.group = group; diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/PartySelector.java b/ccm-core/src/main/java/org/libreccm/admin/ui/PartySelector.java index fc4702f62..6d05d3820 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/PartySelector.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/PartySelector.java @@ -47,7 +47,7 @@ public class PartySelector extends Window { public PartySelector(final String caption, final String actionLabel, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final List excludedParties, final PartySelectionAction action) { diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/RoleDetails.java b/ccm-core/src/main/java/org/libreccm/admin/ui/RoleDetails.java index 40cd0446c..a8b55877e 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/RoleDetails.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/RoleDetails.java @@ -54,13 +54,13 @@ public class RoleDetails extends Window { private static final String COL_MEMBER_NAME = "partyname"; private static final String COL_MEMBER_REMOVE = "member_remove"; - private final UsersGroupsRoles usersGroupsRoles; + private final UsersGroupsRolesTab usersGroupsRoles; private final Role role; private final RoleRepository roleRepo; private final RoleManager roleManager; public RoleDetails(final Role role, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final RoleRepository roleRepo, final RoleManager roleManager) { diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/RoleEditor.java b/ccm-core/src/main/java/org/libreccm/admin/ui/RoleEditor.java index 0cb49c380..07fc1f321 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/RoleEditor.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/RoleEditor.java @@ -45,7 +45,7 @@ public class RoleEditor extends Window { private static final long serialVersionUID = -2982855646090602847L; - private final UsersGroupsRoles usersGroupsRoles; + private final UsersGroupsRolesTab usersGroupsRoles; private final Role role; private final RoleRepository roleRepo; private final RoleManager roleManager; @@ -55,7 +55,7 @@ public class RoleEditor extends Window { private TextField roleName; private TextArea roleDescription; - public RoleEditor(final UsersGroupsRoles usersGroupsRoles, + public RoleEditor(final UsersGroupsRolesTab usersGroupsRoles, final RoleRepository roleRepo, final RoleManager roleManager) { @@ -70,7 +70,7 @@ public class RoleEditor extends Window { } public RoleEditor(final Role role, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final RoleRepository roleRepo, final RoleManager roleManager) { diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/RoleSelector.java b/ccm-core/src/main/java/org/libreccm/admin/ui/RoleSelector.java index f6a2780c4..c21f4e0d4 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/RoleSelector.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/RoleSelector.java @@ -44,7 +44,7 @@ public class RoleSelector extends Window { public RoleSelector(final String caption, final String actionLabel, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final List excludedRoles, final RoleSelectionAction action) { diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/RolesTable.java b/ccm-core/src/main/java/org/libreccm/admin/ui/RolesTable.java index f5fe75f70..7ba6ae195 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/RolesTable.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/RolesTable.java @@ -60,7 +60,7 @@ public class RolesTable extends Grid { private final Button createRoleButton; public RolesTable(final AdminView view, - final UsersGroupsRoles usersGroupsRoles) { + final UsersGroupsRolesTab usersGroupsRoles) { super(); @@ -194,11 +194,11 @@ public class RolesTable extends Grid { private static final long serialVersionUID = -1315311220464298282L; private final Role role; - private final UsersGroupsRoles usersGroupsRoles; + private final UsersGroupsRolesTab usersGroupsRoles; private final RoleRepository roleRepo; public ConfirmDeleteDialog(final Role role, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final RoleRepository roleRepo) { this.role = role; this.usersGroupsRoles = usersGroupsRoles; diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/UserDetails.java b/ccm-core/src/main/java/org/libreccm/admin/ui/UserDetails.java index 8b240ed06..92b243b6f 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/UserDetails.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/UserDetails.java @@ -59,13 +59,13 @@ public class UserDetails extends Window { private static final String COL_ROLE_NAME = "role_name"; private static final String COL_ROLE_REMOVE = "role_remove"; - private final UsersGroupsRoles usersGroupsRoles; + private final UsersGroupsRolesTab usersGroupsRoles; private final User user; private final UserRepository userRepo; private final UserManager userManager; public UserDetails(final User user, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final UserRepository userRepo, final UserManager userManager) { diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/UserEditor.java b/ccm-core/src/main/java/org/libreccm/admin/ui/UserEditor.java index b378cc580..fce4ae8e0 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/UserEditor.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/UserEditor.java @@ -71,7 +71,7 @@ public class UserEditor extends Window { } - private final UsersGroupsRoles usersGroupsRoles; + private final UsersGroupsRolesTab usersGroupsRoles; private final User user; private final UserRepository userRepo; private final UserManager userManager; @@ -88,7 +88,7 @@ public class UserEditor extends Window { private CheckBox passwordResetRequired; private CheckBox banned; - public UserEditor(final UsersGroupsRoles usersGroupsRoles, + public UserEditor(final UsersGroupsRolesTab usersGroupsRoles, final UserRepository userRepo, final UserManager userManager) { @@ -103,7 +103,7 @@ public class UserEditor extends Window { } public UserEditor(final User user, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final UserRepository userRepo, final UserManager userManager) { diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/UserSelector.java b/ccm-core/src/main/java/org/libreccm/admin/ui/UserSelector.java index f6c2deee7..62c7b0cf2 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/UserSelector.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/UserSelector.java @@ -51,7 +51,7 @@ public class UserSelector extends Window { public UserSelector(final String caption, final String actionLabel, - final UsersGroupsRoles usersGroupsRoles, + final UsersGroupsRolesTab usersGroupsRoles, final List excludedUsers, final UserSelectionAction action) { diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/UsersGroupsRoles.java b/ccm-core/src/main/java/org/libreccm/admin/ui/UsersGroupsRolesTab.java similarity index 97% rename from ccm-core/src/main/java/org/libreccm/admin/ui/UsersGroupsRoles.java rename to ccm-core/src/main/java/org/libreccm/admin/ui/UsersGroupsRolesTab.java index 3494231c1..02babf368 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/UsersGroupsRoles.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/UsersGroupsRolesTab.java @@ -23,8 +23,6 @@ import com.arsdigita.ui.admin.AdminUiConstants; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.TabSheet; import com.vaadin.ui.UI; -import com.vaadin.ui.VerticalLayout; -import org.libreccm.admin.ui.AdminView; import java.util.ResourceBundle; @@ -32,7 +30,7 @@ import java.util.ResourceBundle; * * @author Jens Pelzetter */ -public class UsersGroupsRoles extends CustomComponent { +public class UsersGroupsRolesTab extends CustomComponent { private static final long serialVersionUID = 7280416743018127366L; @@ -63,7 +61,7 @@ public class UsersGroupsRoles extends CustomComponent { private GroupsTableDataProvider groupsTableDataProvider; private RolesTableDataProvider rolesTableDataProvider; - public UsersGroupsRoles(final AdminView view) { + public UsersGroupsRolesTab(final AdminView view) { this.view = view; @@ -179,7 +177,7 @@ public class UsersGroupsRoles extends CustomComponent { tabSheet.addTab(groupsTable, "Groups"); tabSheet.addTab(rolesTable, "Roles"); - setCompositionRoot(tabSheet); + super.setCompositionRoot(tabSheet); } diff --git a/ccm-core/src/main/java/org/libreccm/admin/ui/UsersTable.java b/ccm-core/src/main/java/org/libreccm/admin/ui/UsersTable.java index a1e43c445..7f6d8aae8 100644 --- a/ccm-core/src/main/java/org/libreccm/admin/ui/UsersTable.java +++ b/ccm-core/src/main/java/org/libreccm/admin/ui/UsersTable.java @@ -57,7 +57,7 @@ public class UsersTable extends Grid { private final Button createUserButton; public UsersTable(final AdminView view, - final UsersGroupsRoles usersGroupsRoles) { + final UsersGroupsRolesTab usersGroupsRoles) { super();