Contact informations can now be edited
git-svn-id: https://svn.libreccm.org/ccm/trunk@4125 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
b1a35b0ed9
commit
1320957bfc
|
|
@ -173,3 +173,4 @@ cms.ui.edit_assoc=Edit
|
||||||
cms.contenttypes.ui.person.contact.type=Contact Type
|
cms.contenttypes.ui.person.contact.type=Contact Type
|
||||||
cms.contenttypes.ui.person.contact.title=Title
|
cms.contenttypes.ui.person.contact.title=Title
|
||||||
cms.contenttypes.ui.contact.person.confirm_remove=Remove address
|
cms.contenttypes.ui.contact.person.confirm_remove=Remove address
|
||||||
|
cms.contenttypes.ui.contact.contactEntry.edit=Edit
|
||||||
|
|
|
||||||
|
|
@ -183,3 +183,4 @@ cms.ui.edit_assoc=Bearbeiten
|
||||||
cms.contenttypes.ui.person.contact.type=Art des Kontaktes
|
cms.contenttypes.ui.person.contact.type=Art des Kontaktes
|
||||||
cms.contenttypes.ui.person.contact.title=Titel
|
cms.contenttypes.ui.person.contact.title=Titel
|
||||||
cms.contenttypes.ui.contact.person.confirm_remove=Addresse l\u00f6schen
|
cms.contenttypes.ui.contact.person.confirm_remove=Addresse l\u00f6schen
|
||||||
|
cms.contenttypes.ui.contact.contactEntry.edit=Bearbeiten
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
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;
|
||||||
|
import com.arsdigita.bebop.ActionLink;
|
||||||
|
import com.arsdigita.bebop.BoxPanel;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ui.ControlButton;
|
||||||
|
import com.arsdigita.bebop.event.ActionListener;
|
||||||
|
import com.arsdigita.bebop.event.ActionEvent;
|
||||||
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Panel for managing contact informations
|
||||||
|
*/
|
||||||
|
public class GenericContactEntriesEditor extends BoxPanel {
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
private final AuthoringKitWizard parent;
|
||||||
|
private final StringParameter selectedEntryParam;
|
||||||
|
private final ParameterSingleSelectionModel selectedEntry;
|
||||||
|
private final Form contactEntryForm;
|
||||||
|
private final GenericContactEntriesTable contactEntriesTable;
|
||||||
|
|
||||||
|
public GenericContactEntriesEditor(final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent) {
|
||||||
|
super(BoxPanel.VERTICAL);
|
||||||
|
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
this.parent = parent;
|
||||||
|
selectedEntryParam = new StringParameter("selectedContactEntry");
|
||||||
|
selectedEntry = new ParameterSingleSelectionModel(selectedEntryParam);
|
||||||
|
|
||||||
|
contactEntryForm = new Form("contactEntryForm");
|
||||||
|
contactEntryForm.add(new GenericContactEntryAddForm(itemModel, this, selectedEntry));
|
||||||
|
add(contactEntryForm);
|
||||||
|
|
||||||
|
contactEntriesTable = new GenericContactEntriesTable(itemModel,
|
||||||
|
this,
|
||||||
|
selectedEntry);
|
||||||
|
add(contactEntriesTable);
|
||||||
|
|
||||||
|
final ActionLink addButton = new AddButton();
|
||||||
|
addButton.addActionListener(
|
||||||
|
new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(final ActionEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
showContactEntryForm(state);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add(addButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(final Page page) {
|
||||||
|
super.register(page);
|
||||||
|
|
||||||
|
page.addGlobalStateParam(selectedEntryParam);
|
||||||
|
|
||||||
|
page.setVisibleDefault(contactEntriesTable, true);
|
||||||
|
page.setVisibleDefault(contactEntryForm, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void showContactEntryForm(final PageState state) {
|
||||||
|
contactEntryForm.setVisible(state, true);
|
||||||
|
contactEntriesTable.setVisible(state, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void hideContactEntryForm(final PageState state) {
|
||||||
|
contactEntryForm.setVisible(state, false);
|
||||||
|
contactEntriesTable.setVisible(state, true);
|
||||||
|
|
||||||
|
selectedEntry.clearSelection(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class AddButton extends ActionLink {
|
||||||
|
|
||||||
|
public AddButton() {
|
||||||
|
super(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||||
|
"cms.contenttypes.ui.contact.add_contactEntry")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisible(final PageState state) {
|
||||||
|
if (super.isVisible(state)) {
|
||||||
|
final SecurityManager securityManager =
|
||||||
|
Utilities.getSecurityManager(state);
|
||||||
|
final ContentItem item = (ContentItem) itemModel.getSelectedObject(state);
|
||||||
|
|
||||||
|
return securityManager.canAccess(state.getRequest(),
|
||||||
|
SecurityManager.EDIT_ITEM,
|
||||||
|
item);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -25,51 +25,43 @@ import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
|
|
||||||
/**
|
|
||||||
* A UI step to manipulate <code>Phones </code> for the Contact object
|
|
||||||
* which is retrieved from the ItemSelectionModel.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author Shashin Shinde <a href="mailto:sshinde@redhat.com">sshinde@redhat.com</a>
|
|
||||||
* @version $Id: PhoBaseContactEntriesPropertiesStepva 287 2005-02-22 00:29:02Z sskracic $
|
|
||||||
*/
|
|
||||||
public class GenericContactEntriesPropertiesStep extends SimpleEditStep {
|
public class GenericContactEntriesPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
/** The name of the editing sheet added to this step */
|
/** The name of the editing sheet added to this step */
|
||||||
private static String ADD_CONTACT_ENTRY_SHEET_NAME = "addContactEntry";
|
private static String ADD_CONTACT_ENTRY_SHEET_NAME = "addContactEntry";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param itemModel
|
* @param itemModel
|
||||||
* @param parent
|
* @param parent
|
||||||
*/
|
*/
|
||||||
public GenericContactEntriesPropertiesStep(ItemSelectionModel itemModel,
|
public GenericContactEntriesPropertiesStep(ItemSelectionModel itemModel,
|
||||||
AuthoringKitWizard parent) {
|
AuthoringKitWizard parent) {
|
||||||
this(itemModel, parent, null);
|
this(itemModel, parent, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param itemModel
|
* @param itemModel
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param prefix
|
* @param prefix
|
||||||
*/
|
*/
|
||||||
public GenericContactEntriesPropertiesStep(ItemSelectionModel itemModel,
|
public GenericContactEntriesPropertiesStep(ItemSelectionModel itemModel,
|
||||||
AuthoringKitWizard parent,
|
AuthoringKitWizard parent,
|
||||||
String prefix) {
|
String prefix) {
|
||||||
super(itemModel, parent, prefix);
|
super(itemModel, parent, prefix);
|
||||||
|
|
||||||
BasicItemForm addContactEntrySheet = new GenericContactEntryAddForm(itemModel);
|
BasicItemForm addContactEntrySheet = new GenericContactEntryAddForm(itemModel);
|
||||||
add(ADD_CONTACT_ENTRY_SHEET_NAME,
|
add(ADD_CONTACT_ENTRY_SHEET_NAME,
|
||||||
ContenttypesGlobalizationUtil.globalize(
|
ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.contact.add_contactEntry"),
|
"cms.contenttypes.ui.contact.add_contactEntry"),
|
||||||
new WorkflowLockedComponentAccess(addContactEntrySheet,
|
new WorkflowLockedComponentAccess(addContactEntrySheet,
|
||||||
itemModel),
|
itemModel),
|
||||||
addContactEntrySheet.getSaveCancelSection().getCancelButton());
|
addContactEntrySheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
GenericContactEntriesTable contactEntriesTable = new GenericContactEntriesTable(itemModel);
|
GenericContactEntriesTable contactEntriesTable = new GenericContactEntriesTable(itemModel);
|
||||||
setDisplayComponent(contactEntriesTable);
|
setDisplayComponent(contactEntriesTable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
import com.arsdigita.util.LockableImpl;
|
import com.arsdigita.util.LockableImpl;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all existing contact entries for a selected contact.
|
* Lists all existing contact entries for a selected contact.
|
||||||
|
|
@ -50,13 +51,21 @@ import java.math.BigDecimal;
|
||||||
*/
|
*/
|
||||||
public class GenericContactEntriesTable extends Table implements TableActionListener {
|
public class GenericContactEntriesTable extends Table implements TableActionListener {
|
||||||
|
|
||||||
|
private final int COL_KEY = 0;
|
||||||
|
private final int COL_VALUE = 1;
|
||||||
|
private final int COL_DESC = 2;
|
||||||
|
private final int COL_EDIT = 3;
|
||||||
|
private final int COL_DEL = 4;
|
||||||
|
|
||||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
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;
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private GenericContactEntriesEditor m_editor;
|
||||||
|
private ParameterSingleSelectionModel m_selectedEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of GenericContactEntriesTable.
|
* Creates a new instance of GenericContactEntriesTable.
|
||||||
*
|
*
|
||||||
* @param itemModel
|
* @param itemModel
|
||||||
*/
|
*/
|
||||||
public GenericContactEntriesTable(final ItemSelectionModel itemModel) {
|
public GenericContactEntriesTable(final ItemSelectionModel itemModel) {
|
||||||
|
|
@ -71,33 +80,45 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
||||||
|
|
||||||
// define columns
|
// define columns
|
||||||
tab_model.add(new TableColumn(
|
tab_model.add(new TableColumn(
|
||||||
0,
|
COL_KEY,
|
||||||
new Label(ContenttypesGlobalizationUtil.globalize(
|
new Label(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.contact.contactEntry.key")),
|
"cms.contenttypes.ui.contact.contactEntry.key"))));
|
||||||
TABLE_COL_EDIT));
|
|
||||||
tab_model.add(new TableColumn(
|
tab_model.add(new TableColumn(
|
||||||
1,
|
COL_VALUE,
|
||||||
new Label(ContenttypesGlobalizationUtil.globalize(
|
new Label(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.contact.contactEntry.value"))));
|
"cms.contenttypes.ui.contact.contactEntry.value"))));
|
||||||
tab_model.add(new TableColumn(
|
tab_model.add(new TableColumn(
|
||||||
2,
|
COL_DESC,
|
||||||
new Label(ContenttypesGlobalizationUtil.globalize(
|
new Label(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.contact.contactEntry.description"))));
|
"cms.contenttypes.ui.contact.contactEntry.description"))));
|
||||||
tab_model.add(new TableColumn(
|
tab_model.add(new TableColumn(
|
||||||
3,
|
COL_EDIT,
|
||||||
|
new Label(ContenttypesGlobalizationUtil.globalize(
|
||||||
|
"cms.contenttypes.ui.contact.contactEntry.edit"))));
|
||||||
|
tab_model.add(new TableColumn(
|
||||||
|
COL_DEL,
|
||||||
new Label(ContenttypesGlobalizationUtil.globalize(
|
new Label(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.contact.contactEntry.action")),
|
"cms.contenttypes.ui.contact.contactEntry.action")),
|
||||||
TABLE_COL_DEL));
|
TABLE_COL_DEL));
|
||||||
|
|
||||||
setModelBuilder(new ContactTableModelBuilder(itemModel));
|
setModelBuilder(new ContactTableModelBuilder(itemModel));
|
||||||
|
|
||||||
tab_model.get(0).setCellRenderer(new EditCellRenderer());
|
tab_model.get(COL_EDIT).setCellRenderer(new EditCellRenderer());
|
||||||
tab_model.get(3).setCellRenderer(new DeleteCellRenderer());
|
tab_model.get(COL_DEL).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
|
||||||
addTableActionListener(this);
|
addTableActionListener(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GenericContactEntriesTable(final ItemSelectionModel itemModel,
|
||||||
|
final GenericContactEntriesEditor editor,
|
||||||
|
final ParameterSingleSelectionModel selectedEntry) {
|
||||||
|
this(itemModel);
|
||||||
|
|
||||||
|
m_editor = editor;
|
||||||
|
m_selectedEntry = selectedEntry;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XXXX
|
* XXXX
|
||||||
*
|
*
|
||||||
|
|
@ -144,7 +165,7 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check collection for the existence of another row.
|
* Check collection for the existence of another row.
|
||||||
*
|
*
|
||||||
* If exists, fetch the value of current GenericContactEntryCollection object
|
* If exists, fetch the value of current GenericContactEntryCollection object
|
||||||
* into m_contactEntry class variable.
|
* into m_contactEntry class variable.
|
||||||
*/
|
*/
|
||||||
|
|
@ -168,7 +189,7 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(int columnIndex) {
|
public Object getElementAt(int columnIndex) {
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0:
|
case COL_KEY:
|
||||||
GenericContactEntryKeys keys = new GenericContactEntryKeys(m_contactEntry.getKey());
|
GenericContactEntryKeys keys = new GenericContactEntryKeys(m_contactEntry.getKey());
|
||||||
keys.addLanguageFilter(
|
keys.addLanguageFilter(
|
||||||
GlobalizationHelper.getNegotiatedLocale()
|
GlobalizationHelper.getNegotiatedLocale()
|
||||||
|
|
@ -182,15 +203,17 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
return m_contactEntry.getKey();
|
return m_contactEntry.getKey();
|
||||||
case 1:
|
case COL_VALUE:
|
||||||
return m_contactEntry.getValue();
|
return m_contactEntry.getValue();
|
||||||
case 2:
|
case COL_DESC:
|
||||||
return (m_contactEntry.getDescription() != null
|
return (m_contactEntry.getDescription() != null
|
||||||
&& m_contactEntry.getDescription().length() > MAX_DESC_LENGTH)
|
&& m_contactEntry.getDescription().length() > MAX_DESC_LENGTH)
|
||||||
? m_contactEntry.getDescription().substring(
|
? m_contactEntry.getDescription().substring(
|
||||||
0, MAX_DESC_LENGTH)
|
0, MAX_DESC_LENGTH)
|
||||||
: m_contactEntry.getDescription();
|
: m_contactEntry.getDescription();
|
||||||
case 3:
|
case COL_EDIT:
|
||||||
|
return new Label(GlobalizationUtil.globalize("cms.ui.edit"));
|
||||||
|
case COL_DEL:
|
||||||
return new Label(GlobalizationUtil.globalize("cms.ui.delete"));
|
return new Label(GlobalizationUtil.globalize("cms.ui.delete"));
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -217,20 +240,18 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
||||||
boolean isSelected, Object key,
|
boolean isSelected, Object key,
|
||||||
int row, int column) {
|
int row, int column) {
|
||||||
|
|
||||||
return new Label(value.toString());
|
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(state);
|
||||||
// SecurityManager sm = Utilities.getSecurityManager(state);
|
|
||||||
// GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(state);
|
boolean canEdit = sm.canAccess(state.getRequest(),
|
||||||
//
|
SecurityManager.EDIT_ITEM,
|
||||||
// boolean canEdit = sm.canAccess(state.getRequest(),
|
contact);
|
||||||
// SecurityManager.EDIT_ITEM,
|
if (canEdit) {
|
||||||
// contact);
|
ControlLink link = new ControlLink((Label)value);
|
||||||
// if (canEdit) {
|
return link;
|
||||||
// ControlLink link = new ControlLink(value.toString());
|
} else {
|
||||||
// return link;
|
return (Label) value;
|
||||||
// } else {
|
}
|
||||||
// return new Label(value.toString());
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -284,15 +305,15 @@ public class GenericContactEntriesTable extends Table implements TableActionList
|
||||||
// Get selected column
|
// Get selected column
|
||||||
TableColumn col = getColumnModel().get(evt.getColumn().intValue());
|
TableColumn col = getColumnModel().get(evt.getColumn().intValue());
|
||||||
|
|
||||||
// Edit
|
switch(evt.getColumn()) {
|
||||||
if (col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
case COL_EDIT:
|
||||||
|
m_selectedEntry.setSelectedKey(state, evt.getRowKey().toString());
|
||||||
|
m_editor.showContactEntryForm(state);
|
||||||
|
break;
|
||||||
|
case COL_DEL:
|
||||||
|
contact.removeContactEntry(contactEntry);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete
|
|
||||||
if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
|
||||||
contact.removeContactEntry(contactEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,10 @@ import com.arsdigita.bebop.event.PrintListener;
|
||||||
import com.arsdigita.bebop.form.Option;
|
import com.arsdigita.bebop.form.Option;
|
||||||
import com.arsdigita.bebop.form.SingleSelect;
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
import com.arsdigita.bebop.form.TextField;
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.RelationAttributeResourceBundleControl;
|
import com.arsdigita.cms.RelationAttributeResourceBundleControl;
|
||||||
|
|
@ -41,6 +43,7 @@ import com.arsdigita.globalization.GlobalizationHelper;
|
||||||
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.TooManyListenersException;
|
import java.util.TooManyListenersException;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
@ -53,6 +56,8 @@ public class GenericContactEntryAddForm extends BasicItemForm {
|
||||||
private static final Logger s_log = Logger.getLogger(GenericContactEntryAddForm.class);
|
private static final Logger s_log = Logger.getLogger(GenericContactEntryAddForm.class);
|
||||||
|
|
||||||
private ItemSelectionModel m_itemModel;
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private ParameterSingleSelectionModel m_selectedEntry;
|
||||||
|
private GenericContactEntriesEditor m_editor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of CategoryLocalizationAddForm.
|
* Creates a new instance of CategoryLocalizationAddForm.
|
||||||
|
|
@ -66,6 +71,15 @@ public class GenericContactEntryAddForm extends BasicItemForm {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GenericContactEntryAddForm(ItemSelectionModel itemModel,
|
||||||
|
GenericContactEntriesEditor editor,
|
||||||
|
ParameterSingleSelectionModel selectedEntry) {
|
||||||
|
|
||||||
|
this(itemModel);
|
||||||
|
m_selectedEntry = selectedEntry;
|
||||||
|
m_editor = editor;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addWidgets() {
|
protected void addWidgets() {
|
||||||
|
|
||||||
|
|
@ -134,7 +148,18 @@ public class GenericContactEntryAddForm extends BasicItemForm {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void init(FormSectionEvent fse) {
|
public void init(FormSectionEvent fse) {
|
||||||
|
final PageState state = fse.getPageState();
|
||||||
|
|
||||||
|
if (m_selectedEntry.getSelectedKey(state) != null) {
|
||||||
|
final GenericContactEntry entry =
|
||||||
|
new GenericContactEntry(new BigDecimal((String) m_selectedEntry.getSelectedKey(state)));
|
||||||
|
|
||||||
|
final FormData data = fse.getFormData();
|
||||||
|
|
||||||
|
data.put(GenericContactEntry.KEY, entry.getKey());
|
||||||
|
data.put(GenericContactEntry.VALUE, entry.getValue());
|
||||||
|
data.put(GenericContactEntry.DESCRIPTION, entry.getDescription());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -143,6 +168,7 @@ public class GenericContactEntryAddForm extends BasicItemForm {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void process(FormSectionEvent fse) {
|
public void process(FormSectionEvent fse) {
|
||||||
|
final PageState state = fse.getPageState();
|
||||||
FormData data = fse.getFormData();
|
FormData data = fse.getFormData();
|
||||||
GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(fse.getPageState());
|
GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(fse.getPageState());
|
||||||
|
|
||||||
|
|
@ -151,13 +177,27 @@ public class GenericContactEntryAddForm extends BasicItemForm {
|
||||||
&& getSaveCancelSection().getSaveButton()
|
&& getSaveCancelSection().getSaveButton()
|
||||||
.isSelected(fse.getPageState())) {
|
.isSelected(fse.getPageState())) {
|
||||||
|
|
||||||
GenericContactEntry contactEntry = new GenericContactEntry(
|
if (m_selectedEntry.getSelectedKey(state) == null) {
|
||||||
contact,
|
GenericContactEntry contactEntry = new GenericContactEntry(
|
||||||
(String) data.get(GenericContactEntry.KEY),
|
contact,
|
||||||
(String) data.get(GenericContactEntry.VALUE),
|
(String) data.get(GenericContactEntry.KEY),
|
||||||
(String) data.get(GenericContactEntry.DESCRIPTION));
|
(String) data.get(GenericContactEntry.VALUE),
|
||||||
|
(String) data.get(GenericContactEntry.DESCRIPTION));
|
||||||
|
|
||||||
contact.addContactEntry(contactEntry);
|
contact.addContactEntry(contactEntry);
|
||||||
|
} else {
|
||||||
|
final GenericContactEntry entry =
|
||||||
|
new GenericContactEntry(new BigDecimal((String) m_selectedEntry.getSelectedKey(state)));
|
||||||
|
entry.setKey((String) data.get(GenericContactEntry.KEY));
|
||||||
|
entry.setValue((String) data.get(GenericContactEntry.VALUE));
|
||||||
|
entry.setDescription((String) data.get(GenericContactEntry.DESCRIPTION));
|
||||||
|
|
||||||
|
entry.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_editor != null) {
|
||||||
|
m_editor.hideContactEntryForm(fse.getPageState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,17 +36,17 @@ import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Central entry point into the AuthoringStep for the basic properties of a
|
* Central entry point into the AuthoringStep for the basic properties of a
|
||||||
* basic contact (GenericContact). This class has to be specified in the
|
* basic contact (GenericContact). This class has to be specified in the
|
||||||
* content type's definition XML.
|
* content type's definition XML.
|
||||||
*
|
*
|
||||||
* It uses a segmented Panel to provide several components in one editing step.
|
* It uses a segmented Panel to provide several components in one editing step.
|
||||||
* Handles the basic contentpage properties (title, name) and additional
|
* Handles the basic contentpage properties (title, name) and additional
|
||||||
* basic properties
|
* basic properties
|
||||||
* - Person
|
* - Person
|
||||||
* - Address
|
* - Address
|
||||||
* - Various contact entries.
|
* - Various contact entries.
|
||||||
*
|
*
|
||||||
* @author quasi <quasi@quasiweb.de>
|
* @author quasi <quasi@quasiweb.de>
|
||||||
*/
|
*/
|
||||||
public class GenericContactPropertiesStep extends SimpleEditStep {
|
public class GenericContactPropertiesStep extends SimpleEditStep {
|
||||||
|
|
@ -64,7 +64,7 @@ public class GenericContactPropertiesStep extends SimpleEditStep {
|
||||||
* @param itemModel
|
* @param itemModel
|
||||||
* @param parent
|
* @param parent
|
||||||
*/
|
*/
|
||||||
public GenericContactPropertiesStep(ItemSelectionModel itemModel,
|
public GenericContactPropertiesStep(ItemSelectionModel itemModel,
|
||||||
AuthoringKitWizard parent) {
|
AuthoringKitWizard parent) {
|
||||||
|
|
||||||
// Construct a new SimpleEditComponent with basic funtionality
|
// Construct a new SimpleEditComponent with basic funtionality
|
||||||
|
|
@ -84,37 +84,37 @@ public class GenericContactPropertiesStep extends SimpleEditStep {
|
||||||
* - attached person
|
* - attached person
|
||||||
* - attached address
|
* - attached address
|
||||||
* - contact entries for this contact
|
* - contact entries for this contact
|
||||||
*
|
*
|
||||||
* @param itemModel
|
* @param itemModel
|
||||||
* @param parent
|
* @param parent
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected SegmentedPanel createEditSheet(ItemSelectionModel itemModel,
|
protected SegmentedPanel createEditSheet(ItemSelectionModel itemModel,
|
||||||
AuthoringKitWizard parent) {
|
AuthoringKitWizard parent) {
|
||||||
|
|
||||||
/* Use a Segmented Panel for the multiple parts of data */
|
/* Use a Segmented Panel for the multiple parts of data */
|
||||||
SegmentedPanel segmentedPanel = new SegmentedPanel();
|
SegmentedPanel segmentedPanel = new SegmentedPanel();
|
||||||
|
|
||||||
/* The different parts of information are displayed in seperated
|
/* The different parts of information are displayed in seperated
|
||||||
* segments each containing a SimpleEditStep */
|
* segments each containing a SimpleEditStep */
|
||||||
/* Well, not so simple anymore... */
|
/* Well, not so simple anymore... */
|
||||||
|
|
||||||
/* A new SimpleEditStep for basic properties */
|
/* A new SimpleEditStep for basic properties */
|
||||||
SimpleEditStep basicProperties = new SimpleEditStep(itemModel,
|
SimpleEditStep basicProperties = new SimpleEditStep(itemModel,
|
||||||
parent,
|
parent,
|
||||||
EDIT_BASIC_SHEET_NAME);
|
EDIT_BASIC_SHEET_NAME);
|
||||||
|
|
||||||
/* Create the edit component for this SimpleEditStep and the
|
/* Create the edit component for this SimpleEditStep and the
|
||||||
* corresponding link */
|
* corresponding link */
|
||||||
BasicPageForm editBasicSheet = new GenericContactPropertyForm(itemModel,
|
BasicPageForm editBasicSheet = new GenericContactPropertyForm(itemModel,
|
||||||
this);
|
this);
|
||||||
basicProperties.add(
|
basicProperties.add(
|
||||||
EDIT_BASIC_SHEET_NAME,
|
EDIT_BASIC_SHEET_NAME,
|
||||||
ContenttypesGlobalizationUtil.globalize(
|
ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericcontact.edit_basic_properties"),
|
"cms.contenttypes.ui.genericcontact.edit_basic_properties"),
|
||||||
new WorkflowLockedComponentAccess(
|
new WorkflowLockedComponentAccess(
|
||||||
editBasicSheet,
|
editBasicSheet,
|
||||||
itemModel),
|
itemModel),
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton());
|
editBasicSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
/* Set the displayComponent for this step */
|
/* Set the displayComponent for this step */
|
||||||
|
|
@ -122,7 +122,7 @@ public class GenericContactPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
/* Add the basic properties SimpleEditStep to the segmented panel with
|
/* Add the basic properties SimpleEditStep to the segmented panel with
|
||||||
* provided title */
|
* provided title */
|
||||||
segmentedPanel.addSegment(new
|
segmentedPanel.addSegment(new
|
||||||
Label(ContenttypesGlobalizationUtil.globalize(
|
Label(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericcontact.basic_properties")),
|
"cms.contenttypes.ui.genericcontact.basic_properties")),
|
||||||
basicProperties);
|
basicProperties);
|
||||||
|
|
@ -131,12 +131,12 @@ public class GenericContactPropertiesStep extends SimpleEditStep {
|
||||||
// If not disabled via registry, add the ui for attaching a person
|
// If not disabled via registry, add the ui for attaching a person
|
||||||
if (!GenericContact.getConfig().getHidePerson()) {
|
if (!GenericContact.getConfig().getHidePerson()) {
|
||||||
|
|
||||||
GenericContactPersonPropertiesStep personProperties = new
|
GenericContactPersonPropertiesStep personProperties = new
|
||||||
GenericContactPersonPropertiesStep(itemModel, parent);
|
GenericContactPersonPropertiesStep(itemModel, parent);
|
||||||
// Add step to segmented panel with the provided title
|
// Add step to segmented panel with the provided title
|
||||||
segmentedPanel.addSegment(new
|
segmentedPanel.addSegment(new
|
||||||
Label(ContenttypesGlobalizationUtil.globalize(
|
Label(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericcontact.person")),
|
"cms.contenttypes.ui.genericcontact.person")),
|
||||||
personProperties);
|
personProperties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -145,23 +145,25 @@ public class GenericContactPropertiesStep extends SimpleEditStep {
|
||||||
// If not disabled via registry, add the ui for attaching an address
|
// If not disabled via registry, add the ui for attaching an address
|
||||||
if (!GenericContact.getConfig().getHideAddress()) {
|
if (!GenericContact.getConfig().getHideAddress()) {
|
||||||
|
|
||||||
GenericContactAddressPropertiesStep addressProperties = new
|
GenericContactAddressPropertiesStep addressProperties = new
|
||||||
GenericContactAddressPropertiesStep(itemModel, parent);
|
GenericContactAddressPropertiesStep(itemModel, parent);
|
||||||
// Add step to segmented panel with the provided title
|
// Add step to segmented panel with the provided title
|
||||||
segmentedPanel.addSegment(new
|
segmentedPanel.addSegment(new
|
||||||
Label(ContenttypesGlobalizationUtil.globalize(
|
Label(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericcontact.address")),
|
"cms.contenttypes.ui.genericcontact.address")),
|
||||||
addressProperties);
|
addressProperties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add UI for adding several contact entries.
|
// Add UI for adding several contact entries.
|
||||||
GenericContactEntriesPropertiesStep contactEntries = new
|
//GenericContactEntriesPropertiesStep contactEntries = new
|
||||||
GenericContactEntriesPropertiesStep(itemModel, parent);
|
// GenericContactEntriesPropertiesStep(itemModel, parent);
|
||||||
|
GenericContactEntriesEditor contactEntries =
|
||||||
|
new GenericContactEntriesEditor(itemModel, parent);
|
||||||
// Add step to segmented panel with the provided title
|
// Add step to segmented panel with the provided title
|
||||||
segmentedPanel.addSegment(new
|
segmentedPanel.addSegment(new
|
||||||
Label(ContenttypesGlobalizationUtil.globalize(
|
Label(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericcontact.contactEntry")),
|
"cms.contenttypes.ui.genericcontact.contactEntry")),
|
||||||
contactEntries);
|
contactEntries);
|
||||||
|
|
||||||
return segmentedPanel;
|
return segmentedPanel;
|
||||||
|
|
@ -170,7 +172,7 @@ public class GenericContactPropertiesStep extends SimpleEditStep {
|
||||||
/**
|
/**
|
||||||
* Creates and returns the sheet for editing the basic properties
|
* Creates and returns the sheet for editing the basic properties
|
||||||
* of a contact. (@see GenericContactPropertyForm).
|
* of a contact. (@see GenericContactPropertyForm).
|
||||||
*
|
*
|
||||||
* @param itemModel
|
* @param itemModel
|
||||||
* @return The sheet for editing the properties of the contact.
|
* @return The sheet for editing the properties of the contact.
|
||||||
*/
|
*/
|
||||||
|
|
@ -180,9 +182,9 @@ public class GenericContactPropertiesStep extends SimpleEditStep {
|
||||||
/* The DisplayComponent for the Basic Properties */
|
/* The DisplayComponent for the Basic Properties */
|
||||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||||
|
|
||||||
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"),
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"),
|
||||||
"title");
|
"title");
|
||||||
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"),
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"),
|
||||||
"name");
|
"name");
|
||||||
|
|
||||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue