如何在现有网页编辑器面板中提供自定义组件 [英] How to provide a custom component in the existing Web page Editor Palette

查看:27
本文介绍了如何在现有网页编辑器面板中提供自定义组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在名为myHTMLComponent"的网页编辑器面板中添加一个新的自定义组件.因此,只要用户使用 WPE 打开任何 html 页面,myHTMLComponentM 就应该出现在那里.我该怎么做呢?此外,这个组件还需要相应地生成代码更改.如何达到预期的效果.

I want to add a new custom component in the Web page Editor Palete named "myHTMLComponent". So, as soon as user opens any html page with WPE, myHTMLComponentM should be present there. How can I do the needful, moreover this component will as well need to generate the code changes accordingly. How to achieve the desired result.

对此我有什么意见吗?我已经创建了标准元数据标签,但是接下来呢!

Is there any input I can get for this. I already created standardmetadata tag, but what next!

推荐答案

终于找到了问题的解决方案.

Finally, I found the solution of the problem.

要在调色板中添加新类别,我们需要在 plugin.xml 中使用 pagedesignerextension,如下 -

For adding new categories in the palette, we need to use pagedesignerextension in plugin.xml as following -

<extension
point="org.eclipse.jst.pagedesigner.pageDesignerExtension">
<paletteFactory
class="com.comp.myeditor.palette.CustomEditorPaletteFactory">
</paletteFactory>
</extension>

CustomEditorPaletteFactory 将扩展 AbstractPaletteFactory.在 createPaletteRoot() 中,我们可以添加我们的类别.

Where CustomEditorPaletteFactory will be extending AbstractPaletteFactory. Here in createPaletteRoot(), we can add our category.

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;
}

这将在调色板中创建组件类别,我们可以使用 componentsdrawer 添加任意数量的组件.

This will create the component category in the palette and we can add as many components as needed using the componentsdrawer.

在现有类别中添加新类别 -在构造函数中添加这个 -

For adding a new category in the existing one - Add this in the constructor -

super();
        this._paletteContext = PaletteItemManager.createPaletteContext(file);
        this._manager = PaletteItemManager.getInstance(_paletteContext);

然后像这样使用 Palette Grouping -

Then use Palette Grouping like this -

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", 

这篇关于如何在现有网页编辑器面板中提供自定义组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆