public static EditableTableComponent instance(
      RequestContext context, String id, TableComponent table) {
    Locale locale = context.getLocale();
    ResourceBundle resb = ResourceBundle.getBundle("com.tonbeller.wcf.table.resources", locale);
    String path = PluginUtils.getPluginDir() + "/ui/resources/wcf/tableproperties.xml";

    /*
    URL url = null;
    try {
    //	url = ResourceLocator.getResource(context.getServletContext(),
    			//locale, path);
    	url = context.getServletContext().getResource(path);
    } catch (Exception e) {
    	e.printStackTrace();
    	throw new SoftException(e);
    }
    */
    // Document doc = XmlUtils.parse(url);
    Document doc = null;
    try {
      doc = XmlUtils.parse(new File(path).toURL());
    } catch (MalformedURLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // In replaceI18n(...) wird geprüft, ob "bundle"-Attribut vorhanden
    FormDocument.replaceI18n(context, doc, null);

    TablePropertiesFormComponent formComp =
        new TablePropertiesFormComponent(id + ".form", null, doc, table);
    formComp.setVisible(false);
    formComp.setCloseable(true);
    return new EditableTableComponent(id, null, table, formComp);
  }
  public Document render(RequestContext context) throws Exception {
    if (isEditFormVisible()) return formComp.render(context);

    Document doc = tableComp.render(context);
    if (editable) doc.getDocumentElement().setAttribute("editId", editButtonId);
    return doc;
  }
  /**
   * creates an editable table component.
   *
   * @param id
   * @param tableComp
   * @param formComp - form for editing the table properties
   */
  public EditableTableComponent(
      String id,
      Component parent,
      TableComponent tableComp,
      TablePropertiesFormComponent formComp) {
    super(id, parent);
    this.tableComp = tableComp;
    this.formComp = formComp;
    tableComp.setParent(this);
    formComp.setParent(this);

    // this is a little sloppy, because both components
    // are validated although only one can be visible
    addFormListener(tableComp);
    addFormListener(formComp);

    editButtonId = id + ".edit";
    getDispatcher().addRequestListener(editButtonId, null, editButtonListener);
  }
 /** @param newModel */
 public void setModel(TableModel newModel) {
   tableComp.setModel(newModel);
   formComp.columnTreeModelChanged();
 }
 public boolean isEditFormVisible() {
   return formComp.isVisible();
 }
 public void destroy(HttpSession session) throws Exception {
   formComp.destroy(session);
   tableComp.destroy(session);
   super.destroy(session);
 }
 public void initialize(RequestContext context) throws Exception {
   super.initialize(context);
   tableComp.initialize(context);
   formComp.initialize(context);
 }
 public void request(RequestContext context) throws Exception {
   tableComp.validate(context);
   formComp.setVisible(true);
 }