CategoryLocalization
EditForm angebunden. Verknüpfung funktioniert, mit einer Ausnahme: der Parameter für die Sprachvariante wird noch nicht erkann und erzeugt daher einen Assert-Fehler. git-svn-id: https://svn.libreccm.org/ccm/trunk@1808 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
b3105ac2e8
commit
8aea372fd5
|
|
@ -25,6 +25,7 @@ import com.arsdigita.bebop.Form;
|
|||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.bebop.event.ActionEvent;
|
||||
|
|
@ -32,6 +33,7 @@ import com.arsdigita.bebop.event.ActionListener;
|
|||
import com.arsdigita.bebop.event.ChangeEvent;
|
||||
import com.arsdigita.bebop.event.ChangeListener;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.categorization.CategorizedCollection;
|
||||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.categorization.CategoryCollection;
|
||||
|
|
@ -80,6 +82,8 @@ class CategoryItemPane extends BaseItemPane {
|
|||
private final SingleSelectionModel m_model;
|
||||
private final CategoryRequestLocal m_category;
|
||||
private final SimpleContainer m_detailPane;
|
||||
private final StringParameter m_catLocaleParam = new StringParameter("catLocale");
|
||||
private final ParameterSingleSelectionModel m_catLocale;
|
||||
|
||||
public CategoryItemPane(final SingleSelectionModel model,
|
||||
final CategoryRequestLocal category,
|
||||
|
|
@ -88,9 +92,9 @@ class CategoryItemPane extends BaseItemPane {
|
|||
final ActionLink deleteLink) {
|
||||
m_model = model;
|
||||
m_category = category;
|
||||
m_catLocale = new ParameterSingleSelectionModel(m_catLocaleParam);
|
||||
|
||||
// Details
|
||||
|
||||
m_detailPane = new SimpleContainer();
|
||||
add(m_detailPane);
|
||||
setDefault(m_detailPane);
|
||||
|
|
@ -145,7 +149,8 @@ class CategoryItemPane extends BaseItemPane {
|
|||
m_category.getCategory(state)
|
||||
.getCategoryLocalizationCollection().size();
|
||||
|
||||
if (countLanguages < countSupportedLanguages) {
|
||||
if (m_category.getCategory(state).canEdit()
|
||||
&& countLanguages < countSupportedLanguages) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -339,14 +344,14 @@ class CategoryItemPane extends BaseItemPane {
|
|||
|
||||
final ActionGroup group = new ActionGroup();
|
||||
setBody(group);
|
||||
m_catLocalizationTable = new CategoryLocalizationTable(m_category, m_model);
|
||||
m_catLocalizationTable = new CategoryLocalizationTable(m_category, m_model, m_catLocale);
|
||||
group.setSubject(m_catLocalizationTable);
|
||||
group.addAction(new AdminVisible(addLink), ActionGroup.ADD);
|
||||
|
||||
m_editCategoryLocalizationForm = new CategoryLocalizationEditForm(m_category, "de");
|
||||
m_editCategoryLocalizationForm = new CategoryLocalizationEditForm(m_category, m_catLocale);
|
||||
add(m_editCategoryLocalizationForm);
|
||||
connect(m_editCategoryLocalizationForm);
|
||||
connect(m_catLocalizationTable, 0, m_editCategoryLocalizationForm);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -529,7 +534,7 @@ class CategoryItemPane extends BaseItemPane {
|
|||
super(c, s);
|
||||
}
|
||||
|
||||
// Build the preview link. This uses a standard redirect link to find
|
||||
// Build the preview link. This uses a standard redirect link to find
|
||||
// the content. The prepareURL method is called by the printwriter
|
||||
@Override
|
||||
protected String prepareURL(final PageState state, String location) {
|
||||
|
|
@ -593,6 +598,7 @@ class CategoryItemPane extends BaseItemPane {
|
|||
* and the user is allowed to edit this item.
|
||||
*
|
||||
* @param state
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -614,6 +620,7 @@ class CategoryItemPane extends BaseItemPane {
|
|||
*
|
||||
* @param item
|
||||
* @param state
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isItemEditable(ContentItem item, PageState state) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package com.arsdigita.cms.ui.category;
|
|||
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
|
|
@ -37,30 +38,27 @@ import org.apache.log4j.Logger;
|
|||
* in order to present forms for managing the multi-language categories.
|
||||
*
|
||||
* @author Sören Bernstein (quasimodo) quasi@zes.uni-bremen.de
|
||||
* @version $Id: CategoryLocalizationEditForm.java $
|
||||
* @version $Id: CategoryLocalizationEditForm.java $
|
||||
*/
|
||||
public class CategoryLocalizationEditForm extends CategoryLocalizationForm {
|
||||
|
||||
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
(CategoryLocalizationEditForm.class);
|
||||
|
||||
private final String m_categoryLocalizationLocale;
|
||||
|
||||
|
||||
private final SingleSelectionModel m_catLocale;
|
||||
/**
|
||||
* Creates a new instance of CategoryLocalizationEditForm
|
||||
*/
|
||||
public CategoryLocalizationEditForm(final CategoryRequestLocal category,
|
||||
final String locale) {
|
||||
|
||||
public CategoryLocalizationEditForm(final CategoryRequestLocal category, SingleSelectionModel catLocale) {
|
||||
|
||||
super("EditCategoryLocalization", gz(
|
||||
"cms.ui.category.localization_edit"), category);
|
||||
|
||||
// Speichere Locale ab
|
||||
m_categoryLocalizationLocale = locale;
|
||||
|
||||
|
||||
m_catLocale = catLocale;
|
||||
|
||||
addInitListener(new InitListener());
|
||||
addProcessListener(new ProcessListener());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -69,45 +67,46 @@ public class CategoryLocalizationEditForm extends CategoryLocalizationForm {
|
|||
private class InitListener implements FormInitListener {
|
||||
public final void init(final FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
|
||||
|
||||
final PageState state = e.getPageState();
|
||||
final Category category = m_category.getCategory(state);
|
||||
|
||||
final String categoryLocalizationLocale = (String) m_catLocale.getSelectedKey(state);
|
||||
|
||||
// Hide Locale-Widget and lock it (read-only)
|
||||
m_locale.addOption(new Option(m_categoryLocalizationLocale,
|
||||
new Locale(m_categoryLocalizationLocale).getDisplayLanguage()), state);
|
||||
// m_locale.setValue(state, m_categoryLocalizationLocale);
|
||||
m_locale.addOption(new Option(categoryLocalizationLocale,
|
||||
new Locale(categoryLocalizationLocale).getDisplayLanguage()), state);
|
||||
m_locale.setValue(state, categoryLocalizationLocale);
|
||||
// m_locale.setVisible(state, false);
|
||||
m_locale.lock();
|
||||
|
||||
m_name.setValue(state, category.getName((String) m_locale.getValue(state)));
|
||||
m_description.setValue(state, category.getDescription(
|
||||
(String) m_locale.getValue(state)));
|
||||
m_url.setValue(state, category.getURL((String) m_locale.getValue(state)));
|
||||
|
||||
if (category.isEnabled((String) m_locale.getValue(state))) {
|
||||
m_name.setValue(state, category.getName(categoryLocalizationLocale));
|
||||
m_description.setValue(state, category.getDescription(categoryLocalizationLocale));
|
||||
m_url.setValue(state, category.getURL(categoryLocalizationLocale));
|
||||
|
||||
if (category.isEnabled(categoryLocalizationLocale)) {
|
||||
m_isEnabled.setValue(state, "yes");
|
||||
} else {
|
||||
m_isEnabled.setValue(state, "no");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ##todo: document purpose of this
|
||||
*/
|
||||
private class ProcessListener implements FormProcessListener {
|
||||
public final void process(final FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
|
||||
|
||||
final PageState state = e.getPageState();
|
||||
final Category category = m_category.getCategory(state);
|
||||
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Editing localization for locale " + m_locale +
|
||||
" for category " + category);
|
||||
}
|
||||
|
||||
|
||||
if (category.canEdit()) {
|
||||
category.setName((String) m_name.getValue(state),
|
||||
(String) m_locale.getValue(state));
|
||||
|
|
|
|||
|
|
@ -21,13 +21,11 @@ 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;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.table.DefaultTableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
|
|
@ -36,13 +34,7 @@ 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;
|
||||
|
|
@ -61,22 +53,23 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
|
|||
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 SingleSelectionModel m_catLocale;
|
||||
|
||||
/**
|
||||
* Creates a new instance of CategoryLocalizationTable
|
||||
*/
|
||||
public CategoryLocalizationTable(final CategoryRequestLocal category,
|
||||
final SingleSelectionModel model) {
|
||||
public CategoryLocalizationTable(final CategoryRequestLocal category, final SingleSelectionModel model, SingleSelectionModel catLocale) {
|
||||
|
||||
super();
|
||||
|
||||
m_category = category;
|
||||
m_model = model;
|
||||
m_catLocale = catLocale;
|
||||
|
||||
// if table is empty:
|
||||
setEmptyView(new Label(GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_none")));
|
||||
TableColumnModel tab_model = getColumnModel();
|
||||
TableColumnModel tab_model = getColumnModel();
|
||||
|
||||
// define columns
|
||||
// XXX globalize
|
||||
|
|
@ -196,25 +189,15 @@ TableColumnModel tab_model = getColumnModel();
|
|||
private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
public Component getComponent(Table table, PageState state, Object value,
|
||||
boolean isSelected, Object key,
|
||||
boolean isSelected, final Object key,
|
||||
int row, int column) {
|
||||
|
||||
|
||||
// if (canEdit) {
|
||||
// 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;
|
||||
if (m_category.getCategory(state).canEdit()) {
|
||||
return new ControlLink(value.toString());
|
||||
} else {
|
||||
return new Label(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -224,10 +207,14 @@ TableColumnModel tab_model = getColumnModel();
|
|||
boolean isSelected, Object key,
|
||||
int row, int column) {
|
||||
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_confirm_delete").localize());
|
||||
return link;
|
||||
if (m_category.getCategory(state).canDelete()) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) GlobalizationUtil.globalize(
|
||||
"cms.ui.category.localization_confirm_delete").localize());
|
||||
return link;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -252,6 +239,7 @@ TableColumnModel tab_model = getColumnModel();
|
|||
|
||||
// Edit
|
||||
if (col.getHeaderKey().toString().equals(TABLE_COL_LANG)) {
|
||||
m_catLocale.setSelectedKey(state, categoryLocalization.getLocale());
|
||||
}
|
||||
|
||||
// Delete
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue