本文整理汇总了Java中org.netbeans.spi.palette.PaletteItemRegistration类的典型用法代码示例。如果您正苦于以下问题:Java PaletteItemRegistration类的具体用法?Java PaletteItemRegistration怎么用?Java PaletteItemRegistration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PaletteItemRegistration类属于org.netbeans.spi.palette包,在下文中一共展示了PaletteItemRegistration类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.netbeans.spi.palette.PaletteItemRegistration; //导入依赖的package包/类
private void process(Element e, PaletteItemRegistration pir) throws LayerGenerationException {
LayerBuilder builder = layer(e);
TypeMirror activeEditorDrop = type(ActiveEditorDrop.class);
LayerBuilder.File f = builder.file(pir.paletteid() + "/" + pir.category() + "/" + pir.itemid() + ".xml");
StringBuilder paletteFile = new StringBuilder();
paletteFile.append("<!DOCTYPE editor_palette_item PUBLIC '-//NetBeans//Editor Palette Item 1.1//EN' 'http://www.netbeans.org/dtds/editor-palette-item-1_1.dtd'>\n");
paletteFile.append("<editor_palette_item version=\"1.1\">\n");
if (pir.body().isEmpty()) {
// body empty we need a activeEditorDrop
if (e.getKind() == ElementKind.CLASS && isAssignable(e.asType(), activeEditorDrop)) {
String className = processingEnv.getElementUtils().getBinaryName((TypeElement) e).toString();
paletteFile.append(" <class name=\"").append(className).append("\"/>\n");
} else {
throw new LayerGenerationException("Class annotated with @PaletteItemRegistration has to implements ActiveEditorDrop", e);
}
} else {
// body not empty put info
paletteFile.append("<body> <![CDATA[");
paletteFile.append(pir.body());
paletteFile.append("]]> </body>\n");
}
// icon shoud be in classpath
if (!pir.icon16().isEmpty()) {
builder.validateResource(pir.icon16(), e, pir, "icon16", true);
paletteFile.append("<icon16 urlvalue=\"").append(pir.icon16()).append("\" />\n");
} else {
throw new LayerGenerationException("Icon 16 must be set ", e);
}
if (!pir.icon32().isEmpty()) {
builder.validateResource(pir.icon32(), e, pir, "icon32", true);
paletteFile.append("<icon32 urlvalue=\"").append(pir.icon32()).append("\" />\n");
} else {
throw new LayerGenerationException("Icon 32 must be set ", e);
}
paletteFile.append("<inline-description>");
paletteFile.append("<display-name>");
paletteFile.append(pir.name());
paletteFile.append("</display-name>");
paletteFile.append("<tooltip> <![CDATA[ ");
paletteFile.append(pir.tooltip());
paletteFile.append("]]></tooltip>");
paletteFile.append("</inline-description>");
paletteFile.append("</editor_palette_item>");
f.contents(paletteFile.toString());
f.write();
}