diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeForm.java index 8a11f76..199f207 100644 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeForm.java +++ b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeForm.java @@ -5,16 +5,22 @@ */ 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.FormInitListener; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.cms.ui.assets.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.globalization.GlobalizedMessage; -import org.scientificcms.publications.contenttypes.CollectedVolumeItem; +import org.libreccm.cdi.utils.CdiUtil; +import org.scientificcms.publications.ArticleInCollectedVolume; +import org.scientificcms.publications.CollectedVolume; +import org.scientificcms.publications.SciPublicationsConstants; +import org.scientificcms.publications.contenttypes.ArticleInCollectedVolumeItem; /** * Form for adding an association between an ArticleInCollectedVolume and a @@ -26,43 +32,71 @@ public class ArticleInCollectedVolumeCollectedVolumeForm extends BasicItemForm implements FormProcessListener, FormInitListener { - private ItemSearchWidget itemSearch; + private final static String COLLECTED_VOLUME_SEARCH + = "collectedVolumeSearch"; - private final String ITEM_SEARCH = "collectedVolume"; + private PublicationSearchWidget collectedVolumeSearch; public ArticleInCollectedVolumeCollectedVolumeForm( - final String formName, final ItemSelectionModel itemSelectionModel, final StringParameter selectedLanguageParam) { - super(formName, itemSelectionModel, selectedLanguageParam); + super( + "ArticleInCollectedVolumeCollectedVolumeForm", + itemSelectionModel, + selectedLanguageParam + ); } @Override protected void addWidgets() { - itemSearch = new ItemSearchWidget( - ITEM_SEARCH, - CollectedVolumeItem.class + collectedVolumeSearch = new PublicationSearchWidget( + COLLECTED_VOLUME_SEARCH, CollectedVolume.class ); - itemSearch. - - itemSearch.setDefaultCreationFolder(config - .getDefaultCollectedVolumesFolder()); - itemSearch.setLabel(PublicationGlobalizationUtil.globalize( - "publications.ui.articleInCollectedVolume.selectCollectedVolume")); - add(itemSearch); + + collectedVolumeSearch.setLabel( + new GlobalizedMessage( + "publications.ui.articleInCollectedVolume.selectCollectedVolume", + SciPublicationsConstants.BUNDLE + ) + ); + add(collectedVolumeSearch); } @Override public void init(final FormSectionEvent event) throws FormProcessException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + final PageState state = event.getPageState(); + + setVisible(state, true); } @Override - public void process(final FormSectionEvent event) throws - FormProcessException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public void process(final FormSectionEvent event) + throws FormProcessException { + + final FormData data = event.getFormData(); + final PageState state = event.getPageState(); + + final ArticleInCollectedVolumeItem articleItem + = (ArticleInCollectedVolumeItem) getItemSelectionModel() + .getSelectedObject(state); + final ArticleInCollectedVolume article = articleItem.getPublication(); + + if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { + final CollectedVolume collectedVolume = (CollectedVolume) data.get( + COLLECTED_VOLUME_SEARCH + ); + + final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); + final ArticleInCollectedVolumeController controller = cdiUtil + .findBean(ArticleInCollectedVolumeController.class); + controller.setCollectedVolume( + article.getPublicationId(), collectedVolume.getPublicationId() + ); + } + + init(event); } } diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeStep.java index 2da68f2..7a180e6 100644 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeStep.java +++ b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeStep.java @@ -25,7 +25,7 @@ import org.scientificcms.publications.SciPublicationsConstants; public class ArticleInCollectedVolumeCollectedVolumeStep extends SimpleEditStep { - private String ADD_COLLECTED_VOLUME_STEP = "addCollectedVolume"; + private final static String ADD_COLLECTED_VOLUME_STEP = "addCollectedVolume"; public ArticleInCollectedVolumeCollectedVolumeStep( final ItemSelectionModel itemModel,