CCM NG/ccm-cms: Started implementation of an AssetSearchWidget (similar to the ItemSearchWidget)
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4668 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
c70c6a830f
commit
eb0e24f9fa
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.form.Submit;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.LongParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.dispatcher.CMSPage;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.toolbox.ui.LayoutPanel;
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page contains the widgets for selecting an asset.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class AssetSearchPage extends CMSPage {
|
||||||
|
|
||||||
|
private static final String QUERY_PARAM = "query";
|
||||||
|
private static final String WIDGET_PARAM = "widget";
|
||||||
|
private static final String ASSET_TYPE_PARAM = "assettype";
|
||||||
|
|
||||||
|
private final LongParameter contentSectionId;
|
||||||
|
|
||||||
|
private TextField query;
|
||||||
|
|
||||||
|
public AssetSearchPage() {
|
||||||
|
super(new Label(new GlobalizedMessage("cms.ui.assets.search_page.title",
|
||||||
|
CmsConstants.CMS_BUNDLE)),
|
||||||
|
new SimpleContainer());
|
||||||
|
|
||||||
|
addGlobalStateParam(new StringParameter(ASSET_TYPE_PARAM));
|
||||||
|
addGlobalStateParam(new StringParameter(WIDGET_PARAM));
|
||||||
|
addGlobalStateParam(new StringParameter(QUERY_PARAM));
|
||||||
|
|
||||||
|
contentSectionId = new LongParameter("content-section-id");
|
||||||
|
|
||||||
|
final LayoutPanel mainPanel = new LayoutPanel();
|
||||||
|
|
||||||
|
final Form queryForm = new Form("asset-search-page-query-form");
|
||||||
|
queryForm.add(new Label(new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.search_page.query",
|
||||||
|
CmsConstants.CMS_BUNDLE)));
|
||||||
|
query = new TextField("asset-search-page-query-form");
|
||||||
|
queryForm.add(query);
|
||||||
|
final Submit querySubmit = new Submit(new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.search_page.query.submit"));
|
||||||
|
queryForm.add(querySubmit);
|
||||||
|
|
||||||
|
queryForm.addInitListener(new FormInitListener() {
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final FormData data = event.getFormData();
|
||||||
|
|
||||||
|
final String query = (String) data.get(QUERY_PARAM);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -141,16 +141,22 @@ public class BookmarkForm extends AssetForm {
|
||||||
|
|
||||||
final Bookmark bookmark = new Bookmark();
|
final Bookmark bookmark = new Bookmark();
|
||||||
|
|
||||||
bookmark
|
updateData(bookmark, state);
|
||||||
.getDescription()
|
|
||||||
.addValue(getSelectedLocale(state),
|
|
||||||
(String) description.getValue(state));
|
|
||||||
|
|
||||||
bookmark.setUrl((String) url.getValue(state));
|
|
||||||
|
|
||||||
return bookmark;
|
return bookmark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateData(final Bookmark bookmark,
|
||||||
|
final PageState state) {
|
||||||
|
bookmark
|
||||||
|
.getDescription()
|
||||||
|
.addValue(getSelectedLocale(state),
|
||||||
|
(String) description.getValue(state));
|
||||||
|
|
||||||
|
bookmark.setUrl((String) url.getValue(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateAsset(final Asset asset, final PageState state)
|
protected void updateAsset(final Asset asset, final PageState state)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
@ -168,12 +174,7 @@ public class BookmarkForm extends AssetForm {
|
||||||
|
|
||||||
final Bookmark bookmark = (Bookmark) asset;
|
final Bookmark bookmark = (Bookmark) asset;
|
||||||
|
|
||||||
bookmark
|
updateData(bookmark, state);
|
||||||
.getDescription()
|
|
||||||
.addValue(getSelectedLocale(state),
|
|
||||||
(String) description.getValue(state));
|
|
||||||
|
|
||||||
bookmark.setUrl((String) url.getValue(state));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* 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.PageState;
|
||||||
|
import com.arsdigita.cms.ui.assets.AssetPane;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.librecms.assets.ExternalVideoAsset;
|
||||||
|
import org.librecms.contentsection.Asset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ExternalVideoAssetForm extends BookmarkForm {
|
||||||
|
|
||||||
|
public ExternalVideoAssetForm(final AssetPane assetPane) {
|
||||||
|
super(assetPane);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addWidgets() {
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
//ToDo
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initForm(final PageState state,
|
||||||
|
final Optional<Asset> selectedAsset) {
|
||||||
|
super.initForm(state, selectedAsset);
|
||||||
|
|
||||||
|
// ToDo
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void showLocale(final PageState state) {
|
||||||
|
|
||||||
|
super.showLocale(state);
|
||||||
|
|
||||||
|
//ToDo
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Asset createAsset(final PageState state)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
Objects.requireNonNull(state);
|
||||||
|
|
||||||
|
final ExternalVideoAsset externalVideoAsset = new ExternalVideoAsset();
|
||||||
|
|
||||||
|
updateData(externalVideoAsset, state);
|
||||||
|
|
||||||
|
// ToDo
|
||||||
|
|
||||||
|
return externalVideoAsset;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateAsset(final Asset asset, final PageState state) {
|
||||||
|
|
||||||
|
Objects.requireNonNull(asset);
|
||||||
|
Objects.requireNonNull(state);
|
||||||
|
|
||||||
|
if (!(asset instanceof ExternalVideoAsset)) {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"Provided asset is not an instance of class (or sub class of) "
|
||||||
|
+ "'%s' but is an instance of class '%s'",
|
||||||
|
ExternalVideoAsset.class.getName(),
|
||||||
|
asset.getClass().getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
final ExternalVideoAsset externalVideoAsset = (ExternalVideoAsset) asset;
|
||||||
|
|
||||||
|
updateData(externalVideoAsset, state);
|
||||||
|
|
||||||
|
// ToDo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -262,3 +262,6 @@ cms.ui.asset.initial_locale=Language
|
||||||
cms.ui.asset.add_locale=Add data for language
|
cms.ui.asset.add_locale=Add data for language
|
||||||
cms.ui.admin.assets.edit=Edit asset
|
cms.ui.admin.assets.edit=Edit asset
|
||||||
cms.ui.assets.sidenote.text=Text
|
cms.ui.assets.sidenote.text=Text
|
||||||
|
cms.ui.assets.search_page.title=Select an asset
|
||||||
|
cms.ui.assets.search_page.query=Search for
|
||||||
|
cms.ui.assets.search_page.query.submit=Find
|
||||||
|
|
|
||||||
|
|
@ -261,3 +261,6 @@ cms.ui.asset.initial_locale=Sprache
|
||||||
cms.ui.asset.add_locale=Daten f\u00fcr folgende Sprache hinzuf\u00fcgen
|
cms.ui.asset.add_locale=Daten f\u00fcr folgende Sprache hinzuf\u00fcgen
|
||||||
cms.ui.admin.assets.edit=Asset bearbeiten
|
cms.ui.admin.assets.edit=Asset bearbeiten
|
||||||
cms.ui.assets.sidenote.text=Text
|
cms.ui.assets.sidenote.text=Text
|
||||||
|
cms.ui.assets.search_page.title=W\u00e4hlen Sie ein Asset
|
||||||
|
cms.ui.assets.search_page.query=Suche nach
|
||||||
|
cms.ui.assets.search_page.query.submit=Finden
|
||||||
|
|
|
||||||
|
|
@ -220,3 +220,6 @@ cms.ui.asset.initial_locale=Language
|
||||||
cms.ui.asset.add_locale=Add data for language
|
cms.ui.asset.add_locale=Add data for language
|
||||||
cms.ui.admin.assets.edit=Edit asset
|
cms.ui.admin.assets.edit=Edit asset
|
||||||
cms.ui.assets.sidenote.text=Text
|
cms.ui.assets.sidenote.text=Text
|
||||||
|
cms.ui.assets.search_page.title=Select an asset
|
||||||
|
cms.ui.assets.search_page.query=Search for
|
||||||
|
cms.ui.assets.search_page.query.submit=Find
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue