Commit 88f0a354 authored by Ate Douma's avatar Ate Douma

HIPPLUG-970: rename selection to selections

parents
* text=auto !eol
/LICENSE -text
/NOTICE -text
addon-cms/pom.xml svneol=native#text/plain
addon-repository/pom.xml svneol=native#text/plain
addon-repository/src/main/resources/documentvaluelistprovider.xml svneol=native#text/plain
addon-repository/src/main/resources/hide-selection-namespace.xml svneol=native#text/plain
addon-repository/src/main/resources/hippoecm-extension.xml svneol=native#text/plain
addon-repository/src/main/resources/selection-namespace-BooleanRadioGroup.xml svneol=native#text/plain
addon-repository/src/main/resources/selection-namespace-RadioGroup.xml svneol=native#text/plain
addon-repository/src/main/resources/selection-namespace-listitem.xml svneol=native#text/plain
addon-repository/src/main/resources/selection-namespace-valuelist.xml svneol=native#text/plain
addon-repository/src/main/resources/selection-namespace.xml svneol=native#text/plain
addon-repository/src/main/resources/selection-types.cnd -text
addon-repository/src/main/resources/system-DynamicDropdown.xml svneol=native#text/plain
addon-repository/src/main/resources/system-StaticDropdown.xml svneol=native#text/plain
hst/pom.xml svneol=native#text/plain
/pom.xml svneol=native#text/plain
src/site/resources/images/cmsdocument.jpg -text svneol=unset#image/jpeg
src/site/resources/images/cmsvaluelist.jpg -text svneol=unset#image/jpeg
src/site/resources/images/site.jpg -text svneol=unset#image/jpeg
src/site/resources/images/thm_cmsdocument.jpg -text svneol=unset#image/jpeg
src/site/resources/images/thm_site.jpg -text svneol=unset#image/jpeg
src/site/site.xml svneol=native#text/plain
src/site/xdoc/build-demo.xml svneol=native#text/plain
src/site/xdoc/configuration.xml svneol=native#text/plain
src/site/xdoc/configuration/dynamicdropdown.xml svneol=native#text/plain
src/site/xdoc/configuration/dynamicmultiselect.xml svneol=native#text/plain
src/site/xdoc/configuration/staticdropdown.xml svneol=native#text/plain
src/site/xdoc/index.xml svneol=native#text/plain
src/site/xdoc/install.xml svneol=native#text/plain
src/site/xdoc/install_7_8.xml svneol=native#text/plain
src/site/xdoc/release-notes.xml svneol=native#text/plain
src/site/xdoc/screenshots.xml svneol=native#text/plain
This diff is collapsed.
Hippo Forge Selection Plugins
Copyright 2009-2014 Hippo B.V. (http://www.onehippo.com)
This product includes software developed by:
Hippo B.V., Amsterdam, The Netherlands (http://www.onehippo.com/);
The Apache Software Foundation (http://www.apache.org/).
NOTICE: Only our own original work is licensed under the terms of the
Apache License Version 2.0. The licenses of some libraries might impose
different redistribution or general licensing terms than those stated in the
Apache License. Users and redistributors are hereby requested to verify these
conditions and agree upon them.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2010-2013 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onehippo.forge.selectionplugins</groupId>
<artifactId>selectionplugins</artifactId>
<version>2.09.00-SNAPSHOT</version>
</parent>
<name>Hippo Forge Selection Plugins Addon CMS</name>
<description>Hippo Forge Selection Plugins Addon CMS</description>
<artifactId>selectionplugins-addon-cms</artifactId>
<dependencies>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-api</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-editor-frontend</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-perspectives</artifactId>
</dependency>
<dependency>
<artifactId>jcr</artifactId>
<groupId>javax.jcr</groupId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-api</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-builtin</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-translation-common</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<inherited>true</inherited>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.html</include>
<include>**/*.css</include>
<include>**/*.png</include>
<include>**/*.gif</include>
</includes>
</resource>
</resources>
</build>
</project>
/*
* Copyright 2011-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.forge.selection.frontend;
/** Namespace constants */
public final class Namespace {
public class Property {
public static final String KEY = "selection:key";
public static final String LABEL = "selection:label";
}
public class Type {
public static final String VALUE_LIST = "selection:valuelist";
public static final String VALUE_LIST_ITEM = "selection:listitem";
}
private Namespace() {
}
}
\ No newline at end of file
/*
* Copyright 2010-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.forge.selection.frontend.model;
import java.io.Serializable;
/**
* List item object reflecting the list item in a value list document.
*
* @author Jeroen Hoffman
* @author Dennis Dam
*/
public class ListItem implements Serializable {
private static final long serialVersionUID = -7549187735023108422L;
private final String key;
private final String label;
private final String group;
/**
* Constructor for this class
* @param key the key of the list item
* @param label the label of the list item
*/
public ListItem(final String key, final String label) {
this.key = key;
this.label = label;
this.group=null;
}
/**
* Constructor for this class
* @param key the key of the list item
* @param label the label of the list item
* @param group the group to which this item belongs
*/
public ListItem(final String key, final String label, final String group) {
this.key = key;
this.label = label;
this.group=group;
}
public String getKey() {
return key;
}
public String getLabel() {
return label;
}
public String getGroup() {
return group;
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return getKey();
}
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((key == null) ? 0 : key.hashCode());
return result;
}
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
if (this == obj){ return true;}
if (obj == null){ return false;}
if (getClass() != obj.getClass()){ return false;}
ListItem other = (ListItem) obj;
if (key == null) {
if (other.key != null){ return false;}
} else if (!key.equals(other.key)){ return false;}
if (group == null){
if (other.group != null){ return false;}
} else if (!group.equals(other.group)){ return false; }
return true;
}
}
/*
* Copyright 2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.forge.selection.frontend.model;
import java.io.Serializable;
import java.util.Iterator;
import org.apache.wicket.model.LoadableDetachableModel;
import org.hippoecm.frontend.model.event.EventCollection;
import org.hippoecm.frontend.model.event.IEvent;
import org.hippoecm.frontend.model.event.IObservable;
import org.hippoecm.frontend.model.event.IObservationContext;
import org.hippoecm.frontend.model.event.Observer;
import org.hippoecm.frontend.model.properties.JcrPropertyValueModel;
/**
* Observable wrapper around a JcrPropertyValueModel
*/
public class ObservableValueModel<T extends Serializable> extends LoadableDetachableModel<T> implements IObservable {
private final JcrPropertyValueModel<T> valueModel;
private IObservationContext<? extends IObservable> context;
private Observer<IObservable> observer;
public ObservableValueModel(JcrPropertyValueModel<T> valueModel) {
this.valueModel = valueModel;
}
public JcrPropertyValueModel<T> getValueModel() {
return valueModel;
}
@Override
protected T load() {
return valueModel.getObject();
}
@Override
public void setObservationContext(final IObservationContext<? extends IObservable> context) {
this.context = context;
}
@Override
public void startObservation() {
observer = new Observer<IObservable>(valueModel.getJcrPropertymodel()) {
@Override
public void onEvent(final Iterator<? extends IEvent<IObservable>> events) {
context.notifyObservers(new EventCollection(events));
}
};
context.registerObserver(observer);
}
@Override
public void stopObservation() {
context.unregisterObserver(observer);
}
}
/*
* Copyright 2010-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.forge.selection.frontend.model;
import java.util.ArrayList;
import org.apache.wicket.util.io.IClusterable;
/**
* Value list object, i.e. an array list with ListItem objects, reflecting a
* value list document.
*
* @author Jeroen Hoffman
* @author Dennis Dam
*/
public class ValueList extends ArrayList<ListItem> implements IClusterable {
private static final long serialVersionUID = 1361292197145754639L;
/**
* Constructor.
*/
public ValueList() {
super();
}
/**
* The index of the specified object in this list.
*
* The object can be either a listitem or a string. If it
* is a string, then it represents the key of a list item.
*
* @param element a listitem or a string
* @return index of a list item in the list
*/
@Override
public int indexOf(Object element) {
if (element instanceof ListItem) {
return super.indexOf(element);
}
// string value is considered as the key
if (element instanceof String) {
for (int i = 0; i < size(); i++) {
if (get(i).getKey().equals(element)) {
return i;
}
}
}
return -1;
}
/**
* Returns the key of the list item associated with the provided object.
* The object can be either a listitem or a string. If it
* is a string, then it represents the key of a list item.
*
* @param object a listitem or a string
* @return the key associated with the listitem/string
*/
public String getKey(Object object) {
if (object instanceof ListItem) {
return ((ListItem) object).getKey();
}
// string value is considered as the key itself
if (object instanceof String) {
return (String) object;
}
return null;
}
/**
* Returns the label of the list item associated with the provided object.
* The object can be either a listitem or a string. If it
* is a string, then it represents the key of a list item.
*
* @param object a listitem or a string
* @return the label associated with the listitem/string
*/
public String getLabel(Object object) {
if (object instanceof ListItem) {
return ((ListItem) object).getLabel();
}
// string value is considered as the key
if (object instanceof String) {
for (int i = 0; i < size(); i++) {
if (get(i).getKey().equals(object)) {
return get(i).getLabel();
}
}
}
return null;
}
/**
* Looks up a listitem by matching the given key.
* @param key the key of a listitem
* @return the listitem of which the key is equal to the given key
*/
public ListItem getListItemByKey(String key){
for (int i = 0; i < size(); i++) {
ListItem valueListItem = get(i);
if (valueListItem.getKey().equals(key)) {
return valueListItem;
}
}
return null;
}
}
/*
* Copyright 2010-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.forge.selection.frontend.plugin;
import java.util.Locale;
import org.apache.commons.lang.StringUtils;
import org.hippoecm.frontend.editor.ITemplateEngine;
import org.hippoecm.frontend.model.properties.JcrPropertyValueModel;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.frontend.service.render.RenderPlugin;
import org.onehippo.forge.selection.frontend.model.ValueList;
import org.onehippo.forge.selection.frontend.plugin.sorting.SortHelper;
import org.onehippo.forge.selection.frontend.provider.IValueListProvider;
import org.onehippo.forge.selection.frontend.utils.SelectionUtils;
/**
* Base class for CMS widgets that enable the user to select an item from a list.
* Contains logic for fetching the list and generic plugin functionalities.
* The list is backed by a ValueListProvider service that provides a ValueList
* object.
*
* The default DocumentValueListProvider reads a document of the type
* 'selection:valuelist', which contains key label pairs used to display values
* and labels in the dropdown.
*
* The plugin configuration must then be provided with a <code>source</code>
* property, which can either be a valid UUID of a handle or the path to the
* document based on the JCR root.
*/
public abstract class AbstractChoicePlugin extends RenderPlugin<String> {
private static final long serialVersionUID = 1L;
private static final ValueList EMPTY_VALUE_LIST = new ValueList();
private final SortHelper sortHelper = new SortHelper();
/**
* Constructor for this class.
*
* @param context plugin context
* @param config plugin config
*/
public AbstractChoicePlugin(IPluginContext context, IPluginConfig config) {
super(context, config);
}
/**
* Returns whether plugin is in edit mode
*
* @return true if plugin is in edit mode
*/
protected boolean isInEditMode() {
final String mode = getPluginConfig().getString(ITemplateEngine.MODE);
return "edit".equals(mode);
}
/**
* Returns the list of value items that is used to populate
* the choices for this selectable widget
*
* @return list of values
*/
protected ValueList getValueList() {
// configured provider
ValueList valueList = getValueListFromProvider();
if (valueList != null) {
return valueList;
}
return EMPTY_VALUE_LIST;
}
/**
* Returns the value list provided by the provider configured for this plugin.
*
* @return value list from configured value list provider
*/
private ValueList getValueListFromProvider() {
IValueListProvider selectedProvider = getValueListProvider();
if (selectedProvider == null) {
return null;
}
final Locale locale = SelectionUtils.getLocale(SelectionUtils.getNode(getModel()));
final ValueList valueList = selectedProvider.getValueList(getPluginConfig().getString(Config.SOURCE), locale);
sortHelper.sort(valueList, getPluginConfig());
return valueList;
}
/**
* Returns the value list provider configured for this plugin.
*/
private IValueListProvider getValueListProvider() {
String providerName = getPluginConfig().getString(Config.VALUELIST_PROVIDER, IValueListProvider.SERVICE_VALUELIST_DEFAULT);
if (StringUtils.isNotBlank(providerName)) {
return getPluginContext().getService(providerName, IValueListProvider.class);
}
return null;
}
/**
* Returns the property value model associated with this plugin.
*
* @return property value model
*/
protected JcrPropertyValueModel<String> getValueModel() {
return (JcrPropertyValueModel<String>) getModel();
}
}
/*
* Copyright 2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.forge.selection.frontend.plugin;
import org.apache.wicket.ajax.AjaxRequestTarget;
/**
* @version $Id$
*/
public interface AjaxUpdatesAware {
void onAjaxUpdate(AjaxRequestTarget target, String eventId, Object message);
}
/*
* Copyright 2010-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.