SciProject: Angabe von Förderkennzeichen bei Drittmittelgebern. Das Förderkennzeichen ist eine Eigenschaft der Assoziation zwischen Projekt und Drittmittelgeber. Es können somit mehrere Förderkennzeichen (pro Mittelgeber eines) angegeben werden.
Die Drittmittelgeber können jetzt außerdem sortiert werden. Die genaue Anzeige hängt wie üblich vom Theme am. git-svn-id: https://svn.libreccm.org/ccm/trunk@2469 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
f10243123b
commit
4010761c1a
|
|
@ -190,4 +190,5 @@ public class CategoryFilter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ import com.arsdigita.cms.contenttypes.AuthorshipCollection;
|
||||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
import com.arsdigita.cms.contenttypes.Publication;
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
import com.arsdigita.cms.dispatcher.ItemResolver;
|
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||||
import com.arsdigita.cms.dispatcher.Utilities;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
import com.arsdigita.dispatcher.ObjectNotFoundException;
|
import com.arsdigita.dispatcher.ObjectNotFoundException;
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
@ -82,31 +81,31 @@ public class PublicationAuthorsTable
|
||||||
colModel.add(new TableColumn(
|
colModel.add(new TableColumn(
|
||||||
0,
|
0,
|
||||||
PublicationGlobalizationUtil.globalize(
|
PublicationGlobalizationUtil.globalize(
|
||||||
"publications.ui.authors.author.name").localize(),
|
"publications.ui.authors.author.name"),
|
||||||
TABLE_COL_EDIT));
|
TABLE_COL_EDIT));
|
||||||
colModel.add(new TableColumn(
|
colModel.add(new TableColumn(
|
||||||
1,
|
1,
|
||||||
PublicationGlobalizationUtil.globalize(
|
PublicationGlobalizationUtil.globalize(
|
||||||
"publications.ui.authors.author.isEditor").localize()));
|
"publications.ui.authors.author.isEditor")));
|
||||||
colModel.add(new TableColumn(
|
colModel.add(new TableColumn(
|
||||||
2,
|
2,
|
||||||
PublicationGlobalizationUtil.globalize(
|
PublicationGlobalizationUtil.globalize(
|
||||||
"publications.ui.authors.edit_assoc").localize(),
|
"publications.ui.authors.edit_assoc"),
|
||||||
TABLE_COL_EDIT_ASSOC));
|
TABLE_COL_EDIT_ASSOC));
|
||||||
colModel.add(new TableColumn(
|
colModel.add(new TableColumn(
|
||||||
3,
|
3,
|
||||||
PublicationGlobalizationUtil.globalize(
|
PublicationGlobalizationUtil.globalize(
|
||||||
"publications.ui.authors.author.delete").localize(),
|
"publications.ui.authors.author.delete"),
|
||||||
TABLE_COL_DEL));
|
TABLE_COL_DEL));
|
||||||
colModel.add(new TableColumn(
|
colModel.add(new TableColumn(
|
||||||
4,
|
4,
|
||||||
PublicationGlobalizationUtil.globalize(
|
PublicationGlobalizationUtil.globalize(
|
||||||
"publications.ui.authors.author.up").localize(),
|
"publications.ui.authors.author.up"),
|
||||||
TABLE_COL_UP));
|
TABLE_COL_UP));
|
||||||
colModel.add(new TableColumn(
|
colModel.add(new TableColumn(
|
||||||
5,
|
5,
|
||||||
PublicationGlobalizationUtil.globalize(
|
PublicationGlobalizationUtil.globalize(
|
||||||
"publications.ui.authors.author.down").localize(),
|
"publications.ui.authors.author.down"),
|
||||||
TABLE_COL_DOWN));
|
TABLE_COL_DOWN));
|
||||||
|
|
||||||
setModelBuilder(
|
setModelBuilder(
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
|
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
|
||||||
name="ccm-sci-types-project"
|
name="ccm-sci-types-project"
|
||||||
prettyName="Scientific CMS Project content type"
|
prettyName="Scientific CMS Project content type"
|
||||||
version = "6.6.7"
|
version = "6.6.8"
|
||||||
release="1"
|
release="1"
|
||||||
webapp="ROOT">
|
webapp="ROOT">
|
||||||
|
|
||||||
<ccm:dependencies>
|
<ccm:dependencies>
|
||||||
<ccm:requires name="ccm-core" version="6.6.3" relation="ge"/>
|
<ccm:requires name="ccm-core" version="6.6.3" relation="ge"/>
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,9 @@ association {
|
||||||
to ct_sci_project_sponsor_map.sponsor_id,
|
to ct_sci_project_sponsor_map.sponsor_id,
|
||||||
join ct_sci_project_sponsor_map.project_id
|
join ct_sci_project_sponsor_map.project_id
|
||||||
to ct_sci_project_bundles.bundle_id;
|
to ct_sci_project_bundles.bundle_id;
|
||||||
Integer[0..1] sponsorOrder = ct_sci_project_sponsor_map.sponsor_order INTEGER;
|
|
||||||
|
Integer[0..1] sponsorOrder = ct_sci_project_sponsor_map.sponsor_order INTEGER;
|
||||||
|
String[0..1] sponsorFundingCode = ct_sci_project_sponsor_map.sponsor_funding_code VARCHAR(512);
|
||||||
}
|
}
|
||||||
|
|
||||||
query getIdsOfProjectsOfOrgaUnit {
|
query getIdsOfProjectsOfOrgaUnit {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
create table ct_sci_project_sponsor_map (
|
CREATE TABLE ct_sci_project_sponsor_map (
|
||||||
sponsor_id INTEGER not null,
|
sponsor_id INTEGER not null,
|
||||||
project_id INTEGER not null,
|
project_id INTEGER not null,
|
||||||
sponsor_order INTEGER,
|
sponsor_order INTEGER,
|
||||||
|
|
||||||
constraint ct_sci_pro_spo_map_pro_p_y6bbk
|
CONSTRAINT ct_sci_pro_spo_map_pro_p_y6bbk
|
||||||
primary key(project_id, sponsor_id)
|
PRIMARY KEY(project_id, sponsor_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
alter table ct_sci_project_sponsor_map add
|
ALTER TABLE ct_sci_project_sponsor_map
|
||||||
constraint ct_sci_pro_spo_map_pro_f_8a7hv foreign key (project_id)
|
ADD CONSTRAINT ct_sci_pro_spo_map_pro_f_8a7hv
|
||||||
references ct_sci_project_bundles(bundle_id);
|
FOREIGN KEY (project_id)
|
||||||
alter table ct_sci_project_sponsor_map add
|
REFERENCES ct_sci_project_bundles(bundle_id);
|
||||||
constraint ct_sci_pro_spo_map_spo_f_7x6td foreign key (sponsor_id)
|
ALTER TABLE ct_sci_project_sponsor_map
|
||||||
references cms_orgaunit_bundles(bundle_id);
|
ADD CONSTRAINT ct_sci_pro_spo_map_spo_f_7x6td
|
||||||
|
FOREIGN KEY (sponsor_id)
|
||||||
|
REFERENCES cms_orgaunit_bundles(bundle_id);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE ct_sci_project_sponsor_map
|
||||||
|
ADD COLUMN sponsor_funding_code VARCHAR(512);
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
\echo 'ScientificCMS SciProject module upgrade 6.6.7 -> 6.6.8 (PostgreSQL)'
|
||||||
|
|
||||||
|
begin;
|
||||||
|
|
||||||
|
\i ../default/upgrade/6.6.7-6.6.8/add_sponsor_fundingcode.sql
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
@ -5,4 +5,7 @@
|
||||||
<version from="6.6.6" to="6.6.7">
|
<version from="6.6.6" to="6.6.7">
|
||||||
<script sql="ccm-sci-types-project/upgrade/::database::-6.6.6-6.6.7.sql"/>
|
<script sql="ccm-sci-types-project/upgrade/::database::-6.6.6-6.6.7.sql"/>
|
||||||
</version>
|
</version>
|
||||||
|
<version from="6.6.7" to="6.6.8">
|
||||||
|
<script sql="ccm-sci-types-project/upgrade/::database::-6.6.7-6.6.8.sql"/>
|
||||||
|
</version>
|
||||||
</upgrade>
|
</upgrade>
|
||||||
|
|
@ -194,6 +194,10 @@ public class SciProject extends GenericOrganizationalUnit {
|
||||||
getSciProjectBundle().addSponsor(sponsor);
|
getSciProjectBundle().addSponsor(sponsor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addSponsor(final GenericOrganizationalUnit sponsor, final String fundingCode) {
|
||||||
|
getSciProjectBundle().addSponsor(sponsor, fundingCode);
|
||||||
|
}
|
||||||
|
|
||||||
public void removeSponsor(final GenericOrganizationalUnit sponsor) {
|
public void removeSponsor(final GenericOrganizationalUnit sponsor) {
|
||||||
getSciProjectBundle().removeSponsor(sponsor);
|
getSciProjectBundle().removeSponsor(sponsor);
|
||||||
}
|
}
|
||||||
|
|
@ -202,6 +206,14 @@ public class SciProject extends GenericOrganizationalUnit {
|
||||||
return !getSponsors().isEmpty();
|
return !getSponsors().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void swapWithPreviousSponsor(final GenericOrganizationalUnit sponsor) {
|
||||||
|
getSponsors().swapWithPrevious(sponsor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithNextSponsor(final GenericOrganizationalUnit sponsor) {
|
||||||
|
getSponsors().swapWithNext(sponsor);
|
||||||
|
}
|
||||||
|
|
||||||
public String getFunding() {
|
public String getFunding() {
|
||||||
return (String) get(FUNDING);
|
return (String) get(FUNDING);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ public class SciProjectBundle extends GenericOrganizationalUnitBundle {
|
||||||
"com.arsdigita.cms.contenttypes.SciProjectBundle";
|
"com.arsdigita.cms.contenttypes.SciProjectBundle";
|
||||||
public static final String SPONSORS = "sponsors";
|
public static final String SPONSORS = "sponsors";
|
||||||
public static final String SPONSOR_ORDER = "sponsorOrder";
|
public static final String SPONSOR_ORDER = "sponsorOrder";
|
||||||
|
public static final String SPONSOR_FUNDING_CODE = "sponsorFundingCode";
|
||||||
|
|
||||||
public SciProjectBundle(final ContentItem primary) {
|
public SciProjectBundle(final ContentItem primary) {
|
||||||
super(BASE_DATA_OBJECT_TYPE);
|
super(BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
@ -68,11 +69,16 @@ public class SciProjectBundle extends GenericOrganizationalUnitBundle {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSponsor(final GenericOrganizationalUnit sponsor) {
|
public void addSponsor(final GenericOrganizationalUnit sponsor) {
|
||||||
|
addSponsor(sponsor, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSponsor(final GenericOrganizationalUnit sponsor, final String fundingCode) {
|
||||||
Assert.exists(sponsor, GenericOrganizationalUnit.class);
|
Assert.exists(sponsor, GenericOrganizationalUnit.class);
|
||||||
|
|
||||||
final DataObject link = add(SPONSORS, sponsor.getGenericOrganizationalUnitBundle());
|
final DataObject link = add(SPONSORS, sponsor.getGenericOrganizationalUnitBundle());
|
||||||
|
|
||||||
link.set(SPONSOR_ORDER, Integer.valueOf((int) getSponsors().size()));
|
link.set(SPONSOR_ORDER, Integer.valueOf((int) getSponsors().size()));
|
||||||
|
link.set(SPONSOR_FUNDING_CODE, fundingCode);
|
||||||
|
|
||||||
link.save();
|
link.save();
|
||||||
}
|
}
|
||||||
|
|
@ -136,7 +142,7 @@ public class SciProjectBundle extends GenericOrganizationalUnitBundle {
|
||||||
final DataCollection sponsoredProjects = (DataCollection) sponsorBundle.get(
|
final DataCollection sponsoredProjects = (DataCollection) sponsorBundle.get(
|
||||||
"sponsoredProjects");
|
"sponsoredProjects");
|
||||||
|
|
||||||
while(sponsoredProjects.next()) {
|
while (sponsoredProjects.next()) {
|
||||||
createSponsorProjectAssoc(sponsoredProjects,
|
createSponsorProjectAssoc(sponsoredProjects,
|
||||||
(GenericOrganizationalUnitBundle) liveItem);
|
(GenericOrganizationalUnitBundle) liveItem);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.arsdigita.cms.ContentBundle;
|
||||||
import com.arsdigita.domain.DomainCollection;
|
import com.arsdigita.domain.DomainCollection;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -13,10 +14,16 @@ import java.math.BigDecimal;
|
||||||
*/
|
*/
|
||||||
public class SciProjectSponsorCollection extends DomainCollection {
|
public class SciProjectSponsorCollection extends DomainCollection {
|
||||||
|
|
||||||
|
public final static String SPONSOR_ORDER = "sponsorOrder";
|
||||||
|
public final static String LINK_SPONSOR_ORDER = "link." + SPONSOR_ORDER;
|
||||||
|
public final static String SPONSOR_FUNDING_CODE = "sponsorFundingCode";
|
||||||
|
public final static String LINK_SPONSOR_FUNDING_CODE = "link." + SPONSOR_FUNDING_CODE;
|
||||||
|
|
||||||
|
|
||||||
public SciProjectSponsorCollection(final DataCollection dataCollection) {
|
public SciProjectSponsorCollection(final DataCollection dataCollection) {
|
||||||
super(dataCollection);
|
super(dataCollection);
|
||||||
|
|
||||||
addOrder("name");
|
addOrder(LINK_SPONSOR_ORDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericOrganizationalUnit getSponsor() {
|
public GenericOrganizationalUnit getSponsor() {
|
||||||
|
|
@ -39,4 +46,120 @@ public class SciProjectSponsorCollection extends DomainCollection {
|
||||||
return getSponsor().getTitle();
|
return getSponsor().getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getSponsorOrder() {
|
||||||
|
return (Integer) get(LINK_SPONSOR_ORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSponsorOrder(final Integer order) {
|
||||||
|
final DataObject link = (DataObject) get("link");
|
||||||
|
|
||||||
|
link.set(SPONSOR_ORDER, order);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFundingCode() {
|
||||||
|
return (String) get(LINK_SPONSOR_FUNDING_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFundingCode(final String fundingCode) {
|
||||||
|
final DataObject link = (DataObject) get("link");
|
||||||
|
|
||||||
|
link.set(SPONSOR_FUNDING_CODE, fundingCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithNext(final GenericOrganizationalUnit sponsor) {
|
||||||
|
int currentPos = 0;
|
||||||
|
int currentIndex = 0;
|
||||||
|
int nextIndex = 0;
|
||||||
|
|
||||||
|
rewind();
|
||||||
|
while(next()) {
|
||||||
|
currentPos = getPosition();
|
||||||
|
currentIndex = getSponsorOrder();
|
||||||
|
if (getSponsor().equals(sponsor)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentPos == 0) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"The provided organisation is not an sponsor of this project.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.next()) {
|
||||||
|
nextIndex = this.getSponsorOrder();
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("The provided sponsor ist the last one in the "
|
||||||
|
+ "collection, so there is no next object to switch with.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rewind();
|
||||||
|
|
||||||
|
while(getPosition() != currentPos) {
|
||||||
|
this.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
setSponsorOrder(nextIndex);
|
||||||
|
next();
|
||||||
|
setSponsorOrder(currentIndex);
|
||||||
|
this.rewind();
|
||||||
|
|
||||||
|
normalizeOrder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithPrevious(final GenericOrganizationalUnit sponsor) {
|
||||||
|
int previousPos = 0;
|
||||||
|
int previousIndex = 0;
|
||||||
|
int currentPos = 0;
|
||||||
|
int currentIndex = 0;
|
||||||
|
|
||||||
|
rewind();
|
||||||
|
while(next()) {
|
||||||
|
currentPos = getPosition();
|
||||||
|
currentIndex = getSponsorOrder();
|
||||||
|
|
||||||
|
if (getSponsor().equals(sponsor)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
previousPos = currentPos;
|
||||||
|
previousIndex = currentIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentPos == 0) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"The provided organisation is not an sponsor of this project.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousPos == 0) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"The provided sponsor is the first one in this "
|
||||||
|
+ "collection, so there is no previous one to switch "
|
||||||
|
+ "with."));
|
||||||
|
}
|
||||||
|
|
||||||
|
rewind();
|
||||||
|
while(getPosition() != previousPos) {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
|
||||||
|
setSponsorOrder(currentIndex);
|
||||||
|
next();
|
||||||
|
setSponsorOrder(previousIndex);
|
||||||
|
rewind();
|
||||||
|
|
||||||
|
normalizeOrder();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void normalizeOrder() {
|
||||||
|
rewind();
|
||||||
|
|
||||||
|
int i = 1;
|
||||||
|
while(next()) {
|
||||||
|
setSponsorOrder(i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rewind();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,12 @@ sciproject.ui.sponsor.add=Add sponsoring organization
|
||||||
sciproject.ui.steps.funding.title=Funding description
|
sciproject.ui.steps.funding.title=Funding description
|
||||||
sciproject.ui.funding.edit=Edit funding description
|
sciproject.ui.funding.edit=Edit funding description
|
||||||
sciproject.ui.funding.upload=Upload
|
sciproject.ui.funding.upload=Upload
|
||||||
sciproject.ui.sponsor\ =Sponsoring organization
|
sciproject.ui.sponsor=Sponsoring organization
|
||||||
sciproject.ui.sponsor_name=Sponsoring organization
|
sciproject.ui.sponsor_name=Sponsoring organization
|
||||||
sciproject.ui.sponsor_remove=Action
|
sciproject.ui.sponsor_remove=Action
|
||||||
|
sciproject.ui.sponsor_fundingcode=Funding code
|
||||||
|
sciproject.ui.sponsor.remove=Remove
|
||||||
|
sciproject.ui.sponsor_edit_assoc=Edit
|
||||||
|
sciproject.ui.sponsor.up=Up
|
||||||
|
sciproject.ui.sponsor.down=Down
|
||||||
|
sciproject.ui.sponsor.edit_assoc=Edit
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,12 @@ sciproject.ui.sponsor.add=Drittmittelgeber hinzuf\u00fcgen
|
||||||
sciproject.ui.steps.funding.title=Beschreibung Finanzierung
|
sciproject.ui.steps.funding.title=Beschreibung Finanzierung
|
||||||
sciproject.ui.funding.edit=Beschreibung der Finanzierung bearbeiten
|
sciproject.ui.funding.edit=Beschreibung der Finanzierung bearbeiten
|
||||||
sciproject.ui.funding.upload=Hochladen
|
sciproject.ui.funding.upload=Hochladen
|
||||||
sciproject.ui.sponsor\ =Drittmittelgeber
|
sciproject.ui.sponsor=Drittmittelgeber
|
||||||
sciproject.ui.sponsor_name=Drittmittelgeber
|
sciproject.ui.sponsor_name=Drittmittelgeber
|
||||||
sciproject.ui.sponsor_remove=Aktion
|
sciproject.ui.sponsor_remove=Aktion
|
||||||
|
sciproject.ui.sponsor_fundingcode=F\u00f6rderkennzeichen
|
||||||
|
sciproject.ui.sponsor.remove=Entfernen
|
||||||
|
sciproject.ui.sponsor_edit_assoc=Bearbeiten
|
||||||
|
sciproject.ui.sponsor.up=Hoch
|
||||||
|
sciproject.ui.sponsor.down=Runter
|
||||||
|
sciproject.ui.sponsor.edit_assoc=Bearbeiten
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
import com.arsdigita.cms.ContentType;
|
import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
|
|
@ -15,6 +17,7 @@ import com.arsdigita.cms.contenttypes.SciProjectConfig;
|
||||||
import com.arsdigita.cms.contenttypes.SciProjectSponsorCollection;
|
import com.arsdigita.cms.contenttypes.SciProjectSponsorCollection;
|
||||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
import com.arsdigita.kernel.Kernel;
|
import com.arsdigita.kernel.Kernel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -23,29 +26,66 @@ import com.arsdigita.kernel.Kernel;
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class SciProjectSponsorForm extends BasicItemForm implements FormInitListener,
|
public class SciProjectSponsorForm extends BasicItemForm implements FormInitListener,
|
||||||
FormProcessListener {
|
FormProcessListener,
|
||||||
|
FormSubmissionListener {
|
||||||
|
|
||||||
|
private final SimpleEditStep editStep;
|
||||||
private ItemSearchWidget itemSearch;
|
private ItemSearchWidget itemSearch;
|
||||||
private final String ITEM_SEARCH = "setSponsor";
|
private TextField fundingCode;
|
||||||
private final static SciProjectConfig CONFIG = SciProject.getConfig();
|
private Label selectedSponsorLabel;
|
||||||
|
private static final String ITEM_SEARCH = "setSponsor";
|
||||||
|
private static final String FUNDING_CODE = "fundingCode";
|
||||||
|
//private static final SciProjectConfig CONFIG = SciProject.getConfig();
|
||||||
|
|
||||||
public SciProjectSponsorForm(final ItemSelectionModel itemModel) {
|
public SciProjectSponsorForm(final ItemSelectionModel itemModel,
|
||||||
|
final SimpleEditStep editStep) {
|
||||||
super("SciProjectSetSponsor", itemModel);
|
super("SciProjectSetSponsor", itemModel);
|
||||||
|
this.editStep = editStep;
|
||||||
|
addSubmissionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addWidgets() {
|
public void addWidgets() {
|
||||||
add(new Label(SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor")));
|
add(new Label(SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor")));
|
||||||
|
|
||||||
itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType(
|
itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType(
|
||||||
GenericOrganizationalUnit.class.getName()));
|
GenericOrganizationalUnit.class.getName()));
|
||||||
itemSearch.setEditAfterCreate(false);
|
itemSearch.setEditAfterCreate(false);
|
||||||
add(itemSearch);
|
add(itemSearch);
|
||||||
|
|
||||||
|
selectedSponsorLabel = new Label("");
|
||||||
|
add(selectedSponsorLabel);
|
||||||
|
|
||||||
|
add(new Label(SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_fundingcode")));
|
||||||
|
fundingCode = new TextField(FUNDING_CODE);
|
||||||
|
add(fundingCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
final FormData data = event.getFormData();
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final GenericOrganizationalUnit sponsor = ((SciProjectSponsorStep) editStep).
|
||||||
|
getSelectedSponsor();
|
||||||
|
final String sponsorFundingCode = ((SciProjectSponsorStep) editStep).
|
||||||
|
getSelectedSponsorFundingCode();
|
||||||
|
|
||||||
|
if (sponsor == null) {
|
||||||
|
itemSearch.setVisible(state, true);
|
||||||
|
selectedSponsorLabel.setVisible(state, false);
|
||||||
|
} else {
|
||||||
|
data.put(ITEM_SEARCH, sponsor);
|
||||||
|
if ((sponsorFundingCode == null) || sponsorFundingCode.isEmpty()) {
|
||||||
|
fundingCode.setValue(state, null);
|
||||||
|
} else {
|
||||||
|
fundingCode.setValue(state, sponsorFundingCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
itemSearch.setVisible(state, false);
|
||||||
|
selectedSponsorLabel.setLabel(sponsor.getTitle(), state);
|
||||||
|
selectedSponsorLabel.setVisible(state, true);
|
||||||
|
}
|
||||||
|
|
||||||
setVisible(state, true);
|
setVisible(state, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,44 +96,89 @@ public class SciProjectSponsorForm extends BasicItemForm implements FormInitList
|
||||||
final SciProject project = (SciProject) getItemSelectionModel().getSelectedObject(state);
|
final SciProject project = (SciProject) getItemSelectionModel().getSelectedObject(state);
|
||||||
|
|
||||||
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
GenericOrganizationalUnit sponsor = (GenericOrganizationalUnit) data.get(ITEM_SEARCH);
|
final GenericOrganizationalUnit sponsor = ((SciProjectSponsorStep) editStep).
|
||||||
sponsor = (GenericOrganizationalUnit) sponsor.getContentBundle().getInstance(project.
|
getSelectedSponsor();
|
||||||
getLanguage());
|
|
||||||
|
|
||||||
if ((project.getSponsors() != null) && !(project.getSponsors().isEmpty())) {
|
String sponsorFundingCode;
|
||||||
final SciProjectSponsorCollection sponsors = project.getSponsors();
|
if (fundingCode.getValue(state) == null) {
|
||||||
sponsors.next();
|
sponsorFundingCode = null;
|
||||||
project.removeSponsor(sponsors.getSponsor());
|
} else {
|
||||||
sponsors.close();
|
sponsorFundingCode = (String) fundingCode.getValue(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
project.addSponsor(sponsor);
|
// sponsor = (GenericOrganizationalUnit) data.get(ITEM_SEARCH);
|
||||||
itemSearch.publishCreatedItem(data, sponsor);
|
// sponsor = (GenericOrganizationalUnit) sponsor.getContentBundle().getInstance(project.
|
||||||
|
// getLanguage());
|
||||||
|
|
||||||
|
if (sponsor == null) {
|
||||||
|
final GenericOrganizationalUnit sponsorToAdd = (GenericOrganizationalUnit) data.get(
|
||||||
|
ITEM_SEARCH);
|
||||||
|
|
||||||
|
if ((sponsorFundingCode == null) || sponsorFundingCode.isEmpty()) {
|
||||||
|
project.addSponsor(sponsorToAdd);
|
||||||
|
} else {
|
||||||
|
project.addSponsor(sponsorToAdd, sponsorFundingCode);
|
||||||
|
}
|
||||||
|
itemSearch.publishCreatedItem(data, sponsor);
|
||||||
|
} else {
|
||||||
|
final SciProjectSponsorCollection sponsors = project.getSponsors();
|
||||||
|
|
||||||
|
while (sponsors.next()) {
|
||||||
|
if (sponsors.getSponsor().equals(sponsor)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sponsors.setFundingCode(sponsorFundingCode);
|
||||||
|
|
||||||
|
((SciProjectSponsorStep) editStep).setSelectedSponsor(null);
|
||||||
|
((SciProjectSponsorStep) editStep).setSelectedSponsorFundingCode(null);
|
||||||
|
|
||||||
|
sponsors.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init(event);
|
init(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submitted(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
if (getSaveCancelSection().getCancelButton().isSelected(event.getPageState())) {
|
||||||
|
((SciProjectSponsorStep) editStep).setSelectedSponsor(null);
|
||||||
|
((SciProjectSponsorStep) editStep).setSelectedSponsorFundingCode(null);
|
||||||
|
|
||||||
|
init(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate(final FormSectionEvent event) throws FormProcessException {
|
public void validate(final FormSectionEvent event) throws FormProcessException {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
final FormData data = event.getFormData();
|
final FormData data = event.getFormData();
|
||||||
|
boolean editing = false; //Are we editing the association?
|
||||||
|
|
||||||
if (data.get(ITEM_SEARCH) == null) {
|
if ((((SciProjectSponsorStep) editStep).getSelectedSponsor() == null)
|
||||||
data.addError(SciProjectGlobalizationUtil.globalize(
|
&& (data.get(ITEM_SEARCH) == null)) {
|
||||||
"sciproject.ui.sponsor_no_sponsor_selected"));
|
data.addError(SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_no_sponsor_selected"));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final SciProject project = (SciProject) getItemSelectionModel().getSelectedItem(state);
|
final SciProject project = (SciProject) getItemSelectionModel().getSelectedObject(state);
|
||||||
final GenericOrganizationalUnit sponsor = (GenericOrganizationalUnit) data.get(ITEM_SEARCH);
|
GenericOrganizationalUnit sponsor = (GenericOrganizationalUnit) data.get(ITEM_SEARCH);
|
||||||
if (!(sponsor.getContentBundle().hasInstance(project.getLanguage(),
|
if (sponsor == null) {
|
||||||
Kernel.getConfig().languageIndependentItems()))) {
|
sponsor = ((SciProjectSponsorStep) editStep).getSelectedSponsor();
|
||||||
data.addError(SciProjectGlobalizationUtil.globalize(
|
editing = true;
|
||||||
"sciproject.ui.sponsor.no_suitable_language_variant"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
if (!editing) {
|
||||||
|
final SciProjectSponsorCollection sponsors = project.getSponsors();
|
||||||
|
sponsors.addFilter(String.format("id = %s", sponsor.getContentBundle().getID().toString()));
|
||||||
|
if (sponsors.size() > 0) {
|
||||||
|
data.addError(SciProjectGlobalizationUtil.globalize(
|
||||||
|
"sciproject.ui.sponsor.already_added"));
|
||||||
|
}
|
||||||
|
|
||||||
|
sponsors.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,19 +24,29 @@ import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
import com.arsdigita.cms.contenttypes.SciProject;
|
import com.arsdigita.cms.contenttypes.SciProject;
|
||||||
import com.arsdigita.cms.contenttypes.SciProjectSponsorCollection;
|
import com.arsdigita.cms.contenttypes.SciProjectSponsorCollection;
|
||||||
import com.arsdigita.cms.dispatcher.ItemResolver;
|
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||||
|
import com.arsdigita.cms.ui.ControlButton;
|
||||||
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
import com.arsdigita.util.LockableImpl;
|
import com.arsdigita.util.LockableImpl;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class SciProjectSponsorSheet extends Table {
|
public class SciProjectSponsorSheet extends Table {
|
||||||
|
|
||||||
private ItemSelectionModel itemModel;
|
|
||||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
private final String TABLE_COL_EDIT_ASSOC = "table_col_edit_assoc";
|
||||||
private final String TABLE_COL_DEL = "table_col_del";
|
private final String TABLE_COL_DEL = "table_col_del";
|
||||||
|
private final String TABLE_COL_UP = "table_col_up";
|
||||||
|
private final String TABLE_COL_DOWN = "table_col_down";
|
||||||
|
private final String SELECTED_PROJECT = "selected_project_sponsor_association_project";
|
||||||
|
private final String SELECTED_SPONSOR = "selected_project_sponsor_association_sponsor";
|
||||||
|
private ItemSelectionModel itemModel;
|
||||||
|
private SimpleEditStep editStep;
|
||||||
|
|
||||||
public SciProjectSponsorSheet(final ItemSelectionModel itemModel) {
|
public SciProjectSponsorSheet(final ItemSelectionModel itemModel,
|
||||||
|
final SimpleEditStep editStep) {
|
||||||
super();
|
super();
|
||||||
this.itemModel = itemModel;
|
this.itemModel = itemModel;
|
||||||
|
this.editStep = editStep;
|
||||||
|
|
||||||
setEmptyView(new Label(SciProjectGlobalizationUtil.globalize(
|
setEmptyView(new Label(SciProjectGlobalizationUtil.globalize(
|
||||||
"sciproject.ui.sponsor_none")));
|
"sciproject.ui.sponsor_none")));
|
||||||
|
|
@ -44,18 +54,37 @@ public class SciProjectSponsorSheet extends Table {
|
||||||
final TableColumnModel columnModel = getColumnModel();
|
final TableColumnModel columnModel = getColumnModel();
|
||||||
columnModel.add(new TableColumn(
|
columnModel.add(new TableColumn(
|
||||||
0,
|
0,
|
||||||
SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_name").localize(),
|
SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_name"),
|
||||||
TABLE_COL_EDIT));
|
TABLE_COL_EDIT));
|
||||||
|
|
||||||
columnModel.add(new TableColumn(
|
columnModel.add(new TableColumn(
|
||||||
0,
|
1,
|
||||||
SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_remove").localize(),
|
SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_fundingcode")));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
2,
|
||||||
|
SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_edit_assoc"),
|
||||||
|
TABLE_COL_EDIT_ASSOC));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
3,
|
||||||
|
SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_remove"),
|
||||||
TABLE_COL_DEL));
|
TABLE_COL_DEL));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
4,
|
||||||
|
SciProjectGlobalizationUtil.globalize(
|
||||||
|
"sciproject.ui.sponsor.up"),
|
||||||
|
TABLE_COL_UP));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
5,
|
||||||
|
SciProjectGlobalizationUtil.globalize(
|
||||||
|
"sciproject.ui.sponsor.down"),
|
||||||
|
TABLE_COL_DOWN));
|
||||||
|
|
||||||
setModelBuilder(new ModelBuilder(itemModel));
|
setModelBuilder(new ModelBuilder(itemModel));
|
||||||
|
|
||||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
columnModel.get(2).setCellRenderer(new EditAssocCellRenderer());
|
||||||
|
columnModel.get(3).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
columnModel.get(4).setCellRenderer(new UpCellRenderer());
|
||||||
|
columnModel.get(5).setCellRenderer(new DownCellRenderer());
|
||||||
|
|
||||||
addTableActionListener(new ActionListener());
|
addTableActionListener(new ActionListener());
|
||||||
}
|
}
|
||||||
|
|
@ -68,6 +97,7 @@ public class SciProjectSponsorSheet extends Table {
|
||||||
this.itemModel = itemModel;
|
this.itemModel = itemModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
public TableModel makeModel(final Table table, final PageState state) {
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
final SciProject project = (SciProject) itemModel.getSelectedObject(state);
|
final SciProject project = (SciProject) itemModel.getSelectedObject(state);
|
||||||
|
|
@ -87,10 +117,12 @@ public class SciProjectSponsorSheet extends Table {
|
||||||
sponsors = project.getSponsors();
|
sponsors = project.getSponsors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
return table.getColumnModel().size();
|
return table.getColumnModel().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean nextRow() {
|
public boolean nextRow() {
|
||||||
boolean ret;
|
boolean ret;
|
||||||
|
|
||||||
|
|
@ -103,18 +135,25 @@ public class SciProjectSponsorSheet extends Table {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getElementAt(final int columnIndex) {
|
public Object getElementAt(final int columnIndex) {
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
return sponsors.getTitle();
|
return sponsors.getTitle();
|
||||||
case 1:
|
case 1:
|
||||||
return SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor.remove").
|
return sponsors.getFundingCode();
|
||||||
localize();
|
case 2:
|
||||||
|
return SciProjectGlobalizationUtil.globalize(
|
||||||
|
"sciproject.ui.sponsor.edit_assoc").localize();
|
||||||
|
case 3:
|
||||||
|
return SciProjectGlobalizationUtil.globalize(
|
||||||
|
"sciproject.ui.sponsor.remove").localize();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getKeyAt(final int columnIndex) {
|
public Object getKeyAt(final int columnIndex) {
|
||||||
return sponsors.getID();
|
return sponsors.getID();
|
||||||
}
|
}
|
||||||
|
|
@ -160,6 +199,38 @@ public class SciProjectSponsorSheet extends Table {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class EditAssocCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int col) {
|
||||||
|
final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
|
||||||
|
final SciProject project = (SciProject) itemModel.getSelectedObject(state);
|
||||||
|
|
||||||
|
final boolean canEdit = securityManager.canAccess(
|
||||||
|
state.getRequest(),
|
||||||
|
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
|
||||||
|
project);
|
||||||
|
|
||||||
|
if (canEdit) {
|
||||||
|
final ControlLink link = new ControlLink(value.toString());
|
||||||
|
return link;
|
||||||
|
} else {
|
||||||
|
final Label label = new Label(value.toString());
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
|
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -190,26 +261,100 @@ public class SciProjectSponsorSheet extends Table {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class UpCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(
|
||||||
|
Table table,
|
||||||
|
PageState state,
|
||||||
|
Object value,
|
||||||
|
boolean isSelected,
|
||||||
|
Object key,
|
||||||
|
int row,
|
||||||
|
int col) {
|
||||||
|
if (0 == row) {
|
||||||
|
final Label label = new Label("");
|
||||||
|
return label;
|
||||||
|
} else {
|
||||||
|
final ControlLink link = new ControlLink("up");
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DownCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(
|
||||||
|
Table table,
|
||||||
|
PageState state,
|
||||||
|
Object value,
|
||||||
|
boolean isSelected,
|
||||||
|
Object key,
|
||||||
|
int row,
|
||||||
|
int col) {
|
||||||
|
|
||||||
|
final SciProject project = (SciProject) itemModel.getSelectedObject(state);
|
||||||
|
final SciProjectSponsorCollection sponsors = project.getSponsors();
|
||||||
|
|
||||||
|
if ((sponsors.size() - 1) == row) {
|
||||||
|
final Label label = new Label("");
|
||||||
|
return label;
|
||||||
|
} else {
|
||||||
|
final ControlLink link = new ControlLink("down");
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private class ActionListener implements TableActionListener {
|
private class ActionListener implements TableActionListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void cellSelected(final TableActionEvent event) {
|
public void cellSelected(final TableActionEvent event) {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
final GenericOrganizationalUnit sponsor = new GenericOrganizationalUnit(new BigDecimal(
|
final GenericOrganizationalUnit sponsor = new GenericOrganizationalUnit(new BigDecimal(
|
||||||
event.getRowKey().toString()));
|
event.getRowKey().toString()));
|
||||||
final SciProject project = (SciProject) itemModel.getSelectedObject(state);
|
final SciProject project = (SciProject) itemModel.getSelectedObject(state);
|
||||||
|
final SciProjectSponsorCollection sponsors = project.getSponsors();
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
final TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||||
|
|
||||||
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
||||||
//Nothing yet
|
//Nothing yet
|
||||||
|
} else if (TABLE_COL_EDIT_ASSOC.equals(column.getHeaderKey().toString())) {
|
||||||
|
|
||||||
|
while (sponsors.next()) {
|
||||||
|
if (sponsors.getSponsor().equals(sponsor)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
((SciProjectSponsorStep) editStep).setSelectedSponsor(sponsor);
|
||||||
|
((SciProjectSponsorStep) editStep).setSelectedSponsorFundingCode(sponsors.
|
||||||
|
getFundingCode());
|
||||||
|
|
||||||
|
editStep.showComponent(state,
|
||||||
|
SciProjectSponsorStep.SCIPROJECT_SPONSOR_STEP);
|
||||||
|
|
||||||
|
sponsors.close();
|
||||||
|
|
||||||
} else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
|
} else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
|
||||||
Assert.exists(sponsor, GenericOrganizationalUnit.class);
|
Assert.exists(sponsor, GenericOrganizationalUnit.class);
|
||||||
|
|
||||||
project.removeSponsor(sponsor);
|
project.removeSponsor(sponsor);
|
||||||
|
} else if (TABLE_COL_UP.equals(column.getHeaderKey().toString())) {
|
||||||
|
project.swapWithPreviousSponsor(sponsor);
|
||||||
|
} else if (TABLE_COL_DOWN.equals(column.getHeaderKey().toString())) {
|
||||||
|
project.swapWithNextSponsor(sponsor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void headSelected(final TableActionEvent event) {
|
public void headSelected(final TableActionEvent event) {
|
||||||
//Nothing
|
//Nothing
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
|
|
@ -13,7 +14,10 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
*/
|
*/
|
||||||
public class SciProjectSponsorStep extends SimpleEditStep {
|
public class SciProjectSponsorStep extends SimpleEditStep {
|
||||||
|
|
||||||
private String SCIPROJECT_SPONSOR_STEP = "SciProjectSponsorStep";
|
protected final static String SCIPROJECT_SPONSOR_STEP = "SciProjectSponsorStep";
|
||||||
|
|
||||||
|
private GenericOrganizationalUnit selectedSponsor;
|
||||||
|
private String selectedSponsorFundingCode;
|
||||||
|
|
||||||
public SciProjectSponsorStep(final ItemSelectionModel itemModel,
|
public SciProjectSponsorStep(final ItemSelectionModel itemModel,
|
||||||
final AuthoringKitWizard parent) {
|
final AuthoringKitWizard parent) {
|
||||||
|
|
@ -25,14 +29,30 @@ public class SciProjectSponsorStep extends SimpleEditStep {
|
||||||
final String prefix) {
|
final String prefix) {
|
||||||
super(itemModel, parent, prefix);
|
super(itemModel, parent, prefix);
|
||||||
|
|
||||||
final BasicItemForm sponsorForm = new SciProjectSponsorForm(itemModel);
|
final BasicItemForm sponsorForm = new SciProjectSponsorForm(itemModel, this);
|
||||||
add(SCIPROJECT_SPONSOR_STEP,
|
add(SCIPROJECT_SPONSOR_STEP,
|
||||||
(String) SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor.add").localize(),
|
(String) SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor.add").localize(),
|
||||||
new WorkflowLockedComponentAccess(sponsorForm, itemModel),
|
new WorkflowLockedComponentAccess(sponsorForm, itemModel),
|
||||||
sponsorForm.getSaveCancelSection().getCancelButton());
|
sponsorForm.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
final SciProjectSponsorSheet sheet = new SciProjectSponsorSheet(itemModel);
|
final SciProjectSponsorSheet sheet = new SciProjectSponsorSheet(itemModel, this);
|
||||||
setDisplayComponent(sheet);
|
setDisplayComponent(sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected GenericOrganizationalUnit getSelectedSponsor() {
|
||||||
|
return selectedSponsor;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSelectedSponsor(final GenericOrganizationalUnit selectedSponsor) {
|
||||||
|
this.selectedSponsor = selectedSponsor;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getSelectedSponsorFundingCode() {
|
||||||
|
return selectedSponsorFundingCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSelectedSponsorFundingCode(final String selectedSponsorFundingCode) {
|
||||||
|
this.selectedSponsorFundingCode = selectedSponsorFundingCode;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -457,6 +457,9 @@ public class SciProjectSummaryTab implements GenericOrgaUnitTab {
|
||||||
final Element sponsorElem = sponsorsElem.newChildElement("sponsor");
|
final Element sponsorElem = sponsorsElem.newChildElement("sponsor");
|
||||||
final GenericOrganizationalUnit sponsor = sponsors.getSponsor();
|
final GenericOrganizationalUnit sponsor = sponsors.getSponsor();
|
||||||
sponsorElem.setText(sponsor.getTitle());
|
sponsorElem.setText(sponsor.getTitle());
|
||||||
|
if ((sponsors.getFundingCode() != null) && !sponsors.isEmpty()) {
|
||||||
|
sponsorElem.addAttribute("fundingCode", sponsors.getFundingCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue