public void init() {
   currentId = null;
   trustBox.setSelectedIndex(0);
   descBox.setText("");
   defaultDescBox.setText("");
   accountCredIdBox.setText("");
   accountCredNameBox.setSelectedIndex(0);
   accountDebIdBox.setText("");
   accountDebNameBox.setSelectedIndex(0);
   actionClubBox.setSelectedIndex(0);
   actionTrustBox.setSelectedIndex(0);
 }
    public void init(String id) {
      currentId = id;

      JSONObject object = trustActionCache.getTrustAction(id);

      String trust = Util.str(object.get("fond"));
      String desc = Util.str(object.get("description"));
      String defaultdesc = Util.str(object.get("defaultdesc"));
      String actionclub = Util.str(object.get("actionclub"));
      String actiontrust = Util.str(object.get("actionfond"));
      String debetpost = Util.strSkipNull(object.get("debetpost"));
      String creditpost = Util.strSkipNull(object.get("creditpost"));

      Util.setIndexByValue(trustBox.getListbox(), trust);
      descBox.setText(desc);
      defaultDescBox.setText(defaultdesc);
      accountCredIdBox.setText(creditpost);
      Util.setIndexByValue(accountCredNameBox, creditpost);
      accountDebIdBox.setText(debetpost);
      Util.setIndexByValue(accountDebNameBox, debetpost);
      Util.setIndexByValue(actionClubBox, actionclub);
      Util.setIndexByValue(actionTrustBox, actiontrust);
    }
    private void doSave() {
      StringBuffer sb = new StringBuffer();
      sb.append("action=save");

      Util.addPostParam(sb, "id", currentId);
      Util.addPostParam(sb, "trust", trustBox.getText());
      Util.addPostParam(sb, "description", descBox.getText());
      Util.addPostParam(sb, "defaultdesc", defaultDescBox.getText());
      Util.addPostParam(sb, "clubaction", Util.getSelected(actionClubBox));
      Util.addPostParam(sb, "trustaction", Util.getSelected(actionTrustBox));
      Util.addPostParam(sb, "debetpost", accountDebIdBox.getText());
      Util.addPostParam(sb, "creditpost", accountCredIdBox.getText());

      ServerResponse callback =
          new ServerResponse() {

            @Override
            public void serverResponse(JSONValue value) {
              JSONObject obj = value.isObject();

              String serverResponse = Util.str(obj.get("result"));

              if ("0".equals(serverResponse)) {
                mainErrorLabel.setText(messages.save_failed());
                Util.timedMessage(mainErrorLabel, "", 5);
              } else {
                /* Could probably be more effective, but why bother? */
                TrustActionCache.getInstance(constants, messages).flush(me);

                hide();
              }
            }
          };

      AuthResponder.post(constants, messages, callback, sb, "registers/trustaction.php");
    }
    TrustActionEditFields() {
      setText(elements.project());
      FlexTable edittable = new FlexTable();
      edittable.setStyleName("edittable");

      edittable.setText(0, 0, elements.trust());
      trustBox = new ListBoxWithErrorText("trust");
      trustActionCache.fillTrustList(trustBox.getListbox());
      edittable.setWidget(0, 1, trustBox);

      edittable.setText(1, 0, elements.description());
      descBox = new TextBoxWithErrorText("description");
      descBox.setMaxLength(40);
      descBox.setVisibleLength(40);
      edittable.setWidget(1, 1, descBox);

      edittable.setText(2, 0, elements.trust_default_desc());
      defaultDescBox = new TextBoxWithErrorText("trust_default_desc");
      defaultDescBox.setMaxLength(50);
      defaultDescBox.setVisibleLength(50);
      edittable.setWidget(2, 1, defaultDescBox);

      edittable.setText(3, 0, elements.trust_actionclub());
      actionClubBox = new ListBox();
      addDebetKredit(actionClubBox);
      edittable.setWidget(3, 1, actionClubBox);

      edittable.setText(4, 0, elements.trust_actiontrust());
      actionTrustBox = new ListBox();
      addDebetKredit(actionTrustBox);
      edittable.setWidget(4, 1, actionTrustBox);

      edittable.setText(5, 0, elements.trust_creditpost());
      HorizontalPanel hpcred = new HorizontalPanel();

      HTML errorAccountCredHtml = new HTML();
      accountCredIdBox = new TextBoxWithErrorText("account", errorAccountCredHtml);
      accountCredIdBox.setVisibleLength(6);
      accountCredNameBox = new ListBox();
      accountCredNameBox.setVisibleItemCount(1);

      hpcred.add(accountCredIdBox);
      hpcred.add(accountCredNameBox);
      hpcred.add(errorAccountCredHtml);

      PosttypeCache.getInstance(constants, messages).fillAllPosts(accountCredNameBox);
      Util.syncListbox(accountCredNameBox, accountCredIdBox.getTextBox());

      edittable.setWidget(5, 1, hpcred);

      edittable.setText(6, 0, elements.trust_debetpost());
      HorizontalPanel hpdeb = new HorizontalPanel();

      HTML errorAccountDebHtml = new HTML();
      accountDebIdBox = new TextBoxWithErrorText("account", errorAccountDebHtml);
      accountDebIdBox.setVisibleLength(6);
      accountDebNameBox = new ListBox();
      accountDebNameBox.setVisibleItemCount(1);

      hpdeb.add(accountDebIdBox);
      hpdeb.add(accountDebNameBox);
      hpdeb.add(errorAccountDebHtml);

      PosttypeCache.getInstance(constants, messages).fillAllPosts(accountDebNameBox);
      Util.syncListbox(accountDebNameBox, accountDebIdBox.getTextBox());

      edittable.setWidget(6, 1, hpdeb);

      DockPanel dp = new DockPanel();
      dp.add(edittable, DockPanel.NORTH);

      saveButton = new NamedButton("projectEditView_saveButton", elements.save());
      saveButton.addClickHandler(this);
      cancelButton = new NamedButton("projectEditView_cancelButton", elements.cancel());
      cancelButton.addClickHandler(this);

      mainErrorLabel = new HTML();
      mainErrorLabel.setStyleName("error");

      HorizontalPanel buttonPanel = new HorizontalPanel();
      buttonPanel.add(saveButton);
      buttonPanel.add(cancelButton);
      buttonPanel.add(mainErrorLabel);
      dp.add(buttonPanel, DockPanel.NORTH);
      setWidget(dp);
    }