use of org.xwiki.uiextension.UIExtension in project xwiki-platform by xwiki.
the class AbstractPanelsUIExtensionManager method get.
@Override
public List<UIExtension> get(String extensionPointId) {
List<UIExtension> panels = new ArrayList<UIExtension>();
String panelConfigurationString = getConfiguration();
// Verify that there's a panel configuration property defined, and if not don't return any panel extension.
if (!StringUtils.isEmpty(panelConfigurationString)) {
List<String> panelSerializedReferences = new ArrayList<String>();
for (String serializedReference : getConfiguration().split(",")) {
panelSerializedReferences.add(serializer.serialize(resolver.resolve(serializedReference.trim())));
}
try {
List<UIExtension> allExtensions = contextComponentManagerProvider.get().getInstanceList(UIExtension.class);
for (String panelSerializedReference : panelSerializedReferences) {
for (UIExtension extension : allExtensions) {
if (extension.getId().equals(panelSerializedReference)) {
panels.add(extension);
}
}
}
} catch (ComponentLookupException e) {
logger.error("Failed to lookup Panels instances, error: [{}]", e);
}
}
return panels;
}
use of org.xwiki.uiextension.UIExtension in project xwiki-platform by xwiki.
the class ExcludeFilter method filter.
@Override
public List<UIExtension> filter(List<UIExtension> extensions, String... ids) {
List<String> extensionIds = Arrays.asList(ids);
List<UIExtension> results = new ArrayList<UIExtension>();
for (UIExtension extension : extensions) {
if (!extensionIds.contains(extension.getId())) {
results.add(extension);
}
}
return results;
}
use of org.xwiki.uiextension.UIExtension in project xwiki-platform by xwiki.
the class SelectFilter method filter.
/**
* @param extensions The list of {@link UIExtension}s to filter
* @param ids The IDs of the {@link UIExtension}s to select
* @return The filtered list
*/
@Override
public List<UIExtension> filter(List<UIExtension> extensions, String... ids) {
List<String> extensionIds = Arrays.asList(ids);
List<UIExtension> results = new ArrayList<UIExtension>();
for (String id : extensionIds) {
for (UIExtension extension : extensions) {
if (id.equals(extension.getId())) {
results.add(extension);
}
}
}
return results;
}
use of org.xwiki.uiextension.UIExtension in project xwiki-platform by xwiki.
the class UIExtensionScriptService method getExtensions.
/**
* Retrieves the list of {@link UIExtension} for a given Extension Point.
*
* Examples:
* <ul>
* <li>Get only the {@link UIExtension}s with the given IDs for the Extension Point "platform.example"
* <pre>$services.uix.getExtensions('platform.example', {'select' : 'id1, id2, id3'})</pre></li>
* <li>Get all the {@link UIExtension}s for the Extension Point "platform.example" except the
* {@link UIExtension}s with the IDs "id2" and "id3"
* <pre>$services.uix.getExtensions('platform.example', {'exclude' : 'id2, id3'})</pre></li>
* <li>Get all the {@link UIExtension}s for the Extension Point "platform.example" and order them by one of their
* parameter
* <pre>$services.uix.getExtensions('platform.example', {'sortByParameter' : 'parameterKey'})</pre></li>
* <li>Get only the {@link UIExtension}s with the given IDs for the Extension Point "platform.example" and order
* them by one of their parameter
* <pre>$services.uix.getExtensions('platform.example',
* {'select' : 'id1, id2, id3', 'sortByParameter' : 'parameterKey'})</pre></li>
* </ul>
*
* @param extensionPointId The ID of the Extension Point to retrieve the {@link UIExtension}s for
* @param filters Optional filters to apply before retrieving the list
* @return the list of {@link UIExtension} for the given Extension Point
*/
public List<UIExtension> getExtensions(String extensionPointId, Map<String, String> filters) {
List<UIExtension> extensions = getExtensions(extensionPointId);
for (Map.Entry<String, String> entry : filters.entrySet()) {
String filterHint = entry.getKey();
try {
UIExtensionFilter filter = contextComponentManagerProvider.get().getInstance(UIExtensionFilter.class, filterHint);
extensions = filter.filter(extensions, this.parseFilterParameters(entry.getValue()));
} catch (ComponentLookupException e) {
logger.warn("Unable to find a UIExtensionFilter for hint [{}] " + "while getting UIExtensions for extension point [{}]", filterHint, extensionPointId);
}
}
return extensions;
}
use of org.xwiki.uiextension.UIExtension in project xwiki-platform by xwiki.
the class SortByCustomOrderFilter method filter.
/**
* @param extensions The list of {@link UIExtension}s to filter
* @param ids The IDs of {@link UIExtension} to display first, in the desired order
* @return The filtered list
*/
@Override
public List<UIExtension> filter(List<UIExtension> extensions, String... ids) {
List<String> extensionIds = Arrays.asList(ids);
Collections.reverse(extensionIds);
List<UIExtension> results = new ArrayList<UIExtension>();
results.addAll(extensions);
for (String id : extensionIds) {
for (UIExtension extension : results) {
if (id.equals(extension.getId())) {
results.remove(extension);
results.add(0, extension);
break;
}
}
}
return results;
}
Aggregations