GenericContact
* UI zum Bearbeiten von Personen angepaßt * ContactEntryType verwendet nun RelationAttribute für die Typisierung Diverse kleine Änderungen git-svn-id: https://svn.libreccm.org/ccm/trunk@598 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
478a66f4b9
commit
78f895d701
|
|
@ -8,7 +8,6 @@ import com.arsdigita.domain.DomainCollection;
|
|||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.Filter;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -67,15 +67,15 @@ cms.contenttypes.ui.contact.contactEntry.value=Inhalt
|
|||
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.phone_private=Telefon (Privat)
|
||||
cms.contenttypes.ui.contact.contactEntry.key.phone_mobile=Telefon (Mobil)
|
||||
cms.contenttypes.ui.contact.contactEntry.key.email=E-Mail
|
||||
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.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.phone_private=Telefon (Privat)
|
||||
#cms.contenttypes.ui.contact.contactEntry.key.phone_mobile=Telefon (Mobil)
|
||||
#cms.contenttypes.ui.contact.contactEntry.key.email=E-Mail
|
||||
#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.contact.contactEntry.none=Zur Zeit sind keine Kontaktinformationen vorhanden
|
||||
|
|
|
|||
|
|
@ -42,18 +42,19 @@ public class GenericContact extends ContentPage implements
|
|||
// public static final String CONTACT_TYPE = "";
|
||||
public static final String ADDRESS = "address";
|
||||
public static final String CONTACT_ENTRIES = "contactentries";
|
||||
private static final String RELATION_ATTRIBUTES =
|
||||
"GenericContactType;GenericContactEntryType";
|
||||
public static final String CONTACTS_KEY = GenericPersonContactCollection.CONTACTS_KEY;
|
||||
private static final String RELATION_ATTRIBUTES = "GenericContactType;GenericContactEntryType";
|
||||
|
||||
// Config
|
||||
private static final GenericContactConfig s_config =
|
||||
new GenericContactConfig();
|
||||
new GenericContactConfig();
|
||||
|
||||
static {
|
||||
s_config.load();
|
||||
}
|
||||
/** Data object type for tihs domain object */
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.contenttypes.GenericContact";
|
||||
"com.arsdigita.cms.contenttypes.GenericContact";
|
||||
|
||||
public GenericContact() {
|
||||
super(BASE_DATA_OBJECT_TYPE);
|
||||
|
|
@ -114,7 +115,7 @@ public class GenericContact extends ContentPage implements
|
|||
}
|
||||
|
||||
// Set the person for this contact
|
||||
public void setPerson(GenericPerson person) {
|
||||
public void setPerson(GenericPerson person, String contactType) {
|
||||
//set(PERSON, person);
|
||||
if (getPerson() != null) {
|
||||
unsetPerson();
|
||||
|
|
@ -123,8 +124,8 @@ public class GenericContact extends ContentPage implements
|
|||
if (person != null) {
|
||||
Assert.exists(person, GenericPerson.class);
|
||||
DataObject link = add(PERSON, person);
|
||||
link.set(GenericPerson.CONTACTS_ORDER,
|
||||
new BigDecimal(person.getContacts().size()));
|
||||
link.set(GenericPerson.CONTACTS_KEY, contactType);
|
||||
link.set(GenericPerson.CONTACTS_ORDER, new BigDecimal(person.getContacts().size()));
|
||||
link.save();
|
||||
}
|
||||
}
|
||||
|
|
@ -182,6 +183,30 @@ public class GenericContact extends ContentPage implements
|
|||
remove(CONTACT_ENTRIES, contactEntry);
|
||||
}
|
||||
|
||||
public String getContactType() {
|
||||
|
||||
GenericPerson person = getPerson();
|
||||
|
||||
if(person != null) {
|
||||
GenericPersonContactCollection collection = person.getContacts();
|
||||
collection.next();
|
||||
return (String) collection.getContactType();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setContactType(String contactType) {
|
||||
|
||||
GenericPerson person = getPerson();
|
||||
if(person != null) {
|
||||
GenericPersonContactCollection collection = person.getContacts();
|
||||
collection.next();
|
||||
DataObject link = (DataObject) collection.get("link");
|
||||
link.set(CONTACTS_KEY, contactType);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPerson() {
|
||||
return !(this.getPerson() == null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@ import com.arsdigita.persistence.DataCollection;
|
|||
*/
|
||||
public class GenericContactTypeCollection extends RelationAttributeCollection {
|
||||
|
||||
public static final String CONTACTS_KEY = GenericPerson.CONTACTS_KEY;
|
||||
public static final String CONTACTS_ORDER = GenericPerson.CONTACTS_ORDER;
|
||||
public static final String ATTRIBUTE_NAME = "person";
|
||||
public static final String ATTRIBUTE_NAME = "GenericContactTypes";
|
||||
|
||||
/**
|
||||
* Creates a new instance of GenericContactEntryCollection
|
||||
|
|
@ -28,18 +26,10 @@ public class GenericContactTypeCollection extends RelationAttributeCollection {
|
|||
}
|
||||
|
||||
public GenericContactTypeCollection(String key) {
|
||||
super(ATTRIBUTE_NAME, CONTACTS_KEY);
|
||||
super(ATTRIBUTE_NAME, key);
|
||||
}
|
||||
|
||||
public GenericContactTypeCollection(DataCollection dataCollection) {
|
||||
super(dataCollection);
|
||||
}
|
||||
|
||||
// public void setContactOrder(String contact_order) {
|
||||
// set(CONTACT_ORDER, contact_order);
|
||||
// }
|
||||
|
||||
public String getContactOrder() {
|
||||
return (String) get(CONTACTS_ORDER);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
|
|||
|
||||
// GenericContact type field
|
||||
add(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.type")));
|
||||
ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACTS_KEY);
|
||||
ParameterModel contactTypeParam = new StringParameter(CONTACTS_KEY);
|
||||
SingleSelect contactType = new SingleSelect(contactTypeParam);
|
||||
contactType.addValidationListener(new NotNullValidationListener());
|
||||
contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
|
||||
|
|
@ -117,7 +117,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
|
|||
|
||||
if (contact != null) {
|
||||
data.put(ITEM_SEARCH, contact.getPerson());
|
||||
// data.put(CONTACTS_KEY, contact.getContactType());
|
||||
data.put(CONTACTS_KEY, contact.getContactType());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,8 +127,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
|
|||
GenericContact contact = (GenericContact) getItemSelectionModel().getSelectedObject(state);
|
||||
|
||||
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
|
||||
contact.setPerson((GenericPerson) data.get(ITEM_SEARCH));
|
||||
// contact.setContactType(data.get(CONTACTS_KEY));
|
||||
contact.setPerson((GenericPerson) data.get(ITEM_SEARCH), (String) data.get(CONTACTS_KEY));
|
||||
}
|
||||
init(fse);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,16 +15,22 @@ 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.Option;
|
||||
import com.arsdigita.bebop.form.SingleSelect;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.RelationAttribute;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||
import com.arsdigita.cms.contenttypes.GenericContactTypeCollection;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -36,10 +42,13 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm implemen
|
|||
|
||||
private static final Logger logger = Logger.getLogger(GenericContactPropertyForm.class);
|
||||
private GenericContactPersonPropertiesStep m_step;
|
||||
|
||||
public static final String SURNAME = GenericPerson.SURNAME;
|
||||
public static final String GIVENNAME = GenericPerson.GIVENNAME;
|
||||
public static final String TITLEPRE = GenericPerson.TITLEPRE;
|
||||
public static final String TITLEPOST = GenericPerson.TITLEPOST;
|
||||
public static final String CONTACTS_KEY = GenericPersonContactCollection.CONTACTS_KEY;
|
||||
|
||||
/**
|
||||
* ID of the form
|
||||
*/
|
||||
|
|
@ -93,6 +102,24 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm implemen
|
|||
titlepostParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
|
||||
TextField titlepost = new TextField(titlepostParam);
|
||||
add(titlepost);
|
||||
|
||||
// GenericContact type field
|
||||
add(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.type")));
|
||||
ParameterModel contactTypeParam = new StringParameter(CONTACTS_KEY);
|
||||
SingleSelect contactType = new SingleSelect(contactTypeParam);
|
||||
contactType.addValidationListener(new NotNullValidationListener());
|
||||
contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
|
||||
|
||||
// Add the Options to the SingleSelect widget
|
||||
GenericContactTypeCollection contacttypes = new GenericContactTypeCollection();
|
||||
contacttypes.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().getLanguage());
|
||||
|
||||
while (contacttypes.next()) {
|
||||
RelationAttribute ct = contacttypes.getRelationAttribute();
|
||||
contactType.addOption(new Option(ct.getKey(), ct.getName()));
|
||||
}
|
||||
|
||||
add(contactType);
|
||||
}
|
||||
|
||||
public void init(FormSectionEvent fse) {
|
||||
|
|
@ -105,6 +132,7 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm implemen
|
|||
data.put(GIVENNAME, contact.getPerson().getGivenName());
|
||||
data.put(TITLEPRE, contact.getPerson().getTitlePre());
|
||||
data.put(TITLEPOST, contact.getPerson().getTitlePost());
|
||||
// data.put(CONTACTS_KEY, contact.getContactType());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -122,16 +150,17 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm implemen
|
|||
|
||||
if (getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
|
||||
|
||||
if (contact.getPerson() == null) {
|
||||
contact.setPerson(new GenericPerson());
|
||||
contact.getPerson().setName("Person for " + contact.getName() + "(" + contact.getID() + ")");
|
||||
contact.getPerson().setTitle("Person for " + contact.getName() + "(" + contact.getID() + ")");
|
||||
}
|
||||
// if (contact.getPerson() == null) {
|
||||
// contact.setPerson(new GenericPerson());
|
||||
// contact.getPerson().setName("Person for " + contact.getName() + "(" + contact.getID() + ")");
|
||||
// contact.getPerson().setTitle("Person for " + contact.getName() + "(" + contact.getID() + ")");
|
||||
// }
|
||||
|
||||
contact.getPerson().setSurname((String) data.get(SURNAME));
|
||||
contact.getPerson().setGivenName((String) data.get(GIVENNAME));
|
||||
contact.getPerson().setTitlePre((String) data.get(TITLEPRE));
|
||||
contact.getPerson().setTitlePost((String) data.get(TITLEPOST));
|
||||
// contact.setContactType((String) data.get(CONTACTS_KEY));
|
||||
|
||||
contact.getPerson().save();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,9 +35,11 @@ import com.arsdigita.cms.SecurityManager;
|
|||
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||
import com.arsdigita.cms.contenttypes.GenericContactEntry;
|
||||
import com.arsdigita.cms.contenttypes.GenericContactEntryCollection;
|
||||
import com.arsdigita.cms.contenttypes.GenericContactEntryKeys;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
|
@ -46,39 +48,37 @@ import java.math.BigDecimal;
|
|||
*
|
||||
* @author Sören Bernstein (quasimodo) quasi@barkhof.uni-bremen.de
|
||||
*/
|
||||
public class GenericContactEntriesTable extends Table implements TableActionListener{
|
||||
|
||||
|
||||
public class GenericContactEntriesTable extends Table implements TableActionListener {
|
||||
|
||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance of GenericContactEntriesTable
|
||||
*/
|
||||
public GenericContactEntriesTable(final ItemSelectionModel itemModel) {
|
||||
|
||||
|
||||
super();
|
||||
this.m_itemModel = itemModel;
|
||||
|
||||
|
||||
// if table is empty:
|
||||
setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.contactEntry.none")));
|
||||
TableColumnModel tab_model = getColumnModel();
|
||||
|
||||
|
||||
// define columns
|
||||
tab_model.add(new TableColumn(0, ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.contactEntry.key").localize(), TABLE_COL_EDIT));
|
||||
tab_model.add(new TableColumn(1, ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.contactEntry.value").localize()));
|
||||
tab_model.add(new TableColumn(2, ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.contactEntry.description").localize()));
|
||||
tab_model.add(new TableColumn(3, ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.contactEntry.action").localize(), TABLE_COL_DEL));
|
||||
|
||||
|
||||
setModelBuilder(new ContactTableModelBuilder(itemModel));
|
||||
|
||||
|
||||
tab_model.get(0).setCellRenderer(new EditCellRenderer());
|
||||
tab_model.get(3).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
|
||||
addTableActionListener(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -86,24 +86,19 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
|||
*
|
||||
*/
|
||||
private class ContactTableModelBuilder extends LockableImpl implements TableModelBuilder {
|
||||
|
||||
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
|
||||
public ContactTableModelBuilder(ItemSelectionModel itemModel) {
|
||||
m_itemModel = itemModel;
|
||||
}
|
||||
|
||||
|
||||
public TableModel makeModel(Table table, PageState state) {
|
||||
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
|
||||
|
||||
GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(state);
|
||||
|
||||
// if (contact != null && contact.hasContactEntries()) {
|
||||
return new ContactTableModel(table, state, contact);
|
||||
// } else {
|
||||
// return Table.EMPTY_MODEL;
|
||||
// }
|
||||
return new ContactTableModel(table, state, contact);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -112,22 +107,21 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
|||
*
|
||||
*/
|
||||
private class ContactTableModel implements TableModel {
|
||||
|
||||
|
||||
final private int MAX_DESC_LENGTH = 25;
|
||||
|
||||
private Table m_table;
|
||||
private GenericContactEntryCollection m_contactEntryCollection;
|
||||
private GenericContactEntry m_contactEntry;
|
||||
|
||||
|
||||
private ContactTableModel(Table t, PageState ps, GenericContact contact) {
|
||||
m_table = t;
|
||||
m_contactEntryCollection = contact.getContactEntries();
|
||||
}
|
||||
|
||||
|
||||
public int getColumnCount() {
|
||||
return m_table.getColumnModel().size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check collection for the existence of another row.
|
||||
*
|
||||
|
|
@ -135,39 +129,44 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
|||
* into m_contactEntry class variable.
|
||||
*/
|
||||
public boolean nextRow() {
|
||||
|
||||
if(m_contactEntryCollection != null && m_contactEntryCollection.next()){
|
||||
|
||||
if (m_contactEntryCollection != null && m_contactEntryCollection.next()) {
|
||||
m_contactEntry = m_contactEntryCollection.getContactEntry();
|
||||
return true;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the
|
||||
* @see com.arsdigita.bebop.table.TableModel#getElementAt(int)
|
||||
*/
|
||||
public Object getElementAt(int columnIndex) {
|
||||
switch (columnIndex){
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return (String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.contactEntry.key." + m_contactEntry.getKey()).localize();
|
||||
GenericContactEntryKeys keys = new GenericContactEntryKeys(m_contactEntry.getKey());
|
||||
keys.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().getLanguage());
|
||||
if (keys.next()) {
|
||||
return keys.getName();
|
||||
}
|
||||
return m_contactEntry.getKey();
|
||||
case 1:
|
||||
return m_contactEntry.getValue();
|
||||
case 2:
|
||||
return (m_contactEntry.getDescription() != null && m_contactEntry.getDescription().length() > MAX_DESC_LENGTH)
|
||||
? m_contactEntry.getDescription().substring(0, MAX_DESC_LENGTH)
|
||||
: m_contactEntry.getDescription();
|
||||
? m_contactEntry.getDescription().substring(0, MAX_DESC_LENGTH)
|
||||
: m_contactEntry.getDescription();
|
||||
case 3:
|
||||
return GlobalizationUtil.globalize("cms.ui.delete").localize();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.arsdigita.bebop.table.TableModel#getKeyAt(int)
|
||||
|
|
@ -175,26 +174,25 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
|||
public Object getKeyAt(int columnIndex) {
|
||||
return m_contactEntry.getID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for the permissions to edit item and put either a Label or
|
||||
* a ControlLink accordingly.
|
||||
*/
|
||||
private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
|
||||
public Component getComponent(Table table, PageState state, Object value,
|
||||
boolean isSelected, Object key,
|
||||
int row, int column) {
|
||||
|
||||
boolean isSelected, Object key,
|
||||
int row, int column) {
|
||||
|
||||
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||
GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(state);
|
||||
|
||||
|
||||
boolean canEdit = sm.canAccess(state.getRequest(),
|
||||
SecurityManager.EDIT_ITEM,
|
||||
contact);
|
||||
if(canEdit) {
|
||||
SecurityManager.EDIT_ITEM,
|
||||
contact);
|
||||
if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
return link;
|
||||
} else {
|
||||
|
|
@ -202,24 +200,24 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for the permissions to delete item and put either a Label or
|
||||
* a ControlLink accordingly.
|
||||
*/
|
||||
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
|
||||
public Component getComponent(Table table, PageState state, Object value,
|
||||
boolean isSelected, Object key,
|
||||
int row, int column) {
|
||||
|
||||
boolean isSelected, Object key,
|
||||
int row, int column) {
|
||||
|
||||
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||
GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(state);
|
||||
|
||||
|
||||
boolean canDelete = sm.canAccess(state.getRequest(),
|
||||
SecurityManager.DELETE_ITEM,
|
||||
contact);
|
||||
if(canDelete) {
|
||||
SecurityManager.DELETE_ITEM,
|
||||
contact);
|
||||
if (canDelete) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.confirm_delete").localize());
|
||||
return link;
|
||||
|
|
@ -228,38 +226,37 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provide implementation to TableActionListener method.
|
||||
* Code that comes into picture when a link on the table is clicked.
|
||||
* Handles edit and delete event.
|
||||
*/
|
||||
public void cellSelected(TableActionEvent evt) {
|
||||
|
||||
|
||||
PageState state = evt.getPageState();
|
||||
|
||||
|
||||
// Get selected GenericContactEntry
|
||||
GenericContactEntry contactEntry =
|
||||
new GenericContactEntry(new BigDecimal(evt.getRowKey().toString()));
|
||||
|
||||
new GenericContactEntry(new BigDecimal(evt.getRowKey().toString()));
|
||||
|
||||
// Get GenericContact
|
||||
GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(state);
|
||||
|
||||
|
||||
// Get selected column
|
||||
TableColumn col = getColumnModel().get(evt.getColumn().intValue());
|
||||
|
||||
|
||||
// Edit
|
||||
if(col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||
|
||||
if (col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||
}
|
||||
|
||||
|
||||
// Delete
|
||||
if(col.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
contact.removeContactEntry(contactEntry);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* provide Implementation to TableActionListener method.
|
||||
* Does nothing in our case.
|
||||
|
|
@ -267,6 +264,4 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
|||
public void headSelected(TableActionEvent e) {
|
||||
throw new UnsupportedOperationException("Not Implemented");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ import com.arsdigita.cms.contenttypes.GenericContactEntry;
|
|||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import java.util.StringTokenizer;
|
||||
import com.arsdigita.cms.contenttypes.GenericContactEntryKeys;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -63,10 +64,11 @@ public class GenericContactEntryAddForm extends BasicItemForm {
|
|||
contactEntryKey.addOption(new Option("", new Label((String)ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
|
||||
|
||||
// Add the Options to the SingleSelect widget
|
||||
StringTokenizer keyList = GenericContact.getConfig().getContactEntryKeys();
|
||||
while(keyList.hasMoreElements()) {
|
||||
String currentKey = keyList.nextToken();
|
||||
contactEntryKey.addOption(new Option(currentKey, ((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.contactEntry.key." + currentKey).localize())));
|
||||
GenericContactEntryKeys keyList = new GenericContactEntryKeys();
|
||||
keyList.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().getLanguage());
|
||||
while(keyList.next()) {
|
||||
String currentKey = keyList.getKey();
|
||||
contactEntryKey.addOption(new Option(currentKey, keyList.getName()));
|
||||
}
|
||||
|
||||
add(contactEntryKey);
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
|
||||
/**
|
||||
|
|
@ -47,50 +45,17 @@ public class GenericContactPersonPropertiesStep extends SimpleEditStep {
|
|||
addPerson = new WorkflowLockedComponentAccess(addPersonSheet, itemModel);
|
||||
add(ADD_PERSON_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.attach_person").localize(), addPerson, addPersonSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
BasicPageForm editPersonSheet = new GenericContactEditPersonPropertyForm(itemModel, this);
|
||||
editPerson = new WorkflowLockedComponentAccess(editPersonSheet, itemModel);
|
||||
add(EDIT_PERSON_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.edit_person").localize(), editPerson, editPersonSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
BasicPageForm deletePersonSheet = new GenericContactDeletePersonForm(itemModel, this);
|
||||
delPerson = new WorkflowLockedComponentAccess(deletePersonSheet, itemModel);
|
||||
add(DELETE_PERSON_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.delete_person").localize(), delPerson, deletePersonSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
/* Set the displayComponent for this step */
|
||||
setDisplayComponent(getPersonPropertySheet(itemModel));
|
||||
|
||||
}
|
||||
|
||||
public static Component getPersonPropertySheet(ItemSelectionModel itemModel) {
|
||||
/*DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||
|
||||
sheet.add(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname"), "person." + GenericPerson.SURNAME);
|
||||
sheet.add(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.givenname"), "person." + GenericPerson.GIVENNAME);
|
||||
sheet.add(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepre"), "person." + GenericPerson.TITLEPRE);
|
||||
sheet.add(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepost"), "person." + GenericPerson.TITLEPOST);*/
|
||||
|
||||
GenericContactPersonSheet sheet = new GenericContactPersonSheet(
|
||||
itemModel);
|
||||
|
||||
GenericContactPersonSheet sheet = new GenericContactPersonSheet(itemModel);
|
||||
return sheet;
|
||||
}
|
||||
|
||||
public static Component getEmptyPersonPropertySheet(ItemSelectionModel itemModel) {
|
||||
return new Label(((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.emptyPerson").localize()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(PageState ps) {
|
||||
|
||||
if(((GenericContact) getItemSelectionModel().getSelectedItem(ps)).hasPerson() == false) {
|
||||
addPerson.getComponent().setVisible(ps, true);
|
||||
editPerson.getComponent().setVisible(ps, false);
|
||||
delPerson.getComponent().setVisible(ps, false);
|
||||
} else {
|
||||
addPerson.getComponent().setVisible(ps, false);
|
||||
editPerson.getComponent().setVisible(ps, true);
|
||||
delPerson.getComponent().setVisible(ps, true);
|
||||
}
|
||||
|
||||
return super.isVisible(ps);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package com.arsdigita.cms.contenttypes.ui;
|
|||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
|
|
@ -31,13 +32,18 @@ import com.arsdigita.bebop.table.TableColumn;
|
|||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -93,11 +99,10 @@ public class GenericContactPersonSheet
|
|||
@Override
|
||||
public TableModel makeModel(Table table, PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
GenericContact contact = (GenericContact) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(state);
|
||||
return new GenericContactPersonSheetModel(table,
|
||||
state,
|
||||
contact);
|
||||
state,
|
||||
contact);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -108,8 +113,8 @@ public class GenericContactPersonSheet
|
|||
private boolean m_done;
|
||||
|
||||
public GenericContactPersonSheetModel(Table table,
|
||||
PageState state,
|
||||
GenericContact contact) {
|
||||
PageState state,
|
||||
GenericContact contact) {
|
||||
m_table = table;
|
||||
m_person = contact.getPerson();
|
||||
if (m_person == null) {
|
||||
|
|
@ -119,7 +124,7 @@ public class GenericContactPersonSheet
|
|||
}
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
public int getColumnCount() {
|
||||
return m_table.getColumnModel().size();
|
||||
}
|
||||
|
||||
|
|
@ -160,14 +165,40 @@ public class GenericContactPersonSheet
|
|||
|
||||
@Override
|
||||
public Component getComponent(Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int column) {
|
||||
Label label = new Label(value.toString());
|
||||
return label;
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int column) {
|
||||
|
||||
com.arsdigita.cms.SecurityManager securityManager = Utilities.getSecurityManager(state);
|
||||
GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
|
||||
contact);
|
||||
|
||||
if (canEdit) {
|
||||
GenericPerson person;
|
||||
|
||||
try {
|
||||
person = new GenericPerson((BigDecimal) key);
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
|
||||
ContentSection section = CMS.getContext().getContentSection();
|
||||
ItemResolver resolver = section.getItemResolver();
|
||||
|
||||
return new Link(value.toString(), resolver.generateItemURL(state, person, section, person.getVersion()));
|
||||
|
||||
} else {
|
||||
|
||||
return new Label(value.toString());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -177,16 +208,15 @@ public class GenericContactPersonSheet
|
|||
|
||||
@Override
|
||||
public Component getComponent(Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
SecurityManager securityManager =
|
||||
Utilities.getSecurityManager(state);
|
||||
GenericContact contact = (GenericContact) m_itemModel.
|
||||
getSelectedObject(
|
||||
Utilities.getSecurityManager(state);
|
||||
GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(
|
||||
|
|
@ -196,8 +226,7 @@ public class GenericContactPersonSheet
|
|||
|
||||
if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) ContenttypesGlobalizationUtil.
|
||||
globalize(
|
||||
link.setConfirmation((String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.contact.person"
|
||||
+ ".confirm_remove").
|
||||
localize());
|
||||
|
|
@ -209,7 +238,7 @@ public class GenericContactPersonSheet
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void cellSelected(TableActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package com.arsdigita.cms.ui.category;
|
|||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.bebop.Table;
|
||||
|
|
@ -34,9 +35,13 @@ import com.arsdigita.bebop.table.TableModelBuilder;
|
|||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.categorization.CategoryLocalization;
|
||||
import com.arsdigita.categorization.CategoryLocalizationCollection;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
|
|
@ -50,49 +55,48 @@ import java.util.Locale;
|
|||
* @author Sören Bernstein (quasimodo) quasi@zes.uni-bremen.de
|
||||
*/
|
||||
public class CategoryLocalizationTable extends Table implements TableActionListener {
|
||||
|
||||
|
||||
private final CategoryRequestLocal m_category;
|
||||
private final SingleSelectionModel m_model;
|
||||
|
||||
private final String TABLE_COL_LANG = "table_col_lang";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
|
||||
/**
|
||||
* Creates a new instance of CategoryLocalizationTable
|
||||
*/
|
||||
public CategoryLocalizationTable(final CategoryRequestLocal category,
|
||||
final SingleSelectionModel model) {
|
||||
|
||||
|
||||
super();
|
||||
|
||||
|
||||
m_category = category;
|
||||
m_model = model;
|
||||
|
||||
|
||||
// if table is empty:
|
||||
setEmptyView(new Label(GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_none")));
|
||||
"cms.ui.category.localization_none")));
|
||||
TableColumnModel tab_model = getColumnModel();
|
||||
|
||||
|
||||
// define columns
|
||||
// XXX globalize
|
||||
tab_model.add(new TableColumn(0, GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization.locale").localize(), TABLE_COL_LANG));
|
||||
"cms.ui.category.localization.locale").localize(), TABLE_COL_LANG));
|
||||
tab_model.add(new TableColumn(1, GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_name").localize()));
|
||||
"cms.ui.category.localization_name").localize()));
|
||||
tab_model.add(new TableColumn(2, GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_description").localize()));
|
||||
"cms.ui.category.localization_description").localize()));
|
||||
tab_model.add(new TableColumn(3, GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_url").localize()));
|
||||
"cms.ui.category.localization_url").localize()));
|
||||
tab_model.add(new TableColumn(4, GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_action").localize(), TABLE_COL_DEL));
|
||||
|
||||
"cms.ui.category.localization_action").localize(), TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(new CategoryLocalizationTableModelBuilder());
|
||||
|
||||
|
||||
tab_model.get(0).setCellRenderer(new EditCellRenderer());
|
||||
tab_model.get(4).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
|
||||
addTableActionListener(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -101,10 +105,10 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
|
|||
*/
|
||||
private class CategoryLocalizationTableModelBuilder extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
|
||||
public TableModel makeModel(Table table, PageState state) {
|
||||
final Category category = m_category.getCategory(state);
|
||||
|
||||
|
||||
if (category != null && category.hasLocalizations()) {
|
||||
return new CategoryLocalizationTableModel(table, state, category);
|
||||
} else {
|
||||
|
|
@ -118,22 +122,21 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
|
|||
*
|
||||
*/
|
||||
private class CategoryLocalizationTableModel implements TableModel {
|
||||
|
||||
|
||||
final private int MAX_DESC_LENGTH = 25;
|
||||
|
||||
private Table m_table;
|
||||
private CategoryLocalizationCollection m_categoryLocalizations;
|
||||
private CategoryLocalization m_categoryLocalization;
|
||||
|
||||
|
||||
private CategoryLocalizationTableModel(Table t, PageState ps, Category category) {
|
||||
m_table = t;
|
||||
m_categoryLocalizations = new CategoryLocalizationCollection(category);
|
||||
}
|
||||
|
||||
|
||||
public int getColumnCount() {
|
||||
return m_table.getColumnModel().size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check collection for the existence of another row.
|
||||
*
|
||||
|
|
@ -141,24 +144,24 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
|
|||
* into m_categoryLocalization class variable.
|
||||
*/
|
||||
public boolean nextRow() {
|
||||
|
||||
if(m_categoryLocalizations != null && m_categoryLocalizations.next()){
|
||||
|
||||
if (m_categoryLocalizations != null && m_categoryLocalizations.next()) {
|
||||
m_categoryLocalization = m_categoryLocalizations.getCategoryLocalization();
|
||||
return true;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the
|
||||
* @see com.arsdigita.bebop.table.TableModel#getElementAt(int)
|
||||
*/
|
||||
public Object getElementAt(int columnIndex) {
|
||||
switch (columnIndex){
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
Locale clLocale = new Locale(m_categoryLocalization.getLocale());
|
||||
return clLocale.getDisplayLanguage(/*Locale*/);
|
||||
|
|
@ -166,19 +169,19 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
|
|||
return m_categoryLocalization.getName();
|
||||
case 2:
|
||||
String desc = m_categoryLocalization.getDescription();
|
||||
if(desc != null && desc.length() > MAX_DESC_LENGTH)
|
||||
if (desc != null && desc.length() > MAX_DESC_LENGTH) {
|
||||
desc = desc.substring(MAX_DESC_LENGTH - 3).concat("...");
|
||||
}
|
||||
return desc;
|
||||
case 3:
|
||||
return m_categoryLocalization.getURL();
|
||||
case 4:
|
||||
return GlobalizationUtil.globalize("cms.ui.delete").localize();
|
||||
// return "Delete";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.arsdigita.bebop.table.TableModel#getKeyAt(int)
|
||||
|
|
@ -186,97 +189,76 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
|
|||
public Object getKeyAt(int columnIndex) {
|
||||
return m_categoryLocalization.getID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for the permissions to edit item and put either a Label or
|
||||
* a ControlLink accordingly.
|
||||
*/
|
||||
|
||||
private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
|
||||
public Component getComponent(Table table, PageState state, Object value,
|
||||
boolean isSelected, Object key,
|
||||
int row, int column) {
|
||||
|
||||
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||
// CategoryLocalization cl =
|
||||
// (CategoryLocalization) m_clSel.getSelectedObject(state);
|
||||
|
||||
// boolean canEdit = sm.canAccess(state.getRequest(),
|
||||
// SecurityManager.DELETE_ITEM,
|
||||
// cl);
|
||||
|
||||
//
|
||||
// if (canEdit) {
|
||||
if (true) {
|
||||
// CategoryLocalization cl;
|
||||
//
|
||||
// try {
|
||||
// cl = new CategoryLocalization((BigDecimal) key);
|
||||
// } catch (DataObjectNotFoundException ex) {
|
||||
// return new Label(value.toString());
|
||||
// }
|
||||
//
|
||||
// ContentSection section = CMS.getContext().getContentSection();
|
||||
// ItemResolver resolver = section.getItemResolver();
|
||||
//
|
||||
// return new Link(value.toString(), resolver.generateItemURL(state, cl, section, cl.getVersion()));
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for the permissions to delete item and put either a Label or
|
||||
* a ControlLink accordingly.
|
||||
*/
|
||||
|
||||
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
|
||||
public Component getComponent(Table table, PageState state, Object value,
|
||||
boolean isSelected, Object key,
|
||||
int row, int column) {
|
||||
|
||||
// SecurityManager sm = Utilities.getSecurityManager(state);
|
||||
// CategoryLocalization categoryLocalization =
|
||||
// new CategoryLocalization(new BigDecimal(evt.getRowKey().toString()));
|
||||
|
||||
// boolean canDelete = sm.canAccess(state.getRequest(),
|
||||
// SecurityManager.DELETE_ITEM,
|
||||
// categoryLocalization);
|
||||
// if (canDelete) {
|
||||
if (true) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_confirm_delete").localize());
|
||||
// link.setConfirmation("Delete this localization?");
|
||||
return link;
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_confirm_delete").localize());
|
||||
return link;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provide implementation to TableActionListener method.
|
||||
* Code that comes into picture when a link on the table is clicked.
|
||||
* Handles edit and delete event.
|
||||
*/
|
||||
public void cellSelected(TableActionEvent evt) {
|
||||
|
||||
|
||||
PageState state = evt.getPageState();
|
||||
|
||||
|
||||
// Get selected CategoryLocalization
|
||||
CategoryLocalization categoryLocalization =
|
||||
new CategoryLocalization(new BigDecimal(evt.getRowKey().toString()));
|
||||
|
||||
new CategoryLocalization(new BigDecimal(evt.getRowKey().toString()));
|
||||
|
||||
// Get Category
|
||||
Category category = m_category.getCategory(state);
|
||||
|
||||
|
||||
// Get selected column
|
||||
TableColumn col = getColumnModel().get(evt.getColumn().intValue());
|
||||
|
||||
|
||||
// Edit
|
||||
if(col.getHeaderKey().toString().equals(TABLE_COL_LANG)) {
|
||||
|
||||
if (col.getHeaderKey().toString().equals(TABLE_COL_LANG)) {
|
||||
}
|
||||
|
||||
|
||||
// Delete
|
||||
if(col.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
category.delLanguage(categoryLocalization.getLocale());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* provide Implementation to TableActionListener method.
|
||||
* Does nothing in our case.
|
||||
|
|
@ -284,6 +266,4 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
|
|||
public void headSelected(TableActionEvent e) {
|
||||
throw new UnsupportedOperationException("Not Implemented");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue