/**
   * Saves the components to table. <br>
   *
   * @throws InterruptedException
   */
  public void doSave() throws InterruptedException {

    final SecRole aRole = getRole();

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // force validation, if on, than execute by component.getValue()
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    if (!isValidationOn()) {
      doSetValidation();
    }

    // fill the object with the components data
    doWriteComponentsToBean(aRole);

    // save it to database
    try {
      getSecurityService().saveOrUpdate(aRole);
    } catch (DataAccessException e) {
      ZksampleMessageUtils.showErrorMessage(e.getMostSpecificCause().toString());

      // Reset to init values
      doResetInitValues();

      doReadOnly();
      btnCtrl.setBtnStatus_Save();
      return;
    }

    // now synchronize the listBox
    ListModelList lml = (ListModelList) listBoxSecRoles.getListModel();

    // Check if the object is new or updated
    // -1 means that the obj is not in the list, so it's new.
    if (lml.indexOf(aRole) == -1) {
      lml.add(aRole);
    } else {
      lml.set(lml.indexOf(aRole), aRole);
    }

    doReadOnly();
    btnCtrl.setBtnStatus_Save();

    // init the old values vars new
    doStoreInitValues();
  }
  /**
   * Cancel the actual operation. <br>
   * <br>
   * Resets to the original status.<br>
   */
  private void doCancel() {
    doResetInitValues();

    aupMenge.setReadonly(true);
    aupEinzelwert.setReadonly(true);
    aupGesamtwert.setReadonly(true);

    btnCtrl.setInitEdit();
  }
  /** Set the components for edit mode. <br> */
  private void doEdit() {

    rolShortdescription.setReadonly(false);
    rolLongdescription.setReadonly(false);

    btnCtrl.setBtnStatus_Edit();

    // remember the old vars
    doStoreInitValues();
  }
  /**
   * Opens the Dialog window modal.
   *
   * <p>It checks if the dialog opens with a new or existing object and set the readOnly mode
   * accordingly.
   *
   * @param anOrderposition
   * @throws InterruptedException
   */
  public void doShowDialog(Orderposition anOrderposition) throws InterruptedException {

    // if aBranche == null then we opened the Dialog without
    // args for a given entity, so we get a new Obj().
    if (anOrderposition == null) {

      /** !!! DO NOT BREAK THE TIERS !!! */
      // We don't create a new DomainObject() in the frontend.
      // We GET it from the backend.
      anOrderposition = getOrderService().getNewOrderposition();
    }

    try {

      if (anOrderposition.getOrder() != null) {
        // fill the components with the data
        doWriteBeanToComponents(anOrderposition);
      }

      // set Readonly mode accordingly if the object is new or not.
      if (anOrderposition.isNew()) {
        btnCtrl.setInitNew();
        doEdit();
      } else {
        btnCtrl.setInitEdit();
        doReadOnly();
      }

      // stores the inital data for comparing if they are changed
      // during user action.
      doStoreInitValues();

      orderPositionDialogWindow.doModal(); // open the dialog in
      // modal
      // mode
    } catch (final Exception e) {
      Messagebox.show(e.toString());
    }
  }
  /** Create a new secRole object. <br> */
  private void doNew() {

    /** !!! DO NOT BREAK THE TIERS !!! */
    // We don't create a new DomainObject() in the frontend.
    // We GET it from the backend.
    setRole(getSecurityService().getNewSecRole());

    doClear(); // clear all commponents
    doEdit(); // edit mode

    btnCtrl.setBtnStatus_New();

    // remember the old vars
    doStoreInitValues();
  }
  /** Set the components for edit mode. <br> */
  private void doEdit() {

    // artNr + description are only be filled by searchBox
    artNr.setReadonly(true);
    artKurzbezeichnung.setReadonly(true);
    bandbox_OrderPositionDialog_ArticleSearch.setDisabled(false);

    aupMenge.setReadonly(false);
    aupEinzelwert.setReadonly(false);
    aupGesamtwert.setReadonly(false);

    btnCtrl.setBtnStatus_Edit();

    // remember the old vars
    doStoreInitValues();
  }
  /** Create a new orderPosition object. <br> */
  private void doNew() {

    /** !!! DO NOT BREAK THE TIERS !!! */
    // We don't create a new DomainObject() in the frontend.
    // We GET it from the backend.
    Orderposition anOrderposition = getOrderService().getNewOrderposition();
    setOrderposition(anOrderposition);
    anOrderposition.setOrder(order);

    doClear(); // clear all commponents
    doEdit(); // edit mode

    btnCtrl.setBtnStatus_New();

    // remember the old vars
    doStoreInitValues();
  }
  /**
   * Saves the components to table. <br>
   *
   * @throws InterruptedException
   */
  public void doSave() throws InterruptedException {

    Orderposition anOrderposition = getOrderposition();

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // force validation, if on, than execute by component.getValue()
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    if (!isValidationOn()) {
      doSetValidation();
    }

    artNr.getValue();

    // additionally calculate new
    if (isDataChanged()) {
      doCalculate();
    }

    // fill the objects with the components data
    doWriteComponentsToBean(anOrderposition);

    // save it to database
    try {
      getOrderService().saveOrUpdate(anOrderposition);
    } catch (DataAccessException e) {
      ZksampleMessageUtils.showErrorMessage(e.getMostSpecificCause().toString());

      // Reset to init values
      doResetInitValues();

      doReadOnly();
      btnCtrl.setBtnStatus_Save();
      return;
    }

    /** Synchronize the listbox in the OrderDialog */
    HibernateSearchObject<Orderposition> soOrderPosition =
        new HibernateSearchObject<Orderposition>(
            Orderposition.class, orderDialogCtrl.getPageSizeOrderPosition());
    soOrderPosition.addFilter(new Filter("order", getOrder(), Filter.OP_EQUAL));
    // deeper loading of a relation to prevent the lazy
    // loading problem.
    soOrderPosition.addFetch("article");

    // Set the ListModel.
    getPlwOrderpositions()
        .init(
            soOrderPosition,
            orderDialogCtrl.listBoxOrderOrderPositions,
            orderDialogCtrl.paging_ListBoxOrderOrderPositions);

    /** Synchronize the OrderList */
    // Listbox listBoxOrderArticle = orderListCtrl.getListBoxOrderArticle();
    // listBoxOrderArticle.setModel(orderDialogCtrl.listBoxOrderOrderPositions.getModel());
    orderListCtrl
        .getListBoxOrderArticle()
        .setModel(orderDialogCtrl.listBoxOrderOrderPositions.getModel());

    // synchronize the TotalCount from the paging component
    orderListCtrl.paging_OrderArticleList.setTotalSize(
        orderDialogCtrl.paging_ListBoxOrderOrderPositions.getTotalSize());

    doReadOnly();
    btnCtrl.setBtnStatus_Save();
    // init the old values vars new
    doStoreInitValues();
  }
 /**
  * Cancel the actual operation. <br>
  * <br>
  * Resets to the original status.<br>
  */
 private void doCancel() {
   doResetInitValues();
   doReadOnly();
   btnCtrl.setInitEdit();
 }