-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transfer LinkInspector settings from the 'OSGi console' to the 'Grani…
…t' console. #47 -fixed git comments
- Loading branch information
Saldatsenka, Siarhei
committed
Sep 16, 2024
1 parent
e176441
commit ceb0d95
Showing
4 changed files
with
41 additions
and
36 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
core/src/main/java/com/exadel/etoolbox/linkinspector/core/services/util/GraniteUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.exadel.etoolbox.linkinspector.core.services.util; | ||
|
||
import com.adobe.granite.ui.components.ds.ValueMapResource; | ||
import com.day.cq.commons.jcr.JcrConstants; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.sling.api.resource.Resource; | ||
import org.apache.sling.api.resource.ResourceResolver; | ||
import org.apache.sling.api.resource.ValueMap; | ||
import org.apache.sling.api.wrappers.ValueMapDecorator; | ||
import org.apache.sling.jcr.resource.api.JcrResourceConstants; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class GraniteUtil { | ||
public static Resource createTab(ResourceResolver resolver, String path, String title, Collection<Resource> children) { | ||
|
||
Resource items = createResource(resolver, path + "/items", Collections.emptyMap(), children); | ||
|
||
Map<String, Object> properties = new HashMap<>(); | ||
properties.put(JcrConstants.JCR_TITLE, title); | ||
properties.put(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY, "granite/ui/components/coral/foundation/container"); | ||
return createResource(resolver, path, properties, Collections.singletonList(items)); | ||
} | ||
|
||
public static Resource createResource(ResourceResolver resolver, String path, Map<String, Object> properties, Collection<Resource> children) { | ||
|
||
ValueMap valueMap = new ValueMapDecorator(properties); | ||
String resourceType = StringUtils.defaultIfEmpty(properties.getOrDefault(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY, StringUtils.EMPTY).toString(), JcrConstants.NT_UNSTRUCTURED); | ||
return new ValueMapResource(resolver, path, resourceType, valueMap, children); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters