Eine Publikation kann jetzt auch über das Formular zu Bearbeiten der Publikation einer Publikationsliste oder einer Reihe hinzugefügt werden.
git-svn-id: https://svn.libreccm.org/ccm/trunk@538 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
006ae50b93
commit
43d3f73c30
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="ArticleInCollectedVolume"
|
label="SciPublications/ArticleInCollectedVolume"
|
||||||
description="Base type for articleInCollectedVolumes"
|
description="Base type for articleInCollectedVolumes"
|
||||||
objectType="com.arsdigita.cms.contenttypes.ArticleInCollectedVolume"
|
objectType="com.arsdigita.cms.contenttypes.ArticleInCollectedVolume"
|
||||||
classname="com.arsdigita.cms.contenttypes.ArticleInCollectedVolume">
|
classname="com.arsdigita.cms.contenttypes.ArticleInCollectedVolume">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="ArticleInJournal"
|
label="SciPublications/ArticleInJournal"
|
||||||
description="Base type for articleInJournals"
|
description="Base type for articleInJournals"
|
||||||
objectType="com.arsdigita.cms.contenttypes.ArticleInJournal"
|
objectType="com.arsdigita.cms.contenttypes.ArticleInJournal"
|
||||||
classname="com.arsdigita.cms.contenttypes.ArticleInJournal">
|
classname="com.arsdigita.cms.contenttypes.ArticleInJournal">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="Expertise"
|
label="SciPublications/Expertise"
|
||||||
description="Base type for Expertises"
|
description="Base type for Expertises"
|
||||||
objectType="com.arsdigita.cms.contenttypes.Expertise"
|
objectType="com.arsdigita.cms.contenttypes.Expertise"
|
||||||
classname="com.arsdigita.cms.contenttypes.Expertise">
|
classname="com.arsdigita.cms.contenttypes.Expertise">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="GreyLiterature"
|
label="SciPublications/GreyLiterature"
|
||||||
description="Base type for greyLiteratures"
|
description="Base type for greyLiteratures"
|
||||||
objectType="com.arsdigita.cms.contenttypes.GreyLiterature"
|
objectType="com.arsdigita.cms.contenttypes.GreyLiterature"
|
||||||
classname="com.arsdigita.cms.contenttypes.GreyLiterature">
|
classname="com.arsdigita.cms.contenttypes.GreyLiterature">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="InProceedings"
|
label="SciPublications/InProceedings"
|
||||||
description="Base type for inProceedingss"
|
description="Base type for inProceedingss"
|
||||||
objectType="com.arsdigita.cms.contenttypes.InProceedings"
|
objectType="com.arsdigita.cms.contenttypes.InProceedings"
|
||||||
classname="com.arsdigita.cms.contenttypes.InProceedings">
|
classname="com.arsdigita.cms.contenttypes.InProceedings">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="InternetArticle"
|
label="SciPublications/InternetArticle"
|
||||||
description="Base type for InternetArticles"
|
description="Base type for InternetArticles"
|
||||||
objectType="com.arsdigita.cms.contenttypes.InternetArticle"
|
objectType="com.arsdigita.cms.contenttypes.InternetArticle"
|
||||||
classname="com.arsdigita.cms.contenttypes.InternetArticle">
|
classname="com.arsdigita.cms.contenttypes.InternetArticle">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="Monograph"
|
label="SciPublications/Monograph"
|
||||||
description="Base type for monographs"
|
description="Base type for monographs"
|
||||||
objectType="com.arsdigita.cms.contenttypes.Monograph"
|
objectType="com.arsdigita.cms.contenttypes.Monograph"
|
||||||
classname="com.arsdigita.cms.contenttypes.Monograph">
|
classname="com.arsdigita.cms.contenttypes.Monograph">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="Publication"
|
label="SciPublications/Publication"
|
||||||
description="Base type for publications"
|
description="Base type for publications"
|
||||||
objectType="com.arsdigita.cms.contenttypes.Publication"
|
objectType="com.arsdigita.cms.contenttypes.Publication"
|
||||||
classname="com.arsdigita.cms.contenttypes.Publication"
|
classname="com.arsdigita.cms.contenttypes.Publication"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="PublicationList"
|
label="SciPublications/PublicationList"
|
||||||
description="A list of publications"
|
description="A list of publications"
|
||||||
objectType="com.arsdigita.cms.contenttypes.PublicationList"
|
objectType="com.arsdigita.cms.contenttypes.PublicationList"
|
||||||
classname="com.arsdigita.cms.contenttypes.PublicationList">
|
classname="com.arsdigita.cms.contenttypes.PublicationList">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="PublicationWithPublisher"
|
label="SciPublications/PublicationWithPublisher"
|
||||||
description="Base type for publications"
|
description="Base type for publications"
|
||||||
objectType="com.arsdigita.cms.contenttypes.PublicationWithPublisher"
|
objectType="com.arsdigita.cms.contenttypes.PublicationWithPublisher"
|
||||||
classname="com.arsdigita.cms.contenttypes.PublicationWithPublisher"
|
classname="com.arsdigita.cms.contenttypes.PublicationWithPublisher"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="Publisher"
|
label="SciPublications/Publisher"
|
||||||
description="Base type for publishers"
|
description="Base type for publishers"
|
||||||
objectType="com.arsdigita.cms.contenttypes.Publisher"
|
objectType="com.arsdigita.cms.contenttypes.Publisher"
|
||||||
classname="com.arsdigita.cms.contenttypes.Publisher">
|
classname="com.arsdigita.cms.contenttypes.Publisher">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="Review"
|
label="SciPublications/Review"
|
||||||
description="Base type for reviews"
|
description="Base type for reviews"
|
||||||
objectType="com.arsdigita.cms.contenttypes.Review"
|
objectType="com.arsdigita.cms.contenttypes.Review"
|
||||||
classname="com.arsdigita.cms.contenttypes.Review">
|
classname="com.arsdigita.cms.contenttypes.Review">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="Series"
|
label="SciPublications/Series"
|
||||||
description="Base type for seriess"
|
description="Base type for seriess"
|
||||||
objectType="com.arsdigita.cms.contenttypes.Series"
|
objectType="com.arsdigita.cms.contenttypes.Series"
|
||||||
classname="com.arsdigita.cms.contenttypes.Series">
|
classname="com.arsdigita.cms.contenttypes.Series">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="UnPublished"
|
label="SciPublications/UnPublished"
|
||||||
description="Base type for unPublisheds"
|
description="Base type for unPublisheds"
|
||||||
objectType="com.arsdigita.cms.contenttypes.UnPublished"
|
objectType="com.arsdigita.cms.contenttypes.UnPublished"
|
||||||
classname="com.arsdigita.cms.contenttypes.UnPublished"
|
classname="com.arsdigita.cms.contenttypes.UnPublished"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type
|
<ctd:content-type
|
||||||
label="WorkingPaper"
|
label="SciPublications/WorkingPaper"
|
||||||
description="Base type for workingPapers"
|
description="Base type for workingPapers"
|
||||||
objectType="com.arsdigita.cms.contenttypes.WorkingPaper"
|
objectType="com.arsdigita.cms.contenttypes.WorkingPaper"
|
||||||
classname="com.arsdigita.cms.contenttypes.WorkingPaper">
|
classname="com.arsdigita.cms.contenttypes.WorkingPaper">
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ public class Publication extends ContentPage {
|
||||||
public final static String AUTHORS = "authors";
|
public final static String AUTHORS = "authors";
|
||||||
public final static String EDITOR = "editor";
|
public final static String EDITOR = "editor";
|
||||||
public final static String AUTHOR_ORDER = "authorOrder";
|
public final static String AUTHOR_ORDER = "authorOrder";
|
||||||
|
public final static String PUBLICATIONLISTS = "publicationLists";
|
||||||
|
public final static String SERIES = "series";
|
||||||
public final static String BASE_DATA_OBJECT_TYPE =
|
public final static String BASE_DATA_OBJECT_TYPE =
|
||||||
"com.arsdigita.cms.contenttypes.Publication";
|
"com.arsdigita.cms.contenttypes.Publication";
|
||||||
|
|
||||||
|
|
@ -181,4 +183,46 @@ public class Publication extends ContentPage {
|
||||||
public boolean hasAuthors() {
|
public boolean hasAuthors() {
|
||||||
return !this.getAuthors().isEmpty();
|
return !this.getAuthors().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PublicationListCollection getPublicationLists() {
|
||||||
|
return new PublicationListCollection(
|
||||||
|
(DataCollection) get(PUBLICATIONLISTS));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPublicationList(PublicationList list) {
|
||||||
|
Assert.exists(list, PublicationList.class);
|
||||||
|
|
||||||
|
add(PUBLICATIONLISTS, list);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePublicationList(PublicationList list) {
|
||||||
|
Assert.exists(list, PublicationList.class);
|
||||||
|
|
||||||
|
remove(PUBLICATIONLISTS, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPublicationLists() {
|
||||||
|
return !this.getPublicationLists().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SeriesCollection getSeries() {
|
||||||
|
return new SeriesCollection((DataCollection) get(SERIES));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSeries(Series series) {
|
||||||
|
Assert.exists(series, Series.class);
|
||||||
|
|
||||||
|
add(SERIES, series);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeSeries(Series series) {
|
||||||
|
Assert.exists(series, Series.class);
|
||||||
|
|
||||||
|
remove(SERIES, series);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSeries() {
|
||||||
|
return !this.getSeries().isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010 Jens Pelzetter,
|
||||||
|
* for the Center of Social Politics of the University of Bremen
|
||||||
|
*
|
||||||
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
|
||||||
|
import com.arsdigita.domain.DomainCollection;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class PublicationCollection extends DomainCollection {
|
||||||
|
|
||||||
|
public PublicationCollection(DataCollection dataCollection) {
|
||||||
|
super(dataCollection);
|
||||||
|
m_dataCollection.addOrder("title asc");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Publication getPublication() {
|
||||||
|
return new Publication(m_dataCollection.getDataObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.domain.DomainCollection;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class SeriesCollection extends DomainCollection {
|
||||||
|
|
||||||
|
public SeriesCollection(DataCollection dataCollection) {
|
||||||
|
super(dataCollection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Series getSeries() {
|
||||||
|
return new Series(m_dataCollection.getDataObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -19,10 +19,9 @@ public class PublicationAuthorsPropertyStep extends SimpleEditStep {
|
||||||
this(itemModel, parent, null);
|
this(itemModel, parent, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PublicationAuthorsPropertyStep(
|
public PublicationAuthorsPropertyStep(ItemSelectionModel itemModel,
|
||||||
ItemSelectionModel itemModel,
|
AuthoringKitWizard parent,
|
||||||
AuthoringKitWizard parent,
|
String prefix) {
|
||||||
String prefix) {
|
|
||||||
super(itemModel, parent, prefix);
|
super(itemModel, parent, prefix);
|
||||||
|
|
||||||
BasicItemForm addAuthorSheet =
|
BasicItemForm addAuthorSheet =
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,7 @@ public class PublicationAuthorsTable
|
||||||
super();
|
super();
|
||||||
m_itemModel = itemModel;
|
m_itemModel = itemModel;
|
||||||
|
|
||||||
setEmptyView(
|
setEmptyView(new Label(PublicationGlobalizationUtil.globalize(
|
||||||
new Label(PublicationGlobalizationUtil.globalize(
|
|
||||||
"publications.ui.authors.none")));
|
"publications.ui.authors.none")));
|
||||||
|
|
||||||
TableColumnModel colModel = getColumnModel();
|
TableColumnModel colModel = getColumnModel();
|
||||||
|
|
@ -95,6 +94,7 @@ public class PublicationAuthorsTable
|
||||||
m_itemModel = itemModel;
|
m_itemModel = itemModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public TableModel makeModel(Table table, PageState state) {
|
public TableModel makeModel(Table table, PageState state) {
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
Publication publication =
|
Publication publication =
|
||||||
|
|
@ -161,6 +161,7 @@ public class PublicationAuthorsTable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getKeyAt(int columnIndex) {
|
public Object getKeyAt(int columnIndex) {
|
||||||
return m_author.getID();
|
return m_author.getID();
|
||||||
}
|
}
|
||||||
|
|
@ -171,14 +172,13 @@ public class PublicationAuthorsTable
|
||||||
implements TableCellRenderer {
|
implements TableCellRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getComponent(
|
public Component getComponent(Table table,
|
||||||
Table table,
|
PageState state,
|
||||||
PageState state,
|
Object value,
|
||||||
Object value,
|
boolean isSelected,
|
||||||
boolean isSelected,
|
Object key,
|
||||||
Object key,
|
int row,
|
||||||
int row,
|
int col) {
|
||||||
int col) {
|
|
||||||
SecurityManager securityManager =
|
SecurityManager securityManager =
|
||||||
Utilities.getSecurityManager(state);
|
Utilities.getSecurityManager(state);
|
||||||
Publication publication = (Publication) m_itemModel.
|
Publication publication = (Publication) m_itemModel.
|
||||||
|
|
@ -211,7 +211,6 @@ public class PublicationAuthorsTable
|
||||||
Object key,
|
Object key,
|
||||||
int row,
|
int row,
|
||||||
int col) {
|
int col) {
|
||||||
|
|
||||||
SecurityManager securityManager =
|
SecurityManager securityManager =
|
||||||
Utilities.getSecurityManager(state);
|
Utilities.getSecurityManager(state);
|
||||||
Publication publication = (Publication) m_itemModel.
|
Publication publication = (Publication) m_itemModel.
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,10 @@ public class PublicationPropertiesStep extends SimpleEditStep {
|
||||||
AuthoringKitWizard parent) {
|
AuthoringKitWizard parent) {
|
||||||
addStep(new PublicationAuthorsPropertyStep(itemModel, parent),
|
addStep(new PublicationAuthorsPropertyStep(itemModel, parent),
|
||||||
"publications.ui.publication.authors");
|
"publications.ui.publication.authors");
|
||||||
|
addStep(new PublicationPublicationListPropertyStep(itemModel, parent),
|
||||||
|
"publications.ui.publication.lists");
|
||||||
|
addStep(new PublicationSeriesPropertyStep(itemModel, parent),
|
||||||
|
"publication.ui.publication.series");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addStep(SimpleEditStep step, String labelKey) {
|
protected void addStep(SimpleEditStep step, String labelKey) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
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.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicationList;
|
||||||
|
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class PublicationPublicationListAddForm
|
||||||
|
extends BasicItemForm
|
||||||
|
implements FormProcessListener,
|
||||||
|
FormInitListener {
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
PublicationPublicationListAddForm.class);
|
||||||
|
private PublicationPropertiesStep m_step;
|
||||||
|
private ItemSearchWidget m_itemSearch;
|
||||||
|
private final String ITEM_SEARCH = "publicationLists";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public PublicationPublicationListAddForm(ItemSelectionModel itemModel) {
|
||||||
|
super("PublicationListEntryForm", itemModel);
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.publicationlist.select_list").localize()));
|
||||||
|
m_itemSearch = new ItemSearchWidget(
|
||||||
|
ITEM_SEARCH,
|
||||||
|
ContentType.findByAssociatedObjectType(
|
||||||
|
PublicationList.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();
|
||||||
|
Publication publication = (Publication) getItemSelectionModel().
|
||||||
|
getSelectedObject(state);
|
||||||
|
|
||||||
|
if (!(this.getSaveCancelSection().getCancelButton().
|
||||||
|
isSelected(state))) {
|
||||||
|
publication.addPublicationList(
|
||||||
|
(PublicationList) data.get(ITEM_SEARCH));
|
||||||
|
}
|
||||||
|
|
||||||
|
init(fse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
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 PublicationPublicationListPropertyStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private static final String ADD_PUBLICATIONLIST_SHEET_NAME =
|
||||||
|
"addPublicationList";
|
||||||
|
|
||||||
|
public PublicationPublicationListPropertyStep(ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent) {
|
||||||
|
this(itemModel, parent, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicationPublicationListPropertyStep(ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent,
|
||||||
|
String prefix) {
|
||||||
|
super(itemModel, parent, prefix);
|
||||||
|
|
||||||
|
BasicItemForm addPublicationListSheet =
|
||||||
|
new PublicationPublicationListAddForm(itemModel);
|
||||||
|
add(ADD_PUBLICATIONLIST_SHEET_NAME,
|
||||||
|
(String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.publicationlists.add_list").localize(),
|
||||||
|
new WorkflowLockedComponentAccess(addPublicationListSheet,
|
||||||
|
itemModel),
|
||||||
|
addPublicationListSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
PublicationPublicationListsTable listsTable =
|
||||||
|
new PublicationPublicationListsTable(itemModel);
|
||||||
|
setDisplayComponent(listsTable);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,239 @@
|
||||||
|
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.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicationList;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicationListCollection;
|
||||||
|
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 PublicationPublicationListsTable
|
||||||
|
extends Table
|
||||||
|
implements TableActionListener {
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
PublicationPublicationListsTable.class);
|
||||||
|
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
private final String TABLE_COL_DEL = "table_col_del";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public PublicationPublicationListsTable(ItemSelectionModel itemModel) {
|
||||||
|
super();
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
|
||||||
|
setEmptyView(new Label(PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.publicationlists.none")));
|
||||||
|
|
||||||
|
TableColumnModel colModel = getColumnModel();
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
0,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.publicationlists.title").localize(),
|
||||||
|
TABLE_COL_EDIT));
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
1,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.publicationlists.remove").localize(),
|
||||||
|
TABLE_COL_DEL));
|
||||||
|
|
||||||
|
setModelBuilder(
|
||||||
|
new PublicationPublicationListsTableModelBuilder(itemModel));
|
||||||
|
|
||||||
|
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||||
|
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
|
||||||
|
s_log.info("Adding table action listener...");
|
||||||
|
addTableActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PublicationPublicationListsTableModelBuilder
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public PublicationPublicationListsTableModelBuilder(
|
||||||
|
ItemSelectionModel itemModel) {
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableModel makeModel(Table table, PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
Publication publication =
|
||||||
|
(Publication) m_itemModel.getSelectedObject(state);
|
||||||
|
return new PublicationPublicationListsTableModel(table,
|
||||||
|
state,
|
||||||
|
publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PublicationPublicationListsTableModel implements TableModel {
|
||||||
|
|
||||||
|
private Table m_table;
|
||||||
|
private PublicationListCollection m_listsCollection;
|
||||||
|
private PublicationList m_list;
|
||||||
|
|
||||||
|
public PublicationPublicationListsTableModel(Table table,
|
||||||
|
PageState state,
|
||||||
|
Publication publication) {
|
||||||
|
m_table = table;
|
||||||
|
m_listsCollection = publication.getPublicationLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return m_table.getColumnModel().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean nextRow() {
|
||||||
|
boolean ret;
|
||||||
|
|
||||||
|
if ((m_listsCollection != null)
|
||||||
|
&& m_listsCollection.next()) {
|
||||||
|
m_list = m_listsCollection.getPublicationList();
|
||||||
|
ret = true;
|
||||||
|
} else {
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return m_list.getTitle();
|
||||||
|
case 1:
|
||||||
|
return PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.publicationlists.remove").
|
||||||
|
localize();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_list.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);
|
||||||
|
Publication publication = (Publication) m_itemModel.
|
||||||
|
getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean canEdit = securityManager.canAccess(
|
||||||
|
state.getRequest(),
|
||||||
|
SecurityManager.EDIT_ITEM,
|
||||||
|
publication);
|
||||||
|
|
||||||
|
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);
|
||||||
|
Publication publication = (Publication) m_itemModel.
|
||||||
|
getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean canDelete = securityManager.canAccess(
|
||||||
|
state.getRequest(),
|
||||||
|
SecurityManager.DELETE_ITEM,
|
||||||
|
publication);
|
||||||
|
|
||||||
|
if (canDelete) {
|
||||||
|
ControlLink link = new ControlLink(value.toString());
|
||||||
|
link.setConfirmation((String) PublicationGlobalizationUtil.
|
||||||
|
globalize(
|
||||||
|
"publications.ui.publicationlists.confirm_remove").
|
||||||
|
localize());
|
||||||
|
return link;
|
||||||
|
} else {
|
||||||
|
Label label = new Label(value.toString());
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cellSelected(TableActionEvent event) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
s_log.info("cellSelected!");
|
||||||
|
|
||||||
|
PublicationList list =
|
||||||
|
new PublicationList(new BigDecimal(event.getRowKey().
|
||||||
|
toString()));
|
||||||
|
|
||||||
|
Publication publication = (Publication) m_itemModel.getSelectedObject(
|
||||||
|
state);
|
||||||
|
|
||||||
|
PublicationListCollection lists = publication.getPublicationLists();
|
||||||
|
|
||||||
|
TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||||
|
|
||||||
|
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||||
|
|
||||||
|
} else if(column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||||
|
publication.removePublicationList(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headSelected(TableActionEvent event) {
|
||||||
|
//Nothing to do here.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
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.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.Series;
|
||||||
|
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class PublicationSeriesAddForm
|
||||||
|
extends BasicItemForm
|
||||||
|
implements FormProcessListener,
|
||||||
|
FormInitListener {
|
||||||
|
|
||||||
|
private static final Logger s_log =
|
||||||
|
Logger.getLogger(PublicationSeriesAddForm.class);
|
||||||
|
private PublicationPropertiesStep m_step;
|
||||||
|
private ItemSearchWidget m_itemSearch;
|
||||||
|
private final String ITEM_SEARCH = "series";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public PublicationSeriesAddForm(ItemSelectionModel itemModel) {
|
||||||
|
super("SeriesEntryForm", itemModel);
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.select_series").localize()));
|
||||||
|
m_itemSearch = new ItemSearchWidget(
|
||||||
|
ITEM_SEARCH,
|
||||||
|
ContentType.findByAssociatedObjectType(Series.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();
|
||||||
|
Publication publication = (Publication) getItemSelectionModel().
|
||||||
|
getSelectedObject(state);
|
||||||
|
|
||||||
|
if (!(this.getSaveCancelSection().getCancelButton().
|
||||||
|
isSelected(state))) {
|
||||||
|
publication.addSeries(
|
||||||
|
(Series) data.get(ITEM_SEARCH));
|
||||||
|
}
|
||||||
|
|
||||||
|
init(fse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
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 PublicationSeriesPropertyStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private static final String ADD_SERIES_SHEET_NAME = "addSeries";
|
||||||
|
|
||||||
|
public PublicationSeriesPropertyStep(ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent) {
|
||||||
|
this(itemModel, parent, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicationSeriesPropertyStep(ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent,
|
||||||
|
String prefix) {
|
||||||
|
super(itemModel, parent, prefix);
|
||||||
|
|
||||||
|
BasicItemForm addSeriesSheet = new PublicationSeriesAddForm(itemModel);
|
||||||
|
add(ADD_SERIES_SHEET_NAME,
|
||||||
|
(String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.add_series").localize(),
|
||||||
|
new WorkflowLockedComponentAccess(addSeriesSheet, itemModel),
|
||||||
|
addSeriesSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
PublicationSeriesTable seriesTable = new PublicationSeriesTable(
|
||||||
|
itemModel);
|
||||||
|
setDisplayComponent(seriesTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,235 @@
|
||||||
|
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.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.Series;
|
||||||
|
import com.arsdigita.cms.contenttypes.SeriesCollection;
|
||||||
|
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 PublicationSeriesTable
|
||||||
|
extends Table
|
||||||
|
implements TableActionListener {
|
||||||
|
|
||||||
|
private static final Logger s_log =
|
||||||
|
Logger.getLogger(PublicationSeriesTable.class);
|
||||||
|
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
private final String TABLE_COL_DEL = "table_col_del";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public PublicationSeriesTable(ItemSelectionModel itemModel) {
|
||||||
|
super();
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
|
||||||
|
setEmptyView(new Label(PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.none")));
|
||||||
|
|
||||||
|
TableColumnModel colModel = getColumnModel();
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
0,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.title").localize(),
|
||||||
|
TABLE_COL_EDIT));
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
1,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.remove").localize(),
|
||||||
|
TABLE_COL_DEL));
|
||||||
|
|
||||||
|
setModelBuilder(
|
||||||
|
new PublicationSeriesTableModelBuilder(itemModel));
|
||||||
|
|
||||||
|
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||||
|
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
|
||||||
|
s_log.info("Adding table action listener...");
|
||||||
|
addTableActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PublicationSeriesTableModelBuilder
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public PublicationSeriesTableModelBuilder(
|
||||||
|
ItemSelectionModel itemModel) {
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableModel makeModel(Table table, PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
Publication publication = (Publication) m_itemModel.
|
||||||
|
getSelectedObject(state);
|
||||||
|
return new PublicationSeriesTableModel(table, state, publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PublicationSeriesTableModel implements TableModel {
|
||||||
|
|
||||||
|
private Table m_table;
|
||||||
|
private SeriesCollection m_seriesCollection;
|
||||||
|
private Series m_series;
|
||||||
|
|
||||||
|
public PublicationSeriesTableModel(Table table,
|
||||||
|
PageState state,
|
||||||
|
Publication publication) {
|
||||||
|
m_table = table;
|
||||||
|
m_seriesCollection = publication.getSeries();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return m_table.getColumnModel().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean nextRow() {
|
||||||
|
boolean ret;
|
||||||
|
|
||||||
|
if ((m_seriesCollection != null)
|
||||||
|
&& m_seriesCollection.next()) {
|
||||||
|
m_series = m_seriesCollection.getSeries();
|
||||||
|
ret = true;
|
||||||
|
} else {
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return m_series.getTitle();
|
||||||
|
case 1:
|
||||||
|
return PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.remove").localize();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_series.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);
|
||||||
|
Publication publication = (Publication) m_itemModel.
|
||||||
|
getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean canEdit = securityManager.canAccess(
|
||||||
|
state.getRequest(),
|
||||||
|
SecurityManager.EDIT_ITEM,
|
||||||
|
publication);
|
||||||
|
|
||||||
|
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);
|
||||||
|
Publication publication = (Publication) m_itemModel.
|
||||||
|
getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean canDelete = securityManager.canAccess(
|
||||||
|
state.getRequest(),
|
||||||
|
SecurityManager.DELETE_ITEM,
|
||||||
|
publication);
|
||||||
|
|
||||||
|
if (canDelete) {
|
||||||
|
ControlLink link = new ControlLink(value.toString());
|
||||||
|
link.setConfirmation((String) PublicationGlobalizationUtil.
|
||||||
|
globalize(
|
||||||
|
"publications.ui.series.confirm_remove").
|
||||||
|
localize());
|
||||||
|
return link;
|
||||||
|
} else {
|
||||||
|
Label label = new Label(value.toString());
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cellSelected(TableActionEvent event) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
s_log.info("cellSelected!");
|
||||||
|
|
||||||
|
Series series =
|
||||||
|
new Series(new BigDecimal(event.getRowKey().
|
||||||
|
toString()));
|
||||||
|
|
||||||
|
Publication publication = (Publication) m_itemModel.getSelectedObject(
|
||||||
|
state);
|
||||||
|
|
||||||
|
SeriesCollection seriesCollection = publication.getSeries();
|
||||||
|
|
||||||
|
TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||||
|
|
||||||
|
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||||
|
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||||
|
publication.removeSeries(series);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headSelected(TableActionEvent event) {
|
||||||
|
//Nothing to do here.
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue