Search in sources :

Example 1 with Icon

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();
}
Also used : Instant(java.time.Instant) Icon(com.enonic.xp.icon.Icon)

Example 2 with Icon

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();
}
Also used : WidgetDescriptor(com.enonic.xp.admin.widget.WidgetDescriptor) Icon(com.enonic.xp.icon.Icon)

Example 3 with Icon

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());
}
Also used : Icon(com.enonic.xp.icon.Icon) Test(org.junit.jupiter.api.Test)

Example 4 with Icon

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");
    }
}
Also used : Icon(com.enonic.xp.icon.Icon)

Example 5 with Icon

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());
}
Also used : Icon(com.enonic.xp.icon.Icon) Test(org.junit.jupiter.api.Test)

Aggregations

Icon (com.enonic.xp.icon.Icon)8 Instant (java.time.Instant)2 Test (org.junit.jupiter.api.Test)2 WidgetDescriptor (com.enonic.xp.admin.widget.WidgetDescriptor)1 ApplicationDescriptor (com.enonic.xp.app.ApplicationDescriptor)1 XmlApplicationParser (com.enonic.xp.xml.parser.XmlApplicationParser)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1