001
014
015 package com.liferay.portal.editor.configuration;
016
017 import com.liferay.portal.kernel.editor.configuration.EditorOptions;
018 import com.liferay.portal.kernel.editor.configuration.EditorOptionsContributor;
019 import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
020 import com.liferay.portal.kernel.util.ListUtil;
021 import com.liferay.portal.theme.ThemeDisplay;
022 import com.liferay.registry.collections.ServiceReferenceMapper;
023 import com.liferay.registry.collections.ServiceTrackerCollections;
024 import com.liferay.registry.collections.ServiceTrackerMap;
025
026 import java.util.Iterator;
027 import java.util.List;
028 import java.util.Map;
029
030
033 public class EditorOptionsProvider
034 extends BaseEditorConfigurationProvider<EditorOptionsContributor> {
035
036 public EditorOptions getEditorOptions(
037 String portletName, String editorConfigKey, String editorName,
038 Map<String, Object> inputEditorTaglibAttributes,
039 ThemeDisplay themeDisplay,
040 LiferayPortletResponse liferayPortletResponse) {
041
042 EditorOptions editorOptions = new EditorOptions();
043
044 Iterator<EditorOptionsContributor> iterator = ListUtil.reverseIterator(
045 getContributors(portletName, editorConfigKey, editorName));
046
047 while (iterator.hasNext()) {
048 EditorOptionsContributor editorOptionsContributor = iterator.next();
049
050 editorOptionsContributor.populateEditorOptions(
051 editorOptions, inputEditorTaglibAttributes, themeDisplay,
052 liferayPortletResponse);
053 }
054
055 return editorOptions;
056 }
057
058 @Override
059 protected ServiceTrackerMap<String, List<EditorOptionsContributor>>
060 getServiceTrackerMap() {
061
062 return _serviceTrackerMap;
063 }
064
065 private static final ServiceReferenceMapper
066 <String, EditorOptionsContributor>
067 _serviceReferenceMapper = new EditorServiceReferenceMapper<>();
068 private static final ServiceTrackerMap
069 <String, List<EditorOptionsContributor>> _serviceTrackerMap =
070 ServiceTrackerCollections.multiValueMap(
071 EditorOptionsContributor.class,
072 "(|(editor.config.key=*)(editor.name=*)(javax.portlet.name=*))",
073 _serviceReferenceMapper);
074
075 static {
076 _serviceTrackerMap.open();
077 }
078
079 }