Organization/Project contenttypes finished so far. Moving entries in the departments table and the contacts table works now.
git-svn-id: https://svn.libreccm.org/ccm/trunk@501 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
157b1b09a8
commit
c24544d3ec
|
|
@ -7,7 +7,7 @@
|
|||
<!-- Is internal will be set the yes when testing is finished. -->
|
||||
<ctd:content-type
|
||||
label="Organization"
|
||||
description="A content type of organization."
|
||||
description="A content type for organizations."
|
||||
objectType="com.arsdigita.cms.contenttypes.Organization"
|
||||
classname="com.arsdigita.cms.contenttypes.Organization">
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,11 @@
|
|||
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
|
||||
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.Organization" extends="com.arsdigita.cms.ContentPage">
|
||||
<xrd:associations rule="include">
|
||||
<xrd:property name="/object/contacts"/>
|
||||
<xrd:property name="/object/addendum"/>
|
||||
<xrd:property name="/object/contacts"/>
|
||||
<xrd:property name="/object/orgaunit_children"/>
|
||||
<xrd:property name="/object/persons"/>
|
||||
<xrd:property name="/object/persons"/>
|
||||
</xrd:associations>
|
||||
</xrd:adapter>
|
||||
</xrd:context>
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ association {
|
|||
to cms_organizationalunits.organizationalunit_id;
|
||||
|
||||
// Link attribute, allows it to customize the order which the childs will be shown.
|
||||
BigDecimal[0..1] orgaunit_children_order = cms_organizationalunits_organizationalunit_map.map_order INTEGER;
|
||||
Integer[0..1] orgaunit_children_order = cms_organizationalunits_organizationalunit_map.map_order INTEGER;
|
||||
}
|
||||
|
||||
// Link for contact points.
|
||||
|
|
@ -63,7 +63,7 @@ association {
|
|||
|
||||
// Some link attributes.
|
||||
String contact_type = cms_organizationalunits_contact_map.contact_type VARCHAR(100);
|
||||
BigDecimal contact_order = cms_organizationalunits_contact_map.map_order INTEGER;
|
||||
Integer contact_order = cms_organizationalunits_contact_map.map_order INTEGER;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -82,6 +82,5 @@ association {
|
|||
|
||||
// Additional attributes for the association
|
||||
String role_name = cms_organizationalunits_person_map.role_name VARCHAR(100);
|
||||
BigDecimal person_order = cms_organizationalunits_person_map.map_order INTEGER;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,18 +75,30 @@ cms.contenttypes.ui.contact.contactEntry.key.www=Homepage
|
|||
cms.contenttypes.ui.genericorganunit.addendum=Addendum
|
||||
cms.contenttypes.ui.genericorgaunit.add_child=Add child
|
||||
cms.contenttypes.ui.genericorgaunit.add_contact=Add contact
|
||||
#cms.contenttypes.ui.genericorganunit.basic_properties=
|
||||
cms.contenttypes.ui.genericorgaunit.add_department=Add organizational unit
|
||||
cms.contenttypes.ui.genericorgaunit.add_person=Add person
|
||||
cms.contenttypes.ui.genericorganunit.basic_properties=Base properties
|
||||
cms.contenttypes.ui.genericorgaunit.child.action=Action
|
||||
cms.contenttypes.ui.genericorgaunit.child.down=Move down
|
||||
cms.contenttypes.ui.genericorgaunit.child.name=Name
|
||||
cms.contenttypes.ui.genericorgaunit.childs.none=No childs
|
||||
#cms.contenttypes.ui.genericorgaunit.child.order=
|
||||
cms.contenttypes.ui.genericorgaunit.child.order=Order
|
||||
cms.contenttypes.ui.genericorgaunit.child.up=Move up
|
||||
cms.contenttypes.ui.genericorgaunit.confirm_delete=Confirm delete
|
||||
cms.contenttypes.ui.genericorgaunit.contact.action=Action
|
||||
cms.contenttypes.ui.genericorgaunit.contacts.none=No contacts
|
||||
cms.contenttypes.ui.genericorgaunit.contact.title=Contacts
|
||||
cms.contenttypes.ui.genericorgaunit.contact.type=Type
|
||||
#cms.contenttypes.ui.genericorgaunit.contact.order=
|
||||
cms.contenttypes.ui.genericorgaunit.edit_basic_properties=Base properties
|
||||
cms.contenttypes.ui.genericorgaunit.contact.order=Order
|
||||
cms.contenttypes.ui.genericorgaunit.edit_basic_properties=Edit base properties
|
||||
cms.contenttypes.ui.genericorganunit.name=Name
|
||||
cms.contenttypes.ui.genericorgaunit.persons.confirm_delete=Confirm Delete
|
||||
cms.contenttypes.ui.genericorgaunit.persons.delete=Remove person
|
||||
cms.contenttypes.ui.genericorgaunit.persons.name=Name
|
||||
cms.contenttypes.ui.genericorgaunit.persons.none=No associated persons found
|
||||
cms.contenttypes.ui.genericorgaunit.persons.role=Role
|
||||
cms.contenttypes.ui.genericorgaunit.select_child=Select child
|
||||
cms.contenttypes.ui.genericorgaunit.select_contact=Select contact
|
||||
cms.contenttypes.ui.orgaunit.contact=Contact points
|
||||
cms.contenttypes.ui.orgaunit.departments=Departments
|
||||
cms.contenttypes.ui.orgaunit.persons=Persons
|
||||
|
|
@ -5,7 +5,7 @@ cms.contenttypes.ui.address.postal_code=Postleitzahl
|
|||
cms.contenttypes.ui.address.city=Stadt
|
||||
cms.contenttypes.ui.address.state=Bundesland
|
||||
cms.contenttypes.ui.address.iso_country_code=Land
|
||||
cms.contenttypes.ui.address.error_iso_country=Bitte w\u00E4hlen Sie ein Land aus
|
||||
cms.contenttypes.ui.address.error_iso_country=Bitte w\u00e4hlen Sie ein Land aus
|
||||
|
||||
person.authoring.contact_properties.title=Kontakte
|
||||
person.authoring.contact_properties.description=Kontakte verwalten
|
||||
|
|
@ -20,7 +20,7 @@ cms.contenttypes.ui.person.birthdate=Geburtstag
|
|||
|
||||
cms.contenttypes.ui.person.contact=Kontakte
|
||||
cms.contenttypes.ui.person.contacts.none=Zur Zeit sind keine Kontakte vorhanden
|
||||
cms.contenttypes.ui.person.add_contact=Kontakt hinzuf\u00FCgen
|
||||
cms.contenttypes.ui.person.add_contact=Kontakt hinzuf\u00fcgen
|
||||
|
||||
cms.contenttypes.ui.contact.basic_properties=Eigenschaften von Contact
|
||||
cms.contenttypes.ui.contact.edit_basic_properties=Bearbeiten
|
||||
|
|
@ -29,42 +29,42 @@ cms.contenttypes.ui.contact.confirm_delete=Sind Sie sicher?
|
|||
cms.contenttypes.ui.contact.person=Person
|
||||
cms.contenttypes.ui.contact.address=Adresse
|
||||
|
||||
cms.contenttypes.ui.contact.attach_address=Adresse verkn\u00FCpfen
|
||||
cms.contenttypes.ui.contact.attach_address=Adresse verkn\u00fcpfen
|
||||
cms.contenttypes.ui.contact.edit_address=Adresse bearbeiten
|
||||
cms.contenttypes.ui.contact.reattach_address=Adresse neu verkn\u00FCpfen
|
||||
cms.contenttypes.ui.contact.delete_address=Adresse l\u00F6schen
|
||||
cms.contenttypes.ui.contact.emptyAddress=Zur Zeit ist keine Adresse verkn\u00FCpft
|
||||
cms.contenttypes.ui.contact.select_address=Bitte w\u00E4hlen Sie eine Eintrag vom Typ BaseAddress
|
||||
cms.contenttypes.ui.contact.select_address.add=Verkn\u00FCpfen
|
||||
cms.contenttypes.ui.contact.select_address.change=Ver\u00E4ndern
|
||||
cms.contenttypes.ui.contact.select_address.wrong_type=Der gew\u00E4hlte Eintrag ist nicht vom Typ BaseAddress
|
||||
cms.contenttypes.ui.contact.reattach_address=Adresse neu verkn\u00fcpfen
|
||||
cms.contenttypes.ui.contact.delete_address=Adresse l\u00f6schen
|
||||
cms.contenttypes.ui.contact.emptyAddress=Zur Zeit ist keine Adresse verkn\u00fcpft
|
||||
cms.contenttypes.ui.contact.select_address=Bitte w\u00e4hlen Sie eine Eintrag vom Typ BaseAddress
|
||||
cms.contenttypes.ui.contact.select_address.add=Verkn\u00fcpfen
|
||||
cms.contenttypes.ui.contact.select_address.change=Ver\u00e4ndern
|
||||
cms.contenttypes.ui.contact.select_address.wrong_type=Der gew\u00e4hlte Eintrag ist nicht vom Typ BaseAddress
|
||||
cms.contenttypes.ui.contact.select_address.cancelled=Abbruch
|
||||
cms.contenttypes.ui.contact.delete_address.label=Wollen Sie die Verkn\u00FCpfung zur Adresse entfernen?
|
||||
cms.contenttypes.ui.contact.delete_address.button_label=L\u00F6schen
|
||||
cms.contenttypes.ui.contact.delete_address.label=Wollen Sie die Verkn\u00fcpfung zur Adresse entfernen?
|
||||
cms.contenttypes.ui.contact.delete_address.button_label=L\u00f6schen
|
||||
|
||||
cms.contenttypes.ui.contact.attach_person=Person verkn\u00FCpfen
|
||||
cms.contenttypes.ui.contact.attach_person=Person verkn\u00fcpfen
|
||||
cms.contenttypes.ui.contact.edit_person=Person bearbeiten
|
||||
cms.contenttypes.ui.contact.reattach_person=Person neu verkn\u00FCpfen
|
||||
cms.contenttypes.ui.contact.delete_person=Person l\u00F6schen
|
||||
cms.contenttypes.ui.contact.emptyPerson=Zur Zeit ist keine Person verkn\u00FCft
|
||||
cms.contenttypes.ui.contact.select_person=Bitte w\u00E4hlen Sie einen Eintrag vom Typ Person
|
||||
cms.contenttypes.ui.contact.select_person.add=Verkn\u00FCpfen
|
||||
cms.contenttypes.ui.contact.select_person.change=Ver\u00E4ndern
|
||||
cms.contenttypes.ui.contact.select_person.wrong_type=Der gew\u00E4hlte Eintrag ist nicht vom Typ Person
|
||||
cms.contenttypes.ui.contact.reattach_person=Person neu verkn\u00fcpfen
|
||||
cms.contenttypes.ui.contact.delete_person=Person l\u00f6schen
|
||||
cms.contenttypes.ui.contact.emptyPerson=Zur Zeit ist keine Person verkn\u00fcft
|
||||
cms.contenttypes.ui.contact.select_person=Bitte w\u00e4hlen Sie einen Eintrag vom Typ Person
|
||||
cms.contenttypes.ui.contact.select_person.add=Verkn\u00fcpfen
|
||||
cms.contenttypes.ui.contact.select_person.change=Ver\u00e4ndern
|
||||
cms.contenttypes.ui.contact.select_person.wrong_type=Der gew\u00e4hlte Eintrag ist nicht vom Typ Person
|
||||
cms.contenttypes.ui.contact.select_person.cancelled=Abbruch
|
||||
cms.contenttypes.ui.contact.delete_person.label=WollenSie die Verkn\u00FCfung zur Person entfernen?
|
||||
cms.contenttypes.ui.contact.delete_person.button_label=L\u00F6schen
|
||||
cms.contenttypes.ui.contact.delete_person.label=WollenSie die Verkn\u00fcfung zur Person entfernen?
|
||||
cms.contenttypes.ui.contact.delete_person.button_label=L\u00f6schen
|
||||
|
||||
cms.contenttypes.ui.contact.add_contactEntry=Kontaktinformation hinzuf\u00FCgen
|
||||
cms.contenttypes.ui.contact.add_contactEntry=Kontaktinformation hinzuf\u00fcgen
|
||||
cms.contenttypes.ui.contact.contactEntry=Kontaktinformationen
|
||||
cms.contenttypes.ui.contact.contactEntry.key=Art der Information
|
||||
cms.contenttypes.ui.contact.contactEntry.value=Inhalt
|
||||
cms.contenttypes.ui.contact.contactEntry.description=Beschreibung (wird nicht \u00F6ffentlich angezeigt)
|
||||
cms.contenttypes.ui.contact.contactEntry.description=Beschreibung (wird nicht \u00f6ffentlich angezeigt)
|
||||
cms.contenttypes.ui.contact.contactEntry.action=Aktionen
|
||||
|
||||
cms.contenttypes.ui.contact.contactEntry.key.contact_type=Kontaktart
|
||||
cms.contenttypes.ui.contact.contactEntry.key.office_hours=\u00D6ffnungszeiten
|
||||
cms.contenttypes.ui.contact.contactEntry.key.phone_office=Telefon (B\u00FCro)
|
||||
cms.contenttypes.ui.contact.contactEntry.key.office_hours=\u00d6ffnungszeiten
|
||||
cms.contenttypes.ui.contact.contactEntry.key.phone_office=Telefon (B\u00fcro)
|
||||
cms.contenttypes.ui.contact.contactEntry.key.phone_private=Telefon (Privat)
|
||||
cms.contenttypes.ui.contact.contactEntry.key.phone_mobile=Telefon (Mobil)
|
||||
cms.contenttypes.ui.contact.contactEntry.key.email=E-Mail
|
||||
|
|
@ -74,3 +74,34 @@ cms.contenttypes.ui.contact.contactEntry.key.www=Homepage
|
|||
|
||||
|
||||
cms.contenttypes.ui.contact.contactEntry.none=Zur Zeit sind keine Kontaktinformationen vorhanden
|
||||
|
||||
cms.contenttypes.ui.genericorganunit.addendum=Zusatz
|
||||
cms.contenttypes.ui.genericorgaunit.add_child=Untergeordnete Organizationseinheit hinzuf\u00fcgen
|
||||
cms.contenttypes.ui.genericorgaunit.add_contact=Kontakt hinzuf\u00fcgen
|
||||
cms.contenttypes.ui.genericorgaunit.add_department=Untergeordnete Organizationseinheit hinzuf\u00fcgen
|
||||
cms.contenttypes.ui.genericorgaunit.add_person=Person hinzuf\u00fcgen
|
||||
cms.contenttypes.ui.genericorganunit.basic_properties=Basiseigenschaften
|
||||
cms.contenttypes.ui.genericorgaunit.child.action=Action
|
||||
cms.contenttypes.ui.genericorgaunit.child.down=Reihenfolge bearbeiten
|
||||
cms.contenttypes.ui.genericorgaunit.child.name=Name
|
||||
cms.contenttypes.ui.genericorgaunit.childs.none=Keine ungeordneten Organizationseinheiten gefunden.
|
||||
cms.contenttypes.ui.genericorgaunit.child.order=Reihenfolge
|
||||
cms.contenttypes.ui.genericorgaunit.child.up=Reihenfolge bearbeiten
|
||||
cms.contenttypes.ui.genericorgaunit.confirm_delete=L\u00f6schen best\u00e4tigen
|
||||
cms.contenttypes.ui.genericorgaunit.contact.action=Action
|
||||
cms.contenttypes.ui.genericorgaunit.contacts.none=Keine Kontaktinformationen
|
||||
cms.contenttypes.ui.genericorgaunit.contact.title=Kontakte
|
||||
cms.contenttypes.ui.genericorgaunit.contact.type=Typ
|
||||
cms.contenttypes.ui.genericorgaunit.contact.order=Reihenfolge
|
||||
cms.contenttypes.ui.genericorgaunit.edit_basic_properties=Basiseigenschaften bearbeiten
|
||||
cms.contenttypes.ui.genericorganunit.name=Name
|
||||
cms.contenttypes.ui.genericorgaunit.persons.confirm_delete=Person wirklich entfernen?
|
||||
cms.contenttypes.ui.genericorgaunit.persons.delete=Person entfernen
|
||||
cms.contenttypes.ui.genericorgaunit.persons.name=Name
|
||||
cms.contenttypes.ui.genericorgaunit.persons.none=Keine verkn\u00fcpften personen
|
||||
cms.contenttypes.ui.genericorgaunit.persons.role=Rolle
|
||||
cms.contenttypes.ui.genericorgaunit.select_child=Untergeordnete Organizationseinheit ausw\u00e4hlen
|
||||
cms.contenttypes.ui.genericorgaunit.select_contact=Kontakt ausw\u00e4hlen
|
||||
cms.contenttypes.ui.orgaunit.contact=Kontaktinformationen
|
||||
cms.contenttypes.ui.orgaunit.departments=Untergeordnete Organizationseinheiten
|
||||
cms.contenttypes.ui.orgaunit.persons=Personen
|
||||
|
|
@ -46,17 +46,20 @@ public class GenericOrganizationalUnit extends ContentPage {
|
|||
public final static String CONTACT_TYPE = "contact_type";
|
||||
public final static String CONTACT_ORDER = "contact_order";
|
||||
public final static String ORGAUNIT_CHILDREN = "orgaunit_children";
|
||||
public final static String ORGAUNIT_CHILDREN_ORDER = "orgaunit_children_order";
|
||||
public final static String ORGAUNIT_CHILDREN_ORDER =
|
||||
"orgaunit_children_order";
|
||||
public final static String PERSONS = "persons";
|
||||
public final static String ROLE = "role_name";
|
||||
public final static String PERSON_ORDER = "person_order";
|
||||
public final static String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericOrganizationalUnit";
|
||||
public final static String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.contenttypes.GenericOrganizationalUnit";
|
||||
|
||||
public GenericOrganizationalUnit() {
|
||||
this(BASE_DATA_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnit(BigDecimal id) throws DataObjectNotFoundException {
|
||||
public GenericOrganizationalUnit(BigDecimal id) throws
|
||||
DataObjectNotFoundException {
|
||||
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +84,8 @@ public class GenericOrganizationalUnit extends ContentPage {
|
|||
}
|
||||
|
||||
public GenericOrganizationalUnitContactCollection getContacts() {
|
||||
return new GenericOrganizationalUnitContactCollection((DataCollection) get(CONTACTS));
|
||||
return new GenericOrganizationalUnitContactCollection((DataCollection) get(
|
||||
CONTACTS));
|
||||
}
|
||||
|
||||
public void addContact(GenericContact contact, String contactType) {
|
||||
|
|
@ -103,7 +107,8 @@ public class GenericOrganizationalUnit extends ContentPage {
|
|||
}
|
||||
|
||||
public GenericOrganizationalUnitChildrenCollection getOrgaUnitChildren() {
|
||||
return new GenericOrganizationalUnitChildrenCollection((DataCollection) get(ORGAUNIT_CHILDREN));
|
||||
return new GenericOrganizationalUnitChildrenCollection((DataCollection) get(
|
||||
ORGAUNIT_CHILDREN));
|
||||
}
|
||||
|
||||
public void addOrgaUnitChildren(GenericOrganizationalUnit child) {
|
||||
|
|
@ -111,7 +116,8 @@ public class GenericOrganizationalUnit extends ContentPage {
|
|||
|
||||
DataObject link = add(ORGAUNIT_CHILDREN, child);
|
||||
|
||||
link.set(ORGAUNIT_CHILDREN_ORDER, BigDecimal.valueOf(getContacts().size()));
|
||||
link.set(ORGAUNIT_CHILDREN_ORDER, Integer.valueOf((int) getOrgaUnitChildren().
|
||||
size()));
|
||||
}
|
||||
|
||||
public void removeOrgaUnitChildren(GenericOrganizationalUnit child) {
|
||||
|
|
@ -124,7 +130,8 @@ public class GenericOrganizationalUnit extends ContentPage {
|
|||
}
|
||||
|
||||
public GenericOrganizationalUnitPersonCollection getPersons() {
|
||||
return new GenericOrganizationalUnitPersonCollection((DataCollection) get(PERSONS));
|
||||
return new GenericOrganizationalUnitPersonCollection((DataCollection) get(
|
||||
PERSONS));
|
||||
}
|
||||
|
||||
public void addPerson(GenericPerson person, String role) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ package com.arsdigita.cms.contenttypes;
|
|||
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import java.math.BigDecimal;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Collection class for the childs of a GenericOrganizationalUnit.
|
||||
|
|
@ -29,26 +31,155 @@ import java.math.BigDecimal;
|
|||
*/
|
||||
public class GenericOrganizationalUnitChildrenCollection extends DomainCollection {
|
||||
|
||||
//public static final String ORDER = "map_order asc";
|
||||
public static final String ORDER = "link.orgaunit_children_order";
|
||||
//public static final String CHILDREN_ORDER = "link.children_order";
|
||||
public static final String CHILDREN_ORDER = "orgaunit_children_order";
|
||||
private final static Logger s_log = Logger.getLogger(
|
||||
GenericOrganizationalUnitChildrenCollection.class);
|
||||
|
||||
public GenericOrganizationalUnitChildrenCollection(DataCollection dataCollection) {
|
||||
public GenericOrganizationalUnitChildrenCollection(
|
||||
DataCollection dataCollection) {
|
||||
super(dataCollection);
|
||||
|
||||
//m_dataCollection.addOrder(ORDER);
|
||||
m_dataCollection.addOrder(ORDER);
|
||||
}
|
||||
|
||||
public String getChildrenOrder() {
|
||||
String retVal = ((BigDecimal) m_dataCollection.get(ORDER)).toString();
|
||||
/**
|
||||
* Gets the value of the order attribute of the current association.
|
||||
*
|
||||
* @return Order value of the current item.
|
||||
*/
|
||||
public Integer getChildrenOrder() {
|
||||
return (Integer) m_dataCollection.get(ORDER);
|
||||
}
|
||||
|
||||
if (retVal == null || retVal.isEmpty()) {
|
||||
retVal = String.valueOf(this.getPosition());
|
||||
/**
|
||||
* Sets the order attribute for the current association.
|
||||
*
|
||||
* @param order The new value for the order.
|
||||
*/
|
||||
public void setChildrenOrder(Integer order) {
|
||||
DataObject link = (DataObject) this.get("link");
|
||||
|
||||
link.set(CHILDREN_ORDER, order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps the item {@code child} with the next one in the collection.
|
||||
*
|
||||
* @param child The child to swap with the next one.
|
||||
* @throws IllegalArgumentException Thrown if the child object provided is
|
||||
* not part of this collection, or if the child is the last one in the
|
||||
* collection.
|
||||
*/
|
||||
public void swapWithNext(GenericOrganizationalUnit child) {
|
||||
int currentPos = 0;
|
||||
int currentIndex = 0;
|
||||
int nextIndex = 0;
|
||||
|
||||
s_log.debug("Searching child...");
|
||||
this.rewind();
|
||||
while (this.next()) {
|
||||
currentPos = this.getPosition();
|
||||
currentIndex = this.getChildrenOrder();
|
||||
s_log.debug(String.format("Position: %d(%d)/%d", currentPos,
|
||||
currentIndex, this.size()));
|
||||
s_log.debug(String.format("getChildrenOrder(): %d",
|
||||
getChildrenOrder()));
|
||||
if (this.getOrgaUnitChild().equals(child)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
if (currentPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided organizational unit is not "
|
||||
+ "part of this collection."));
|
||||
}
|
||||
|
||||
if (this.next()) {
|
||||
nextIndex = this.getChildrenOrder();
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"The provided organizational unit is the last "
|
||||
+ "in the collection, so there is no next object "
|
||||
+ "to swap with.");
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
|
||||
while (this.getPosition() != currentPos) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
this.setChildrenOrder(nextIndex);
|
||||
this.next();
|
||||
this.setChildrenOrder(currentIndex);
|
||||
this.rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps the item {@code child} with the previous one in the collection.
|
||||
*
|
||||
* @param child The child to swap with the previous one.
|
||||
* @throws IllegalArgumentException Thrown if the child object provided is
|
||||
* not part of this collection, or if the child is the first one in the
|
||||
* collection.
|
||||
*/
|
||||
public void swapWithPrevious(GenericOrganizationalUnit child) {
|
||||
int previousPos = 0;
|
||||
int previousIndex = 0;
|
||||
int currentPos = 0;
|
||||
int currentIndex = 0;
|
||||
|
||||
s_log.debug("Searching child...");
|
||||
this.rewind();
|
||||
while (this.next()) {
|
||||
currentPos = this.getPosition();
|
||||
currentIndex = this.getChildrenOrder();
|
||||
s_log.debug(String.format("Position: %d(%d)/%d", currentPos,
|
||||
currentIndex, this.size()));
|
||||
s_log.debug(String.format("getChildrenOrder(): %d",
|
||||
getChildrenOrder()));
|
||||
if (this.getOrgaUnitChild().equals(child)) {
|
||||
break;
|
||||
}
|
||||
|
||||
previousPos = currentPos;
|
||||
previousIndex = currentIndex;
|
||||
}
|
||||
|
||||
if (currentPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided organizational unit is not "
|
||||
+ "part of this collection."));
|
||||
}
|
||||
|
||||
if (previousPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided organizational unit is the first one in this "
|
||||
+ "collection, so there is no previous one to switch "
|
||||
+ "with."));
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
while (this.getPosition() != previousPos) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
this.setChildrenOrder(currentIndex);
|
||||
this.next();
|
||||
this.setChildrenOrder(previousIndex);
|
||||
this.rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current child.
|
||||
*
|
||||
* @return The GenericOrganizationalUnit at the cursors current position.
|
||||
*/
|
||||
public GenericOrganizationalUnit getOrgaUnitChild() {
|
||||
return new GenericOrganizationalUnit(m_dataCollection.getDataObject());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ package com.arsdigita.cms.contenttypes;
|
|||
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Collection class for the GenericOrganizationalUnit -> Contact relation.
|
||||
|
|
@ -29,15 +31,17 @@ import java.math.BigDecimal;
|
|||
*/
|
||||
public class GenericOrganizationalUnitContactCollection extends DomainCollection {
|
||||
|
||||
public static final String ORDER = "link.contact_order asc";
|
||||
public static final String CONTACT_TYPE = "link.contact_type";
|
||||
private final static Logger s_log =
|
||||
Logger.getLogger(
|
||||
GenericOrganizationalUnitContactCollection.class);
|
||||
public static final String CONTACT_ORDER = "link.contact_order";
|
||||
public static final String CONTACT_TYPE = "link.contact_type";
|
||||
|
||||
public GenericOrganizationalUnitContactCollection(
|
||||
DataCollection dataCollection) {
|
||||
super(dataCollection);
|
||||
|
||||
m_dataCollection.addOrder(ORDER);
|
||||
m_dataCollection.addOrder(CONTACT_ORDER);
|
||||
}
|
||||
|
||||
// Get the contact type of the link
|
||||
|
|
@ -46,17 +50,133 @@ public class GenericOrganizationalUnitContactCollection extends DomainCollection
|
|||
}
|
||||
|
||||
// Get the contact order of the link
|
||||
public String getContactOrder() {
|
||||
String retVal = ((BigDecimal) m_dataCollection.get(CONTACT_ORDER)).
|
||||
toString();
|
||||
|
||||
if (retVal == null || retVal.isEmpty()) {
|
||||
retVal = String.valueOf(this.getPosition());
|
||||
}
|
||||
|
||||
return retVal;
|
||||
public Integer getContactOrder() {
|
||||
return (Integer) m_dataCollection.get(CONTACT_ORDER);
|
||||
}
|
||||
|
||||
public void setContactOrder(Integer order) {
|
||||
DataObject link = (DataObject) this.get("link");
|
||||
|
||||
link.set(CONTACT_ORDER, order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps the item {@code contact} with the next one in the collection.
|
||||
*
|
||||
* @param contact The item to swap with the next one.
|
||||
* @throws IllegalArgumentException Thrown if the item provided is
|
||||
* not part of this collection, or if the item is the last one in the
|
||||
* collection.
|
||||
*/
|
||||
public void swapWithNext(GenericContact contact) {
|
||||
int currentPos = 0;
|
||||
int currentIndex = 0;
|
||||
int nextIndex = 0;
|
||||
|
||||
s_log.debug("Searching contact...");
|
||||
this.rewind();
|
||||
while (this.next()) {
|
||||
currentPos = this.getPosition();
|
||||
currentIndex = this.getContactOrder();
|
||||
s_log.debug(String.format("Position: %d(%d)/%d", currentPos,
|
||||
currentIndex, this.size()));
|
||||
s_log.debug(String.format("getContactOrder(): %d",
|
||||
getContactOrder()));
|
||||
if (this.getContact().equals(contact)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided contact is not "
|
||||
+ "part of this collection."));
|
||||
}
|
||||
|
||||
if (this.next()) {
|
||||
nextIndex = this.getContactOrder();
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"The provided contact is the last "
|
||||
+ "in the collection, so there is no next object "
|
||||
+ "to swap with.");
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
|
||||
while (this.getPosition() != currentPos) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
this.setContactOrder(nextIndex);
|
||||
this.next();
|
||||
this.setContactOrder(currentIndex);
|
||||
this.rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps the item {@code contact} with the previous one in the collection.
|
||||
*
|
||||
* @param contact The item to swap with the previous one.
|
||||
* @throws IllegalArgumentException Thrown if the item provided is
|
||||
* not part of this collection, or if the item is the first one in the
|
||||
* collection.
|
||||
*/
|
||||
public void swapWithPrevious(GenericContact contact) {
|
||||
int previousPos = 0;
|
||||
int previousIndex = 0;
|
||||
int currentPos = 0;
|
||||
int currentIndex = 0;
|
||||
|
||||
s_log.debug("Searching child...");
|
||||
this.rewind();
|
||||
while (this.next()) {
|
||||
currentPos = this.getPosition();
|
||||
currentIndex = this.getContactOrder();
|
||||
s_log.debug(String.format("Position: %d(%d)/%d", currentPos,
|
||||
currentIndex, this.size()));
|
||||
s_log.debug(String.format("getContactOrder(): %d",
|
||||
getContactOrder()));
|
||||
|
||||
if (this.getContact().equals(contact)) {
|
||||
break;
|
||||
}
|
||||
|
||||
previousPos = currentPos;
|
||||
previousIndex = currentIndex;
|
||||
}
|
||||
|
||||
if (currentPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided contact is not "
|
||||
+ "part of this collection."));
|
||||
}
|
||||
|
||||
if (previousPos == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided contact is the first one in this "
|
||||
+ "collection, so there is no previous one to switch "
|
||||
+ "with."));
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
while (this.getPosition() != previousPos) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
this.setContactOrder(currentIndex);
|
||||
this.next();
|
||||
this.setContactOrder(previousIndex);
|
||||
this.rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The current contact.
|
||||
*/
|
||||
public GenericContact getContact() {
|
||||
return new GenericContact(m_dataCollection.getDataObject());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
|||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Table for showing the childs of an organization.
|
||||
|
|
@ -53,6 +54,9 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
private final String TABLE_COL_UP = "table_col_up";
|
||||
private final String TABLE_COL_DOWN = "table_col_down";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
private static final Logger s_log =
|
||||
Logger.getLogger(
|
||||
GenericOrganizationalUnitChildTable.class);
|
||||
|
||||
public GenericOrganizationalUnitChildTable(
|
||||
final ItemSelectionModel itemModel) {
|
||||
|
|
@ -78,16 +82,16 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.child.action").localize(),
|
||||
TABLE_COL_DEL));
|
||||
/* tabModel.add(new TableColumn(
|
||||
2,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.child.up").localize(),
|
||||
TABLE_COL_UP));
|
||||
tabModel.add(new TableColumn(
|
||||
3,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.child.down").localize(),
|
||||
TABLE_COL_DOWN));*/
|
||||
2,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.child.up").localize(),
|
||||
TABLE_COL_UP));
|
||||
tabModel.add(new TableColumn(
|
||||
3,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.child.down").localize(),
|
||||
TABLE_COL_DOWN));
|
||||
|
||||
|
||||
setModelBuilder(new GenericOrganizationalUnitChildTableModelBuilder(
|
||||
|
|
@ -95,10 +99,11 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
|
||||
tabModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
tabModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||
//tabModel.get(2).setCellRenderer(new UpCellRenderer());
|
||||
//tabModel.get(3).setCellRenderer(new DownCellRenderer());
|
||||
tabModel.get(2).setCellRenderer(new UpCellRenderer());
|
||||
tabModel.get(3).setCellRenderer(new DownCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
|
||||
}
|
||||
|
||||
private class GenericOrganizationalUnitChildTableModelBuilder extends LockableImpl
|
||||
|
|
@ -111,6 +116,7 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
m_itemModel = itemModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(Table table, PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel.
|
||||
|
|
@ -134,10 +140,12 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
m_childCollection = orgaunit.getOrgaUnitChildren();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return m_table.getColumnModel().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
boolean ret;
|
||||
|
||||
|
|
@ -151,6 +159,7 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int colIndex) {
|
||||
switch (colIndex) {
|
||||
/*case 0:
|
||||
|
|
@ -164,6 +173,7 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(int colIndex) {
|
||||
return m_child.getID();
|
||||
}
|
||||
|
|
@ -172,6 +182,7 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
private class EditCellRenderer extends LockableImpl implements
|
||||
TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
|
|
@ -202,6 +213,7 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
private class DeleteCellRenderer extends LockableImpl implements
|
||||
TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
|
|
@ -235,6 +247,7 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
private class UpCellRenderer extends LockableImpl implements
|
||||
TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
|
|
@ -248,15 +261,28 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);*/
|
||||
|
||||
ControlLink link = new ControlLink("up");
|
||||
/*GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
GenericOrganizationalUnitChildrenCollection children =
|
||||
orgaunit.getOrgaUnitChildren();*/
|
||||
|
||||
return link;
|
||||
s_log.debug(String.format("row = %d", row));
|
||||
//s_log.debug(String.format("children.size = %d", children.size()));
|
||||
|
||||
if (0 == row) {
|
||||
s_log.debug("row is first row in table, don't show 'up'-link...");
|
||||
return new Label("");
|
||||
} else {
|
||||
ControlLink link = new ControlLink("up");
|
||||
return link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DownCellRenderer extends LockableImpl implements
|
||||
TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
|
|
@ -270,9 +296,21 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);*/
|
||||
|
||||
ControlLink link = new ControlLink("down");
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
GenericOrganizationalUnitChildrenCollection children =
|
||||
orgaunit.
|
||||
getOrgaUnitChildren();
|
||||
|
||||
return link;
|
||||
|
||||
if ((children.size() - 1) == row) {
|
||||
s_log.debug(
|
||||
"Row is last row of table, don't show 'down'-link...");
|
||||
return new Label("");
|
||||
} else {
|
||||
ControlLink link = new ControlLink("down");
|
||||
return link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -286,16 +324,18 @@ public class GenericOrganizationalUnitChildTable extends Table implements
|
|||
GenericOrganizationalUnit parent = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
GenericOrganizationalUnitChildrenCollection children =
|
||||
parent.getOrgaUnitChildren();
|
||||
|
||||
TableColumn col = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||
} else if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
parent.removeOrgaUnitChildren(child);
|
||||
/*} else if(col.getHeaderKey().toString().equals(TABLE_COL_UP)) {
|
||||
|
||||
} else if(col.getHeaderKey().toString().equals(TABLE_COL_DOWN)) {
|
||||
|
||||
}*/
|
||||
} else if (col.getHeaderKey().equals(TABLE_COL_UP)) {
|
||||
children.swapWithPrevious(child);
|
||||
} else if (col.getHeaderKey().equals(TABLE_COL_DOWN)) {
|
||||
children.swapWithNext(child);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,79 +43,100 @@ import com.arsdigita.cms.dispatcher.Utilities;
|
|||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Table for showing the contacts associated with an organization.
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class GenericOrganizationalUnitContactTable extends Table implements TableActionListener {
|
||||
public class GenericOrganizationalUnitContactTable extends Table implements
|
||||
TableActionListener {
|
||||
|
||||
private final static Logger s_log = Logger.getLogger(
|
||||
GenericOrganizationalUnitContactTable.class);
|
||||
private final static String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final static String TABLE_COL_DEL = "table_col_del";
|
||||
private final static String TABLE_COL_UP = "table_col_up";
|
||||
private final static String TABLE_COL_DOWN = "table_col_down";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public GenericOrganizationalUnitContactTable(final ItemSelectionModel itemModel) {
|
||||
public GenericOrganizationalUnitContactTable(
|
||||
final ItemSelectionModel itemModel) {
|
||||
super();
|
||||
this.m_itemModel = itemModel;
|
||||
|
||||
setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorgaunit.contacts.none")));
|
||||
setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.contacts.none")));
|
||||
TableColumnModel tabModel = getColumnModel();
|
||||
|
||||
tabModel.add(new TableColumn(
|
||||
0,
|
||||
ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorgaunit.contact.order").localize(),
|
||||
TABLE_COL_EDIT));
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.contact.type").localize()));
|
||||
tabModel.add(new TableColumn(
|
||||
1,
|
||||
ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorgaunit.contact.type").localize()));
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.contact.title").localize()));
|
||||
tabModel.add(new TableColumn(
|
||||
2,
|
||||
ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorgaunit.contact.title").localize()));
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.contact.action").localize(),
|
||||
TABLE_COL_DEL));
|
||||
tabModel.add(new TableColumn(
|
||||
3,
|
||||
ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorgaunit.contact.action").localize(),
|
||||
TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(new GenericOrganizationalUnitTableModelBuilder(itemModel));
|
||||
|
||||
tabModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
tabModel.get(3).setCellRenderer(new DeleteCellRenderer());
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.contact.up").localize(),
|
||||
TABLE_COL_UP));
|
||||
tabModel.add(new TableColumn(
|
||||
4,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.contact.down").localize(),
|
||||
TABLE_COL_DOWN));
|
||||
|
||||
setModelBuilder(
|
||||
new GenericOrganizationalUnitTableModelBuilder(itemModel));
|
||||
|
||||
tabModel.get(1).setCellRenderer(new EditCellRenderer());
|
||||
tabModel.get(2).setCellRenderer(new DeleteCellRenderer());
|
||||
tabModel.get(3).setCellRenderer(new UpCellRenderer());
|
||||
tabModel.get(3).setCellRenderer(new DownCellRenderer());
|
||||
}
|
||||
|
||||
private class GenericOrganizationalUnitTableModelBuilder
|
||||
|
||||
private class GenericOrganizationalUnitTableModelBuilder
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
|
||||
public GenericOrganizationalUnitTableModelBuilder(
|
||||
ItemSelectionModel itemModel) {
|
||||
m_itemModel = itemModel;
|
||||
}
|
||||
|
||||
|
||||
public TableModel makeModel(Table table, PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) m_itemModel.getSelectedObject(state);
|
||||
return new GenericOrganizationalUnitTableModel(table, state, orgaunit);
|
||||
}
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
return new GenericOrganizationalUnitTableModel(table, state,
|
||||
orgaunit);
|
||||
}
|
||||
}
|
||||
|
||||
private class GenericOrganizationalUnitTableModel implements TableModel {
|
||||
|
||||
private final int MAX_DESC_LENGTH = 25;
|
||||
private Table m_table;
|
||||
private GenericOrganizationalUnitContactCollection m_contactCollection;
|
||||
private GenericContact m_contact;
|
||||
private GenericContactTypeCollection contacttypes =
|
||||
new GenericContactTypeCollection();
|
||||
new GenericContactTypeCollection();
|
||||
|
||||
private GenericOrganizationalUnitTableModel(
|
||||
Table table,
|
||||
PageState state,
|
||||
GenericOrganizationalUnit orgaunit
|
||||
) {
|
||||
GenericOrganizationalUnit orgaunit) {
|
||||
m_table = table;
|
||||
m_contactCollection = orgaunit.getContacts();
|
||||
}
|
||||
|
|
@ -128,7 +149,7 @@ public class GenericOrganizationalUnitContactTable extends Table implements Tabl
|
|||
boolean ret;
|
||||
|
||||
if ((m_contactCollection != null)
|
||||
&& m_contactCollection.next()) {
|
||||
&& m_contactCollection.next()) {
|
||||
m_contact = m_contactCollection.getContact();
|
||||
ret = true;
|
||||
} else {
|
||||
|
|
@ -139,15 +160,15 @@ public class GenericOrganizationalUnitContactTable extends Table implements Tabl
|
|||
}
|
||||
|
||||
public Object getElementAt(int columnIndex) {
|
||||
switch(columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return m_contactCollection.getContactOrder();
|
||||
return contacttypes.getContactType(m_contactCollection.
|
||||
getContactType(),
|
||||
DispatcherHelper.
|
||||
getNegotiatedLocale().getLanguage());
|
||||
case 1:
|
||||
return contacttypes.getContactType(m_contactCollection.getContactType(),
|
||||
DispatcherHelper.getNegotiatedLocale().getLanguage());
|
||||
case 2:
|
||||
return m_contact.getTitle();
|
||||
case 3:
|
||||
case 2:
|
||||
return GlobalizationUtil.globalize("cms.ui.delete").localize();
|
||||
default:
|
||||
return null;
|
||||
|
|
@ -162,6 +183,7 @@ public class GenericOrganizationalUnitContactTable extends Table implements Tabl
|
|||
private class EditCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
|
|
@ -170,13 +192,15 @@ public class GenericOrganizationalUnitContactTable extends Table implements Tabl
|
|||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
SecurityManager securityManager = Utilities.getSecurityManager(state);
|
||||
SecurityManager securityManager =
|
||||
Utilities.getSecurityManager(state);
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) m_itemModel.getSelectedObject(state);
|
||||
(GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(state.getRequest(),
|
||||
SecurityManager.EDIT_ITEM,
|
||||
orgaunit);
|
||||
SecurityManager.EDIT_ITEM,
|
||||
orgaunit);
|
||||
if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
return link;
|
||||
|
|
@ -189,6 +213,7 @@ public class GenericOrganizationalUnitContactTable extends Table implements Tabl
|
|||
private class DeleteCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
|
|
@ -197,17 +222,22 @@ public class GenericOrganizationalUnitContactTable extends Table implements Tabl
|
|||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
SecurityManager securityManager = Utilities.getSecurityManager(state);
|
||||
SecurityManager securityManager =
|
||||
Utilities.getSecurityManager(state);
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) m_itemModel.getSelectedObject(state);
|
||||
(GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
boolean canDelete = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
SecurityManager.DELETE_ITEM,
|
||||
orgaunit);
|
||||
if(canDelete) {
|
||||
if (canDelete) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorgaunit.confirm_delete").localize());
|
||||
link.setConfirmation((String) ContenttypesGlobalizationUtil.
|
||||
globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.confirm_delete").
|
||||
localize());
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
|
|
@ -215,24 +245,84 @@ public class GenericOrganizationalUnitContactTable extends Table implements Tabl
|
|||
}
|
||||
}
|
||||
|
||||
private class UpCellRenderer extends LockableImpl implements
|
||||
TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
|
||||
if (0 == row) {
|
||||
s_log.debug("Row is first row in table, don't show up-link");
|
||||
return new Label("");
|
||||
} else {
|
||||
ControlLink link = new ControlLink("up");
|
||||
return link;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class DownCellRenderer extends LockableImpl implements
|
||||
TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
GenericOrganizationalUnitContactCollection contacts =
|
||||
orgaunit.getContacts();
|
||||
|
||||
if ((contacts.size() - 1) == row) {
|
||||
s_log.debug("Row is last row in table, don't show down-link");
|
||||
return new Label("");
|
||||
} else {
|
||||
ControlLink link = new ControlLink("down");
|
||||
return link;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(TableActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
GenericContact contact =
|
||||
new GenericContact(new BigDecimal(event.getRowKey().toString()));
|
||||
GenericContact contact =
|
||||
new GenericContact(new BigDecimal(event.getRowKey().
|
||||
toString()));
|
||||
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) m_itemModel.getSelectedObject(state);
|
||||
(GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
GenericOrganizationalUnitContactCollection contacts =
|
||||
orgaunit.getContacts();
|
||||
|
||||
TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||
|
||||
}
|
||||
|
||||
if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
orgaunit.removeContact(contact);
|
||||
else if(column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
orgaunit.removeContact(contact);
|
||||
} else if(column.getHeaderKey().toString().equals(TABLE_COL_UP)) {
|
||||
contacts.swapWithPrevious(contact);
|
||||
} else if(column.getHeaderKey().toString().equals(TABLE_COL_DOWN)) {
|
||||
contacts.swapWithNext(contact);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,23 +64,18 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.none")));
|
||||
TableColumnModel tabModel = getColumnModel();
|
||||
|
||||
|
||||
tabModel.add(new TableColumn(
|
||||
0,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.order").localize(),
|
||||
TABLE_COL_EDIT));
|
||||
tabModel.add(new TableColumn(
|
||||
1,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.name").localize()));
|
||||
tabModel.add(new TableColumn(
|
||||
2,
|
||||
1,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.role").localize()));
|
||||
tabModel.add(
|
||||
new TableColumn(
|
||||
3,
|
||||
2,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.persons.delete").localize()));
|
||||
|
||||
|
|
@ -88,7 +83,7 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements
|
|||
new GenericOrganizationalUnitTableModelBuilder(itemModel));
|
||||
|
||||
tabModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
tabModel.get(3).setCellRenderer(new DeleteCellRenderer());
|
||||
tabModel.get(2).setCellRenderer(new DeleteCellRenderer());
|
||||
}
|
||||
|
||||
private class GenericOrganizationalUnitTableModelBuilder
|
||||
|
|
|
|||
Loading…
Reference in New Issue