Vaadin Designer 不是可编辑的自定义组件

Vaadin Designer Not an Editable Custom Component

刚开始使用Vaadin,我想使用设计器来修改创建vaadin 项目时给定的默认页面。

但是我一直收到这个错误:'Could not open design view: Failed to parse visually editable class caused by Not an editable CustomComponent'

代码如下:

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
@Theme("timekeeper")
public class TimekeeperUI extends UI {

    VerticalLayout layout = new VerticalLayout();

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = TimekeeperUI.class)
    public static class Servlet extends VaadinServlet {
    }

    @Override
    protected void init(VaadinRequest request) {
        layout.setMargin(true);
        setContent(layout);
    }

}

我想我已经正确安装了 xulrunner,因为我在启动 eclipse 时没有收到这个错误。

感谢任何帮助。

我还没有在任何地方看到它的明确说明,但我 90% 确定 the editor works with descendants of com.vaadin.ui.CustomComponent. Thus, my suggestion is to create a new CustomComponent/Vaadin Composite as described here,对其进行可视化编辑并将其实例添加到您的 UI。

P.S。如果您进行了一些手动更改,但仍希望保持编辑器可解析,则至少应注意以下几点(据我现在回忆):

  • @Autogenerated 字段和方法
  • 它生成的对齐方式为 new Alignment(34) 而不是 Alignment.MIDDLE_RIGHT
  • labels `ContentMode.HTML(不是 100% 确定,但我记得在构造函数中设置这些而不是自动生成的方法)

我使用的 eclipse 服务包似乎有问题。谷歌搜索了好久才告诉我这一点,我花了一段时间才重定向到该页面。