use of com.enonic.xp.icon.Icon in project xp by enonic.
the class ContentTypeHandlerTest method exampleContentType.
private ContentType exampleContentType() {
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:person").displayName("Person").description("Person content type").superType(ContentTypeName.structured()).displayNameExpression("${name}").icon(schemaIcon).form(getExampleForm()).build();
}
use of com.enonic.xp.icon.Icon in project xp by enonic.
the class WidgetDescriptorLoader method load.
@Override
public WidgetDescriptor load(final DescriptorKey key, final Resource resource) {
final WidgetDescriptor.Builder builder = WidgetDescriptor.create();
builder.key(key);
final String descriptorXml = resource.readString();
parseXml(key.getApplicationKey(), builder, descriptorXml);
final Icon icon = loadIcon(key);
builder.setIcon(icon);
return builder.build();
}
use of com.enonic.xp.icon.Icon in project xp by enonic.
the class ApplicationDescriptorTest method getters.
@Test
public void getters() {
final Icon icon = Icon.from(new byte[] { 0, 1 }, "image/png", Instant.now());
final ApplicationKey key = ApplicationKey.from("app");
final ApplicationDescriptor desc = ApplicationDescriptor.create().key(key).description("My Application").icon(icon).build();
assertNotNull(desc);
assertSame(key, desc.getKey());
assertEquals("My Application", desc.getDescription());
assertSame(icon, desc.getIcon());
}
use of com.enonic.xp.icon.Icon in project xp by enonic.
the class IconLoader 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 ApplicationDescriptorTest method testHashCode.
@Test
public void testHashCode() {
final Icon icon = Icon.from(new byte[] { 0, 1 }, "image/png", Instant.now());
final ApplicationKey key = ApplicationKey.from("app");
final ApplicationDescriptor desc1 = ApplicationDescriptor.create().key(key).description("My Application").icon(icon).build();
final ApplicationDescriptor desc2 = ApplicationDescriptor.create().key(key).description("My Application").icon(icon).build();
final ApplicationDescriptor desc3 = ApplicationDescriptor.create().key(key).build();
assertEquals(desc1.hashCode(), desc1.hashCode());
assertEquals(desc1.hashCode(), desc2.hashCode());
assertNotEquals(desc1.hashCode(), desc3.hashCode());
}
Aggregations