我想在网页编辑器面板中添加一个名为“myHTMLComponent”的新自定义组件。 因此,一旦用户使用 WPE 打开任何 html 页面,myHTMLComponentM 就应该出现在那里。 我该如何做需要的事情,而且这个组件还需要相应地生成代码更改。如何达到预期的结果。
我可以为此获得任何意见吗? 我已经创建了标准元数据标记,但下一步是什么!
最佳答案
终于找到了问题的解决方案。
为了在调色板中添加新类别,我们需要在plugin.xml中使用pagedesignerextension,如下所示 -
<extension
point="org.eclipse.jst.pagedesigner.pageDesignerExtension">
<paletteFactory
class="com.comp.myeditor.palette.CustomEditorPaletteFactory">
</paletteFactory>
</extension>
CustomEditorPaletteFactory 将扩展 AbstractPaletteFactory。在 createPaletteRoot() 中,我们可以添加我们的类别。
public PaletteRoot createPaletteRoot(IEditorInput editorInput){
PaletteRoot paletteRoot = new PaletteRoot();
paletteRoot.add(createStandardComponents());
return paletteRoot;
//return null;
}
private static PaletteContainer createStandardComponents() {
PaletteDrawer componentsDrawer = new PaletteDrawer("CustomHTMLComponent");
TagToolPaletteEntry paletteEntry = new TagToolPaletteEntry(
new FormPaletteComponent(".....);
componentsDrawer.add(paletteEntry);
return componentsDrawer;
}
这将在调色板中创建组件类别,我们可以使用组件抽屉添加所需数量的组件。
用于在现有类别中添加新类别 - 在构造函数中添加它 -
super();
this._paletteContext = PaletteItemManager.createPaletteContext(file);
this._manager = PaletteItemManager.getInstance(_paletteContext);
然后像这样使用调色板分组 -
PaletteGroup controls = new PaletteGroup("CUST HTML");
super.add(controls);
ToolEntry tool = new SelectionToolEntry("CUST Cursor",
"Cursor DESCRIPTION");
controls.add(tool);
setDefaultEntry(tool);
//Custom Marquee
controls.add(new MarqueeToolEntry("Marquee", "Marquee Desc"));
controls.add(new PaletteSeparator());
//This class maintins or load all categories features
controls.add(new CustomComponentToolEntry("Custom Component", "Custom Component Descrition",
关于eclipse - 如何在现有网页Editor Palette中提供自定义组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5509679/