CCM NG/ccm-cms: AssetForm improvement, Form for SideNote asset
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4667 8810af33-2d31-482b-a856-94f89814c4df
parent
0bf25ccb05
commit
f9806fea35
|
|
@ -82,7 +82,7 @@ public abstract class AssetForm extends Form implements FormInitListener,
|
|||
private SaveCancelSection saveCancelSection;
|
||||
|
||||
public AssetForm(final AssetPane assetPane) {
|
||||
super("asset-form", new ColumnPanel(2));
|
||||
super("asset-form", new ColumnPanel(1));
|
||||
|
||||
this.assetPane = assetPane;
|
||||
selectionModel = assetPane.getSelectedAssetModel();
|
||||
|
|
@ -164,7 +164,13 @@ public abstract class AssetForm extends Form implements FormInitListener,
|
|||
}
|
||||
showLocaleSubmit = new Submit(new GlobalizedMessage(
|
||||
"cms.ui.asset.show_locale",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
CmsConstants.CMS_BUNDLE)) {
|
||||
|
||||
@Override
|
||||
public boolean isVisible(final PageState state) {
|
||||
return getSelectedAsset(state).isPresent();
|
||||
}
|
||||
};
|
||||
showLocalePanel.add(showLocaleLabel);
|
||||
showLocalePanel.add(showLocaleSelect);
|
||||
showLocalePanel.add(showLocaleSubmit);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import com.arsdigita.bebop.form.TextField;
|
|||
import com.arsdigita.cms.ui.assets.AssetForm;
|
||||
import com.arsdigita.cms.ui.assets.AssetPane;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.assets.Bookmark;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package com.arsdigita.cms.ui.assets.forms;
|
||||
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
|
|
@ -51,29 +52,33 @@ public class LegalMetadataForm extends AssetForm {
|
|||
@Override
|
||||
protected void addWidgets() {
|
||||
|
||||
add(new Label(new GlobalizedMessage(
|
||||
final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
|
||||
|
||||
panel.add(new Label(new GlobalizedMessage(
|
||||
"cms.ui.assets.legalmetadata.rightsholder",
|
||||
CmsConstants.CMS_BUNDLE)));
|
||||
rightsHolder = new TextArea("legalmetadata-rightsholder");
|
||||
add(rightsHolder);
|
||||
panel.add(rightsHolder);
|
||||
|
||||
add(new Label(new GlobalizedMessage(
|
||||
panel.add(new Label(new GlobalizedMessage(
|
||||
"cms.ui.assets.legalmetadata.rights",
|
||||
CmsConstants.CMS_BUNDLE)));
|
||||
rights = new TextArea("legalmetadata-rights");
|
||||
add(rights);
|
||||
panel.add(rights);
|
||||
|
||||
add(new Label(new GlobalizedMessage(
|
||||
panel.add(new Label(new GlobalizedMessage(
|
||||
"cms.ui.assets.legalmetadata.publisher",
|
||||
CmsConstants.CMS_BUNDLE)));
|
||||
publisher = new TextArea("legalmetadata-rights");
|
||||
add(publisher);
|
||||
panel.add(publisher);
|
||||
|
||||
add(new Label(new GlobalizedMessage(
|
||||
panel.add(new Label(new GlobalizedMessage(
|
||||
"cms.ui.assets.legalmetadata.creator",
|
||||
CmsConstants.CMS_BUNDLE)));
|
||||
creator = new TextArea("legalmetadata-creator");
|
||||
add(creator);
|
||||
panel.add(creator);
|
||||
|
||||
add(panel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* Copyright (C) 2017 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package com.arsdigita.cms.ui.assets.forms;
|
||||
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.form.TextArea;
|
||||
import com.arsdigita.cms.ui.assets.AssetForm;
|
||||
import com.arsdigita.cms.ui.assets.AssetPane;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.assets.SideNote;
|
||||
import org.librecms.contentsection.Asset;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class SideNoteForm extends AssetForm {
|
||||
|
||||
private TextArea text;
|
||||
|
||||
public SideNoteForm(final AssetPane assetPane) {
|
||||
super(assetPane);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
|
||||
add(new Label(new GlobalizedMessage("cms.ui.assets.sidenote.text",
|
||||
CmsConstants.CMS_BUNDLE)));
|
||||
text = new TextArea("sidenote-text");
|
||||
add(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initForm(final PageState state,
|
||||
final Optional<Asset> selectedAsset) {
|
||||
|
||||
if (selectedAsset.isPresent()) {
|
||||
if (!(selectedAsset.get() instanceof SideNote)) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"The provided asset must be an instance of '%s' or"
|
||||
+ "an subclass but is an instance of '%s'",
|
||||
SideNote.class.getName(),
|
||||
selectedAsset.get().getClass().getName()));
|
||||
}
|
||||
|
||||
final SideNote sideNote = (SideNote) selectedAsset.get();
|
||||
|
||||
text.setValue(state,
|
||||
sideNote
|
||||
.getText()
|
||||
.getValue(getSelectedLocale(state)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showLocale(final PageState state) {
|
||||
|
||||
final Optional<Asset> selectedAsset = getSelectedAsset(state);
|
||||
|
||||
if (selectedAsset.isPresent()) {
|
||||
if (!(selectedAsset.get() instanceof SideNote)) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"The provided asset must be an instance of '%s' or"
|
||||
+ "an subclass but is an instance of '%s'",
|
||||
SideNote.class.getName(),
|
||||
selectedAsset.get().getClass().getName()));
|
||||
}
|
||||
|
||||
final SideNote sideNote = (SideNote) selectedAsset.get();
|
||||
|
||||
text.setValue(state,
|
||||
sideNote
|
||||
.getText()
|
||||
.getValue(getSelectedLocale(state)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Asset createAsset(final PageState state) throws
|
||||
FormProcessException {
|
||||
|
||||
Objects.requireNonNull(state);
|
||||
|
||||
final SideNote sideNote = new SideNote();
|
||||
|
||||
sideNote
|
||||
.getText()
|
||||
.addValue(getSelectedLocale(state),
|
||||
(String) text.getValue(state));
|
||||
|
||||
return sideNote;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateAsset(final Asset asset, final PageState state)
|
||||
throws FormProcessException {
|
||||
|
||||
Objects.requireNonNull(asset);
|
||||
Objects.requireNonNull(state);
|
||||
|
||||
if (!(asset instanceof SideNote)) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"The provided asset must be an instance of '%s' or"
|
||||
+ "an subclass but is an instance of '%s'",
|
||||
SideNote.class.getName(),
|
||||
asset.getClass().getName()));
|
||||
}
|
||||
|
||||
final SideNote sideNote = (SideNote) asset;
|
||||
|
||||
sideNote
|
||||
.getText()
|
||||
.addValue(getSelectedLocale(state),
|
||||
(String) text.getValue(state));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -35,6 +35,7 @@ import org.librecms.contenttypes.News;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import org.librecms.assets.SideNote;
|
||||
|
||||
@Module(//packageName = "org.librecms.cms",
|
||||
requiredModules = {
|
||||
|
|
@ -60,7 +61,7 @@ import java.util.Properties;
|
|||
}
|
||||
)
|
||||
@ContentTypes({Article.class, Event.class, MultiPartArticle.class, News.class})
|
||||
@AssetTypes({Bookmark.class, LegalMetadata.class})
|
||||
@AssetTypes({Bookmark.class, LegalMetadata.class, SideNote.class})
|
||||
public class Cms implements CcmModule {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(Cms.class);
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ public class LegalMetadata extends Asset implements Serializable {
|
|||
|
||||
public LegalMetadata() {
|
||||
super();
|
||||
rights = new LocalizedString();
|
||||
contributors = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.librecms.assets;
|
||||
|
||||
import com.arsdigita.cms.ui.assets.forms.SideNoteForm;
|
||||
import org.librecms.contentsection.Asset;
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
|
@ -33,6 +34,7 @@ import javax.persistence.JoinTable;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
import static org.librecms.assets.AssetConstants.*;
|
||||
|
||||
/**
|
||||
* Assets for side notes (additional informations) for a content item.
|
||||
|
|
@ -42,6 +44,11 @@ import static org.librecms.CmsConstants.*;
|
|||
@Entity
|
||||
@Table(name = "SIDE_NOTES", schema = DB_SCHEMA)
|
||||
@Audited
|
||||
@AssetType(assetForm = SideNoteForm.class,
|
||||
labelBundle= ASSETS_BUNDLE,
|
||||
labelKey = "sidenote.label",
|
||||
descriptionBundle = ASSETS_BUNDLE,
|
||||
descriptionKey = "sidenote.description")
|
||||
public class SideNote extends Asset implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4566222634780521726L;
|
||||
|
|
|
|||
|
|
@ -261,3 +261,4 @@ cms.ui.asset.show_locale=Show data for language
|
|||
cms.ui.asset.initial_locale=Language
|
||||
cms.ui.asset.add_locale=Add data for language
|
||||
cms.ui.admin.assets.edit=Edit asset
|
||||
cms.ui.assets.sidenote.text=Text
|
||||
|
|
|
|||
|
|
@ -260,3 +260,4 @@ cms.ui.asset.show_locale=Zeige Daten f\u00fcr Sprache
|
|||
cms.ui.asset.initial_locale=Sprache
|
||||
cms.ui.asset.add_locale=Daten f\u00fcr folgende Sprache hinzuf\u00fcgen
|
||||
cms.ui.admin.assets.edit=Asset bearbeiten
|
||||
cms.ui.assets.sidenote.text=Text
|
||||
|
|
|
|||
|
|
@ -219,3 +219,4 @@ cms.ui.asset.show_locale=Show data for language
|
|||
cms.ui.asset.initial_locale=Language
|
||||
cms.ui.asset.add_locale=Add data for language
|
||||
cms.ui.admin.assets.edit=Edit asset
|
||||
cms.ui.assets.sidenote.text=Text
|
||||
|
|
|
|||
|
|
@ -3,3 +3,5 @@ bookmark.label=Bookmark
|
|||
bookmark.description=Asset type to store URLs to external resources.
|
||||
legal_metadata.label=Legal metadata
|
||||
legal_metadata.description=Stores legal metadata like the informations about the creator of an image etc.
|
||||
sidenote.label=Side note
|
||||
sidenote.description=Additional information. Usually appears in the right or left column of an webpage.
|
||||
|
|
|
|||
|
|
@ -3,3 +3,5 @@ bookmark.label=Lesezeichen (URL)
|
|||
bookmark.description=Dieser Asset-Typ dient zur Ablage von URLs zu externen Resourcen.
|
||||
legal_metadata.label=Rechtliche Informationen
|
||||
legal_metadata.description=Rechtliche Informationen, z.B. die Urheberschaft von Bildern etc.
|
||||
sidenote.label=Randbemerkung
|
||||
sidenote.description=Randbemerkung mit zus\u00e4tzlichen Informationen. Erscheint in der Regel in der rechten oder linken Spalte einer Webseite.
|
||||
|
|
|
|||
Loading…
Reference in New Issue