eclipse - 如何在现有网页Editor Palette中提供自定义组件

标签 eclipse eclipse-plugin

我想在网页编辑器面板中添加一个名为“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/

相关文章:

java - 加载资源在本地有效,但在服务器上无效

java - 将 Java 类 X 从项目外部导入到 Eclipse 中?

java - Java Web Start 应用程序中下载的 jar 位于何处?

Eclipse 颜色主题 - 在 jsp 编辑器中难以阅读 javascript

eclipse - 哪个版本的 FindBugs 可以与 Eclipse Luna 配合使用?

Java刽子手游戏重绘()不工作

java - 如何在 Eclipse 中运行 Java 文件服务小程序?

windows - 同步windows文件夹

java - Platform.getBundle 返回 null

android - Eclipse 无法识别 Android 支持库修订版 9