use of org.xwiki.icon.Icon in project xwiki-platform by xwiki.
the class DefaultIconRendererTest method renderHTMLWithJSX.
@Test
public void renderHTMLWithJSX() throws Exception {
IconSet iconSet = new IconSet("default");
iconSet.setJsx("jsx");
iconSet.addIcon("test", new Icon("blabla"));
// Test
mocker.getComponentUnderTest().renderHTML("test", iconSet);
// Verify
verify(jsExtension).use("jsx");
verify(linkExtension, never()).use(any());
verify(skinExtension, never()).use(any());
}
use of org.xwiki.icon.Icon in project xwiki-platform by xwiki.
the class DefaultIconSetLoader method loadIconSet.
@Override
public IconSet loadIconSet(Reader input, String name) throws IconException {
try {
IconSet iconSet = new IconSet(name);
Properties properties = new Properties();
properties.load(input);
// Load all the keys
for (String key : properties.stringPropertyNames()) {
String value = properties.getProperty(key);
if (key.equals(CSS_PROPERTY_NAME)) {
iconSet.setCss(value);
} else if (key.equals(SSX_PROPERTY_NAME)) {
iconSet.setSsx(value);
} else if (key.equals(JSX_PROPERTY_NAME)) {
iconSet.setJsx(value);
} else if (key.equals(RENDER_WIKI_PROPERTY_NAME)) {
iconSet.setRenderWiki(value);
} else if (key.equals(RENDER_HTML_PROPERTY_NAME)) {
iconSet.setRenderHTML(value);
} else if (key.equals(ICON_TYPE_PROPERTY_NAME)) {
iconSet.setType(IconType.valueOf(value.toUpperCase()));
} else {
Icon icon = new Icon();
icon.setValue(properties.getProperty(key));
iconSet.addIcon(key, icon);
}
}
// return
return iconSet;
} catch (IOException e) {
throw new IconException(String.format(ERROR_MSG, name), e);
}
}
use of org.xwiki.icon.Icon in project xwiki-platform by xwiki.
the class DefaultIconRenderer method renderIcon.
private String renderIcon(IconSet iconSet, String iconName, String renderer) throws IconException {
// Get the icon
Icon icon = iconSet.getIcon(iconName);
// The icon may not exist
if (icon == null) {
// return an empty string. Idea: fallback on a different icon instead?
return "";
}
// Interpret the velocity command
StringWriter contentToParse = new StringWriter();
contentToParse.write("#set($icon = \"");
contentToParse.write(icon.getValue());
contentToParse.write("\")\n");
contentToParse.write(renderer);
return velocityRenderer.render(contentToParse.toString());
}
use of org.xwiki.icon.Icon in project xwiki-platform by xwiki.
the class DefaultIconManagerTest method renderHTML.
@Test
public void renderHTML() throws Exception {
IconSet iconSet = new IconSet("silk");
iconSet.addIcon("test", new Icon("hello"));
when(iconSetManager.getCurrentIconSet()).thenReturn(iconSet);
when(iconRenderer.renderHTML("test", iconSet)).thenReturn("rendered icon");
// Test
String result = mocker.getComponentUnderTest().renderHTML("test");
assertEquals("rendered icon", result);
}
use of org.xwiki.icon.Icon in project xwiki-platform by xwiki.
the class DefaultIconRendererTest method renderWithSSX.
@Test
public void renderWithSSX() throws Exception {
IconSet iconSet = new IconSet("default");
iconSet.setSsx("ssx");
iconSet.addIcon("test", new Icon("blabla"));
// Test
mocker.getComponentUnderTest().render("test", iconSet);
// Verify
verify(skinExtension).use("ssx");
verify(linkExtension, never()).use(any());
verify(jsExtension, never()).use(any());
}
Aggregations