Removed legacy components from ccm-cms-profile-site

pull/28/head
Jens Pelzetter 2022-03-14 20:03:05 +01:00
parent 425373f34f
commit 198c7d7b83
11 changed files with 0 additions and 1158 deletions

View File

@ -1,130 +0,0 @@
/*
* Copyright (C) 2021 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.contenttypes.ui;
import org.librecms.assets.Person;
import org.librecms.contentsection.AssetRepository;
import org.librecms.contentsection.ContentItemRepository;
import org.librecms.profilesite.ProfileSiteItem;
import java.util.Locale;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
class ProfileSiteItemController {
public static final String OWNER = "owner";
public static final String POSITION = "position";
public static final String INTERSETS = "interests";
public static final String MISC = "misc";
@Inject
private AssetRepository assetRepository;
@Inject
private ContentItemRepository itemRepository;
@Transactional(Transactional.TxType.REQUIRED)
public void setOwner(final long profileSiteItemId, final long ownerId) {
final ProfileSiteItem profileSiteItem = itemRepository
.findById(profileSiteItemId, ProfileSiteItem.class)
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No ProfileSiteItem with ID %d found.",
profileSiteItemId
)
)
);
final Person owner = assetRepository
.findById(ownerId, Person.class)
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No Person with ID %d found.", ownerId
)
)
);
profileSiteItem.setOwner(owner);
itemRepository.save(profileSiteItem);
}
public void setPosition(
final long profileSiteItemId, final String position, final Locale locale
) {
final ProfileSiteItem profileSiteItem = itemRepository
.findById(profileSiteItemId, ProfileSiteItem.class)
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No ProfileSiteItem with ID %d found.",
profileSiteItemId
)
)
);
profileSiteItem.getPosition().putValue(locale, position);
}
public void setInterests(
final long profileSiteItemId,
final String interests,
final Locale locale
) {
final ProfileSiteItem profileSiteItem = itemRepository
.findById(profileSiteItemId, ProfileSiteItem.class)
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No ProfileSiteItem with ID %d found.",
profileSiteItemId
)
)
);
profileSiteItem.getInterests().putValue(locale, interests);
}
public void setMisc(
final long profileSiteItemId, final String misc, final Locale locale
) {
final ProfileSiteItem profileSiteItem = itemRepository
.findById(profileSiteItemId, ProfileSiteItem.class)
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No ProfileSiteItem with ID %d found.",
profileSiteItemId
)
)
);
profileSiteItem.getMisc().putValue(locale, misc);
}
}

View File

@ -1,93 +0,0 @@
/*
* Copyright (C) 2021 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.contenttypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
import com.arsdigita.cms.ui.authoring.CreationSelector;
import com.arsdigita.cms.ui.authoring.PageCreateForm;
import com.arsdigita.globalization.GlobalizedMessage;
import org.librecms.assets.Person;
import org.librecms.contentsection.ContentItemInitializer;
import org.librecms.profilesite.ProfileSiteConstants;
import org.librecms.profilesite.ProfileSiteItem;
import java.util.Locale;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ProfileSiteItemCreate extends PageCreateForm {
private final static String OWNER_SEARCH = "owner";
private AssetSearchWidget ownerSearch;
public ProfileSiteItemCreate(
final ItemSelectionModel itemModel,
final CreationSelector creationSelector,
final StringParameter selectedLanguageParam
) {
super(itemModel, creationSelector, selectedLanguageParam);
}
@Override
public void addWidgets() {
ownerSearch = new AssetSearchWidget(OWNER_SEARCH, Person.class);
ownerSearch.setLabel(
new GlobalizedMessage(
"profile_site.owner.label", ProfileSiteConstants.BUNDLE
)
);
add(ownerSearch);
}
@Override
public void validate(final FormSectionEvent event)
throws FormProcessException {
super.validate(event);
final FormData formData = event.getFormData();
if (!formData.containsKey(OWNER_SEARCH)
|| formData.get(OWNER_SEARCH) == null) {
formData.addError(
new GlobalizedMessage(
"profile_site.owner.not_selected",
ProfileSiteConstants.BUNDLE
)
);
}
}
@Override
protected ContentItemInitializer<ProfileSiteItem> getItemInitializer(
final FormData formData, final PageState state
) {
return (item) -> item.setOwner((Person) formData.get(OWNER_SEARCH));
}
}

View File

@ -1,121 +0,0 @@
/*
* Copyright (C) 2021 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.contenttypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
import com.arsdigita.globalization.GlobalizedMessage;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.profilesite.ProfileSiteConstants;
import org.librecms.profilesite.ProfileSiteItem;
import java.util.Locale;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ProfileSiteItemInterestsForm
extends BasicItemForm
implements FormProcessListener, FormInitListener {
private final StringParameter selectedLangParam;
public ProfileSiteItemInterestsForm(
final ItemSelectionModel itemModel,
final StringParameter selectedLangParam
) {
super("ProfileSiteItemEditInterests", itemModel, selectedLangParam);
this.selectedLangParam = selectedLangParam;
}
@Override
public void addWidgets() {
add(
new Label(
new GlobalizedMessage(
"profile_site_item.ui.interests",
ProfileSiteConstants.BUNDLE
)
)
);
final ParameterModel interestsParam = new StringParameter(
ProfileSiteItemController.POSITION);
final TextArea interests = new TextArea(interestsParam);
interests.setCols(80);
interests.setRows(8);
add(interests);
}
@Override
public void init(final FormSectionEvent event) throws FormProcessException {
final PageState state = event.getPageState();
final FormData data = event.getFormData();
final ProfileSiteItem profile
= (ProfileSiteItem) getItemSelectionModel()
.getSelectedItem(state);
data.put(ProfileSiteItemController.POSITION, profile.getInterests());
setVisible(state, true);
}
@Override
public void process(final FormSectionEvent event)
throws FormProcessException {
final PageState state = event.getPageState();
final FormData data = event.getFormData();
final ProfileSiteItem profile
= (ProfileSiteItem) getItemSelectionModel()
.getSelectedItem(state);
if ((profile != null)
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
final ProfileSiteItemController controller = CdiUtil
.createCdiUtil()
.findBean(ProfileSiteItemController.class);
final Locale selectedLocale = SelectedLanguageUtil.selectedLocale(
state, selectedLangParam
);
controller.setInterests(
profile.getObjectId(),
(String) data.get(ProfileSiteItemController.POSITION),
selectedLocale
);
}
init(event);
}
}

View File

@ -1,94 +0,0 @@
/*
* Copyright (C) 2021 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.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import org.librecms.profilesite.ProfileSiteConstants;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ProfileSiteItemInterestsStep extends SimpleEditStep {
private String EDIT_POSITION_SHEET_NAME = "editInterests";
public ProfileSiteItemInterestsStep(
final ItemSelectionModel itemModel,
final AuthoringKitWizard parent,
final StringParameter selectedLangParam
) {
this(itemModel, parent, selectedLangParam, null);
}
public ProfileSiteItemInterestsStep(
final ItemSelectionModel itemModel,
final AuthoringKitWizard parent,
final StringParameter selectedLangParam,
final String prefix
) {
super(itemModel, parent, selectedLangParam, prefix);
final BasicItemForm editInterestsForm = new ProfileSiteItemInterestsForm(
itemModel, selectedLangParam
);
add(
EDIT_POSITION_SHEET_NAME,
new GlobalizedMessage(
"profile_site_site.ui.interests.edit",
ProfileSiteConstants.BUNDLE
),
new WorkflowLockedComponentAccess(parent, itemModel),
editInterestsForm.getSaveCancelSection().getCancelButton()
);
setDisplayComponent(getProfileSiteItemInterestsSheet(
itemModel, selectedLangParam)
);
}
public static final Component getProfileSiteItemInterestsSheet(
final ItemSelectionModel itemModel,
final StringParameter selectedLangParam
) {
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
itemModel, false, selectedLangParam
);
sheet.add(
new GlobalizedMessage(
"profile_site_item.ui.interests",
ProfileSiteConstants.BUNDLE
),
ProfileSiteItemController.POSITION
);
return sheet;
}
}

View File

@ -1,121 +0,0 @@
/*
* Copyright (C) 2021 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.contenttypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
import com.arsdigita.globalization.GlobalizedMessage;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.profilesite.ProfileSiteConstants;
import org.librecms.profilesite.ProfileSiteItem;
import java.util.Locale;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ProfileSiteItemMiscForm
extends BasicItemForm
implements FormProcessListener, FormInitListener {
private final StringParameter selectedLangParam;
public ProfileSiteItemMiscForm(
final ItemSelectionModel itemModel,
final StringParameter selectedLangParam
) {
super("ProfileSiteItemEditMisc", itemModel, selectedLangParam);
this.selectedLangParam = selectedLangParam;
}
@Override
public void addWidgets() {
add(
new Label(
new GlobalizedMessage(
"profile_site_item.ui.misc",
ProfileSiteConstants.BUNDLE
)
)
);
final ParameterModel miscParam = new StringParameter(
ProfileSiteItemController.POSITION);
final TextArea misc = new TextArea(miscParam);
misc.setCols(80);
misc.setRows(8);
add(misc);
}
@Override
public void init(final FormSectionEvent event) throws FormProcessException {
final PageState state = event.getPageState();
final FormData data = event.getFormData();
final ProfileSiteItem profile
= (ProfileSiteItem) getItemSelectionModel()
.getSelectedItem(state);
data.put(ProfileSiteItemController.POSITION, profile.getMisc());
setVisible(state, true);
}
@Override
public void process(final FormSectionEvent event)
throws FormProcessException {
final PageState state = event.getPageState();
final FormData data = event.getFormData();
final ProfileSiteItem profile
= (ProfileSiteItem) getItemSelectionModel()
.getSelectedItem(state);
if ((profile != null)
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
final ProfileSiteItemController controller = CdiUtil
.createCdiUtil()
.findBean(ProfileSiteItemController.class);
final Locale selectedLocale = SelectedLanguageUtil.selectedLocale(
state, selectedLangParam
);
controller.setMisc(
profile.getObjectId(),
(String) data.get(ProfileSiteItemController.POSITION),
selectedLocale
);
}
init(event);
}
}

View File

@ -1,94 +0,0 @@
/*
* Copyright (C) 2021 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.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import org.librecms.profilesite.ProfileSiteConstants;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ProfileSiteItemMiscStep extends SimpleEditStep {
private String EDIT_POSITION_SHEET_NAME = "editMisc";
public ProfileSiteItemMiscStep(
final ItemSelectionModel itemModel,
final AuthoringKitWizard parent,
final StringParameter selectedLangParam
) {
this(itemModel, parent, selectedLangParam, null);
}
public ProfileSiteItemMiscStep(
final ItemSelectionModel itemModel,
final AuthoringKitWizard parent,
final StringParameter selectedLangParam,
final String prefix
) {
super(itemModel, parent, selectedLangParam, prefix);
final BasicItemForm editMiscForm = new ProfileSiteItemMiscForm(
itemModel, selectedLangParam
);
add(
EDIT_POSITION_SHEET_NAME,
new GlobalizedMessage(
"profile_site_site.ui.misc.edit",
ProfileSiteConstants.BUNDLE
),
new WorkflowLockedComponentAccess(parent, itemModel),
editMiscForm.getSaveCancelSection().getCancelButton()
);
setDisplayComponent(getProfileSiteItemMiscSheet(
itemModel, selectedLangParam)
);
}
public static final Component getProfileSiteItemMiscSheet(
final ItemSelectionModel itemModel,
final StringParameter selectedLangParam
) {
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
itemModel, false, selectedLangParam
);
sheet.add(
new GlobalizedMessage(
"profile_site_item.ui.misc",
ProfileSiteConstants.BUNDLE
),
ProfileSiteItemController.POSITION
);
return sheet;
}
}

View File

@ -1,121 +0,0 @@
/*
* Copyright (C) 2021 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.contenttypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
import com.arsdigita.globalization.GlobalizedMessage;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.profilesite.ProfileSiteConstants;
import org.librecms.profilesite.ProfileSiteItem;
import java.util.Locale;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ProfileSiteItemPositionForm
extends BasicItemForm
implements FormProcessListener, FormInitListener {
private final StringParameter selectedLangParam;
public ProfileSiteItemPositionForm(
final ItemSelectionModel itemModel,
final StringParameter selectedLangParam
) {
super("ProfileSiteItemEditPosition", itemModel, selectedLangParam);
this.selectedLangParam = selectedLangParam;
}
@Override
public void addWidgets() {
add(
new Label(
new GlobalizedMessage(
"profile_site_item.ui.position",
ProfileSiteConstants.BUNDLE
)
)
);
final ParameterModel positionParam = new StringParameter(
ProfileSiteItemController.POSITION);
final TextArea position = new TextArea(positionParam);
position.setCols(80);
position.setRows(8);
add(position);
}
@Override
public void init(final FormSectionEvent event) throws FormProcessException {
final PageState state = event.getPageState();
final FormData data = event.getFormData();
final ProfileSiteItem profile
= (ProfileSiteItem) getItemSelectionModel()
.getSelectedItem(state);
data.put(ProfileSiteItemController.POSITION, profile.getPosition());
setVisible(state, true);
}
@Override
public void process(final FormSectionEvent event)
throws FormProcessException {
final PageState state = event.getPageState();
final FormData data = event.getFormData();
final ProfileSiteItem profile
= (ProfileSiteItem) getItemSelectionModel()
.getSelectedItem(state);
if ((profile != null)
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
final ProfileSiteItemController controller = CdiUtil
.createCdiUtil()
.findBean(ProfileSiteItemController.class);
final Locale selectedLocale = SelectedLanguageUtil.selectedLocale(
state, selectedLangParam
);
controller.setPosition(
profile.getObjectId(),
(String) data.get(ProfileSiteItemController.POSITION),
selectedLocale
);
}
init(event);
}
}

View File

@ -1,94 +0,0 @@
/*
* Copyright (C) 2021 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.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import org.librecms.profilesite.ProfileSiteConstants;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ProfileSiteItemPositionStep extends SimpleEditStep {
private String EDIT_POSITION_SHEET_NAME = "editPosition";
public ProfileSiteItemPositionStep(
final ItemSelectionModel itemModel,
final AuthoringKitWizard parent,
final StringParameter selectedLangParam
) {
this(itemModel, parent, selectedLangParam, null);
}
public ProfileSiteItemPositionStep(
final ItemSelectionModel itemModel,
final AuthoringKitWizard parent,
final StringParameter selectedLangParam,
final String prefix
) {
super(itemModel, parent, selectedLangParam, prefix);
final BasicItemForm editPositionForm = new ProfileSiteItemPositionForm(
itemModel, selectedLangParam
);
add(
EDIT_POSITION_SHEET_NAME,
new GlobalizedMessage(
"profile_site_site.ui.position.edit",
ProfileSiteConstants.BUNDLE
),
new WorkflowLockedComponentAccess(parent, itemModel),
editPositionForm.getSaveCancelSection().getCancelButton()
);
setDisplayComponent(getProfileSiteItemPositionSheet(
itemModel, selectedLangParam)
);
}
public static final Component getProfileSiteItemPositionSheet(
final ItemSelectionModel itemModel,
final StringParameter selectedLangParam
) {
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
itemModel, false, selectedLangParam
);
sheet.add(
new GlobalizedMessage(
"profile_site_item.ui.position",
ProfileSiteConstants.BUNDLE
),
ProfileSiteItemController.POSITION
);
return sheet;
}
}

View File

@ -1,129 +0,0 @@
/*
* Copyright (C) 2021 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.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import org.librecms.assets.Person;
import org.librecms.profilesite.ProfileSiteConstants;
import org.librecms.profilesite.ProfileSiteItem;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ProfileSiteItemPropertiesStep extends SimpleEditStep {
public static final String EDIT_SHEET_NAME = "editProfileSiteItem";
public ProfileSiteItemPropertiesStep(
final ItemSelectionModel itemModel,
final AuthoringKitWizard parent,
final StringParameter selectedLangParam
) {
super(itemModel, parent, selectedLangParam);
setDefaultEditKey(EDIT_SHEET_NAME);
final SimpleEditStep basicProperties = new SimpleEditStep(
itemModel, parent, selectedLangParam, EDIT_SHEET_NAME
);
final BasicPageForm editBasicSheet = new ProfileSiteItemPropertyForm(
itemModel, this, selectedLangParam
);
basicProperties.add(
EDIT_SHEET_NAME,
new GlobalizedMessage(
ProfileSiteConstants.BUNDLE,
"profile_site.ui.edit_basic_properties"
),
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
editBasicSheet.getSaveCancelSection().getCancelButton()
);
basicProperties.setDisplayComponent(
getProfileSiteItemPropertiesSheet(itemModel, selectedLangParam)
);
final SegmentedPanel segmentedPanel = new SegmentedPanel();
segmentedPanel.addSegment(
new Label(
new GlobalizedMessage(
ProfileSiteConstants.BUNDLE,
"profile_site.ui.basic_properties"
)
),
basicProperties
);
setDisplayComponent(segmentedPanel);
}
public static Component getProfileSiteItemPropertiesSheet(
final ItemSelectionModel itemModel,
final StringParameter selectedLangParam
) {
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
itemModel, false, selectedLangParam
);
sheet.add(
new GlobalizedMessage(
ProfileSiteConstants.BUNDLE, "profile_site.ui.OWNER"
),
ProfileSiteItemController.OWNER,
new OwnerFormatter()
);
return sheet;
}
private static class OwnerFormatter
implements DomainObjectPropertySheet.AttributeFormatter {
@Override
public String format(
final Object obj, final String attribute, final PageState state
) {
final ProfileSiteItem profileSiteItem = (ProfileSiteItem) obj;
final Person owner = profileSiteItem.getOwner();
if (owner == null) {
return "";
} else {
return owner.getDisplayName();
}
}
}
}

View File

@ -1,117 +0,0 @@
/*
* Copyright (C) 2021 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.contenttypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.globalization.GlobalizedMessage;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.assets.Person;
import org.librecms.profilesite.ProfileSiteConstants;
import org.librecms.profilesite.ProfileSiteItem;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ProfileSiteItemPropertyForm
extends BasicPageForm
implements FormInitListener, FormProcessListener, FormValidationListener {
public static final String ID = "PublicPersonalProfile_edit";
private static final String OWNER_SEARCH = "ownerSearch";
private final ItemSelectionModel itemModel;
public ProfileSiteItemPropertyForm(
final ItemSelectionModel itemModel,
final ProfileSiteItemPropertiesStep step,
final StringParameter selectedLangParam
) {
super(ID, itemModel, selectedLangParam);
this.itemModel = itemModel;
addValidationListener(this);
}
@Override
public void addWidgets() {
super.addWidgets();
final AssetSearchWidget ownerSearch = new AssetSearchWidget(
OWNER_SEARCH, Person.class
);
add(ownerSearch);
}
@Override
public void init(final FormSectionEvent event) throws FormProcessException {
final FormData formData = event.getFormData();
final ProfileSiteItem profileSiteItem = (ProfileSiteItem) super
.initBasicWidgets(event);
formData.put(OWNER_SEARCH, profileSiteItem.getOwner());
}
@Override
public void validate(final FormSectionEvent event)
throws FormProcessException {
super.validate(event);
final FormData formData = event.getFormData();
if (!formData.containsKey(OWNER_SEARCH)
|| formData.get(OWNER_SEARCH) == null) {
formData.addError(
new GlobalizedMessage(
"profile_site.owner.not_selected",
ProfileSiteConstants.BUNDLE
)
);
}
}
@Override
public void process(final FormSectionEvent event)
throws FormProcessException {
final ProfileSiteItem profileSiteItem = (ProfileSiteItem) super
.processBasicWidgets(event);
final FormData formData = event.getFormData();
final Person owner = (Person) formData.get(OWNER_SEARCH);
final ProfileSiteItemController controller = CdiUtil
.createCdiUtil()
.findBean(ProfileSiteItemController.class);
controller.setOwner(profileSiteItem.getObjectId(), owner.getObjectId());
init(event);
}
}

View File

@ -18,17 +18,10 @@
*/
package org.librecms.profilesite;
import com.arsdigita.cms.contenttypes.ui.ProfileSiteItemCreate;
import com.arsdigita.cms.contenttypes.ui.ProfileSiteItemInterestsStep;
import com.arsdigita.cms.contenttypes.ui.ProfileSiteItemMiscStep;
import com.arsdigita.cms.contenttypes.ui.ProfileSiteItemPositionStep;
import com.arsdigita.cms.contenttypes.ui.ProfileSiteItemPropertiesStep;
import org.libreccm.l10n.LocalizedString;
import org.librecms.assets.Person;
import org.librecms.contentsection.ContentItem;
import org.librecms.contenttypes.AuthoringKit;
import org.librecms.contenttypes.AuthoringStep;
import org.librecms.contenttypes.ContentTypeDescription;
import java.util.Objects;
@ -53,43 +46,6 @@ import static org.librecms.profilesite.ProfileSiteConstants.*;
labelBundle = "org.librecms.profilesite.ProfileSiteItem",
descriptionBundle = "org.librecms.profilesite.ProfileSiteItem"
)
@AuthoringKit(
createComponent = ProfileSiteItemCreate.class,
steps = {
@AuthoringStep(
component = ProfileSiteItemPropertiesStep.class,
labelBundle = ProfileSiteConstants.BUNDLE,
labelKey = "profile_site_item.basic_properties.label",
descriptionBundle = ProfileSiteConstants.BUNDLE,
descriptionKey = "profile_site_item.basic_properties.description",
order = 1
),
@AuthoringStep(
component = ProfileSiteItemPositionStep.class,
labelBundle = ProfileSiteConstants.BUNDLE,
labelKey = "profile_site_item.position.label",
descriptionBundle = ProfileSiteConstants.BUNDLE,
descriptionKey = "profile_site_item.position.description",
order = 2
),
@AuthoringStep(
component = ProfileSiteItemInterestsStep.class,
labelBundle = ProfileSiteConstants.BUNDLE,
labelKey = "profile_site_item.interests.label",
descriptionBundle = ProfileSiteConstants.BUNDLE,
descriptionKey = "profile_site_item.interests.description",
order = 3
),
@AuthoringStep(
component = ProfileSiteItemMiscStep.class,
labelBundle = ProfileSiteConstants.BUNDLE,
labelKey = "profile_site_item.misc.label",
descriptionBundle = ProfileSiteConstants.BUNDLE,
descriptionKey = "profile_site_item.misc.description",
order = 4
)
}
)
public class ProfileSiteItem extends ContentItem {
private static final long serialVersionUID = 1L;