diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInCollectedVolume.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInCollectedVolume.java index 292db0568..e44bed3ba 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInCollectedVolume.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ArticleInCollectedVolume.java @@ -77,6 +77,14 @@ public class ArticleInCollectedVolume extends PublicationWithPublisher { set(PAGES_TO, pagesTo); } + public String getChapter() { + return (String) get(CHAPTER); + } + + public void setChapter(String chapter) { + set(CHAPTER, chapter); + } + public CollectedVolume getCollectedVolume() { return (CollectedVolume) get(COLLECTED_VOLUME); } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertiesStep.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertiesStep.java new file mode 100644 index 000000000..6912e7c3d --- /dev/null +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertiesStep.java @@ -0,0 +1,50 @@ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Label; +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; + +/** + * + * @author Jens Pelzetter + */ +public class ArticleInCollectedVolumePropertiesStep + extends PublicationWithPublisherPropertiesStep { + + public ArticleInCollectedVolumePropertiesStep( + ItemSelectionModel itemModel, + AuthoringKitWizard parent) { + super(itemModel, parent); + } + + @Override + protected void addBasicProperties( + ItemSelectionModel itemModel, + AuthoringKitWizard parent) { + SimpleEditStep basicProperties = new SimpleEditStep(itemModel, + parent, + EDIT_SHEET_NAME); + + BasicPageForm editBasicSheet = + new ArticleInCollectedVolumePropertyForm(itemModel, this); + + basicProperties.add(EDIT_SHEET_NAME, + (String) PublicationGlobalizationUtil.globalize( + "publications.ui.article_in_collected_volume.edit_basic_sheet"). + localize(), new WorkflowLockedComponentAccess(editBasicSheet, + itemModel), + editBasicSheet. + getSaveCancelSection().getCancelButton()); + + basicProperties.setDisplayComponent( + getPublicationPropertySheet(itemModel)); + + getSegmentedPanel().addSegment( + new Label((String) PublicationGlobalizationUtil.globalize( + "publications.ui.publication.basic_properties"). + localize()), basicProperties); + } +} diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertyForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertyForm.java new file mode 100644 index 000000000..413100079 --- /dev/null +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertyForm.java @@ -0,0 +1,114 @@ +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.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.TextField; +import com.arsdigita.bebop.parameters.IntegerParameter; +import com.arsdigita.bebop.parameters.ParameterModel; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.ArticleInCollectedVolume; +import org.apache.log4j.Logger; + +/** + * + * @author Jens Pelzetter + */ +public class ArticleInCollectedVolumePropertyForm + extends PublicationWithPublisherPropertyForm + implements FormProcessListener, + FormInitListener, + FormSubmissionListener { + + private static final Logger s_log = + Logger.getLogger( + ArticleInCollectedVolumePropertyForm.class); + private ArticleInCollectedVolumePropertiesStep m_step; + public static final String ID = "ArticleInCollectedVolumeEdit"; + + public ArticleInCollectedVolumePropertyForm(ItemSelectionModel itemModel) { + this(itemModel, null); + } + + public ArticleInCollectedVolumePropertyForm( + ItemSelectionModel itemModel, + ArticleInCollectedVolumePropertiesStep step) { + super(itemModel, step); + m_step = step; + addSubmissionListener(this); + } + + @Override + protected void addWidgets() { + super.addWidgets(); + + add(new Label((String) PublicationGlobalizationUtil.globalize( + "publications.ui.article_in_collected_volume.pages_from"). + localize())); + ParameterModel fromParam = new IntegerParameter( + ArticleInCollectedVolume.PAGES_FROM); + TextField pagesFrom = new TextField(fromParam); + add(pagesFrom); + + add(new Label((String) PublicationGlobalizationUtil.globalize( + "publications.ui.article_in_collected_volume.pages_from"). + localize())); + ParameterModel toParam = new IntegerParameter( + ArticleInCollectedVolume.PAGES_TO); + TextField pagesTo = new TextField(toParam); + add(pagesTo); + + add(new Label((String) PublicationGlobalizationUtil.globalize( + "publications.ui.article_in_collected_volume.chapter"). + localize())); + ParameterModel chapterParam = new StringParameter( + ArticleInCollectedVolume.CHAPTER); + TextField chapter = new TextField(chapterParam); + add(chapter); + } + + @Override + public void init(FormSectionEvent fse) throws FormProcessExeception { + super.init(fse); + + FormData data = fse.getFormData(); + ArticleInCollectedVolume article = + (ArticleInCollectedVolume) super. + initBasicWidgets(fse); + + data.put(ArticleInCollectedVolume.PAGES_FROM, article.getPagesFrom()); + data.put(ArticleInCollectedVolume.PAGES_TO, article.getPagesTo()); + data.put(ArticleInCollectedVolume.CHAPTER, article.getChapter()); + } + + @Override + public void process(FormSectionEvent fse) throws FormProcessException { + super.process(fse); + + FormData data = fse.getFormData(); + ArticleInCollectedVolume article = + (ArticleInCollectedVolume) super. + processBasicWidgets(fse); + + if ((article != null) && getSaveCancelSection().getSaveButton(). + isSelected(fse.getPageState())) { + article.setPagesFrom((Integer) data.get( + ArticleInCollectedVolume.PAGES_FROM)); + article.setPagesTo((Integer) data.get( + ArticleInCollectedVolume.PAGES_TO)); + article.setChapter((String) data.get( + ArticleInCollectedVolume.CHAPTER)); + + article.save(); + } + + if (m_step != null) { + m_step.maybeForwardToNextStep(fse.getPageState()); + } + } +} diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticleAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticleAddForm.java new file mode 100644 index 000000000..7eadc83ec --- /dev/null +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticleAddForm.java @@ -0,0 +1,76 @@ +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.cms.ContentType; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.ArticleInCollectedVolume; +import com.arsdigita.cms.contenttypes.CollectedVolume; +import com.arsdigita.cms.ui.ItemSearchWidget; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import org.apache.log4j.Logger; + +/** + * + * @author Jens Pelzetter + */ +public class CollectedVolumeArticleAddForm + extends BasicItemForm + implements FormProcessListener, + FormInitListener { + + private static final Logger s_log = + Logger.getLogger( + CollectedVolumeArticleAddForm.class); + private CollectedVolumePropertiesStep m_step; + private ItemSearchWidget m_itemSearch; + private final String ITEM_SEARCH = "articles"; + private ItemSelectionModel m_itemModel; + + public CollectedVolumeArticleAddForm(ItemSelectionModel itemModel) { + super("ArticlesAddForm", itemModel); + m_itemModel = itemModel; + } + + @Override + protected void addWidgets() { + add(new Label((String) PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.articles.select_article"). + localize())); + m_itemSearch = new ItemSearchWidget( + ITEM_SEARCH, + ContentType.findByAssociatedObjectType( + ArticleInCollectedVolume.class.getName())); + add(m_itemSearch); + } + + @Override + public void init(FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + + setVisible(state, true); + } + + @Override + public void process(FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + CollectedVolume collectedVolume = + (CollectedVolume) getItemSelectionModel(). + getSelectedObject(state); + + if (!(this.getSaveCancelSection().getCancelButton(). + isSelected(state))) { + collectedVolume.addArticle((ArticleInCollectedVolume) data.get( + ITEM_SEARCH)); + } + + init(fse); + } +} diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesStep.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesStep.java new file mode 100644 index 000000000..b36d91a0e --- /dev/null +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesStep.java @@ -0,0 +1,40 @@ +package com.arsdigita.cms.contenttypes.ui; + +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; + +/** + * + * @author Jens Pelzetter + */ +public class CollectedVolumeArticlesStep extends SimpleEditStep { + + private static final String ADD_ARTICLE_SHEET_NAME = "addArticle"; + + public CollectedVolumeArticlesStep(ItemSelectionModel itemModel, + AuthoringKitWizard parent) { + this(itemModel, parent, null); + } + + public CollectedVolumeArticlesStep(ItemSelectionModel itemModel, + AuthoringKitWizard parent, + String prefix) { + super(itemModel, parent, prefix); + + BasicItemForm addArticleSheet = + new CollectedVolumeArticleAddForm(itemModel); + add(ADD_ARTICLE_SHEET_NAME, + (String) PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.add_article").localize(), + new WorkflowLockedComponentAccess(addArticleSheet, itemModel), + addArticleSheet.getSaveCancelSection().getCancelButton()); + + CollectedVolumeArticlesTable articlesTable = + new CollectedVolumeArticlesTable( + itemModel); + setDisplayComponent(articlesTable); + } +} diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesTable.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesTable.java new file mode 100644 index 000000000..84e56bcb6 --- /dev/null +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesTable.java @@ -0,0 +1,314 @@ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.ControlLink; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.Table; +import com.arsdigita.bebop.event.TableActionEvent; +import com.arsdigita.bebop.event.TableActionListener; +import com.arsdigita.bebop.table.TableCellRenderer; +import com.arsdigita.bebop.table.TableColumn; +import com.arsdigita.bebop.table.TableColumnModel; +import com.arsdigita.bebop.table.TableModel; +import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.SecurityManager; +import com.arsdigita.cms.contenttypes.ArticleInCollectedVolume; +import com.arsdigita.cms.contenttypes.ArticleInCollectedVolumeCollection; +import com.arsdigita.cms.contenttypes.CollectedVolume; +import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.util.LockableImpl; +import java.math.BigDecimal; +import org.apache.log4j.Logger; + +/** + * + * @author Jens Pelzetter + */ +public class CollectedVolumeArticlesTable + extends Table + implements TableActionListener { + + private static final Logger s_log = + Logger.getLogger( + CollectedVolumeArticlesTable.class); + private final String TABLE_COL_EDIT = "table_col_edit"; + private final String TABLE_COL_DEL = "table_col_del"; + private final String TABLE_COL_UP = "table_col_up"; + private final String TABLE_COL_DOWN = "table_col_down"; + private ItemSelectionModel m_itemModel; + + public CollectedVolumeArticlesTable(ItemSelectionModel itemModel) { + super(); + m_itemModel = itemModel; + + setEmptyView( + new Label(PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.no_articles"))); + + TableColumnModel colModel = getColumnModel(); + colModel.add(new TableColumn( + 0, + PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.article").localize(), + TABLE_COL_EDIT)); + colModel.add(new TableColumn( + 1, + PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.article.remove").localize(), + TABLE_COL_DEL)); + colModel.add(new TableColumn( + 2, + PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.article.up").localize(), + TABLE_COL_UP)); + colModel.add(new TableColumn( + 3, + PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.article.down").localize(), + TABLE_COL_DOWN)); + + setModelBuilder( + new CollectedVolumeArticlesTableModelBuilder(itemModel)); + + colModel.get(0).setCellRenderer(new EditCellRenderer()); + colModel.get(1).setCellRenderer(new DeleteCellRenderer()); + colModel.get(2).setCellRenderer(new UpCellRenderer()); + colModel.get(3).setCellRenderer(new DownCellRenderer()); + } + + private class CollectedVolumeArticlesTableModelBuilder + extends LockableImpl + implements TableModelBuilder { + + private ItemSelectionModel m_itemModel; + + public CollectedVolumeArticlesTableModelBuilder( + ItemSelectionModel itemModel) { + m_itemModel = itemModel; + } + + public TableModel makeModel(Table table, PageState state) { + table.getRowSelectionModel().clearSelection(state); + CollectedVolume collectedVolume = + (CollectedVolume) m_itemModel.getSelectedObject( + state); + return new CollectedVolumeArticlesTableModel(table, + state, + collectedVolume); + } + } + + private class CollectedVolumeArticlesTableModel implements TableModel { + + private Table m_table; + private ArticleInCollectedVolumeCollection m_articles; + private ArticleInCollectedVolume m_article; + + private CollectedVolumeArticlesTableModel( + Table table, + PageState state, + CollectedVolume collectedVolume) { + m_table = table; + m_articles = collectedVolume.getArticles(); + } + + @Override + public int getColumnCount() { + return m_table.getColumnModel().size(); + } + + @Override + public boolean nextRow() { + boolean ret; + + if ((m_articles != null) && m_articles.next()) { + m_article = m_articles.getArticle(); + ret = true; + } else { + ret = false; + } + + return ret; + } + + @Override + public Object getElementAt(int columnIndex) { + switch (columnIndex) { + case 0: + return m_article.getTitle(); + case 1: + return PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.article.remove"). + localize(); + default: + return null; + } + } + + public Object getKeyAt(int columnIndex) { + return m_article.getID(); + } + } + + private class EditCellRenderer + extends LockableImpl + implements TableCellRenderer { + + @Override + public Component getComponent(Table table, + PageState state, + Object value, + boolean isSelected, + Object key, + int row, + int col) { + SecurityManager securityManager = + Utilities.getSecurityManager(state); + CollectedVolume collectedVolume = (CollectedVolume) m_itemModel. + getSelectedObject(state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + SecurityManager.EDIT_ITEM, + collectedVolume); + + if (canEdit) { + ControlLink link = new ControlLink(value.toString()); + return link; + } else { + Label label = new Label(value.toString()); + return label; + + } + } + } + + private class DeleteCellRenderer + extends LockableImpl + implements TableCellRenderer { + + @Override + public Component getComponent(Table table, + PageState state, + Object value, + boolean isSelected, + Object key, + int row, + int col) { + SecurityManager securityManager = + Utilities.getSecurityManager(state); + CollectedVolume collectedVolume = + (CollectedVolume) m_itemModel.getSelectedObject( + state); + + boolean canEdit = securityManager.canAccess( + state.getRequest(), + SecurityManager.DELETE_ITEM, + collectedVolume); + + if (canEdit) { + ControlLink link = new ControlLink(value.toString()); + link.setConfirmation((String) PublicationGlobalizationUtil. + globalize( + "publications.ui.collected_volume." + + "articles.confirm_remove"). + localize()); + return link; + } else { + Label label = new Label(value.toString()); + return label; + } + } + } + + private class UpCellRenderer + extends LockableImpl + implements TableCellRenderer { + + @Override + public Component getComponent( + Table table, + PageState state, + Object value, + boolean isSelected, + Object key, + int row, + int col) { + + if (0 == row) { + s_log.debug("Row is first row in table, don't show up link"); + Label label = new Label(""); + return label; + } else { + ControlLink link = new ControlLink("up"); + return link; + } + } + } + + private class DownCellRenderer + extends LockableImpl + implements TableCellRenderer { + + @Override + public Component getComponent( + Table table, + PageState state, + Object value, + boolean isSelected, + Object key, + int row, + int col) { + + CollectedVolume collectedVolume = + (CollectedVolume) m_itemModel.getSelectedObject( + state); + ArticleInCollectedVolumeCollection articles = + collectedVolume.getArticles(); + + if ((articles.size() - 1) + == row) { + s_log.debug("Row is last row in table, don't show down link"); + Label label = new Label(""); + return label; + } else { + ControlLink link = new ControlLink("down"); + return link; + } + } + } + + @Override + public void cellSelected(TableActionEvent event) { + PageState state = event.getPageState(); + + ArticleInCollectedVolume article = + new ArticleInCollectedVolume( + new BigDecimal(event.getRowKey().toString())); + + CollectedVolume collectedVolume = + (CollectedVolume) m_itemModel.getSelectedObject(state); + + ArticleInCollectedVolumeCollection articles = + collectedVolume.getArticles(); + + TableColumn column = getColumnModel().get(event.getColumn().intValue()); + + if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) { + + } else if(column.getHeaderKey().toString().equals(TABLE_COL_DEL)) { + collectedVolume.removeArticle(article); + } else if(column.getHeaderKey().toString().equals(TABLE_COL_UP)) { + articles.swapWithPrevious(article); + } else if(column.getHeaderKey().toString().equals(TABLE_COL_DOWN)) { + articles.swapWithNext(article); + } + } + + @Override + public void headSelected(TableActionEvent event) { + //Nothing to do. + } +} diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertiesStep.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertiesStep.java new file mode 100644 index 000000000..e187b27c2 --- /dev/null +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertiesStep.java @@ -0,0 +1,60 @@ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Label; +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; + +/** + * + * @author Jens Pelzetter + */ +public class CollectedVolumePropertiesStep + extends PublicationWithPublisherPropertiesStep { + + public CollectedVolumePropertiesStep( + ItemSelectionModel itemModel, + AuthoringKitWizard parent) { + super(itemModel, parent); + } + + @Override + protected void addBasicProperties( + ItemSelectionModel itemModel, + AuthoringKitWizard parent) { + SimpleEditStep basicProperties = new SimpleEditStep(itemModel, + parent, + EDIT_SHEET_NAME); + + BasicPageForm editBasicSheet = + new CollectedVolumePropertyForm(itemModel, this); + + basicProperties.add(EDIT_SHEET_NAME, + (String) PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.edit_basic_sheet"). + localize(), new WorkflowLockedComponentAccess(editBasicSheet, + itemModel), + editBasicSheet.getSaveCancelSection(). + getCancelButton()); + + basicProperties.setDisplayComponent( + getPublicationPropertySheet(itemModel)); + + getSegmentedPanel().addSegment( + new Label((String) PublicationGlobalizationUtil.globalize( + "publications.ui.publication.basic_properties"). + localize()), basicProperties); + } + + @Override + protected void addSteps(ItemSelectionModel itemModel, + AuthoringKitWizard parent) { + super.addSteps(itemModel, + parent); + + addStep(new CollectedVolumeArticlesStep(itemModel, parent), + "publications.ui.collected_volume_articles"); + } +} diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertyForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertyForm.java new file mode 100644 index 000000000..7cf69b251 --- /dev/null +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertyForm.java @@ -0,0 +1,123 @@ +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.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.TextField; +import com.arsdigita.bebop.parameters.IntegerParameter; +import com.arsdigita.bebop.parameters.ParameterModel; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.CollectedVolume; +import org.apache.log4j.Logger; + +/** + * + * @author Jens Pelzetter + */ +public class CollectedVolumePropertyForm + extends PublicationWithPublisherPropertyForm + implements FormProcessListener, + FormInitListener, + FormSubmissionListener { + + private static final Logger s_log = + Logger.getLogger( + CollectedVolumePropertyForm.class); + private CollectedVolumePropertiesStep m_step; + public static final String ID = "CollectedVolumeEdit"; + + public CollectedVolumePropertyForm(ItemSelectionModel itemModel) { + this(itemModel, null); + } + + public CollectedVolumePropertyForm(ItemSelectionModel itemModel, + CollectedVolumePropertiesStep step) { + super(itemModel, step); + m_step = step; + addSubmissionListener(this); + } + + @Override + protected void addWidgets() { + super.addWidgets(); + + add(new Label((String) PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.volume").localize())); + ParameterModel volumeParam = new IntegerParameter( + CollectedVolume.VOLUME); + TextField volume = new TextField(volumeParam); + add(volume); + + add(new Label((String) PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.number_of_volumes"). + localize())); + ParameterModel numberOfVolumesParam = + new IntegerParameter(CollectedVolume.NUMBER_OF_VOLUMES); + TextField numberOfVolumes = new TextField(numberOfVolumesParam); + add(numberOfVolumes); + + add(new Label((String) PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.number_of_pages"). + localize())); + ParameterModel numberOfPagesParam = new IntegerParameter( + CollectedVolume.NUMBER_OF_PAGES); + TextField numberOfPages = new TextField(numberOfPagesParam); + add(numberOfPages); + + add(new Label((String) PublicationGlobalizationUtil.globalize( + "publications.ui.collected_volume.edition"). + localize())); + ParameterModel editionModel = new StringParameter( + CollectedVolume.EDITION); + TextField edition = new TextField(editionModel); + add(edition); + } + + @Override + public void init(FormSectionEvent fse) throws FormProcessException { + super.init(fse); + + FormData data = fse.getFormData(); + CollectedVolume collectedVolume = + (CollectedVolume) super.initBasicWidgets(fse); + + data.put(CollectedVolume.VOLUME, collectedVolume.getVolume()); + data.put(CollectedVolume.NUMBER_OF_VOLUMES, + collectedVolume.getNumberOfVolumes()); + data.put(CollectedVolume.NUMBER_OF_PAGES, + collectedVolume.getNumberOfPages()); + data.put(CollectedVolume.EDITION, collectedVolume.getEdition()); + } + + @Override + public void process(FormSectionEvent fse) throws FormProcessException { + super.process(fse); + + FormData data = fse.getFormData(); + CollectedVolume collectedVolume = + (CollectedVolume) super.processBasicWidgets(fse); + + if ((collectedVolume != null) && getSaveCancelSection(). + getSaveButton().isSelected(fse.getPageState())) { + collectedVolume.setVolume((Integer) data.get( + CollectedVolume.VOLUME)); + collectedVolume.setNumberOfVolumes((Integer) data.get( + CollectedVolume.NUMBER_OF_VOLUMES)); + collectedVolume.setNumberOfPages((Integer) data.get( + CollectedVolume.NUMBER_OF_PAGES)); + collectedVolume.setEdition((String) data.get( + CollectedVolume.EDITION)); + + collectedVolume.save(); + } + + if (m_step != null) { + m_step.maybeForwardToNextStep(fse.getPageState()); + } + } +} diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java index 76484f9e2..ee4f5ef39 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java @@ -4,11 +4,9 @@ import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.SaveCancelSection; 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.RadioGroup; import com.arsdigita.bebop.parameters.BooleanParameter; @@ -92,7 +90,8 @@ public class PublicationAuthorAddForm Publication publication = (Publication) getItemSelectionModel(). getSelectedObject(state); - if (!(this.getSaveCancelSection().getCancelButton().isSelected(state))) { + if (!(this.getSaveCancelSection().getCancelButton(). + isSelected(state))) { publication.addAuthor( (GenericPerson) data.get(ITEM_SEARCH), (Boolean) data.get(AuthorshipCollection.EDITOR)); diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorsPropertyStep.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorsPropertyStep.java index 41c0185ae..07570af49 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorsPropertyStep.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorsPropertyStep.java @@ -37,6 +37,4 @@ public class PublicationAuthorsPropertyStep extends SimpleEditStep { itemModel); setDisplayComponent(authorsTable); } - - }