use of com.enonic.xp.icon.Icon in project xp by enonic.
the class SchemaHelper method loadIcon.
public static Icon loadIcon(final Class clz, final String metaInfFolderName, final String name) {
final String metaInfFolderBasePath = "/" + "META-INF" + "/" + metaInfFolderName;
final String filePath = metaInfFolderBasePath + "/" + name.toLowerCase();
final Icon svgIcon = doLoadIcon(clz, "image/svg+xml", filePath + ".svg");
if (svgIcon != null) {
return svgIcon;
} else {
return doLoadIcon(clz, "image/png", filePath + ".png");
}
}
use of com.enonic.xp.icon.Icon in project xp by enonic.
the class ApplicationDescriptorBuilder method build.
public ApplicationDescriptor build() {
final URL url = bundle.getResource(APP_DESCRIPTOR_FILENAME);
final String xml = parseAppXml(url);
ApplicationDescriptor.Builder appDescriptorBuilder = ApplicationDescriptor.create();
final XmlApplicationParser parser = new XmlApplicationParser().currentApplication(ApplicationKey.from(bundle)).appDescriptorBuilder(appDescriptorBuilder).source(xml);
parser.parse();
if (hasAppIcon(bundle)) {
final URL iconUrl = bundle.getResource(APP_ICON_FILENAME);
try (InputStream stream = iconUrl.openStream()) {
final byte[] iconData = stream.readAllBytes();
final Icon icon = Icon.from(iconData, "image/svg+xml", Instant.ofEpochMilli(this.bundle.getLastModified()));
appDescriptorBuilder.icon(icon);
} catch (IOException e) {
throw new RuntimeException("Unable to load application icon for " + bundle.getSymbolicName(), e);
}
}
return appDescriptorBuilder.build();
}
use of com.enonic.xp.icon.Icon in project xp by enonic.
the class ContentTypeHandlerTest method testContentType.
private ContentType testContentType() {
byte[] data = new byte[] { 1, 2, 3, 4, 5, 6 };
final Instant ts = LocalDateTime.of(2016, 1, 1, 12, 0, 0).toInstant(ZoneOffset.UTC);
Icon schemaIcon = Icon.from(data, "image/png", ts);
return ContentType.create().name("com.enonic.myapp:article").displayName("Article").description("Article content type").superType(ContentTypeName.structured()).displayNameExpression("${title} ${author}").icon(schemaIcon).form(getForm()).build();
}
Aggregations