Next part of the ccm-scipublications-dramaticarts module. Code should be complete now, but is not fully tested yet.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2660 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
c703c92f82
commit
ac7d3b34ab
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||
|
||||
<ctd:content-type label="SciPublications/Movie"
|
||||
description="Publications for movies"
|
||||
objectType="com.arsdigita.cms.contenttypes.SciPublicationsMovie"
|
||||
classname="com.arsdigita.cms.contenttypes.SciPublicationsMovie"
|
||||
mode="hidden">
|
||||
|
||||
<ctd:authoring-kit createComponent="com.arsdigita.cms.contenttypes.ui.SciPublicationsMovieCreate">
|
||||
|
||||
<ctd:authoring-step
|
||||
labelKey="publications.ui.publication_properties.title"
|
||||
labelBundle="com.arsdigita.cms.contenttypes.ui.PublicationResources"
|
||||
descriptionKey="publications.ui.publication_properties.title.description"
|
||||
descriptionBundle="com.arsdigita.cms.contenttypes.ui.PublicationResources"
|
||||
component="com.arsdigita.cms.contenttypes.ui.PublicationPropertiesStep"
|
||||
ordering="1"/>
|
||||
|
||||
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
||||
|
||||
</ctd:authoring-kit>
|
||||
|
||||
</ctd:content-type>
|
||||
|
||||
|
||||
</ctd:content-types>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||
|
||||
<ctd:content-type label="SciPublications/Play"
|
||||
description="Publications for plays"
|
||||
objectType="com.arsdigita.cms.contenttypes.SciPublicationsPlay"
|
||||
classname="com.arsdigita.cms.contenttypes.SciPublicationsPlay"
|
||||
mode="hidden">
|
||||
|
||||
<ctd:authoring-kit createComponent="com.arsdigita.cms.contenttypes.ui.SciPublicationsPlayCreate">
|
||||
|
||||
<ctd:authoring-step
|
||||
labelKey="publications.ui.publication_properties.title"
|
||||
labelBundle="com.arsdigita.cms.contenttypes.ui.PublicationResources"
|
||||
descriptionKey="publications.ui.publication_properties.title.description"
|
||||
descriptionBundle="com.arsdigita.cms.contenttypes.ui.PublicationResources"
|
||||
component="com.arsdigita.cms.contenttypes.ui.PublicationPropertiesStep"
|
||||
ordering="1"/>
|
||||
|
||||
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
||||
|
||||
</ctd:authoring-kit>
|
||||
|
||||
</ctd:content-type>
|
||||
|
||||
|
||||
</ctd:content-types>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
|
||||
|
||||
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator" >
|
||||
|
||||
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.SciPublicationsMovie"
|
||||
extends="com.arsdigita.cms.contenttypes.Publication">
|
||||
|
||||
</xrd:adapter>
|
||||
|
||||
</xrd:context>
|
||||
|
||||
</xrd:adapters>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
|
||||
|
||||
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator" >
|
||||
|
||||
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.SciPublicationsPlay"
|
||||
extends="com.arsdigita.cms.contenttypes.PublicationWithPublisher">
|
||||
|
||||
</xrd:adapter>
|
||||
|
||||
</xrd:context>
|
||||
|
||||
</xrd:adapters>
|
||||
|
|
@ -11,8 +11,8 @@
|
|||
<provides>
|
||||
<table name="ct_scipublications_movies"/>
|
||||
<table name="ct_scipublications_plays"/>
|
||||
<initializer class="com.arsdigita.cms.contenttypes.SciPublicationsMoviesInitalizer"/>
|
||||
<initializer class="com.arsdigita.cms.contenttypes.SciPublicationsPlayInitalizer"/>
|
||||
<initializer class="com.arsdigita.cms.contenttypes.SciPublicationsMovieInitializer"/>
|
||||
<initializer class="com.arsdigita.cms.contenttypes.SciPublicationsPlayInitializer"/>
|
||||
</provides>
|
||||
<scripts>
|
||||
<schema directory="ccm-sci-publications-dramaticarts"/>
|
||||
|
|
|
|||
|
|
@ -61,49 +61,99 @@ public class SciPublicationsMovie extends Publication {
|
|||
return (SciPublicationsMovieBundle) getContentBundle();
|
||||
}
|
||||
|
||||
public SciPublicationsDirectorCollection getDirectors() {
|
||||
return getSciPublicationsMovieBundle().getDirectors();
|
||||
public GenericPerson getDirector() {
|
||||
final GenericPersonBundle bundle = getSciPublicationsMovieBundle().getDirector();
|
||||
if (bundle == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (GenericPerson) bundle.getPrimaryInstance();
|
||||
}
|
||||
}
|
||||
|
||||
public void addDirector(final GenericPerson director) {
|
||||
public GenericPerson getDirector(final String language) {
|
||||
final GenericPersonBundle bundle = getSciPublicationsMovieBundle().getDirector();
|
||||
if (bundle == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (GenericPerson) bundle.getInstance(language);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDirector(final GenericPerson director) {
|
||||
getSciPublicationsMovieBundle().addDirector(director);
|
||||
}
|
||||
|
||||
public void removeDirector(final GenericPerson director) {
|
||||
public GenericOrganizationalUnit getProductionCompany() {
|
||||
final GenericOrganizationalUnitBundle bundle = getSciPublicationsMovieBundle()
|
||||
.getProductionCompany();
|
||||
|
||||
if (bundle == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (GenericOrganizationalUnit) bundle.getPrimaryInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnit getProductionCompany(final String language) {
|
||||
final GenericOrganizationalUnitBundle bundle = getSciPublicationsMovieBundle()
|
||||
.getProductionCompany();
|
||||
|
||||
if (bundle == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (GenericOrganizationalUnit) bundle.getInstance(language);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setProductionCompany(final GenericOrganizationalUnit company) {
|
||||
getSciPublicationsMovieBundle().setProductionCompany(company);
|
||||
}
|
||||
|
||||
private SciPublicationsDirectorCollection getDirectors() {
|
||||
return getSciPublicationsMovieBundle().getDirectors();
|
||||
}
|
||||
|
||||
private void addDirector(final GenericPerson director) {
|
||||
getSciPublicationsMovieBundle().addDirector(director);
|
||||
}
|
||||
|
||||
private void removeDirector(final GenericPerson director) {
|
||||
getSciPublicationsMovieBundle().removeDirector(director);
|
||||
}
|
||||
|
||||
public void swapWithPreviousDirector(final GenericPerson director) {
|
||||
private void swapWithPreviousDirector(final GenericPerson director) {
|
||||
|
||||
getDirectors().swapWithPrevious(director);
|
||||
getSciPublicationsMovieBundle().updateDirectorsStr();
|
||||
|
||||
}
|
||||
|
||||
public void swapWithNextDirector(final GenericPerson director) {
|
||||
private void swapWithNextDirector(final GenericPerson director) {
|
||||
|
||||
getDirectors().swapWithNext(director);
|
||||
getSciPublicationsMovieBundle().updateDirectorsStr();
|
||||
|
||||
}
|
||||
|
||||
public boolean hasDirectors() {
|
||||
private boolean hasDirectors() {
|
||||
return !getDirectors().isEmpty();
|
||||
}
|
||||
|
||||
public SciPublicationsProductionCompanyCollection getProductionCompanies() {
|
||||
private SciPublicationsProductionCompanyCollection getProductionCompanies() {
|
||||
return getSciPublicationsMovieBundle().getProductionCompanies();
|
||||
}
|
||||
|
||||
public void addProductionCompany(final GenericOrganizationalUnit company) {
|
||||
private void addProductionCompany(final GenericOrganizationalUnit company) {
|
||||
getSciPublicationsMovieBundle().addProducationCompany(company);
|
||||
}
|
||||
|
||||
public void removeProductionCompany(final GenericOrganizationalUnit company) {
|
||||
private void removeProductionCompany(final GenericOrganizationalUnit company) {
|
||||
getSciPublicationsMovieBundle().removeProductionCompany(company);
|
||||
}
|
||||
|
||||
public boolean hasProductionCompanies() {
|
||||
private boolean hasProductionCompanies() {
|
||||
return !getProductionCompanies().isEmpty();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -230,11 +230,44 @@ public class SciPublicationsMovieBundle extends PublicationBundle {
|
|||
|
||||
}
|
||||
|
||||
public SciPublicationsDirectorCollection getDirectors() {
|
||||
public GenericPersonBundle getDirector() {
|
||||
final DataCollection collection = (DataCollection) get(DIRECTOR);
|
||||
|
||||
if (collection.size() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
final DataObject dataObject;
|
||||
|
||||
collection.next();
|
||||
dataObject = collection.getDataObject();
|
||||
collection.close();
|
||||
|
||||
return (GenericPersonBundle) DomainObjectFactory.newInstance(dataObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDirector(final GenericPerson director) {
|
||||
final GenericPersonBundle oldDirector = getDirector();
|
||||
|
||||
if (oldDirector != null) {
|
||||
remove(DIRECTOR, oldDirector);
|
||||
}
|
||||
|
||||
if (director != null) {
|
||||
Assert.exists(director, GenericPerson.class);
|
||||
|
||||
final DataObject link = add(DIRECTOR,
|
||||
director.getGenericPersonBundle());
|
||||
link.set(DIRECTOR_ORDER, Integer.valueOf(1));
|
||||
link.save();
|
||||
}
|
||||
}
|
||||
|
||||
protected SciPublicationsDirectorCollection getDirectors() {
|
||||
return new SciPublicationsDirectorCollection((DataCollection) get(DIRECTOR));
|
||||
}
|
||||
|
||||
public void addDirector(final GenericPerson director) {
|
||||
protected void addDirector(final GenericPerson director) {
|
||||
Assert.exists(director, GenericPerson.class);
|
||||
|
||||
final DataObject link = add(DIRECTOR, director.getGenericPersonBundle());
|
||||
|
|
@ -244,7 +277,7 @@ public class SciPublicationsMovieBundle extends PublicationBundle {
|
|||
updateDirectorsStr();
|
||||
}
|
||||
|
||||
public void removeDirector(final GenericPerson director) {
|
||||
protected void removeDirector(final GenericPerson director) {
|
||||
Assert.exists(director, GenericPerson.class);
|
||||
|
||||
remove(DIRECTOR, director.getContentBundle());
|
||||
|
|
@ -256,7 +289,7 @@ public class SciPublicationsMovieBundle extends PublicationBundle {
|
|||
|
||||
final SciPublicationsDirectorCollection directors = getDirectors();
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
while(directors.next()) {
|
||||
while (directors.next()) {
|
||||
if (builder.length() > 0) {
|
||||
builder.append("; ");
|
||||
}
|
||||
|
|
@ -270,21 +303,54 @@ public class SciPublicationsMovieBundle extends PublicationBundle {
|
|||
final ItemCollection instances = getInstances();
|
||||
|
||||
SciPublicationsMovie movie;
|
||||
while(instances.next()) {
|
||||
while (instances.next()) {
|
||||
movie = (SciPublicationsMovie) instances.getDomainObject();
|
||||
movie.set(SciPublicationsMovie.DIRECTORS_STR, directorStr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnitBundle getProductionCompany() {
|
||||
final DataCollection collection = (DataCollection) get(PRODUCATION_COMPANY);
|
||||
|
||||
if (collection.size() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
final DataObject dataObject;
|
||||
|
||||
collection.next();
|
||||
dataObject = collection.getDataObject();
|
||||
collection.close();
|
||||
|
||||
return (GenericOrganizationalUnitBundle) DomainObjectFactory.newInstance(dataObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void setProductionCompany(final GenericOrganizationalUnit productionCompany) {
|
||||
final GenericOrganizationalUnitBundle oldCompany = getProductionCompany();
|
||||
|
||||
if (oldCompany != null) {
|
||||
remove(PRODUCATION_COMPANY, oldCompany);
|
||||
}
|
||||
|
||||
if (productionCompany != null) {
|
||||
Assert.exists(productionCompany, GenericOrganizationalUnit.class);
|
||||
|
||||
final DataObject link = add(PRODUCATION_COMPANY,
|
||||
productionCompany.getGenericOrganizationalUnitBundle());
|
||||
link.set(PRODUCATION_COMPANY_ORDER, Integer.valueOf(1));
|
||||
link.save();
|
||||
}
|
||||
}
|
||||
|
||||
protected SciPublicationsProductionCompanyCollection getProductionCompanies() {
|
||||
|
||||
return new SciPublicationsProductionCompanyCollection((DataCollection) get(
|
||||
PRODUCATION_COMPANY));
|
||||
|
||||
}
|
||||
|
||||
public SciPublicationsProductionCompanyCollection getProductionCompanies() {
|
||||
|
||||
return new SciPublicationsProductionCompanyCollection((DataCollection) get(PRODUCATION_COMPANY));
|
||||
|
||||
}
|
||||
|
||||
public void addProducationCompany(final GenericOrganizationalUnit company) {
|
||||
protected void addProducationCompany(final GenericOrganizationalUnit company) {
|
||||
|
||||
Assert.exists(company, GenericOrganizationalUnit.class);
|
||||
|
||||
|
|
@ -295,7 +361,7 @@ public class SciPublicationsMovieBundle extends PublicationBundle {
|
|||
|
||||
}
|
||||
|
||||
public void removeProductionCompany(final GenericOrganizationalUnit company) {
|
||||
protected void removeProductionCompany(final GenericOrganizationalUnit company) {
|
||||
|
||||
Assert.exists(company, GenericOrganizationalUnit.class);
|
||||
|
||||
|
|
@ -316,7 +382,8 @@ public class SciPublicationsMovieBundle extends PublicationBundle {
|
|||
public static PublicationBundleCollection getProducedMovies(
|
||||
final GenericOrganizationalUnit company) {
|
||||
|
||||
final GenericOrganizationalUnitBundle companyBundle = company.getGenericOrganizationalUnitBundle();
|
||||
final GenericOrganizationalUnitBundle companyBundle = company
|
||||
.getGenericOrganizationalUnitBundle();
|
||||
|
||||
final DataCollection collection = (DataCollection) companyBundle.get("producedMovie");
|
||||
|
||||
|
|
@ -338,4 +405,5 @@ public class SciPublicationsMovieBundle extends PublicationBundle {
|
|||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ package com.arsdigita.cms.contenttypes;
|
|||
public class SciPublicationsMovieInitializer extends ContentTypeInitializer {
|
||||
|
||||
public SciPublicationsMovieInitializer() {
|
||||
super("empty.pdl.mf", SciPublicationsMovie.BASE_DATA_OBJECT_TYPE);
|
||||
super("ccm-sci-publications-dramaticarts.pdl.mf",
|
||||
SciPublicationsMovie.BASE_DATA_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -69,23 +69,51 @@ public class SciPublicationsPlay extends PublicationWithPublisher {
|
|||
set(FIRST_PRODUCTION_YEAR, year);
|
||||
}
|
||||
|
||||
public DomainCollection getProductionTheateres() {
|
||||
public GenericOrganizationalUnit getProductionTheater() {
|
||||
final GenericOrganizationalUnitBundle bundle = getSciPublicationsPlayBundle()
|
||||
.getProductionTheater();
|
||||
|
||||
if (bundle == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (GenericOrganizationalUnit) bundle.getPrimaryInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnit getProductionTheater(final String language) {
|
||||
final GenericOrganizationalUnitBundle bundle = getSciPublicationsPlayBundle()
|
||||
.getProductionTheater();
|
||||
|
||||
if (bundle == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (GenericOrganizationalUnit) bundle.getInstance(language);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setProductionTheater(final GenericOrganizationalUnit theater) {
|
||||
getSciPublicationsPlayBundle().setProductionTheater(theater);
|
||||
}
|
||||
|
||||
private DomainCollection getProductionTheateres() {
|
||||
return getSciPublicationsPlayBundle().getProductionTheateres();
|
||||
}
|
||||
|
||||
public void addProductionTheater(final GenericOrganizationalUnit theater) {
|
||||
private void addProductionTheater(final GenericOrganizationalUnit theater) {
|
||||
getSciPublicationsPlayBundle().addProducationTheater(theater);
|
||||
}
|
||||
|
||||
public void removeProductionTheater(final GenericOrganizationalUnit theater) {
|
||||
private void removeProductionTheater(final GenericOrganizationalUnit theater) {
|
||||
getSciPublicationsPlayBundle().removeProductionTheater(theater);
|
||||
}
|
||||
|
||||
public boolean hasProductionTheaters() {
|
||||
private boolean hasProductionTheaters() {
|
||||
return !getProductionTheateres().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public List<ExtraXMLGenerator> getExtraXMLGenerators() {
|
||||
final List<ExtraXMLGenerator> generators = super.getExtraXMLGenerators();
|
||||
generators.add(new SciPublicationsPlayExtraXMLGenerator());
|
||||
|
|
@ -98,4 +126,5 @@ public class SciPublicationsPlay extends PublicationWithPublisher {
|
|||
generators.add(new SciPublicationsPlayExtraXMLGenerator());
|
||||
return generators;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,13 +172,47 @@ public class SciPublicationsPlayBundle extends PublicationWithPublisherBundle {
|
|||
|
||||
}
|
||||
|
||||
public DomainCollection getProductionTheateres() {
|
||||
public GenericOrganizationalUnitBundle getProductionTheater() {
|
||||
final DataCollection collection = (DataCollection) get(PRODUCTION_THEATER);
|
||||
|
||||
if (collection.size() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
final DataObject dataObject;
|
||||
|
||||
collection.next();
|
||||
dataObject = collection.getDataObject();
|
||||
collection.close();
|
||||
|
||||
return (GenericOrganizationalUnitBundle) DomainObjectFactory.newInstance(dataObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setProductionTheater(final GenericOrganizationalUnit theater) {
|
||||
final GenericOrganizationalUnitBundle oldTheater = getProductionTheater();
|
||||
|
||||
if (oldTheater != null) {
|
||||
remove(PRODUCTION_THEATER, oldTheater);
|
||||
}
|
||||
|
||||
if (theater != null) {
|
||||
Assert.exists(theater, GenericOrganizationalUnit.class);
|
||||
|
||||
final DataObject link = add(PRODUCTION_THEATER,
|
||||
theater.getGenericOrganizationalUnitBundle());
|
||||
link.set(PRODUCTION_THEATER_ORDER, Integer.valueOf(1));
|
||||
link.save();
|
||||
}
|
||||
}
|
||||
|
||||
protected DomainCollection getProductionTheateres() {
|
||||
|
||||
return new DomainCollection((DataCollection) get(PRODUCTION_THEATER));
|
||||
|
||||
}
|
||||
|
||||
public void addProducationTheater(final GenericOrganizationalUnit theater) {
|
||||
protected void addProducationTheater(final GenericOrganizationalUnit theater) {
|
||||
|
||||
Assert.exists(theater, GenericOrganizationalUnit.class);
|
||||
|
||||
|
|
@ -188,7 +222,7 @@ public class SciPublicationsPlayBundle extends PublicationWithPublisherBundle {
|
|||
link.save();
|
||||
}
|
||||
|
||||
public void removeProductionTheater(final GenericOrganizationalUnit theater) {
|
||||
protected void removeProductionTheater(final GenericOrganizationalUnit theater) {
|
||||
|
||||
Assert.exists(theater, GenericOrganizationalUnit.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
* 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.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.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsDramaticArtsGlobalisationUtil;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsMovie;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMovieDirectorForm extends BasicItemForm implements FormInitListener,
|
||||
FormProcessListener {
|
||||
|
||||
private ItemSearchWidget itemSearch;
|
||||
private final String ITEM_SEARCH = "setDirector";
|
||||
|
||||
public SciPublicationsMovieDirectorForm(final ItemSelectionModel itemModel) {
|
||||
super("SciPublicationsMovieSetDirector", itemModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWidgets() {
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
add(new Label(globalisationUtil.globalise("publications.dramaticarts.ui.movie.director")));
|
||||
itemSearch = new ItemSearchWidget(
|
||||
ITEM_SEARCH, ContentType.findByAssociatedObjectType(
|
||||
GenericPerson.BASE_DATA_OBJECT_TYPE));
|
||||
itemSearch.setEditAfterCreate(false);
|
||||
add(itemSearch);
|
||||
}
|
||||
|
||||
@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 FormData data = event.getFormData();
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final SciPublicationsMovie movie = (SciPublicationsMovie) getItemSelectionModel()
|
||||
.getSelectedObject(state);
|
||||
|
||||
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
final GenericPerson director = (GenericPerson) data.get(ITEM_SEARCH);
|
||||
movie.setDirector(director);
|
||||
itemSearch.publishCreatedItem(data, director);
|
||||
}
|
||||
|
||||
init(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(final FormSectionEvent event) throws FormProcessException {
|
||||
//final PageState state = event.getPageState();
|
||||
final FormData data = event.getFormData();
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
|
||||
if (data.get(ITEM_SEARCH) == null) {
|
||||
data.addError(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.movie.director.no_director_selected"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,268 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
* 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.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
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.CMS;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsDramaticArtsGlobalisationUtil;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsMovie;
|
||||
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMovieDirectorSheet
|
||||
extends Table
|
||||
implements TableActionListener {
|
||||
|
||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
private final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
private ItemSelectionModel itemModel;
|
||||
|
||||
public SciPublicationsMovieDirectorSheet(final ItemSelectionModel itemModel) {
|
||||
super();
|
||||
|
||||
this.itemModel = itemModel;
|
||||
|
||||
setEmptyView(new Label(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.movie.director.none")));
|
||||
|
||||
final TableColumnModel columnModel = getColumnModel();
|
||||
columnModel.add(new TableColumn(
|
||||
0,
|
||||
globalisationUtil.globalise("publications.dramaticarts.ui.movie.director"),
|
||||
TABLE_COL_EDIT));
|
||||
columnModel.add(new TableColumn(
|
||||
1,
|
||||
globalisationUtil.globalise("publications.dramaticarts.ui.movie.director.remove"),
|
||||
TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(new ModelBuilder(itemModel));
|
||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
}
|
||||
|
||||
private class ModelBuilder
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
private ItemSelectionModel itemModel;
|
||||
|
||||
public ModelBuilder(final ItemSelectionModel itemModel) {
|
||||
this.itemModel = itemModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table, final PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
|
||||
final SciPublicationsMovie movie = (SciPublicationsMovie) itemModel.getSelectedObject(
|
||||
state);
|
||||
return new SheetModel(table, state, movie);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class SheetModel implements TableModel {
|
||||
|
||||
private Table table;
|
||||
private GenericPerson director;
|
||||
private boolean done;
|
||||
|
||||
public SheetModel(final Table table,
|
||||
final PageState state,
|
||||
final SciPublicationsMovie movie) {
|
||||
this.table = table;
|
||||
director = movie.getDirector();
|
||||
if (director == null) {
|
||||
done = false;
|
||||
} else {
|
||||
done = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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 director.getFullName();
|
||||
case 1:
|
||||
return globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.movie.director.remove");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return director.getID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
public EditCellRenderer() {
|
||||
super();
|
||||
}
|
||||
|
||||
@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 com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
|
||||
|
||||
final SciPublicationsMovie movie = (SciPublicationsMovie) itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
final boolean canEdit = securityManager.canAccess(state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
|
||||
movie);
|
||||
|
||||
if (canEdit) {
|
||||
final GenericPerson director;
|
||||
try {
|
||||
director = new GenericPerson((BigDecimal) key);
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
|
||||
final ContentSection section = director.getContentSection();
|
||||
final ItemResolver resolver = section.getItemResolver();
|
||||
final Link link = new Link(value.toString(),
|
||||
resolver.generateItemURL(state,
|
||||
movie,
|
||||
section,
|
||||
director.getVersion()));
|
||||
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
public DeleteCellRenderer() {
|
||||
super();
|
||||
}
|
||||
|
||||
@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 com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
|
||||
|
||||
final SciPublicationsMovie movie = (SciPublicationsMovie) itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
final boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.DELETE_ITEM,
|
||||
movie);
|
||||
|
||||
if (canEdit) {
|
||||
final ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.movie.director.remove.confirm"));
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final SciPublicationsMovie movie = (SciPublicationsMovie) itemModel.getSelectedObject(state);
|
||||
|
||||
final TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
||||
//Nothing
|
||||
} else if(TABLE_COL_DEL.equals(column.getHeaderKey().toString())){
|
||||
movie.setDirector(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
* 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.ui;
|
||||
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsDramaticArtsGlobalisationUtil;
|
||||
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 <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMovieDirectorStep extends SimpleEditStep {
|
||||
|
||||
private String SET_MOVIE_DIRECTOR_STEP = "setMovieDirectorStep";
|
||||
|
||||
public SciPublicationsMovieDirectorStep(final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, null);
|
||||
}
|
||||
|
||||
public SciPublicationsMovieDirectorStep(final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent,
|
||||
final String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
final BasicItemForm setDirectorForm = new SciPublicationsMovieDirectorForm(itemModel);
|
||||
add(SET_MOVIE_DIRECTOR_STEP,
|
||||
globalisationUtil.globalise("publications.dramaticarts.movie.ui.director"),
|
||||
new WorkflowLockedComponentAccess(setDirectorForm, itemModel),
|
||||
setDirectorForm.getSaveCancelSection().getCancelButton());
|
||||
|
||||
final SciPublicationsMovieDirectorSheet sheet = new SciPublicationsMovieDirectorSheet(
|
||||
itemModel);
|
||||
setDisplayComponent(sheet);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
* 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.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.GenericOrganizationalUnit;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsDramaticArtsGlobalisationUtil;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsMovie;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMovieProductionCompanyForm
|
||||
extends BasicItemForm
|
||||
implements FormInitListener,
|
||||
FormProcessListener {
|
||||
|
||||
private ItemSearchWidget itemSearch;
|
||||
private final String ITEM_SEARCH = "setProductionCompany";
|
||||
|
||||
|
||||
public SciPublicationsMovieProductionCompanyForm(final ItemSelectionModel itemModel) {
|
||||
super("SciPublicationsMovieSetProductionCompany", itemModel);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addWidgets() {
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
add(new Label(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.movie.production_company")));
|
||||
itemSearch = new ItemSearchWidget(
|
||||
ITEM_SEARCH, ContentType.findByAssociatedObjectType(
|
||||
GenericOrganizationalUnit.BASE_DATA_OBJECT_TYPE));
|
||||
itemSearch.setEditAfterCreate(false);
|
||||
add(itemSearch);
|
||||
}
|
||||
|
||||
@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 FormData data = event.getFormData();
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final SciPublicationsMovie movie = (SciPublicationsMovie) getItemSelectionModel()
|
||||
.getSelectedObject(state);
|
||||
|
||||
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
final GenericOrganizationalUnit productionCompany = (GenericOrganizationalUnit) data
|
||||
.get(ITEM_SEARCH);
|
||||
movie.setProductionCompany(productionCompany);
|
||||
itemSearch.publishCreatedItem(data, productionCompany);
|
||||
}
|
||||
|
||||
init(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(final FormSectionEvent event) throws FormProcessException {
|
||||
//final PageState state = event.getPageState();
|
||||
final FormData data = event.getFormData();
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
|
||||
if (data.get(ITEM_SEARCH) == null) {
|
||||
data.addError(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.movie.production_company.no_company_selected"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,267 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
* 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.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
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.CMS;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsDramaticArtsGlobalisationUtil;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsMovie;
|
||||
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMovieProductionCompanySheet
|
||||
extends Table
|
||||
implements TableActionListener {
|
||||
|
||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
private final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
private ItemSelectionModel itemModel;
|
||||
|
||||
public SciPublicationsMovieProductionCompanySheet(final ItemSelectionModel itemModel) {
|
||||
super();
|
||||
|
||||
this.itemModel = itemModel;
|
||||
|
||||
setEmptyView(new Label(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.movie.production_company.none")));
|
||||
|
||||
final TableColumnModel columnModel = getColumnModel();
|
||||
columnModel.add(new TableColumn(
|
||||
0,
|
||||
globalisationUtil.globalise("publications.dramaticarts.ui.movie.production_company"),
|
||||
TABLE_COL_EDIT));
|
||||
columnModel.add(new TableColumn(
|
||||
1,
|
||||
globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.movie.production_company.remove"),
|
||||
TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(new ModelBuilder(itemModel));
|
||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
}
|
||||
|
||||
private class ModelBuilder extends LockableImpl implements TableModelBuilder {
|
||||
|
||||
private ItemSelectionModel itemModel;
|
||||
|
||||
public ModelBuilder(final ItemSelectionModel itemModel) {
|
||||
this.itemModel = itemModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table, final PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
|
||||
final SciPublicationsMovie movie = (SciPublicationsMovie) itemModel.getSelectedObject(
|
||||
state);
|
||||
return new SheetModel(table, state, movie);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class SheetModel implements TableModel {
|
||||
|
||||
private Table table;
|
||||
private GenericOrganizationalUnit productionCompany;
|
||||
private boolean done;
|
||||
|
||||
public SheetModel(final Table table,
|
||||
final PageState state,
|
||||
final SciPublicationsMovie movie) {
|
||||
this.table = table;
|
||||
productionCompany = movie.getProductionCompany();
|
||||
if (productionCompany == null) {
|
||||
done = false;
|
||||
} else {
|
||||
done = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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 productionCompany.getTitle();
|
||||
case 1:
|
||||
return globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.movie.production_company.remove");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return productionCompany.getID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
public EditCellRenderer() {
|
||||
super();
|
||||
}
|
||||
|
||||
@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 com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
|
||||
|
||||
final SciPublicationsMovie movie = (SciPublicationsMovie) itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
final boolean canEdit = securityManager.canAccess(state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
|
||||
movie);
|
||||
|
||||
if (canEdit) {
|
||||
final GenericOrganizationalUnit company;
|
||||
try {
|
||||
company = new GenericOrganizationalUnit((BigDecimal) key);
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
|
||||
final ContentSection section = company.getContentSection();
|
||||
final ItemResolver resolver = section.getItemResolver();
|
||||
final Link link = new Link(value.toString(),
|
||||
resolver.generateItemURL(state,
|
||||
company,
|
||||
section,
|
||||
company.getVersion()));
|
||||
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
public DeleteCellRenderer() {
|
||||
super();
|
||||
}
|
||||
|
||||
@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 com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
|
||||
|
||||
final SciPublicationsMovie movie = (SciPublicationsMovie) itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
final boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.DELETE_ITEM,
|
||||
movie);
|
||||
|
||||
if (canEdit) {
|
||||
final ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.movie.production_company.remove.confirm"));
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final SciPublicationsMovie movie = (SciPublicationsMovie) itemModel.getSelectedObject(state);
|
||||
|
||||
final TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
||||
//Nothing
|
||||
} else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
|
||||
movie.setProductionCompany(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
* 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.ui;
|
||||
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsDramaticArtsGlobalisationUtil;
|
||||
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 <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMovieProductionCompanyStep extends SimpleEditStep {
|
||||
|
||||
private String SET_PRODUCTION_COMPANY_STEP = "setProductionCompanyStep";
|
||||
|
||||
public SciPublicationsMovieProductionCompanyStep(final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, null);
|
||||
}
|
||||
|
||||
public SciPublicationsMovieProductionCompanyStep(final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent,
|
||||
final String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
final BasicItemForm setProductionCompanyForm
|
||||
= new SciPublicationsMovieProductionCompanyForm(itemModel);
|
||||
add(SET_PRODUCTION_COMPANY_STEP,
|
||||
globalisationUtil.globalise("publications.ui.dramaticarts.movie.producationcompany"),
|
||||
new WorkflowLockedComponentAccess(setProductionCompanyForm, itemModel),
|
||||
setProductionCompanyForm.getSaveCancelSection().getCancelButton());
|
||||
|
||||
final SciPublicationsMovieProductionCompanySheet sheet
|
||||
= new SciPublicationsMovieProductionCompanySheet(
|
||||
itemModel);
|
||||
setDisplayComponent(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -70,8 +70,8 @@ public class SciPublicationsMoviePropertiesStep extends PublicationPropertiesSte
|
|||
|
||||
getSegmentedPanel().addSegment(
|
||||
new Label(PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.publication.basic_properties"),
|
||||
basicProperties));
|
||||
"publications.ui.publication.basic_properties")),
|
||||
basicProperties);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ public class SciPublicationsMoviePropertiesStep extends PublicationPropertiesSte
|
|||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil = new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
addStep(new SciPublicationsMovieDirectorStep(itemModel, parent),
|
||||
globalisationUtil.globalise("publications.dramaticarts.ui.director"));
|
||||
addStep(new SciPublicationsMovieProducationCompanyStep(itemModel, parent),
|
||||
addStep(new SciPublicationsMovieProductionCompanyStep(itemModel, parent),
|
||||
globalisationUtil.globalise("publications.dramaticarts.ui.producationcompany"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
* 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.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsMoviePropertyForm
|
||||
extends PublicationPropertyForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
|
||||
private final SciPublicationsMoviePropertiesStep step;
|
||||
|
||||
public SciPublicationsMoviePropertyForm(final ItemSelectionModel itemModel) {
|
||||
this(itemModel, null);
|
||||
}
|
||||
|
||||
public SciPublicationsMoviePropertyForm(final ItemSelectionModel itemModel,
|
||||
final SciPublicationsMoviePropertiesStep step) {
|
||||
super(itemModel, step);
|
||||
this.step = step;
|
||||
addSubmissionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
super.addWidgets();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||
super.init(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent event) throws FormProcessException {
|
||||
super.process(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
* 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.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.GenericOrganizationalUnit;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsDramaticArtsGlobalisationUtil;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsMovie;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsPlay;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsPlayProductionTheaterForm
|
||||
extends BasicItemForm
|
||||
implements FormInitListener,
|
||||
FormProcessListener {
|
||||
|
||||
private ItemSearchWidget itemSearch;
|
||||
private final String ITEM_SEARCH = "setProductionTheater";
|
||||
|
||||
public SciPublicationsPlayProductionTheaterForm(final ItemSelectionModel itemModel) {
|
||||
super("SciPublicationsPlaySetProductionTheater", itemModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWidgets() {
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
add(new Label(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.play.production_theater")));
|
||||
itemSearch = new ItemSearchWidget(
|
||||
ITEM_SEARCH, ContentType.findByAssociatedObjectType(
|
||||
GenericOrganizationalUnit.BASE_DATA_OBJECT_TYPE));
|
||||
itemSearch.setEditAfterCreate(false);
|
||||
add(itemSearch);
|
||||
}
|
||||
|
||||
@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 FormData data = event.getFormData();
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final SciPublicationsPlay play = (SciPublicationsPlay) getItemSelectionModel()
|
||||
.getSelectedObject(state);
|
||||
|
||||
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
final GenericOrganizationalUnit theater = (GenericOrganizationalUnit) data.get(
|
||||
ITEM_SEARCH);
|
||||
play.setProductionTheater(theater);
|
||||
itemSearch.publishCreatedItem(data, theater);
|
||||
}
|
||||
|
||||
init(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(final FormSectionEvent event) throws FormProcessException {
|
||||
//final PageState state = event.getPageState();
|
||||
final FormData data = event.getFormData();
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
|
||||
if (data.get(ITEM_SEARCH) == null) {
|
||||
data.addError(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.play.production_theater.no_theater_selected"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,267 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
* 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.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
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.CMS;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsDramaticArtsGlobalisationUtil;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsPlay;
|
||||
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsPlayProductionTheaterSheet
|
||||
extends Table
|
||||
implements TableActionListener {
|
||||
|
||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
private final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
private ItemSelectionModel itemModel;
|
||||
|
||||
public SciPublicationsPlayProductionTheaterSheet(final ItemSelectionModel itemModel) {
|
||||
super();
|
||||
this.itemModel = itemModel;
|
||||
|
||||
setEmptyView(new Label(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.play.production_theater.none")));
|
||||
|
||||
final TableColumnModel columnModel = getColumnModel();
|
||||
columnModel.add(new TableColumn(
|
||||
0,
|
||||
globalisationUtil.globalise("publications.dramaticarts.ui.play.production_theater"),
|
||||
TABLE_COL_EDIT));
|
||||
columnModel.add(new TableColumn(
|
||||
1,
|
||||
globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.play.production_theater.remove"),
|
||||
TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(new ModelBuilder(itemModel));
|
||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
|
||||
}
|
||||
|
||||
private class ModelBuilder extends LockableImpl implements TableModelBuilder {
|
||||
|
||||
private ItemSelectionModel itemModel;
|
||||
|
||||
public ModelBuilder(final ItemSelectionModel itemModel) {
|
||||
this.itemModel = itemModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table, final PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
|
||||
final SciPublicationsPlay play = (SciPublicationsPlay) itemModel.getSelectedObject(
|
||||
state);
|
||||
return new SheetModel(table, state, play);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class SheetModel implements TableModel {
|
||||
|
||||
private Table table;
|
||||
private GenericOrganizationalUnit productionTheater;
|
||||
private boolean done;
|
||||
|
||||
public SheetModel(final Table table,
|
||||
final PageState state,
|
||||
final SciPublicationsPlay play) {
|
||||
this.table = table;
|
||||
productionTheater = play.getProductionTheater();
|
||||
if (productionTheater == null) {
|
||||
done = false;
|
||||
} else {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
@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 productionTheater.getTitle();
|
||||
case 1:
|
||||
return globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.play.production_theater.remove");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return productionTheater.getID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
public EditCellRenderer() {
|
||||
super();
|
||||
}
|
||||
|
||||
@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 com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
|
||||
|
||||
final SciPublicationsPlay play = (SciPublicationsPlay) itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
final boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
|
||||
play);
|
||||
|
||||
if (canEdit) {
|
||||
final GenericOrganizationalUnit productionTheater;
|
||||
try {
|
||||
productionTheater = new GenericOrganizationalUnit((BigDecimal) key);
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
|
||||
final ContentSection section = productionTheater.getContentSection();
|
||||
final ItemResolver resolver = section.getItemResolver();
|
||||
final Link link = new Link(value.toString(),
|
||||
resolver.generateItemURL(state,
|
||||
productionTheater,
|
||||
section,
|
||||
productionTheater.getVersion()));
|
||||
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
public DeleteCellRenderer() {
|
||||
super();
|
||||
}
|
||||
|
||||
@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 com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
|
||||
|
||||
final SciPublicationsPlay play = (SciPublicationsPlay) itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
final boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.DELETE_ITEM,
|
||||
play);
|
||||
|
||||
if (canEdit) {
|
||||
final ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.play.production_theater.remove.confirm"));
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final SciPublicationsPlay play = (SciPublicationsPlay) itemModel.getSelectedObject(state);
|
||||
|
||||
final TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
||||
//Nothing
|
||||
} else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
|
||||
play.setProductionTheater(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
* 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.ui;
|
||||
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsDramaticArtsGlobalisationUtil;
|
||||
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 <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsPlayProductionTheaterStep extends SimpleEditStep {
|
||||
|
||||
private String SET_PRODUCTION_THEATER_STEP = "setProductionTheaterStep";
|
||||
|
||||
public SciPublicationsPlayProductionTheaterStep(final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, null);
|
||||
}
|
||||
|
||||
public SciPublicationsPlayProductionTheaterStep(final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent,
|
||||
final String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
final BasicItemForm setProductionTheaterForm = new SciPublicationsPlayProductionTheaterForm(
|
||||
itemModel);
|
||||
add(SET_PRODUCTION_THEATER_STEP,
|
||||
globalisationUtil.globalise("publications.dramaticarts.play.ui.productiontheater"),
|
||||
new WorkflowLockedComponentAccess(setProductionTheaterForm, itemModel),
|
||||
setProductionTheaterForm.getSaveCancelSection().getCancelButton());
|
||||
|
||||
final SciPublicationsPlayProductionTheaterSheet sheet
|
||||
= new SciPublicationsPlayProductionTheaterSheet(
|
||||
itemModel);
|
||||
setDisplayComponent(sheet);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -44,16 +44,17 @@ public class SciPublicationsPlayPropertiesStep extends PublicationWithPublisherP
|
|||
}
|
||||
|
||||
public static Component getSciPublicationsPlayPropertySheet(
|
||||
final ItemSelectionModel itemModel) {
|
||||
final ItemSelectionModel itemModel) {
|
||||
|
||||
final DomainObjectPropertySheet sheet = (DomainObjectPropertySheet) PublicationWithPublisherPropertiesStep.
|
||||
getPublicationWithPublisherPropertySheet(itemModel);
|
||||
final DomainObjectPropertySheet sheet
|
||||
= (DomainObjectPropertySheet) PublicationWithPublisherPropertiesStep
|
||||
.getPublicationWithPublisherPropertySheet(itemModel);
|
||||
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
|
||||
sheet.add(globalisationUtil.globalise(
|
||||
"publications.dramaticarts.ui.play.first_production_year"),
|
||||
"publications.dramaticarts.ui.play.first_production_year"),
|
||||
SciPublicationsPlay.FIRST_PRODUCTION_YEAR);
|
||||
|
||||
return sheet;
|
||||
|
|
@ -72,15 +73,15 @@ public class SciPublicationsPlayPropertiesStep extends PublicationWithPublisherP
|
|||
|
||||
basicProperties.add(EDIT_SHEET_NAME,
|
||||
PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.publication.edit_basic_sheet"),
|
||||
"publications.ui.publication.edit_basic_sheet"),
|
||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
||||
editBasicSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
basicProperties.setDisplayComponent(getSciPublicationsPlayPropertySheet(itemModel));
|
||||
|
||||
getSegmentedPanel().addSegment(new Label(PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.publication.basic_properties"),
|
||||
basicProperties));
|
||||
"publications.ui.publication.basic_properties")),
|
||||
basicProperties);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -90,8 +91,9 @@ public class SciPublicationsPlayPropertiesStep extends PublicationWithPublisherP
|
|||
|
||||
super.addSteps(itemModel, parent);
|
||||
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil = new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
addStep(new SciPublicationsPlayProducationTheaterStep(itemModel, parent),
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil
|
||||
= new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
addStep(new SciPublicationsPlayProductionTheaterStep(itemModel, parent),
|
||||
globalisationUtil.
|
||||
globalise("publications.dramaticarts.ui.first_producation_theater"));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Jens Pelzetter
|
||||
*
|
||||
* 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.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsDramaticArtsGlobalisationUtil;
|
||||
import com.arsdigita.cms.contenttypes.SciPublicationsPlay;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SciPublicationsPlayPropertyForm
|
||||
extends PublicationWithPublisherPropertyForm
|
||||
implements FormInitListener,
|
||||
FormProcessListener,
|
||||
FormSubmissionListener {
|
||||
|
||||
private final SciPublicationsPlayPropertiesStep step;
|
||||
|
||||
public SciPublicationsPlayPropertyForm(final ItemSelectionModel itemModel) {
|
||||
this(itemModel, null);
|
||||
}
|
||||
|
||||
public SciPublicationsPlayPropertyForm(final ItemSelectionModel itemModel,
|
||||
final SciPublicationsPlayPropertiesStep step) {
|
||||
super(itemModel, step);
|
||||
this.step = step;
|
||||
addSubmissionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
super.addWidgets();
|
||||
|
||||
final SciPublicationsDramaticArtsGlobalisationUtil globalisationUtil = new SciPublicationsDramaticArtsGlobalisationUtil();
|
||||
final ParameterModel firstProdYearParam = new IntegerParameter(SciPublicationsPlay.FIRST_PRODUCTION_YEAR);
|
||||
final TextField firstProdYear = new TextField(firstProdYearParam);
|
||||
firstProdYear.setMaxLength(4);
|
||||
firstProdYear.setLabel(globalisationUtil.globalise("publications.dramaticarts.ui.play.first_producation_year"));
|
||||
add(firstProdYear);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||
super.init(event);
|
||||
|
||||
final FormData data = event.getFormData();
|
||||
final SciPublicationsPlay play = (SciPublicationsPlay) super.initBasicWidgets(event);
|
||||
|
||||
data.put(SciPublicationsPlay.FIRST_PRODUCTION_YEAR, play.getFirstProductionYear());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent event) throws FormProcessException {
|
||||
super.process(event);
|
||||
|
||||
final FormData data = event.getFormData();
|
||||
final SciPublicationsPlay play = (SciPublicationsPlay) super.processBasicWidgets(event);
|
||||
|
||||
if ((play != null)
|
||||
&& getSaveCancelSection().getSaveButton().isSelected(event.getPageState())) {
|
||||
play.setFirstProductionYear((Integer) data.get(SciPublicationsPlay.FIRST_PRODUCTION_YEAR));
|
||||
play.save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue