public void addItem() {
    try {

      // 1. Deklarasikan object awal
      model.newItemHeader = new SMerk();
      // Karena tidak pisa pake null representation

      model.newItemHeader.setId("New");
      model.newItemHeader.setDescription("");

      // 2. SET NEW DATA ITEM TO BINDER
      model.getBinderHeader().setItemDataSource(model.newItemHeader);

      // 3. REFRESH VIEW AND SHOW FORM LAYOUT
      view.bindAndBuildFieldGroupComponent();
      view.getFormLayout().setVisible(true);

      // 3.SET FORM STATE AND BUTTON STATE
      model.setOperationStatus(EnumOperationStatus.ADDING.getStrCode());
      view.setFormButtonAndTextState();

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
  @Override
  public void buttonClick(ClickEvent event) {
    // TODO Auto-generated method stub
    // Antisipasi
    if (model.getOperationStatus() == null)
      model.setOperationStatus(EnumOperationStatus.OPEN.getStrCode());
    if (model.getOperationStatus().equals(""))
      model.setOperationStatus(EnumOperationStatus.OPEN.getStrCode());

    if (event.getButton() == view.getBtnNewForm()) {
      addItem();
      view.showWindowForm();
    } else if (event.getButton() == view.getBtnEditForm()) {
      view.showWindowForm();
    } else if (event.getButton() == view.getBtnDeleteForm()) {
      deleteForm();
    } else if (event.getButton() == view.getBtnSaveForm()) {
      ConfirmDialog commitDialog =
          ConfirmDialog.show(
              view.getUI(),
              "Konfirmasi Simpan",
              "Simpan Data?",
              "Save",
              "No",
              new ConfirmDialog.Listener() {
                public void onClose(ConfirmDialog dialog) {
                  if (dialog.isConfirmed()) {
                    // Confirmed to continue
                    try {
                      if (model
                          .getOperationStatus()
                          .equals(EnumOperationStatus.ADDING.getStrCode())) {
                        if (insertAndValidateForm() == 0) {
                          view.getTable().focus();
                          view.closeWindowForm();
                        } else {
                          view.focustIdOrDesc();
                        }
                      } else if (model
                          .getOperationStatus()
                          .equals(EnumOperationStatus.EDITING.getStrCode())) {
                        if (updateAndValidateForm() == 0) {
                          view.getTable().focus();
                          view.closeWindowForm();
                        } else {
                          view.focustIdOrDesc();
                        }
                      }

                    } catch (Exception ex) {
                      Notification.show("Terjadi Kesalahan Simpan");
                    }

                  } else {
                    view.focustIdOrDesc();
                  }
                }
              });
      commitDialog.setStyleName("dialog");
      commitDialog.getOkButton().setStyleName("small");
      commitDialog.getCancelButton().setStyleName("small");
      // Jangan lupa
      commitDialog.focus();

    } else if (event.getButton() == view.getBtnCancelForm()) {
      if (model.getOperationStatus().equals(EnumOperationStatus.ADDING.getStrCode())) {
        discardForm();
      } else if (model.getOperationStatus().equals(EnumOperationStatus.ADDING.getStrCode())
          || model.getOperationStatus().equals(EnumOperationStatus.EDITING.getStrCode())) {
        if (view.getFormLayout().isVisible()) {
          discardForm();
        }
      } else {
        view.getTable().focus();
      }

      //			discardForm(operationStatus);
    } else if (event.getButton() == view.getBtnSearch()) {
      searchForm();
    } else if (event.getButton() == view.getBtnPrint()) {
      printForm();
    } else if (event.getButton() == view.getBtnHelp()) {
      helpForm();
    } else if (event.getButton() == view.getBtnUtility()) {
      view.showWindowUtility();
    }
    // Tidak semua akan di refresh container nya >> Jadi refresh container tidak bisa di taruh
    // disini

  }
  public void setFormButtonAndTextState() {

    // KODE REFNO SELALU READ ONLY KARENA OTOMATIS
    if (model.getOperationStatus().equals(EnumOperationStatus.OPEN.getStrCode())) {
      tabSheet.setSelectedTab(panelUtamaDetil);
      tabSheet.getTab(panelUtamaList).setEnabled(true);

      btnNewForm.setEnabled(true);
      btnEditForm.setEnabled(true);
      btnDeleteForm.setEnabled(true);
      btnSearch.setEnabled(true);
      btnPosting.setEnabled(true);

      btnAddItem.setEnabled(false);
      btnEditItem.setEnabled(false);
      btnRemoveItem.setEnabled(false);

      btnSaveForm.setEnabled(false);
      btnCancelForm.setEnabled(false);

      tableDetil.setReadOnly(true);

      fieldNomor.setReadOnly(true);

      fieldAmount.setReadOnly(true);
      fieldAmountafterppn.setReadOnly(true);
      fieldDisc1.setReadOnly(true);
      fieldDisc1rp.setReadOnly(true);
      fieldDisc1rpafterppn.setReadOnly(true);
      fieldDisc2.setReadOnly(true);
      fieldDisc2rp.setReadOnly(true);
      fieldDisc2rpafterppn.setReadOnly(true);
      fieldDisc.setReadOnly(true);
      fieldDiscrp.setReadOnly(true);
      fieldDiscrpafterppn.setReadOnly(true);

      fieldPpnpercent.setReadOnly(true);
      fieldPpnrp.setReadOnly(true);
      fieldAmountafterdisc.setReadOnly(true);
      fieldAmountafterdiscafterppn.setReadOnly(true);

    } else if (model.getOperationStatus().equals(EnumOperationStatus.ADDING.getStrCode())) {
      tabSheet.setSelectedTab(panelUtamaDetil);
      tabSheet.getTab(panelUtamaList).setEnabled(false);
      btnNewForm.setEnabled(false);
      btnEditForm.setEnabled(false);
      btnDeleteForm.setEnabled(false);
      btnSearch.setEnabled(false);
      btnPosting.setEnabled(false);

      btnAddItem.setEnabled(true);
      btnEditItem.setEnabled(true);
      btnRemoveItem.setEnabled(true);

      btnSaveForm.setEnabled(true);
      btnCancelForm.setEnabled(true);

      tableDetil.setReadOnly(false);

      fieldNomor.setReadOnly(true);

      fieldAmount.setReadOnly(false);
      fieldAmountafterppn.setReadOnly(false);
      fieldDisc1.setReadOnly(false);
      fieldDisc1rp.setReadOnly(false);
      fieldDisc1rpafterppn.setReadOnly(false);
      fieldDisc2.setReadOnly(false);
      fieldDisc2rp.setReadOnly(false);
      fieldDisc2rpafterppn.setReadOnly(false);
      fieldDisc.setReadOnly(false);
      fieldDiscrp.setReadOnly(false);
      fieldDiscrpafterppn.setReadOnly(false);

      fieldPpnpercent.setReadOnly(false);
      fieldPpnrp.setReadOnly(false);
      fieldAmountafterdisc.setReadOnly(false);
      fieldAmountafterdiscafterppn.setReadOnly(false);

    } else if (model.getOperationStatus().equals(EnumOperationStatus.EDITING.getStrCode())) {
      tabSheet.setSelectedTab(panelUtamaDetil);
      tabSheet.getTab(panelUtamaList).setEnabled(false);

      btnNewForm.setEnabled(false);
      btnEditForm.setEnabled(false);
      btnDeleteForm.setEnabled(false);
      btnSearch.setEnabled(false);
      btnPosting.setEnabled(false);

      btnAddItem.setEnabled(true);
      btnEditItem.setEnabled(true);
      btnRemoveItem.setEnabled(true);

      btnSaveForm.setEnabled(true);
      btnCancelForm.setEnabled(true);

      tableDetil.setReadOnly(false);

      fieldNomor.setReadOnly(false);

      fieldAmount.setReadOnly(false);
      fieldAmountafterppn.setReadOnly(false);
      fieldDisc1.setReadOnly(false);
      fieldDisc1rp.setReadOnly(false);
      fieldDisc1rpafterppn.setReadOnly(false);
      fieldDisc2.setReadOnly(false);
      fieldDisc2rp.setReadOnly(false);
      fieldDisc2rpafterppn.setReadOnly(false);
      fieldDisc.setReadOnly(false);
      fieldDiscrp.setReadOnly(false);
      fieldDiscrpafterppn.setReadOnly(false);

      fieldPpnpercent.setReadOnly(false);
      fieldPpnrp.setReadOnly(false);
      fieldAmountafterdisc.setReadOnly(false);
      fieldAmountafterdiscafterppn.setReadOnly(false);
    }

    if (checkPosting.getValue() == true) {
      btnPosting.setEnabled(false);
      btnPostingBatal.setEnabled(true);
    } else {
      btnPosting.setEnabled(true);
      btnPostingBatal.setEnabled(false);
    }

    checkEndofday.setReadOnly(true);
    checkPosting.setReadOnly(true);
  }