Current version of ccm-cms/GenericOrganizationalUnit
git-svn-id: https://svn.libreccm.org/ccm/trunk@467 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
2ac510fb7d
commit
5077522fd0
|
|
@ -0,0 +1,68 @@
|
|||
//
|
||||
// Copyright (C) 2010 Jens Pelzetter, for the Center of Social Politics (ZeS) of
|
||||
// the University of Bremen
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; either version 2.1 of
|
||||
// the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
//
|
||||
|
||||
model com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
|
||||
//PDL definition for a commons base type for orgnizations, departments, projects etc.
|
||||
object type GenericOrganizationalUnit extends ContentPage {
|
||||
String[0..1] orgaunit_name = cms_organizationalunit.name VARCHAR(256);
|
||||
|
||||
String[0..1] addendum = cms_organizationalunit.nameaddendum VARCHAR(512);
|
||||
|
||||
reference key (cms_organizationalunits.organizationalunit_id);
|
||||
}
|
||||
|
||||
//Parent <-> child relation organizationalunits to build department structures etc.
|
||||
association {
|
||||
|
||||
GenericOrganizationalUnit[0..n] children = join cms_organizationalunits.organizationalunit_id
|
||||
to cms_organizationalunit_organizationalunit_map.children_id,
|
||||
join cms_organizationalunit_organizationalunit_map.parent_id
|
||||
to cms_organizationalunits.organizationalunit_id;
|
||||
|
||||
GenericOrganizationalUnit[0..1] parent = join cms_organizationalunits.organizationalunit_id
|
||||
to cms_organizationalunit_organizationalunit_map.parent_id,
|
||||
join cms_organizationalunit_organizationalunit_map.children_id
|
||||
to cms_organizationalunits.organizationalunit_id;
|
||||
|
||||
//Link attribute, allows it to customize the order which the childs will be shown.
|
||||
BigDecimal[0..1] order = cms_organizationalunit_organizationalunit_map.order INTEGER;
|
||||
}
|
||||
|
||||
//Link for contact points.
|
||||
association {
|
||||
|
||||
GenericOrganizationalUnit[0..1] organizationalunit = join cms_contacts.contact_id
|
||||
to cms_organizationalunit_contact_map.contact_id,
|
||||
join cms_organizationalunit_contact_map.organizationalunit_id
|
||||
to cms_organizationalunits.organizationalunit_id;
|
||||
|
||||
GenericContact[0..n] contacts = join cms_organizationalunits.organizationalunit_id
|
||||
to cms_organizationalunit_contact_map.organizationalunit_id,
|
||||
join cms_organizationalunit_contact_map.contact_id
|
||||
to cms_contacts.contact_id;
|
||||
|
||||
//Some link attributes.
|
||||
String contact_type = cms_organizationalunit_contact_map.contact_type VARCHAR(100);
|
||||
BigDecimal contact_order = cms_organizationalunit_contact_map.contact_order INTEGER;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||
|
||||
<!-- Is internal will be set the yes when testing is finished. -->
|
||||
<ctd:content-type
|
||||
label="GenericOrganizationalUnit"
|
||||
description="A generic content type for organizations and projects."
|
||||
objectType="com.arsdigita.cms.contenttypes.GenericOrganizationalUnit"
|
||||
class="com.arsdigita.cms.contenttypes.GenericOrganizationalUnit"
|
||||
isInternal="no">
|
||||
|
||||
<ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
|
||||
|
||||
<ctd:authoring-step
|
||||
labelKey="cms.contenttypes.shared.basic_properties.title"
|
||||
labelBundle="cms.contenttypes.cms.ui.CMSResources"
|
||||
descriptionKey="cms.contenttypes.shared.basic_properties.description"
|
||||
descriptionBundle="com.arsdigita.cms.ui.CMSResources"
|
||||
component="com.arsdigita.cms.contenttypes.ui.GenericOrganizationalUnitPropertiesStep"
|
||||
ordering="1"
|
||||
/>
|
||||
|
||||
<ctd:authoring-step
|
||||
labelKey="genericorgaunit.authoring.contact_properties.title"
|
||||
labelBundle="com.arsdigita.cms.contenttypes.ContenttypesResources"
|
||||
descriptionKey="genericorgaunit.authoring.contact_properties.description"
|
||||
descriptionBundle="com.arsdigita.cms.contenttypes.ContenttypesResources"
|
||||
component="com.arsdigita.cms.contenttypes.ui.GenericOrganizationalUnitContactPropertiesStep"
|
||||
ordering="2"
|
||||
/>
|
||||
|
||||
<ctd:authoring-step
|
||||
labelKey="genericorgaunit.authoring.child_properties.title"
|
||||
labelBundle="com.arsdigita.cms.contenttypes.ContenttypesResources"
|
||||
descriptionKey="genericorgaunit.authoring.child_properties.description"
|
||||
descriptionBundle="com.arsdigita.cms.contenttypes.ContenttypesResources"
|
||||
component="com.arsdigita.cms.contenttypes.ui.GenericOrganizationalUnitChildrenPropertiesStep"
|
||||
ordering="3"
|
||||
/>
|
||||
|
||||
|
||||
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
||||
</ctd:authoring-kit>
|
||||
|
||||
</ctd:content-type>
|
||||
|
||||
</ctd:content-types>
|
||||
|
|
@ -72,3 +72,21 @@ cms.contenttypes.ui.contact.contactEntry.key.fax=Fax
|
|||
cms.contenttypes.ui.contact.contactEntry.key.im=Instant Messenger
|
||||
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.child.action=Action
|
||||
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.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.genericorganunit.name=Name
|
||||
cms.contenttypes.ui.genericorgaunit.select_child=Select child
|
||||
cms.contenttypes.ui.genericorgaunit.select_contact=Select contact
|
||||
|
|
|
|||
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* Copyright (c) 2010 Jens Pelzetter, for the Center of Social Politics of the University of Bremen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.util.Assert;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class GenericOrganizationalUnit extends ContentPage {
|
||||
|
||||
public final static String ORGAUNIT_NAME = "ORGAUNIT_NAME";
|
||||
public final static String ADDENDUM = "ORGAUNIT_ADDENDUM";
|
||||
public final static String CONTACTS = "CONTACTS";
|
||||
public final static String CONTACT_TYPE = "CONTACT_TYPE";
|
||||
public final static String CONTACT_ORDER = "CONTACT_ORDER";
|
||||
public final static String ORGAUNIT_CHILDREN = "CHILDREN";
|
||||
public final static String CHILDREN_ORDER = "CHILDREN_ORDER";
|
||||
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 {
|
||||
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnit(OID oid) throws DataObjectNotFoundException {
|
||||
super(oid);
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnit(DataObject obj) {
|
||||
super(obj);
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnit(String type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeSave() {
|
||||
super.beforeSave();
|
||||
|
||||
Assert.exists(getContentType(), ContentType.class);
|
||||
}
|
||||
|
||||
public String getOrgaUnitName() {
|
||||
return (String) get(ORGAUNIT_NAME);
|
||||
}
|
||||
|
||||
public void setOrgaUnitName(String orgaUnitName) {
|
||||
set(ORGAUNIT_NAME, orgaUnitName);
|
||||
}
|
||||
|
||||
public String getAddendum() {
|
||||
return (String) get(ADDENDUM);
|
||||
}
|
||||
|
||||
public void setAddendum(String addendum) {
|
||||
set(ADDENDUM, addendum);
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnitContactCollection getContacts() {
|
||||
return new GenericOrganizationalUnitContactCollection((DataCollection) get(CONTACTS));
|
||||
}
|
||||
|
||||
public void addContact(GenericContact contact, String contactType) {
|
||||
Assert.exists(contact, GenericContact.class);
|
||||
|
||||
DataObject link = add(CONTACTS, contact);
|
||||
|
||||
link.set(CONTACT_TYPE, contactType);
|
||||
link.set(CONTACT_ORDER, BigDecimal.valueOf(getContacts().size()));
|
||||
}
|
||||
|
||||
public void removeContact(GenericContact contact) {
|
||||
Assert.exists(contact, GenericContact.class);
|
||||
remove(CONTACTS, contact);
|
||||
}
|
||||
|
||||
public boolean hasContacts() {
|
||||
return !this.getContacts().isEmpty();
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnitChildrenCollection getOrgaUnitChildren() {
|
||||
return new GenericOrganizationalUnitChildrenCollection((DataCollection) get(ORGAUNIT_CHILDREN));
|
||||
}
|
||||
|
||||
public void addOrgaUnitChildren(GenericOrganizationalUnit child) {
|
||||
Assert.exists(child, GenericOrganizationalUnit.class);
|
||||
|
||||
DataObject link = add(ORGAUNIT_CHILDREN, child);
|
||||
|
||||
link.set(CHILDREN_ORDER, BigDecimal.valueOf(getContacts().size()));
|
||||
}
|
||||
|
||||
public void removeOrgaUnitChildren(GenericOrganizationalUnit child) {
|
||||
Assert.exists(child, GenericOrganizationalUnit.class);
|
||||
remove(ORGAUNIT_CHILDREN, child);
|
||||
}
|
||||
|
||||
public boolean hasOrgaUnitChildren() {
|
||||
return !this.getOrgaUnitChildren().isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jensp
|
||||
*/
|
||||
public class GenericOrganizationalUnitChildrenCollection extends DomainCollection {
|
||||
|
||||
public static final String ORDER = "link.contact_order asc";
|
||||
public static final String CHILDREN_ORDER = "link.children_order";
|
||||
|
||||
public GenericOrganizationalUnitChildrenCollection(DataCollection dataCollection) {
|
||||
super(dataCollection);
|
||||
|
||||
m_dataCollection.addOrder(ORDER);
|
||||
}
|
||||
|
||||
public String getChildrenOrder() {
|
||||
String retVal = ((BigDecimal) m_dataCollection.get(CHILDREN_ORDER)).toString();
|
||||
|
||||
if (retVal == null || retVal.isEmpty()) {
|
||||
retVal = String.valueOf(this.getPosition());
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnit getOrgaUnitChild() {
|
||||
return new GenericOrganizationalUnit(m_dataCollection.getDataObject());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jensp
|
||||
*/
|
||||
public class GenericOrganizationalUnitContactCollection extends DomainCollection {
|
||||
|
||||
public static final String ORDER = "link.contact_order asc";
|
||||
public static final String CONTACT_TYPE = "link.contact_type";
|
||||
public static final String CONTACT_ORDER = "link.contact_order";
|
||||
|
||||
|
||||
public GenericOrganizationalUnitContactCollection(DataCollection dataCollection) {
|
||||
super(dataCollection);
|
||||
|
||||
m_dataCollection.addOrder(ORDER);
|
||||
}
|
||||
|
||||
// Get the contact type of the link
|
||||
public String getContactType() {
|
||||
return (String) m_dataCollection.get(CONTACT_TYPE);
|
||||
}
|
||||
|
||||
// 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 GenericContact getContact() {
|
||||
return new GenericContact(m_dataCollection.getDataObject());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class GenericOrganizationalUnitAddChildForm extends BasicItemForm {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
GenericOrganizationalUnitAddChildForm.class);
|
||||
private GenericOrganizationalUnitPropertiesStep m_step;
|
||||
private ItemSearchWidget m_itemSearch;
|
||||
private SaveCancelSection m_saveCancelSection;
|
||||
private final String ITEM_SEARCH = "orgaunitChild";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public GenericOrganizationalUnitAddChildForm(ItemSelectionModel itemModel) {
|
||||
super("ChildAddForm", itemModel);
|
||||
m_itemModel = itemModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorgaunit.select_child").localize()));
|
||||
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType(GenericOrganizationalUnit.class.getName()));
|
||||
add(this.m_itemSearch);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
|
||||
setVisible(state, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
GenericOrganizationalUnit parent = (GenericOrganizationalUnit) getItemSelectionModel().getSelectedObject(state);
|
||||
|
||||
if (!(this.getSaveCancelSection().getCancelButton().isSelected(state))) {
|
||||
parent.addOrgaUnitChildren((GenericOrganizationalUnit) data.get(ITEM_SEARCH));
|
||||
}
|
||||
|
||||
init(fse);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,224 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitChildrenCollection;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jensp
|
||||
*/
|
||||
public class GenericOrganizationalUnitChildTable extends Table implements
|
||||
TableActionListener {
|
||||
|
||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public GenericOrganizationalUnitChildTable(
|
||||
final ItemSelectionModel itemModel) {
|
||||
super();
|
||||
this.m_itemModel = itemModel;
|
||||
|
||||
setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.childs.none")));
|
||||
TableColumnModel tabModel = getColumnModel();
|
||||
|
||||
tabModel.add(new TableColumn(
|
||||
0,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.child.order").localize(),
|
||||
TABLE_COL_EDIT));
|
||||
tabModel.add(new TableColumn(
|
||||
1,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.child.name").localize()));
|
||||
tabModel.add(new TableColumn(
|
||||
2,
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.child.action").localize(),
|
||||
TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(new GenericOrganizationalUnitChildTableModelBuilder(
|
||||
itemModel));
|
||||
|
||||
tabModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
tabModel.get(2).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
}
|
||||
|
||||
private class GenericOrganizationalUnitChildTableModelBuilder extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public GenericOrganizationalUnitChildTableModelBuilder(
|
||||
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 GenericOrganizationalUnitChildTableModel(table, state,
|
||||
orgaunit);
|
||||
}
|
||||
}
|
||||
|
||||
private class GenericOrganizationalUnitChildTableModel implements TableModel {
|
||||
|
||||
final private int MAX_DESC_LENGTH = 25;
|
||||
private Table m_table;
|
||||
private GenericOrganizationalUnitChildrenCollection m_childCollection;
|
||||
private GenericOrganizationalUnit m_child;
|
||||
|
||||
private GenericOrganizationalUnitChildTableModel(Table table,
|
||||
PageState state,
|
||||
GenericOrganizationalUnit orgaunit) {
|
||||
m_table = table;
|
||||
m_childCollection = orgaunit.getOrgaUnitChildren();
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return m_table.getColumnModel().size();
|
||||
}
|
||||
|
||||
public boolean nextRow() {
|
||||
boolean ret;
|
||||
|
||||
if ((m_childCollection != null) && m_childCollection.next()) {
|
||||
m_child = m_childCollection.getOrgaUnitChild();
|
||||
ret = true;
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Object getElementAt(int colIndex) {
|
||||
switch (colIndex) {
|
||||
case 0:
|
||||
return m_childCollection.getChildrenOrder();
|
||||
case 1:
|
||||
return m_child.getOrgaUnitName();
|
||||
case 2:
|
||||
return GlobalizationUtil.globalize("cms.ui.delete").localize();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getKeyAt(int colIndex) {
|
||||
return m_child.getID();
|
||||
}
|
||||
}
|
||||
|
||||
private class EditCellRenderer extends LockableImpl implements
|
||||
TableCellRenderer {
|
||||
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
com.arsdigita.cms.SecurityManager securityManager = Utilities.
|
||||
getSecurityManager(state);
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
|
||||
orgaunit);
|
||||
if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer extends LockableImpl implements
|
||||
TableCellRenderer {
|
||||
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
com.arsdigita.cms.SecurityManager securityManager = Utilities.
|
||||
getSecurityManager(state);
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.DELETE_ITEM,
|
||||
orgaunit);
|
||||
if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) ContenttypesGlobalizationUtil.
|
||||
globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.confirm_delete").
|
||||
localize());
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cellSelected(TableActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
GenericOrganizationalUnit child = new GenericOrganizationalUnit(new BigDecimal(event.
|
||||
getRowKey().toString()));
|
||||
|
||||
GenericOrganizationalUnit parent = (GenericOrganizationalUnit) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
TableColumn col = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||
}
|
||||
|
||||
if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
parent.removeOrgaUnitChildren(child);
|
||||
}
|
||||
}
|
||||
|
||||
public void headSelected(TableActionEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jensp
|
||||
*/
|
||||
public class GenericOrganizationalUnitChildrenPropertiesStep extends SimpleEditStep {
|
||||
|
||||
private static String ADD_CHILD_SHEET_NAME = "addChild";
|
||||
|
||||
public GenericOrganizationalUnitChildrenPropertiesStep(
|
||||
ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, null);
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnitChildrenPropertiesStep(
|
||||
ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent,
|
||||
String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
BasicItemForm addChildSheet = new GenericOrganizationalUnitAddChildForm(
|
||||
itemModel);
|
||||
add(ADD_CHILD_SHEET_NAME,
|
||||
(String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.add_child").localize(),
|
||||
new WorkflowLockedComponentAccess(addChildSheet, itemModel),
|
||||
addChildSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
GenericOrganizationalUnitChildTable childrenTable = new GenericOrganizationalUnitChildTable(
|
||||
(itemModel));
|
||||
setDisplayComponent(childrenTable);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.form.Option;
|
||||
import com.arsdigita.bebop.form.SingleSelect;
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||
import com.arsdigita.cms.contenttypes.GenericContactType;
|
||||
import com.arsdigita.cms.contenttypes.GenericContactTypeCollection;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class GenericOrganizationalUnitContactAddForm extends BasicItemForm {
|
||||
|
||||
private final static Logger s_log = Logger.getLogger(
|
||||
GenericOrganizationalUnitContactAddForm.class);
|
||||
private GenericOrganizationalUnitPropertiesStep m_step;
|
||||
private ItemSearchWidget m_itemSearch;
|
||||
private SaveCancelSection m_saveCancelSection;
|
||||
private final String ITEM_SEARCH = "personAddress";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public GenericOrganizationalUnitContactAddForm(ItemSelectionModel itemModel) {
|
||||
super("ContactEntryAddForm", itemModel);
|
||||
m_itemModel = itemModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
add(new Label((String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.select_contact").localize()));
|
||||
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
|
||||
findByAssociatedObjectType(GenericContact.class.getName()));
|
||||
add(m_itemSearch);
|
||||
|
||||
add(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.contact.type")));
|
||||
ParameterModel contactTypeParam = new StringParameter(
|
||||
GenericOrganizationalUnitContactCollection.CONTACT_TYPE);
|
||||
SingleSelect contactType = new SingleSelect(contactTypeParam);
|
||||
contactType.addValidationListener(new NotNullValidationListener());
|
||||
contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.
|
||||
globalize("cms.ui.select_one").localize())));
|
||||
|
||||
GenericContactTypeCollection contacttypes =
|
||||
new GenericContactTypeCollection();
|
||||
contacttypes.filterLanguage(DispatcherHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
|
||||
while (contacttypes.next()) {
|
||||
GenericContactType ct = contacttypes.getContactType();
|
||||
contactType.addOption(new Option(ct.getKey(), ct.getName()));
|
||||
}
|
||||
|
||||
add(contactType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
|
||||
setVisible(state, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
if (!(this.getSaveCancelSection().getCancelButton().isSelected(state))) {
|
||||
orgaunit.addContact((GenericContact) data.get(ITEM_SEARCH), (String) data.
|
||||
get(GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
|
||||
}
|
||||
|
||||
init(fse);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class GenericOrganizationalUnitContactPropertiesStep
|
||||
extends SimpleEditStep {
|
||||
|
||||
private static String ADD_CONTACT_SHEET_NAME = "addContact";
|
||||
|
||||
public GenericOrganizationalUnitContactPropertiesStep(
|
||||
ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, null);
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnitContactPropertiesStep(
|
||||
ItemSelectionModel itemModel, AuthoringKitWizard parent,
|
||||
String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
BasicItemForm addContactSheet =
|
||||
new GenericOrganizationalUnitContactAddForm(
|
||||
itemModel);
|
||||
add(ADD_CONTACT_SHEET_NAME,
|
||||
(String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.add_contact").localize(),
|
||||
new WorkflowLockedComponentAccess(addContactSheet, itemModel),
|
||||
addContactSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
GenericOrganizationalUnitContactTable contactsTable = new GenericOrganizationalUnitContactTable(
|
||||
itemModel);
|
||||
setDisplayComponent(contactsTable);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||
import com.arsdigita.cms.contenttypes.GenericContactTypeCollection;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitContactCollection;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class GenericOrganizationalUnitContactTable extends Table implements TableActionListener {
|
||||
|
||||
private final static String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final static String TABLE_COL_DEL = "table_col_del";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public GenericOrganizationalUnitContactTable(final ItemSelectionModel itemModel) {
|
||||
super();
|
||||
this.m_itemModel = itemModel;
|
||||
|
||||
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));
|
||||
tabModel.add(new TableColumn(
|
||||
1,
|
||||
ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorgaunit.contact.type").localize()));
|
||||
tabModel.add(new TableColumn(
|
||||
2,
|
||||
ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorgaunit.contact.title").localize()));
|
||||
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());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
private GenericOrganizationalUnitTableModel(
|
||||
Table table,
|
||||
PageState state,
|
||||
GenericOrganizationalUnit orgaunit
|
||||
) {
|
||||
m_table = table;
|
||||
m_contactCollection = orgaunit.getContacts();
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return m_table.getColumnModel().size();
|
||||
}
|
||||
|
||||
public boolean nextRow() {
|
||||
boolean ret;
|
||||
|
||||
if ((m_contactCollection != null)
|
||||
&& m_contactCollection.next()) {
|
||||
m_contact = m_contactCollection.getContact();
|
||||
ret = true;
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Object getElementAt(int columnIndex) {
|
||||
switch(columnIndex) {
|
||||
case 0:
|
||||
return m_contactCollection.getContactOrder();
|
||||
case 1:
|
||||
return contacttypes.getContactType(m_contactCollection.getContactType(),
|
||||
DispatcherHelper.getNegotiatedLocale().getLanguage());
|
||||
case 2:
|
||||
return m_contact.getTitle();
|
||||
case 3:
|
||||
return GlobalizationUtil.globalize("cms.ui.delete").localize();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getKeyAt(int columnIndex) {
|
||||
return m_contact.getID();
|
||||
}
|
||||
}
|
||||
|
||||
private class EditCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
SecurityManager securityManager = Utilities.getSecurityManager(state);
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) m_itemModel.getSelectedObject(state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(state.getRequest(),
|
||||
SecurityManager.EDIT_ITEM,
|
||||
orgaunit);
|
||||
if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
SecurityManager securityManager = Utilities.getSecurityManager(state);
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) m_itemModel.getSelectedObject(state);
|
||||
|
||||
boolean canDelete = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
SecurityManager.DELETE_ITEM,
|
||||
orgaunit);
|
||||
if(canDelete) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorgaunit.confirm_delete").localize());
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(TableActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
GenericContact contact =
|
||||
new GenericContact(new BigDecimal(event.getRowKey().toString()));
|
||||
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) m_itemModel.getSelectedObject(state);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(TableActionEvent e) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SegmentedPanel;
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import java.text.DateFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class GenericOrganizationalUnitPropertiesStep extends SimpleEditStep {
|
||||
|
||||
public static final String EDIT_SHEET_NAME = "edit";
|
||||
|
||||
public GenericOrganizationalUnitPropertiesStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
super(itemModel, parent);
|
||||
|
||||
SegmentedPanel segmentedPanel = new SegmentedPanel();
|
||||
|
||||
setDefaultEditKey(EDIT_SHEET_NAME);
|
||||
|
||||
SimpleEditStep basicProperties = new SimpleEditStep(itemModel,
|
||||
parent,
|
||||
EDIT_SHEET_NAME);
|
||||
|
||||
BasicPageForm editBasicSheet =
|
||||
new GenericOrganizationalUnitPropertyForm(itemModel, this);
|
||||
basicProperties.add(EDIT_SHEET_NAME,
|
||||
(String) ContenttypesGlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.genericorgaunit.edit_basic_properties").localize(),
|
||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
||||
editBasicSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
basicProperties.setDisplayComponent(getGenericOrganizationalUnitPropertySheet(itemModel));
|
||||
|
||||
segmentedPanel.addSegment(
|
||||
new Label((String) ContenttypesGlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.genericorganunit.basic_properties").localize()),
|
||||
basicProperties);
|
||||
|
||||
setDisplayComponent(segmentedPanel);
|
||||
}
|
||||
|
||||
public static Component
|
||||
getGenericOrganizationalUnitPropertySheet(
|
||||
ItemSelectionModel itemModel) {
|
||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||
|
||||
sheet.add(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganunit.name"),
|
||||
GenericOrganizationalUnit.NAME);
|
||||
sheet.add(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganunit.addendum"),
|
||||
GenericOrganizationalUnit.ADDENDUM);
|
||||
|
||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.ui.authoring.page_launch_date").localize(),
|
||||
ContentPage.LAUNCH_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
ContentPage page = (ContentPage) item;
|
||||
if (page.getLaunchDate() != null) {
|
||||
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
|
||||
} else {
|
||||
return (String) ContenttypesGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return sheet;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.DateParameter;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jensp
|
||||
*/
|
||||
public class GenericOrganizationalUnitPropertyForm extends BasicPageForm
|
||||
implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
||||
|
||||
private final static Logger s_log = Logger.getLogger(GenericOrganizationalUnitPropertyForm.class);
|
||||
private GenericOrganizationalUnitPropertiesStep m_step;
|
||||
public static final String ORGAUNIT_NAME = GenericOrganizationalUnit.ORGAUNIT_NAME;
|
||||
public static final String ADDENDUM = GenericOrganizationalUnit.ADDENDUM;
|
||||
public static final String ID = "GenericOrgaUnit_edit";
|
||||
|
||||
public GenericOrganizationalUnitPropertyForm(ItemSelectionModel itemModel) {
|
||||
this(itemModel, null);
|
||||
}
|
||||
|
||||
public GenericOrganizationalUnitPropertyForm(ItemSelectionModel itemModel,
|
||||
GenericOrganizationalUnitPropertiesStep step) {
|
||||
super(ID, itemModel);
|
||||
m_step = step;
|
||||
addSubmissionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
super.addWidgets();
|
||||
|
||||
add(new Label(
|
||||
(String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorganunit.name").localize()));
|
||||
ParameterModel nameParam = new StringParameter(ORGAUNIT_NAME);
|
||||
TextField name = new TextField(nameParam);
|
||||
add(name);
|
||||
|
||||
add(new Label(
|
||||
(String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.genericorgaunit.addendum").localize()));
|
||||
ParameterModel addendumParam = new StringParameter(ADDENDUM);
|
||||
TextField addendum = new TextField(addendumParam);
|
||||
add(addendum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitted(FormSectionEvent fse) throws FormProcessException {
|
||||
if ((m_step != null)
|
||||
&& getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
|
||||
m_step.cancelStreamlinedCreation(fse.getPageState());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) super.initBasicWidgets(fse);
|
||||
|
||||
data.put(ORGAUNIT_NAME, orgaunit.getOrgaUnitName());
|
||||
data.put(ORGAUNIT_NAME, orgaunit.getAddendum());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) super.processBasicWidgets(fse);
|
||||
|
||||
if ((orgaunit != null)
|
||||
&& getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
|
||||
orgaunit.setOrgaUnitName((String) data.get(ORGAUNIT_NAME));
|
||||
orgaunit.setAddendum((String) data.get(ADDENDUM));
|
||||
|
||||
orgaunit.save();
|
||||
}
|
||||
|
||||
if (m_step != null) {
|
||||
m_step.maybeForwardToNextStep(fse.getPageState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ ccm-cms
|
|||
|
||||
# Content assets
|
||||
ccm-cms-assets-fileattachment
|
||||
ccm-cms-assets-imagestep
|
||||
ccm-cms-assets-notes
|
||||
ccm-cms-assets-relatedlink
|
||||
|
||||
|
|
@ -61,7 +62,7 @@ ccm-user-preferences
|
|||
# -- ccm-ldn-dublin
|
||||
# -- ccm-ldn-exporter
|
||||
# -- ccm-ldn-freeform
|
||||
ccm-ldn-image-step
|
||||
#ccm-ldn-image-step
|
||||
# -- ccm-ldn-importer
|
||||
ccm-ldn-navigation
|
||||
ccm-ldn-portal
|
||||
|
|
|
|||
Loading…
Reference in New Issue