private void saveOrder(Order order){
    Document document = DocumentHelper.createDocument();
    Element orderElement = document.addElement(OrderTableModel.ORDER_NODE);
    orderElement.addElement(OrderTableModel.ORDER_NUMBER_NODE)
      .addText(order.getOrderNumber());
    orderElement.addElement(OrderTableModel.ITEM_NUMBER_NODE)
      .addText(order.getItemNumber());
    orderElement.addElement(OrderTableModel.MACHINE_ID_NODE)
      .addText(order.getMachineId());
    orderElement.addElement(OrderTableModel.DATE_NODE)
      .addText(ProductionMonitoring.STORAGE_DATE_FORMAT.format(order.getDate()));
    orderElement.addElement(OrderTableModel.SYS_DATE_NODE)
      .addText(ProductionMonitoring.STORAGE_DATE_FORMAT.format(order.getSysDate()));
    orderElement.addElement(OrderTableModel.CYCLE_NODE)
      .addText(String.valueOf(order.getCycle()));
    orderElement.addElement(OrderTableModel.SHIFT_NODE)
      .addText(String.valueOf(order.getShift()));
    orderElement.addElement(OrderTableModel.NUM_ACTIVE_CAVITIES_NODE)
      .addText(String.valueOf(order.getNumActiveCavities()));
    orderElement.addElement(OrderTableModel.NUM_ITEMS_PLANNED_NODE)
      .addText(String.valueOf(order.getNumItemsPlanned()));
    List<Monitoring> monitorings = order.getMonitoring();
    if (monitorings != null && monitorings.size() > 0){
      Collections.sort(monitorings, new CompareMonitoringByDate());
      Element monitoringsElement = orderElement.addElement(OrderTableModel.MONITORINGS_NODE);
      int newOrder = 1;
      for (Monitoring monitoring : monitorings){
        if (monitoring.getOrderNumber() != "?" && 
            !monitoring.getOrderNumber().equals(order.getOrderNumber())){
          MessageBox.displayMessageBox(table.getShell(), SWT.ERROR, "Chyba !",
            "Data objednavky c.: " + order.getOrderNumber() +
            " obsahuju zaznamy monitoringu ktore maju cislo objednavky: " + monitoring.getOrderNumber() +
            ".\nZapiste si obidve cisla objednavky a opravte data rucne");
        }
        Element monitoringElement = monitoringsElement.addElement(OrderTableModel.MONITORING_NODE); 
        monitoringElement.addElement(OrderTableModel.MONITORING_DATE_NODE)
          .addText(ProductionMonitoring.STORAGE_DATE_FORMAT.format(monitoring.getDate()));
        monitoringElement.addElement(OrderTableModel.MONITORING_SYS_DATE_NODE)
          .addText(ProductionMonitoring.STORAGE_DATE_FORMAT.format(monitoring.getSysDate()));
        monitoringElement.addElement(OrderTableModel.PLANNED_IDLE_TIME_NODE)
            .addText(String.valueOf(monitoring.getPlannedIdleTime()));
        monitoringElement.addElement(OrderTableModel.FORM_EXCHANGE_NODE)
          .addText(String.valueOf(monitoring.getFormExchange()));
        monitoringElement.addElement(OrderTableModel.MONITORING_PRODUCED_NODE)
            .addText(String.valueOf(monitoring.getProduced()));
        monitoringElement.addElement(OrderTableModel.NABEHOVE_NODE).addText(
            String.valueOf(monitoring.getNabehove()));
        monitoringElement.addElement(OrderTableModel.PRESTREKY_NODE).addText(
            String.valueOf(monitoring.getPrestreky()));
        monitoringElement.addElement(OrderTableModel.NEDOSTREKY_NODE).addText(
            String.valueOf(monitoring.getNedostreky()));
        monitoringElement.addElement(OrderTableModel.ZHORENE_NODE).addText(
            String.valueOf(monitoring.getZhorene()));
        monitoringElement.addElement(OrderTableModel.VADA_MATERIALU_NODE)
            .addText(String.valueOf(monitoring.getVadaMaterialu()));
        monitoringElement.addElement(
            OrderTableModel.DEFORMACIE_NODE).addText(
            String.valueOf(monitoring.getDeformacie()));
        monitoringElement.addElement(
            OrderTableModel.POSKODENY_ZASTREK_ZALIS_NODE).addText(
            String.valueOf(monitoring.getPoskodenyZastrekZalis()));
        monitoringElement.addElement(
            OrderTableModel.CHYBAJUCI_ZASTREK_NODE).addText(
            String.valueOf(monitoring.getChybajuciZastrek()));
        monitoringElement.addElement(OrderTableModel.BOD_VSTREKU_NODE).addText(
            String.valueOf(monitoring.getBodVstreku()));
        monitoringElement.addElement(
            OrderTableModel.PRITOMNOST_PRUZNYCH_ELEMENTOV_NODE).addText(
            String.valueOf(monitoring.getPritomnostPruznychElementov()));
        monitoringElement.addElement(OrderTableModel.VYHADZANE_NODE).addText(
            String.valueOf(monitoring.getVyhadzane()));
        monitoringElement.addElement(OrderTableModel.PRESTREKY_V_OTVOROCH_NODE)
            .addText(String.valueOf(monitoring.getPrestrekyVOtvoroch()));
        monitoringElement.addElement(OrderTableModel.FARBA_NODE).addText(
            String.valueOf(monitoring.getFarba()));
        monitoringElement.addElement(OrderTableModel.ZASTAVENIE_STROJA_NODE)
            .addText(String.valueOf(monitoring.getZastavenieStroja()));
        monitoringElement.addElement(OrderTableModel.INE_NODE).addText(
            String.valueOf(monitoring.getIne()));
        monitoringElement.addElement(OrderTableModel.NEDOLISOVANE_STROJ_NODE).addText(
            String.valueOf(monitoring.getNedolisovaneStroj()));
        monitoringElement.addElement(OrderTableModel.NEDOLISOVANE_FORMA_NODE).addText(
            String.valueOf(monitoring.getNedolisovaneForma()));
        monitoringElement.addElement(OrderTableModel.NEDOLISOVANE_PERIFERIE_NODE).addText(
            String.valueOf(monitoring.getNedolisovanePeriferie()));
        monitoringElement.addElement(OrderTableModel.MONITORING_ORDER_NODE)
          .addText(String.valueOf(newOrder++));
      }
    }
    // Pretty print the document to System.out
    OutputFormat format = OutputFormat.createPrettyPrint();
    XMLWriter writer;
    try {
      writer = new XMLWriter( new FileWriter(ProductionMonitoring.DATA_LOCATION + 
          File.separator + 
          (order.getOrderNumber() == null || order.getOrderNumber().equals("?") ? "unknown" : order.getOrderNumber()) +
          ".xml")
       , format );
      writer.write( document );
      writer.close();
    } catch (IOException e) {
      MessageBox.displayMessageBox(table.getShell(), SWT.ERROR, "Chyba !",
        "Chyba pri zapise dat!\n" +
        "Data neboli spravne ulozene!\n"+ e);
    }
  }