@Override
 public void writeValueEOF() {
   m_sID = null;
   m_jdate.setText(null);
   m_ReasonModel.setSelectedKey(null);
   m_LocationsModel.setSelectedKey(m_App.getInventoryLocation());
   productid = null;
   productref = null;
   productcode = null;
   productname = null;
   m_jreference.setText(null);
   m_jcodebar.setText(null);
   jproduct.setText(null);
   attsetid = null;
   attsetinstid = null;
   attsetinstdesc = null;
   jattributes.setText(null);
   m_junits.setText(null);
   m_jprice.setText(null);
   m_jdate.setEnabled(false);
   m_jbtndate.setEnabled(false);
   m_jreason.setEnabled(false);
   m_jreference.setEnabled(false);
   m_jEnter1.setEnabled(false);
   m_jcodebar.setEnabled(false);
   m_jEnter.setEnabled(false);
   m_jLocation.setEnabled(false);
   jproduct.setEnabled(false);
   jEditProduct.setEnabled(false);
   jattributes.setEnabled(false);
   jEditAttributes.setEnabled(false);
   m_junits.setEnabled(false);
   m_jprice.setEnabled(false);
   m_cat.setComponentEnabled(false);
 }
 public void writeValueDelete(Object value) {
   Object[] diary = (Object[]) value;
   m_sID = (String) diary[0];
   m_jdate.setText(Formats.TIMESTAMP.formatValue(diary[1]));
   m_ReasonModel.setSelectedKey(diary[2]);
   m_LocationsModel.setSelectedKey(diary[3]);
   productid = (String) diary[4];
   productref = (String) diary[8];
   productcode = (String) diary[9];
   productname = (String) diary[10];
   m_jreference.setText(productref);
   m_jcodebar.setText(productcode);
   jproduct.setText(productname);
   attsetid = (String) diary[11];
   attsetinstid = (String) diary[5];
   attsetinstdesc = (String) diary[12];
   jattributes.setText(attsetinstdesc);
   m_junits.setText(Formats.DOUBLE.formatValue(signum((Double) diary[6], (Integer) diary[2])));
   m_jprice.setText(Formats.CURRENCY.formatValue(diary[7]));
   m_jdate.setEnabled(false);
   m_jbtndate.setEnabled(false);
   m_jreason.setEnabled(false);
   m_jreference.setEnabled(false);
   m_jEnter1.setEnabled(false);
   m_jcodebar.setEnabled(false);
   m_jEnter.setEnabled(false);
   m_jLocation.setEnabled(false);
   jproduct.setEnabled(false);
   jEditProduct.setEnabled(false);
   jattributes.setEnabled(false);
   jEditAttributes.setEnabled(false);
   m_junits.setEnabled(false);
   m_jprice.setEnabled(false);
   m_cat.setComponentEnabled(false);
 }
  /** Creates new form StockDiaryEditor */
  public StockDiaryEditor(AppView app, DirtyManager dirty) {

    m_App = app;
    m_dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales");

    // MSL
    m_dlSuppliers =
        (DataLogicSuppliers) m_App.getBean("com.openbravo.pos.suppliers.DataLogicSuppliers");

    initComponents();

    m_cat = new JCatalog(m_dlSales, true);
    m_cat.getComponent().setPreferredSize(new Dimension(0, 245));
    m_cat.addActionListener(new CatalogListener());
    add(m_cat.getComponent(), BorderLayout.SOUTH);

    // El modelo de locales
    m_sentlocations = m_dlSales.getLocationsList();
    m_LocationsModel = new ComboBoxValModel();

    m_ReasonModel = new ComboBoxValModel();
    m_ReasonModel.add(MovementReason.IN_PURCHASE);
    m_ReasonModel.add(MovementReason.IN_REFUND);
    m_ReasonModel.add(MovementReason.IN_MOVEMENT);
    m_ReasonModel.add(MovementReason.OUT_SALE);
    m_ReasonModel.add(MovementReason.OUT_REFUND);
    m_ReasonModel.add(MovementReason.OUT_BREAK);
    m_ReasonModel.add(MovementReason.OUT_MOVEMENT);
    m_jreason.setModel(m_ReasonModel);

    m_jdate.getDocument().addDocumentListener(dirty);
    m_jreason.addActionListener(dirty);
    m_jLocation.addActionListener(dirty);
    jproduct.getDocument().addDocumentListener(dirty);
    jattributes.getDocument().addDocumentListener(dirty);
    m_junits.getDocument().addDocumentListener(dirty);
    m_jprice.getDocument().addDocumentListener(dirty);

    writeValueEOF();
  }
  public void writeValueEdit(Object value) {
    // MSL
    SupplierInfoExt suppl;
    // -- MSL
    Object[] diary = (Object[]) value;
    m_sID = (String) diary[0];
    m_jdate.setText(Formats.TIMESTAMP.formatValue(diary[1]));
    m_ReasonModel.setSelectedKey(diary[2]);
    m_LocationsModel.setSelectedKey(diary[3]);
    productid = (String) diary[4];
    productref = (String) diary[8];
    productcode = (String) diary[9];
    productname = (String) diary[10];
    m_jreference.setText(productref);
    m_jcodebar.setText(productcode);
    jproduct.setText(productname);
    attsetid = (String) diary[11];
    attsetinstid = (String) diary[5];
    attsetinstdesc = (String) diary[12];
    jattributes.setText(attsetinstdesc);
    m_junits.setText(Formats.DOUBLE.formatValue(signum((Double) diary[6], (Integer) diary[2])));
    m_jprice.setText(Formats.CURRENCY.formatValue(diary[7]));
    m_jdate.setEnabled(false);
    m_jbtndate.setEnabled(false);
    m_jreason.setEnabled(false);
    m_jreference.setEnabled(false);
    m_jEnter1.setEnabled(false);
    m_jcodebar.setEnabled(false);
    m_jEnter.setEnabled(false);
    m_jLocation.setEnabled(false);
    jproduct.setEnabled(true);
    jEditProduct.setEnabled(true);
    jattributes.setEnabled(false);
    jEditAttributes.setEnabled(false);
    m_junits.setEnabled(false);
    m_jprice.setEnabled(false);
    m_cat.setComponentEnabled(false);

    // MSL
    supplierid = (String) diary[13];
    if (supplierid != null) {
      try {
        suppl = m_dlSuppliers.loadSupplierExt(supplierid);
        m_jSupplierId.setText(suppl.getName());
      } catch (BasicException e) {
        m_jSupplierId.setText(null);
      }
    } else {
      m_jSupplierId.setText(null);
    }
  }
  /**
   * Creates new form StockDiaryEditor
   *
   * @param app
   * @param dirty
   * @throws com.openbravo.basic.BasicException
   */
  public StockDiaryEditor(AppView app, DirtyManager dirty) throws BasicException {

    m_App = app;
    m_dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales");

    initComponents();

    // El modelo de locales
    m_sentlocations = m_dlSales.getLocationsList();
    m_LocationsModel = new ComboBoxValModel();

    m_ReasonModel = new ComboBoxValModel();
    m_ReasonModel.add(MovementReason.IN_PURCHASE);
    m_ReasonModel.add(MovementReason.IN_REFUND);
    m_ReasonModel.add(MovementReason.IN_MOVEMENT);
    m_ReasonModel.add(MovementReason.OUT_SALE);
    m_ReasonModel.add(MovementReason.OUT_REFUND);
    m_ReasonModel.add(MovementReason.OUT_BREAK);
    m_ReasonModel.add(MovementReason.OUT_MOVEMENT);

    m_jreason.setModel(m_ReasonModel);

    m_cat = new JCatalog(m_dlSales);
    m_cat.addActionListener(new CatalogListener());

    catcontainer.add(m_cat.getComponent(), BorderLayout.CENTER);

    m_jdate.getDocument().addDocumentListener(dirty);
    m_jreason.addActionListener(dirty);
    m_jLocation.addActionListener(dirty);
    jproduct.getDocument().addDocumentListener(dirty);
    jattributes.getDocument().addDocumentListener(dirty);
    m_junits.getDocument().addDocumentListener(dirty);
    m_jprice.getDocument().addDocumentListener(dirty);

    writeValueEOF();
  }
  public void writeValueInsert() {
    m_sID = UUID.randomUUID().toString();
    m_jdate.setText(Formats.TIMESTAMP.formatValue(DateUtils.getTodayMinutes()));
    m_ReasonModel.setSelectedItem(MovementReason.IN_PURCHASE);
    m_LocationsModel.setSelectedKey(m_App.getInventoryLocation());
    productid = null;
    productref = null;
    productcode = null;
    productname = null;
    m_jreference.setText(null);
    m_jcodebar.setText(null);
    jproduct.setText(null);
    attsetid = null;
    attsetinstid = null;
    attsetinstdesc = null;
    jattributes.setText(null);
    m_jcodebar.setText(null);
    m_junits.setText(null);
    m_jprice.setText(null);
    m_jdate.setEnabled(true);
    m_jbtndate.setEnabled(true);
    m_jreason.setEnabled(true);
    m_jreference.setEnabled(true);
    m_jEnter1.setEnabled(true);
    m_jcodebar.setEnabled(true);
    m_jEnter.setEnabled(true);
    m_jLocation.setEnabled(true);
    jproduct.setEnabled(true);
    jEditProduct.setEnabled(true);
    jattributes.setEnabled(true);
    jEditAttributes.setEnabled(true);
    m_junits.setEnabled(true);
    m_jprice.setEnabled(true);
    m_cat.setComponentEnabled(true);

    // MSL
    supplierid = null;
    m_jSupplierId.setText(null);
  }
  /** @throws BasicException */
  public void activate() throws BasicException {
    m_cat.loadCatalog();

    m_LocationsModel = new ComboBoxValModel(m_sentlocations.list());
    m_jLocation.setModel(m_LocationsModel); // para que lo refresque
  }