private void jButton2ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton2ActionPerformed
    if (mpv5.ui.dialogs.Popup.Y_N_dialog(
        "Really delete all invoices, orders and offers from the database? This is irreversible!!! Contacts and Products will not be affected.",
        Messages.ARE_YOU_SURE)) {
      if (Popup.Y_N_dialog(Messages.ARE_YOU_SURE)) {
        Popup.notice(
            QueryHandler.instanceOf()
                .freeQuery("delete from items", MPSecurityManager.ADMINISTRATE, "Item reset done.")
                .getMessage());
        final String fmessage = "ITEM RESET: removed all invoices, orders and offers from database";
        final String fdbid = "items";
        final int fids = 0;
        final int fgids = 1;

        Runnable runnable =
            new Runnable() {

              @Override
              public void run() {
                QueryHandler.instanceOf()
                    .clone(Context.getHistory())
                    .insertHistoryItem(
                        fmessage,
                        mpv5.db.objects.User.getCurrentUser().__getCname(),
                        fdbid,
                        fids,
                        fgids);
              }
            };
        SwingUtilities.invokeLater(runnable);
      }
    }
  } // GEN-LAST:event_jButton2ActionPerformed
  private void importXML() {
    master.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    isConsumed = true;
    XMLReader x;
    ArrayList<ArrayList<DatabaseObject>> objs = null;

    if (master.getStore().hasProperty("file")) {
      x = new XMLReader();
      x.setOverwriteExisting(true);
      try {
        x.newDoc(new File(master.getStore().getProperty("file")), false);
        objs = x.getObjects();
        jTable1.setModel(
            ImportTableModel.getModel(objs, !master.getStore().getProperty("overwrite", false)));
        jLabel2.setText(
            jLabel2.getText()
                + " "
                + master.getStore().getProperty("file")
                + " ("
                + jTable1.getRowCount()
                + ")");
        TableFormat.format(jTable1, 0, 0);
        TableFormat.format(jTable1, 1, 33);
        TableFormat.format(jTable1, 2, 100);
      } catch (Exception ex) {
        Popup.error(ex);
        Log.Debug(ex);
      } finally {
        master.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      }
    }
  }
  @SuppressWarnings("unchecked")
  private void importCsv() {
    master.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    isConsumed = true;
    CSVReaderWriter x;
    Object[][] arr;

    if (master.getStore().hasProperty("file")) {
      x =
          new CSVReaderWriter(
              new File(master.getStore().getProperty("file")),
              master.getStore().getProperty("separator"));
      List<Object[]> d = x.read();
      try {
        d = ArrayUtilities.removeDuplicates(d);
        arr = ArrayUtilities.listToTableArray(d);
        arr = ArrayUtilities.inserValue(arr, null, null);

        jTable1.setModel(new MPTableModel(arr));
        jLabel2.setText(
            jLabel2.getText()
                + " "
                + master.getStore().getProperty("file")
                + " ("
                + jTable1.getRowCount()
                + ")");

      } catch (Exception ex) {
        Popup.error(ex);
        Log.Debug(ex);
      } finally {
        master.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      }
    }
    //
    //
    //        if (objs != null && objs.size() < 0) {
    //        } else {
    //            Popup.notice(Messages.NO_DATA_FOUND);
    //        }
    //      for (int i = 0; i < objs.size(); i++) {
    //                ArrayList<DatabaseObject> arrayList = objs.get(i);
    //                for (int j = 0; j < arrayList.size(); j++) {
    //                    DatabaseObject databaseObject = arrayList.get(j);
    //                    Log.Debug(this, "Parsing " + databaseObject.getDbIdentity() + " : " +
    // databaseObject.__getCname() + " from file: " + master.getStore().getProperty("file"));
    //                    databaseObject.save();
    //                }
    //            }
  }
  private void setSettings() {

    if (font.getText().equalsIgnoreCase(getFontString(Font.decode(null)))) {
      LocalSettings.setProperty(
          LocalSettings.DEFAULT_FONT, getFontString(jFontChooser1.getSelectedFont()));

    } else if (font.getText() != null
        && font.getText().length() > 0
        && !(getFontString(font.getText())).equalsIgnoreCase(getFontString(Font.decode(null)))) {
      LocalSettings.setProperty(LocalSettings.DEFAULT_FONT, getFontString(font.getText()));

    } else {
      Popup.notice(Messages.VALUE_NOT_VALID + font.getText());
    }

    jFontChooser1.setSelectedFont(
        Font.decode(LocalSettings.getProperty(LocalSettings.DEFAULT_FONT)));
    font.setText(getFontString(jFontChooser1.getSelectedFont()));

    applyFont(Font.decode(getFontString(font.getText())));
  }