Forms for Proceedings
parent
a298b0b299
commit
77deea649a
|
|
@ -49,6 +49,7 @@ public class CollectedVolumeArticlesTable
|
||||||
);
|
);
|
||||||
|
|
||||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
|
||||||
private final String TABLE_COL_DEL = "table_col_del";
|
private final String TABLE_COL_DEL = "table_col_del";
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
@ -114,9 +115,6 @@ public class CollectedVolumeArticlesTable
|
||||||
final CollectedVolume collectedVolume = collectedVolumeItem
|
final CollectedVolume collectedVolume = collectedVolumeItem
|
||||||
.getPublication();
|
.getPublication();
|
||||||
|
|
||||||
final List<ArticleInCollectedVolume> articles = collectedVolume
|
|
||||||
.getArticles();
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
final TableColumn column = getColumnModel().get(event.getColumn());
|
||||||
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||||
|
|
@ -173,7 +171,9 @@ public class CollectedVolumeArticlesTable
|
||||||
private class CollectedVolumeArticlesTableModel implements TableModel {
|
private class CollectedVolumeArticlesTableModel implements TableModel {
|
||||||
|
|
||||||
private final Table table;
|
private final Table table;
|
||||||
|
|
||||||
private final Iterator<ArticleInCollectedVolume> articles;
|
private final Iterator<ArticleInCollectedVolume> articles;
|
||||||
|
|
||||||
private ArticleInCollectedVolume article;
|
private ArticleInCollectedVolume article;
|
||||||
|
|
||||||
private CollectedVolumeArticlesTableModel(
|
private CollectedVolumeArticlesTableModel(
|
||||||
|
|
@ -192,7 +192,12 @@ public class CollectedVolumeArticlesTable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean nextRow() {
|
public boolean nextRow() {
|
||||||
return articles != null && articles.hasNext();
|
if (articles != null && articles.hasNext()) {
|
||||||
|
article = articles.next();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
public class ExpertiseOrganizationSheet extends Table
|
public class ExpertiseOrganizationSheet
|
||||||
|
extends Table
|
||||||
implements TableActionListener {
|
implements TableActionListener {
|
||||||
|
|
||||||
private static final String TABLE_COL_EDIT = "table_col_edit";
|
private static final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
|
@ -145,7 +146,9 @@ public class ExpertiseOrganizationSheet extends Table
|
||||||
private class ExpertiseOrganizationSheetModel implements TableModel {
|
private class ExpertiseOrganizationSheetModel implements TableModel {
|
||||||
|
|
||||||
private final Table table;
|
private final Table table;
|
||||||
|
|
||||||
private final Organization organization;
|
private final Organization organization;
|
||||||
|
|
||||||
private boolean done;
|
private boolean done;
|
||||||
|
|
||||||
public ExpertiseOrganizationSheetModel(
|
public ExpertiseOrganizationSheetModel(
|
||||||
|
|
@ -262,5 +265,4 @@ public class ExpertiseOrganizationSheet extends Table
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,184 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import org.librecms.assets.Organization;
|
||||||
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
import org.scientificcms.publications.InProceedings;
|
||||||
|
import org.scientificcms.publications.Proceedings;
|
||||||
|
import org.scientificcms.publications.ProceedingsManager;
|
||||||
|
import org.scientificcms.publications.PublicationRepository;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class ProceedingsController {
|
||||||
|
|
||||||
|
public static final String NAME_OF_CONFERENCE = "nameOfConference";
|
||||||
|
|
||||||
|
public static final String PLACE_OF_CONFERENCE = "placeOfConference";
|
||||||
|
|
||||||
|
public static final String START_DATE = "startDate";
|
||||||
|
|
||||||
|
public static final String END_DATE = "endDate";
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetRepository assetRepository;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ProceedingsManager proceedingsManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PublicationRepository publicationRepository;
|
||||||
|
|
||||||
|
public void saveProceedings(
|
||||||
|
final long proceedingsId, final Map<String, Object> data
|
||||||
|
) {
|
||||||
|
final Proceedings proceedings = publicationRepository
|
||||||
|
.findByIdAndType(proceedingsId, Proceedings.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Procceedings with ID %d found.", proceedingsId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (data.containsKey(NAME_OF_CONFERENCE)) {
|
||||||
|
proceedings.setNameOfConference(
|
||||||
|
(String) data.get(NAME_OF_CONFERENCE)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.containsKey(PLACE_OF_CONFERENCE)) {
|
||||||
|
proceedings.setPlaceOfConference((String) data.get(
|
||||||
|
PLACE_OF_CONFERENCE)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.containsKey(START_DATE)) {
|
||||||
|
proceedings.setStartDate((LocalDate) data.get(START_DATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.containsKey(END_DATE)) {
|
||||||
|
proceedings.setStartDate((LocalDate) data.get(END_DATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
publicationRepository.save(proceedings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InProceedings findPaper(final long paperId) {
|
||||||
|
final InProceedings paper = publicationRepository
|
||||||
|
.findByIdAndType(paperId, InProceedings.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No InProcceedings with ID %d found.", paperId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return paper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPaper(final long proceedingsId, final long paperId) {
|
||||||
|
final Proceedings proceedings = publicationRepository
|
||||||
|
.findByIdAndType(proceedingsId, Proceedings.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Procceedings with ID %d found.", proceedingsId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final InProceedings paper = publicationRepository
|
||||||
|
.findByIdAndType(paperId, InProceedings.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No InProcceedings with ID %d found.", paperId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
proceedingsManager.addPaperToCollectedVolume(paper, proceedings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePaper(final long proceedingsId, final long paperId) {
|
||||||
|
final Proceedings proceedings = publicationRepository
|
||||||
|
.findByIdAndType(proceedingsId, Proceedings.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Procceedings with ID %d found.", proceedingsId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final InProceedings paper = publicationRepository
|
||||||
|
.findByIdAndType(paperId, InProceedings.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No InProcceedings with ID %d found.", paperId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
proceedingsManager.removeArticleFromCollectedVolume(paper, proceedings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrganizier(final long proceedingsId, final long organizerId) {
|
||||||
|
final Proceedings proceedings = publicationRepository
|
||||||
|
.findByIdAndType(proceedingsId, Proceedings.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Procceedings with ID %d found.", proceedingsId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final Organization organizer = assetRepository
|
||||||
|
.findById(organizerId, Organization.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Organization with ID %d found.", organizerId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
proceedings.setOrganizer(organizer);
|
||||||
|
publicationRepository.save(proceedings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unsetOrganizier(final long proceedingsId) {
|
||||||
|
final Proceedings proceedings = publicationRepository
|
||||||
|
.findByIdAndType(proceedingsId, Proceedings.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Procceedings with ID %d found.", proceedingsId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
proceedings.setOrganizer(null);
|
||||||
|
publicationRepository.save(proceedings);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
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.AssetSearchWidget;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.librecms.assets.Organization;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ProceedingsOrganizerForm
|
||||||
|
extends BasicItemForm
|
||||||
|
implements FormProcessListener, FormInitListener {
|
||||||
|
|
||||||
|
private static final String ORGA_SEARCH = "conferenceOrganization";
|
||||||
|
|
||||||
|
private AssetSearchWidget orgaSearch;
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public ProceedingsOrganizerForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super("ProceeingsOrganizerForm", itemModel, selectedLangParam);
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
orgaSearch = new AssetSearchWidget(
|
||||||
|
ORGA_SEARCH, Organization.class
|
||||||
|
);
|
||||||
|
orgaSearch.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.organizer",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(orgaSearch);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
setVisible(state, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel.
|
||||||
|
getSelectedItem(state);
|
||||||
|
|
||||||
|
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
|
final Organization organization = (Organization) orgaSearch
|
||||||
|
.getValue(state);
|
||||||
|
final ProceedingsController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ProceedingsController.class);
|
||||||
|
controller.setOrganizier(
|
||||||
|
proceedingsItem.getPublication().getPublicationId(),
|
||||||
|
organization.getObjectId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
init(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,269 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
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.Text;
|
||||||
|
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.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
import org.librecms.assets.Organization;
|
||||||
|
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||||
|
import org.scientificcms.publications.Proceedings;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ProceedingsOrganizerSheet
|
||||||
|
extends Table
|
||||||
|
implements TableActionListener {
|
||||||
|
|
||||||
|
private static final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
|
||||||
|
private static final String TABLE_COL_DEL = "table_col_del";
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public ProceedingsOrganizerSheet(final ItemSelectionModel itemModel) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
|
||||||
|
setEmptyView(
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.organizer.none",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final TableColumnModel columnModel = getColumnModel();
|
||||||
|
columnModel.add(
|
||||||
|
new TableColumn(
|
||||||
|
0,
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.organizer",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TABLE_COL_EDIT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
columnModel.add(
|
||||||
|
new TableColumn(
|
||||||
|
1,
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.organizer.remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TABLE_COL_DEL
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
setModelBuilder(new ProceedingsOrganizerSheetModelBuilder(itemModel));
|
||||||
|
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||||
|
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
|
||||||
|
addTableActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cellSelected(final TableActionEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
|
||||||
|
final TableColumn column = getColumnModel().get(event.getColumn());
|
||||||
|
|
||||||
|
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||||
|
// Nothing
|
||||||
|
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||||
|
final ProceedingsController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ProceedingsController.class);
|
||||||
|
controller.unsetOrganizier(
|
||||||
|
proceedingsItem.getPublication().getPublicationId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headSelected(final TableActionEvent event) {
|
||||||
|
//Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProceedingsOrganizerSheetModelBuilder
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public ProceedingsOrganizerSheetModelBuilder(
|
||||||
|
final ItemSelectionModel itemModel
|
||||||
|
) {
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final TableModel makeModel(
|
||||||
|
final Table table, final PageState state
|
||||||
|
) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
return new ProceedingsOrganizerSheetModel(
|
||||||
|
table, state, proceedingsItem.getPublication()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProceedingsOrganizerSheetModel implements TableModel {
|
||||||
|
|
||||||
|
private final Table table;
|
||||||
|
|
||||||
|
private final Organization organizer;
|
||||||
|
|
||||||
|
private boolean done;
|
||||||
|
|
||||||
|
public ProceedingsOrganizerSheetModel(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Proceedings proceedings
|
||||||
|
) {
|
||||||
|
this.table = table;
|
||||||
|
organizer = proceedings.getOrganizer();
|
||||||
|
done = organizer != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return table.getColumnModel().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean nextRow() {
|
||||||
|
boolean ret;
|
||||||
|
|
||||||
|
if (done) {
|
||||||
|
ret = true;
|
||||||
|
done = false;
|
||||||
|
} else {
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(final int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return organizer.getTitle();
|
||||||
|
case 1:
|
||||||
|
return new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.organizer.remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKeyAt(final int columnIndex) {
|
||||||
|
return organizer.getObjectId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EditCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Component getComponent(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column
|
||||||
|
) {
|
||||||
|
return new Text((String) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DeleteCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int col
|
||||||
|
) {
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
|
||||||
|
final PermissionChecker permissionChecker = cdiUtil
|
||||||
|
.findBean(PermissionChecker.class);
|
||||||
|
|
||||||
|
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
|
||||||
|
final boolean canEdit = permissionChecker.isPermitted(
|
||||||
|
ItemPrivileges.DELETE, proceedingsItem
|
||||||
|
);
|
||||||
|
|
||||||
|
if (canEdit) {
|
||||||
|
final ControlLink link = new ControlLink((Component) value);
|
||||||
|
link.setConfirmation(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publication.ui.proceedings.organizer.remove.confirm",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return link;
|
||||||
|
} else {
|
||||||
|
return new Text("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
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 org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ProceedingsOrganizerStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private static final String SET_PROCEEDINGS_ORGANIZER_STEP
|
||||||
|
= "setProceedingsOrganizerStep";
|
||||||
|
|
||||||
|
public ProceedingsOrganizerStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
this(itemModel, parent, selectedLangParam, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProceedingsOrganizerStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam,
|
||||||
|
final String prefix
|
||||||
|
) {
|
||||||
|
super(itemModel, parent, selectedLangParam, prefix);
|
||||||
|
|
||||||
|
final BasicItemForm setOrganizerForm = new ProceedingsOrganizerForm(
|
||||||
|
itemModel, selectedLangParam
|
||||||
|
);
|
||||||
|
add(
|
||||||
|
SET_PROCEEDINGS_ORGANIZER_STEP,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.setOrganizer",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
new WorkflowLockedComponentAccess(setOrganizerForm, itemModel),
|
||||||
|
setOrganizerForm.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
final ProceedingsOrganizerSheet sheet = new ProceedingsOrganizerSheet(
|
||||||
|
itemModel
|
||||||
|
);
|
||||||
|
setDisplayComponent(sheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
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.authoring.BasicItemForm;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.scientificcms.publications.InProceedings;
|
||||||
|
import org.scientificcms.publications.Proceedings;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ProceedingsPapersAddForm extends BasicItemForm
|
||||||
|
implements FormProcessListener,
|
||||||
|
FormInitListener {
|
||||||
|
|
||||||
|
private static final String PAPER_SEARCH = "papers";
|
||||||
|
|
||||||
|
private PublicationSearchWidget paperSearch;
|
||||||
|
|
||||||
|
public ProceedingsPapersAddForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super("PapersAddForm", itemModel, selectedLangParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
paperSearch = new PublicationSearchWidget(
|
||||||
|
PAPER_SEARCH, InProceedings.class
|
||||||
|
);
|
||||||
|
paperSearch.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.select_paper",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(paperSearch);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
setVisible(state, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final FormData formData = event.getFormData();
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final ProceedingsItem proceedingsItem
|
||||||
|
= (ProceedingsItem) getItemSelectionModel().
|
||||||
|
getSelectedObject(state);
|
||||||
|
final Proceedings proceedings = proceedingsItem.getPublication();
|
||||||
|
|
||||||
|
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
|
final InProceedings paper = (InProceedings) formData.get(
|
||||||
|
PAPER_SEARCH
|
||||||
|
);
|
||||||
|
|
||||||
|
final ProceedingsController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ProceedingsController.class);
|
||||||
|
controller.addPaper(
|
||||||
|
proceedings.getPublicationId(), paper.getPublicationId()
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
init(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
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 org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ProceedingsPapersStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private static final String ADD_PAPER_SHEET_NAME = "addPaper";
|
||||||
|
|
||||||
|
public ProceedingsPapersStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
this(itemModel, parent, selectedLangParam, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProceedingsPapersStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam,
|
||||||
|
final String prefix
|
||||||
|
) {
|
||||||
|
super(itemModel, parent, selectedLangParam, prefix);
|
||||||
|
|
||||||
|
BasicItemForm addPaperSheet = new ProceedingsPapersAddForm(
|
||||||
|
itemModel, selectedLangParam
|
||||||
|
);
|
||||||
|
add(
|
||||||
|
ADD_PAPER_SHEET_NAME,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.add_paper",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
new WorkflowLockedComponentAccess(addPaperSheet, itemModel),
|
||||||
|
addPaperSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
final ProceedingsPapersTable papersTable = new ProceedingsPapersTable(
|
||||||
|
itemModel
|
||||||
|
);
|
||||||
|
setDisplayComponent(papersTable);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,274 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
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.Text;
|
||||||
|
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.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||||
|
import org.scientificcms.publications.InProceedings;
|
||||||
|
import org.scientificcms.publications.Proceedings;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ProceedingsPapersTable
|
||||||
|
extends Table
|
||||||
|
implements TableActionListener {
|
||||||
|
|
||||||
|
private final Logger LOGGER = LogManager.getLogger(
|
||||||
|
ProceedingsPapersTable.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 final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public ProceedingsPapersTable(final ItemSelectionModel itemModel) {
|
||||||
|
super();
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
|
||||||
|
setEmptyView(
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.procreedings.no_papers",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
TableColumnModel colModel = getColumnModel();
|
||||||
|
colModel.add(
|
||||||
|
new TableColumn(
|
||||||
|
0,
|
||||||
|
new Label(new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.paper",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TABLE_COL_EDIT));
|
||||||
|
colModel.add(
|
||||||
|
new TableColumn(
|
||||||
|
1,
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.paper.remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TABLE_COL_DEL));
|
||||||
|
|
||||||
|
setModelBuilder(
|
||||||
|
new ProceedingsPapersTableModelBuilder(itemModel));
|
||||||
|
|
||||||
|
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||||
|
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
|
||||||
|
addTableActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cellSelected(final TableActionEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final ProceedingsController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ProceedingsController.class);
|
||||||
|
|
||||||
|
final InProceedings paper = controller
|
||||||
|
.findPaper((Long) event.getRowKey());
|
||||||
|
|
||||||
|
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
final Proceedings proceedings = proceedingsItem.getPublication();
|
||||||
|
|
||||||
|
TableColumn column = getColumnModel().get(event.getColumn());
|
||||||
|
|
||||||
|
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||||
|
// Nothing
|
||||||
|
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||||
|
controller.removePaper(
|
||||||
|
proceedings.getPublicationId(),
|
||||||
|
paper.getPublicationId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headSelected(TableActionEvent event) {
|
||||||
|
//Noting to do
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProceedingsPapersTableModelBuilder
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public ProceedingsPapersTableModelBuilder(
|
||||||
|
final ItemSelectionModel itemModel
|
||||||
|
) {
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableModel makeModel(final Table table, final PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
final ProceedingsItem proceedings = (ProceedingsItem) itemModel
|
||||||
|
.getSelectedObject(state);
|
||||||
|
return new ProceedingsPapersTableModel(
|
||||||
|
table, state, proceedings.getPublication()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProceedingsPapersTableModel implements TableModel {
|
||||||
|
|
||||||
|
private final Table table;
|
||||||
|
|
||||||
|
private final Iterator<InProceedings> papers;
|
||||||
|
|
||||||
|
private InProceedings paper;
|
||||||
|
|
||||||
|
private ProceedingsPapersTableModel(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Proceedings proceedings
|
||||||
|
) {
|
||||||
|
this.table = table;
|
||||||
|
papers = proceedings.getPapers().iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return table.getColumnModel().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean nextRow() {
|
||||||
|
if (papers != null && papers.hasNext()) {
|
||||||
|
paper = papers.next();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(final int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return paper.getTitle();
|
||||||
|
case 1:
|
||||||
|
return new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.paper.remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKeyAt(final int columnIndex) {
|
||||||
|
return paper.getPublicationId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EditCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int col
|
||||||
|
) {
|
||||||
|
return new Text((String) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DeleteCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column
|
||||||
|
) {
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final PermissionChecker permissionChecker = cdiUtil
|
||||||
|
.findBean(PermissionChecker.class);
|
||||||
|
|
||||||
|
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
|
||||||
|
final boolean canEdit = permissionChecker
|
||||||
|
.isPermitted(ItemPrivileges.EDIT, proceedingsItem
|
||||||
|
);
|
||||||
|
|
||||||
|
if (canEdit) {
|
||||||
|
final ControlLink link = new ControlLink((Component) value);
|
||||||
|
link.setConfirmation(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.paper.confirm_remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return link;
|
||||||
|
} else {
|
||||||
|
return new Text("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,200 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
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.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.CmsConstants;
|
||||||
|
import org.scientificcms.publications.Proceedings;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ProceedingsPropertiesStep
|
||||||
|
extends PublicationWithPublisherPropertiesStep {
|
||||||
|
|
||||||
|
private StringParameter selectedLangParam;
|
||||||
|
|
||||||
|
public ProceedingsPropertiesStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super(itemModel, parent, selectedLangParam);
|
||||||
|
this.selectedLangParam = selectedLangParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component getProceedingsPropertySheet(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
final DomainObjectPropertySheet sheet
|
||||||
|
= (DomainObjectPropertySheet) getPublicationWithPublisherPropertySheet(
|
||||||
|
itemModel, selectedLangParam
|
||||||
|
);
|
||||||
|
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.name_of_conference",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
ProceedingsController.NAME_OF_CONFERENCE);
|
||||||
|
|
||||||
|
sheet.add(new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.place_of_conference",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
ProceedingsController.PLACE_OF_CONFERENCE);
|
||||||
|
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.date_from_of_conference",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
ProceedingsController.START_DATE,
|
||||||
|
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||||
|
|
||||||
|
public String format(
|
||||||
|
final Object item,
|
||||||
|
final String attribute,
|
||||||
|
final PageState state
|
||||||
|
) {
|
||||||
|
final ProceedingsItem proceedingsItem = (ProceedingsItem) item;
|
||||||
|
final Proceedings proceedings = proceedingsItem.getPublication();
|
||||||
|
if (proceedings.getStartDate() != null) {
|
||||||
|
final LocalDate startLocalDate = proceedings.getStartDate();
|
||||||
|
final Date startDate = Date.from(
|
||||||
|
startLocalDate
|
||||||
|
.atStartOfDay()
|
||||||
|
.atZone(ZoneId.systemDefault())
|
||||||
|
.toInstant()
|
||||||
|
);
|
||||||
|
return DateFormat.getDateInstance(DateFormat.LONG)
|
||||||
|
.format(startDate);
|
||||||
|
} else {
|
||||||
|
return (String) new GlobalizedMessage(
|
||||||
|
"cms.ui.unknown",
|
||||||
|
CmsConstants.CMS_BUNDLE
|
||||||
|
).localize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.date_to_of_conference",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
ProceedingsController.END_DATE,
|
||||||
|
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||||
|
|
||||||
|
public String format(
|
||||||
|
final Object item,
|
||||||
|
final String attribute,
|
||||||
|
final PageState state
|
||||||
|
) {
|
||||||
|
final ProceedingsItem proceedingsItem = (ProceedingsItem) item;
|
||||||
|
final Proceedings proceedings = proceedingsItem.getPublication();
|
||||||
|
if (proceedings.getEndDate() != null) {
|
||||||
|
final LocalDate endLocalDate = proceedings.getEndDate();
|
||||||
|
final Date endDate = Date.from(
|
||||||
|
endLocalDate
|
||||||
|
.atStartOfDay()
|
||||||
|
.atZone(ZoneId.systemDefault())
|
||||||
|
.toInstant()
|
||||||
|
);
|
||||||
|
|
||||||
|
return DateFormat.getDateInstance(DateFormat.LONG)
|
||||||
|
.format(endDate);
|
||||||
|
} else {
|
||||||
|
return (String) new GlobalizedMessage(
|
||||||
|
"cms.ui.unknown",
|
||||||
|
CmsConstants.CMS_BUNDLE
|
||||||
|
).localize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addBasicProperties(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent) {
|
||||||
|
final SimpleEditStep basicProperties = new SimpleEditStep(
|
||||||
|
itemModel, parent, selectedLangParam, EDIT_SHEET_NAME);
|
||||||
|
|
||||||
|
BasicPageForm editBasicSheet = new ProceedingsPropertyForm(
|
||||||
|
itemModel, this, selectedLangParam
|
||||||
|
);
|
||||||
|
|
||||||
|
basicProperties.add(
|
||||||
|
EDIT_SHEET_NAME,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.edit_basic_sheet",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
||||||
|
editBasicSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
basicProperties.setDisplayComponent(
|
||||||
|
getProceedingsPropertySheet(itemModel, selectedLangParam)
|
||||||
|
);
|
||||||
|
|
||||||
|
getSegmentedPanel().addSegment(
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.basic_properties",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
basicProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addSteps(
|
||||||
|
final ItemSelectionModel itemModel, final AuthoringKitWizard parent) {
|
||||||
|
super.addSteps(itemModel, parent);
|
||||||
|
|
||||||
|
addStep(
|
||||||
|
new ProceedingsOrganizerStep(itemModel, parent, selectedLangParam),
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.organizer",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
addStep(
|
||||||
|
new ProceedingsPapersStep(itemModel, parent, selectedLangParam),
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.papers",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,200 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
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.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.Date;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.DateParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.scientificcms.publications.Proceedings;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ProceedingsPropertyForm
|
||||||
|
extends PublicationWithPublisherPropertyForm
|
||||||
|
implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
public static final String ID = "proceedingsEdit";
|
||||||
|
|
||||||
|
public ProceedingsPropertyForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
this(itemModel, null, selectedLangParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProceedingsPropertyForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final ProceedingsPropertiesStep step,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super(itemModel, step, selectedLangParam);
|
||||||
|
//m_step = step;
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
final ParameterModel nameOfConfParam = new StringParameter(
|
||||||
|
ProceedingsController.NAME_OF_CONFERENCE
|
||||||
|
);
|
||||||
|
final TextField nameOfConf = new TextField(nameOfConfParam);
|
||||||
|
nameOfConf.addValidationListener(new NotNullValidationListener());
|
||||||
|
nameOfConf.addValidationListener(new NotEmptyValidationListener());
|
||||||
|
nameOfConf.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.name_of_conference",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(nameOfConf);
|
||||||
|
|
||||||
|
final ParameterModel placeOfConfParam = new StringParameter(
|
||||||
|
ProceedingsController.PLACE_OF_CONFERENCE);
|
||||||
|
final TextField placeOfConf = new TextField(placeOfConfParam);
|
||||||
|
placeOfConf.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.place_of_conference",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(placeOfConf);
|
||||||
|
|
||||||
|
final Calendar today = new GregorianCalendar();
|
||||||
|
final ParameterModel dateFromParam = new DateParameter(
|
||||||
|
ProceedingsController.START_DATE);
|
||||||
|
final Date dateFrom = new Date(dateFromParam);
|
||||||
|
dateFrom.setYearRange(1900, today.get(Calendar.YEAR) + 3);
|
||||||
|
|
||||||
|
dateFrom.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.date_from_of_conference",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(dateFrom);
|
||||||
|
|
||||||
|
final ParameterModel dateToParam = new DateParameter(
|
||||||
|
ProceedingsController.END_DATE
|
||||||
|
);
|
||||||
|
final Date dateTo = new Date(dateToParam);
|
||||||
|
dateTo.setYearRange(1900, today.get(Calendar.YEAR) + 3);
|
||||||
|
|
||||||
|
dateTo.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.proceedings.date_to_of_conference",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(dateTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
|
||||||
|
super.init(event);
|
||||||
|
|
||||||
|
final FormData data = event.getFormData();
|
||||||
|
final ProceedingsItem proceedingsItem = (ProceedingsItem) super
|
||||||
|
.initBasicWidgets(event);
|
||||||
|
final Proceedings proceedings = proceedingsItem.getPublication();
|
||||||
|
|
||||||
|
data.put(
|
||||||
|
ProceedingsController.NAME_OF_CONFERENCE,
|
||||||
|
proceedings.getNameOfConference()
|
||||||
|
);
|
||||||
|
data.put(
|
||||||
|
ProceedingsController.PLACE_OF_CONFERENCE,
|
||||||
|
proceedings.getPlaceOfConference()
|
||||||
|
);
|
||||||
|
data.put(
|
||||||
|
ProceedingsController.START_DATE,
|
||||||
|
proceedings.getStartDate()
|
||||||
|
);
|
||||||
|
data.put(
|
||||||
|
ProceedingsController.END_DATE,
|
||||||
|
proceedings.getEndDate()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
super.process(event);
|
||||||
|
|
||||||
|
final FormData formData = event.getFormData();
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final ProceedingsItem proceedingsItem = (ProceedingsItem) super
|
||||||
|
.processBasicWidgets(event);
|
||||||
|
|
||||||
|
if ((proceedingsItem != null)
|
||||||
|
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
|
|
||||||
|
final Map<String, Object> data = new HashMap<>();
|
||||||
|
data.put(
|
||||||
|
ProceedingsController.NAME_OF_CONFERENCE,
|
||||||
|
formData.get(ProceedingsController.NAME_OF_CONFERENCE)
|
||||||
|
);
|
||||||
|
data.put(
|
||||||
|
ProceedingsController.PLACE_OF_CONFERENCE,
|
||||||
|
formData.get(ProceedingsController.PLACE_OF_CONFERENCE)
|
||||||
|
);
|
||||||
|
|
||||||
|
final java.util.Date startDate = (java.util.Date) formData
|
||||||
|
.get(ProceedingsController.START_DATE);
|
||||||
|
data.put(
|
||||||
|
ProceedingsController.START_DATE,
|
||||||
|
startDate.toInstant().atZone(
|
||||||
|
ZoneId.systemDefault()
|
||||||
|
).toLocalDate()
|
||||||
|
);
|
||||||
|
|
||||||
|
final java.util.Date endDate = (java.util.Date) formData
|
||||||
|
.get(ProceedingsController.END_DATE);
|
||||||
|
data.put(
|
||||||
|
ProceedingsController.END_DATE,
|
||||||
|
endDate.toInstant().atZone(
|
||||||
|
ZoneId.systemDefault()
|
||||||
|
).toLocalDate()
|
||||||
|
);
|
||||||
|
|
||||||
|
final ProceedingsController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ProceedingsController.class);
|
||||||
|
controller.saveProceedings(
|
||||||
|
proceedingsItem.getPublication().getPublicationId(), data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue