CCM NG/cc-cms: Step for editing the text of an event item
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4848 8810af33-2d31-482b-a856-94f89814c4df
parent
a571525e62
commit
38fef7550d
|
|
@ -0,0 +1,122 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.ui.authoring;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.form.Option;
|
||||||
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.librecms.contentsection.ContentItemRepository;
|
||||||
|
import org.librecms.contenttypes.Event;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import static com.arsdigita.cms.ui.authoring.TextBody.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class EventTextBody extends TextBody {
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemSelectionModel;
|
||||||
|
private final StringParameter selectedLanguageParam;
|
||||||
|
|
||||||
|
public EventTextBody(final ItemSelectionModel itemSelectionModel,
|
||||||
|
final AuthoringKitWizard authoringKitWizard,
|
||||||
|
final StringParameter selectedLanguageParam) {
|
||||||
|
|
||||||
|
super(itemSelectionModel, selectedLanguageParam);
|
||||||
|
|
||||||
|
this.itemSelectionModel = itemSelectionModel;
|
||||||
|
this.selectedLanguageParam = selectedLanguageParam;
|
||||||
|
|
||||||
|
// Rest the component when it is hidden
|
||||||
|
authoringKitWizard
|
||||||
|
.getList()
|
||||||
|
.addActionListener(event -> reset(event.getPageState()));
|
||||||
|
|
||||||
|
// Set the right component access on the forms
|
||||||
|
final Component uploadComponent = getComponent(FILE_UPLOAD);
|
||||||
|
if (uploadComponent != null) {
|
||||||
|
setComponentAccess(FILE_UPLOAD,
|
||||||
|
new WorkflowLockedComponentAccess(
|
||||||
|
uploadComponent, itemSelectionModel));
|
||||||
|
}
|
||||||
|
final Component textEntryComponent = getComponent(TEXT_ENTRY);
|
||||||
|
setComponentAccess(TEXT_ENTRY,
|
||||||
|
new WorkflowLockedComponentAccess(
|
||||||
|
textEntryComponent, itemSelectionModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the options for the mime type select widget of
|
||||||
|
* <code>GenericArticleForm</code> and sets the default mime type.
|
||||||
|
*
|
||||||
|
* @param mimeSelect
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void setMimeTypeOptions(final SingleSelect mimeSelect) {
|
||||||
|
mimeSelect.addOption(new Option("text/html", "HTML Text"));
|
||||||
|
mimeSelect.setOptionSelected("text/html");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Event getSelectedEvent(final PageState state) {
|
||||||
|
|
||||||
|
return (Event) itemSelectionModel.getSelectedItem(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTextPropertyName() {
|
||||||
|
|
||||||
|
return "text";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getText(final PageState state) {
|
||||||
|
|
||||||
|
final Event event = getSelectedEvent(state);
|
||||||
|
|
||||||
|
final String selectedLanguage = (String) state
|
||||||
|
.getValue(selectedLanguageParam);
|
||||||
|
final Locale selectedLocale;
|
||||||
|
if (selectedLanguage == null) {
|
||||||
|
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
|
||||||
|
} else {
|
||||||
|
selectedLocale = new Locale(selectedLanguage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return event.getText().getValue(selectedLocale);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateText(final PageState state, final String text) {
|
||||||
|
|
||||||
|
final Event event = getSelectedEvent(state);
|
||||||
|
final String selectedLanguage = (String) state.getValue(
|
||||||
|
selectedLanguageParam);
|
||||||
|
final Locale selectedLocale;
|
||||||
|
if (selectedLanguage == null) {
|
||||||
|
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
|
||||||
|
} else {
|
||||||
|
selectedLocale = new Locale(selectedLanguage);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.getText().addValue(selectedLocale, text);
|
||||||
|
final ContentItemRepository itemRepo = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ContentItemRepository.class);
|
||||||
|
itemRepo.save(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -51,7 +51,6 @@ public class NewsTextBody extends TextBody {
|
||||||
setComponentAccess(TEXT_ENTRY,
|
setComponentAccess(TEXT_ENTRY,
|
||||||
new WorkflowLockedComponentAccess(
|
new WorkflowLockedComponentAccess(
|
||||||
textEntryComponent, itemSelectionModel));
|
textEntryComponent, itemSelectionModel));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
package org.librecms.contenttypes;
|
package org.librecms.contenttypes;
|
||||||
|
|
||||||
import com.arsdigita.cms.contenttypes.ui.EventPropertiesStep;
|
import com.arsdigita.cms.contenttypes.ui.EventPropertiesStep;
|
||||||
|
import com.arsdigita.cms.ui.authoring.EventTextBody;
|
||||||
import com.arsdigita.cms.ui.contenttypes.EventCreateForm;
|
import com.arsdigita.cms.ui.contenttypes.EventCreateForm;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -65,6 +66,15 @@ import static org.librecms.CmsConstants.*;
|
||||||
descriptionKey = "cms.contenttypes.shared.basic_properties"
|
descriptionKey = "cms.contenttypes.shared.basic_properties"
|
||||||
+ ".description",
|
+ ".description",
|
||||||
order = 1)
|
order = 1)
|
||||||
|
,
|
||||||
|
@AuthoringStep(
|
||||||
|
component = EventTextBody.class,
|
||||||
|
labelBundle = "org.librecms.CmsResources",
|
||||||
|
labelKey = "cms.contenttypes.shared.body_text.title",
|
||||||
|
descriptionBundle = "org.librecms.CmsResources",
|
||||||
|
descriptionKey = "cms.contenttypes.shared.body_text.description",
|
||||||
|
order = 2
|
||||||
|
)
|
||||||
})
|
})
|
||||||
public class Event extends ContentItem implements Serializable {
|
public class Event extends ContentItem implements Serializable {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue