@FXML
 public void handleUpdateVideoRegionAttribute(ActionEvent e) {
   if (updateVideoRegionAttribute_row.getText().isEmpty()
       || updateVideoRegionAttribute_col.getText().isEmpty()
       || updateVideoRegionAttribute_height.getText().isEmpty()
       || updateVideoRegionAttribute_width.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Every Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service)
           .updateVideoRegionAttribute(
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   updateVideoRegionAttribute_units.getSelectionModel().getSelectedItem()),
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   updateVideoRegionAttribute_function.getSelectionModel().getSelectedItem()),
               Integer.parseInt(updateVideoRegionAttribute_row.getText()),
               Integer.parseInt(updateVideoRegionAttribute_col.getText()),
               Integer.parseInt(updateVideoRegionAttribute_height.getText()),
               Integer.parseInt(updateVideoRegionAttribute_width.getText()),
               Integer.parseInt(updateVideoRegionAttribute_attribute.getText()));
     } catch (NumberFormatException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
 @FXML
 public void handleControlClock(ActionEvent e) {
   if (controlClock_hour.getText().isEmpty()
       || controlClock_min.getText().isEmpty()
       || controlClock_sec.getText().isEmpty()
       || controlClock_row.getText().isEmpty()
       || controlClock_column.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Every Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service)
           .controlClock(
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   controlClock_units.getSelectionModel().getSelectedItem()),
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   controlClock_function.getSelectionModel().getSelectedItem()),
               controlClock_clockID.getSelectionModel().getSelectedItem(),
               Integer.parseInt(controlClock_hour.getText()),
               Integer.parseInt(controlClock_min.getText()),
               Integer.parseInt(controlClock_sec.getText()),
               Integer.parseInt(controlClock_row.getText()),
               Integer.parseInt(controlClock_column.getText()),
               Integer.parseInt(controlClock_attribute.getText()),
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   controlClock_mode.getSelectionModel().getSelectedItem()));
     } catch (NumberFormatException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
 @FXML
 public void handleSaveVideoRegion(ActionEvent e) {
   if (saveVideoRegion_row.getText().isEmpty()
       || saveVideoRegion_column.getText().isEmpty()
       || saveVideoRegion_height.getText().isEmpty()
       || saveVideoRegion_width.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Every Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service)
           .saveVideoRegion(
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   saveVideoRegion_units.getSelectionModel().getSelectedItem()),
               Integer.parseInt(saveVideoRegion_row.getText()),
               Integer.parseInt(saveVideoRegion_column.getText()),
               Integer.parseInt(saveVideoRegion_height.getText()),
               Integer.parseInt(saveVideoRegion_height.getText()),
               saveVideoRegion_bufferID.getSelectionModel().getSelectedItem());
     } catch (NumberFormatException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
 @FXML
 public void handleDrawBox(ActionEvent e) {
   if (drawBox_row.getText().isEmpty()
       || drawBox_column.getText().isEmpty()
       || drawBox_height.getText().isEmpty()
       || drawBox_width.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Every Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service)
           .drawBox(
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   drawBox_units.getSelectionModel().getSelectedItem()),
               Integer.parseInt(drawBox_row.getText()),
               Integer.parseInt(drawBox_column.getText()),
               Integer.parseInt(drawBox_height.getText()),
               Integer.parseInt(drawBox_width.getText()),
               Integer.parseInt(drawBox_attribute.getText()),
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   drawBox_borderType.getSelectionModel().getSelectedItem()));
     } catch (NumberFormatException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
  /** Shows statistics of device if they are supported by the device */
  @Override
  @FXML
  public void handleStatistics(ActionEvent e) {
    String[] stats = new String[] {"", "U_", "M_"};
    try {
      ((RemoteOrderDisplay) service).retrieveStatistics(stats);
      DOMParser parser = new DOMParser();
      parser.parse(new InputSource(new java.io.StringReader(stats[1])));

      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      Document doc = db.parse(new ByteArrayInputStream(stats[1].getBytes()));

      printStatistics(doc.getDocumentElement(), "");

      JOptionPane.showMessageDialog(
          null, statistics, "Statistics", JOptionPane.INFORMATION_MESSAGE);
    } catch (IOException ioe) {
      JOptionPane.showMessageDialog(null, ioe.getMessage());
      ioe.printStackTrace();
    } catch (SAXException saxe) {
      JOptionPane.showMessageDialog(null, saxe.getMessage());
      saxe.printStackTrace();
    } catch (ParserConfigurationException e1) {
      JOptionPane.showMessageDialog(null, e1.getMessage());
      e1.printStackTrace();
    } catch (JposException jpe) {
      jpe.printStackTrace();
      JOptionPane.showMessageDialog(
          null, "Statistics are not supported!", "Statistics", JOptionPane.ERROR_MESSAGE);
    }

    statistics = "";
  }
 /** Sets the CharacterSetComboBox Values corresponding to the allowed Values for this device. */
 private void setUpSelectCharacterSetCharacterSet() {
   selectCharacterSet_characterSet.getItems().clear();
   try {
     for (int i = 0;
         i < ((RemoteOrderDisplay) service).getCharacterSetList().split(",").length;
         i++) {
       selectCharacterSet_characterSet
           .getItems()
           .add(
               Integer.parseInt(
                   (((RemoteOrderDisplay) service).getCharacterSetList().split(","))[i]));
       if (i == 0) {
         selectCharacterSet_characterSet.setValue(
             Integer.parseInt(
                 (((RemoteOrderDisplay) service).getCharacterSetList().split(","))[i]));
       }
     }
   } catch (JposException e) {
     e.printStackTrace();
     JOptionPane.showMessageDialog(
         null,
         "Error occured when getting the CharacterSetList",
         "Error occured!",
         JOptionPane.WARNING_MESSAGE);
   }
 }
 @FXML
 public void handleVideoSound(ActionEvent e) {
   if (videoSound_frequency.getText().isEmpty()
       || videoSound_duration.getText().isEmpty()
       || videoSound_numberOfCycles.getText().isEmpty()
       || videoSound_interSoundWait.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Every Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service)
           .videoSound(
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   videoSound_units.getSelectionModel().getSelectedItem()),
               Integer.parseInt(videoSound_frequency.getText()),
               Integer.parseInt(videoSound_duration.getText()),
               Integer.parseInt(videoSound_numberOfCycles.getText()),
               Integer.parseInt(videoSound_interSoundWait.getText()));
     } catch (NumberFormatException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
  /** Creates a new instance of DevicePrinterJavaPOS */
  public DevicePrinterJavaPOS(String sDevicePrinterName, String sDeviceDrawerName)
      throws TicketPrinterException {

    m_sName = sDevicePrinterName;
    if (sDeviceDrawerName != null && !sDeviceDrawerName.equals("")) {
      m_sName += " - " + sDeviceDrawerName;
    }

    try {
      m_printer = new POSPrinter();
      m_printer.open(sDevicePrinterName);
      m_printer.claim(10000);
      m_printer.setDeviceEnabled(true);
      m_printer.setMapMode(
          POSPrinterConst.PTR_MM_METRIC); // unit = 1/100 mm - i.e. 1 cm = 10 mm = 10 * 100 units
    } catch (JposException e) {
      // cannot live without the printer.
      throw new TicketPrinterException(e.getMessage(), e);
    }

    try {
      m_drawer = new CashDrawer();
      m_drawer.open(sDeviceDrawerName);
      m_drawer.claim(10000);
      m_drawer.setDeviceEnabled(true);
    } catch (JposException e) {
      // can live without the drawer;
      m_drawer = null;
    }
  }
 @FXML
 public void handleClearOutput(ActionEvent e) {
   try {
     ((RemoteOrderDisplay) service).clearOutput();
   } catch (JposException e1) {
     JOptionPane.showMessageDialog(null, e1.getMessage());
     e1.printStackTrace();
   }
 }
 @FXML
 public void handleAsyncMode(ActionEvent e) {
   try {
     ((RemoteOrderDisplay) service).setAsyncMode(asyncMode.selectedProperty().getValue());
   } catch (JposException e1) {
     JOptionPane.showMessageDialog(null, e1.getMessage());
     e1.printStackTrace();
   }
 }
 @FXML
 public void handleSetMapCharacterSet(ActionEvent e) {
   try {
     ((RemoteOrderDisplay) service)
         .setMapCharacterSet(mapCharacterSet.getSelectionModel().getSelectedItem());
   } catch (JposException e1) {
     JOptionPane.showMessageDialog(null, e1.getMessage());
     e1.printStackTrace();
   }
 }
 @FXML
 public void handleResetVideo(ActionEvent e) {
   try {
     ((RemoteOrderDisplay) service)
         .resetVideo(
             RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                 resetVideo_units.getSelectionModel().getSelectedItem()));
   } catch (JposException e1) {
     JOptionPane.showMessageDialog(null, e1.getMessage());
     e1.printStackTrace();
   }
 }
 @FXML
 public void handleCheckHealth(ActionEvent e) {
   try {
     ((RemoteOrderDisplay) service)
         .checkHealth(
             CommonConstantMapper.getConstantNumberFromString(
                 checkHealth_level.getSelectionModel().getSelectedItem()));
   } catch (JposException e1) {
     JOptionPane.showMessageDialog(null, e1.getMessage());
     e1.printStackTrace();
   }
 }
 @Override
 @FXML
 public void handleOCE(ActionEvent e) {
   super.handleOCE(e);
   try {
     if (getDeviceState(service) == JposState.CLAIMED) {
       deviceEnabled.setSelected(true);
       handleDeviceEnable(e);
     }
   } catch (JposException e1) {
     e1.printStackTrace();
   }
 }
 @FXML
 public void handleDeviceEnable(ActionEvent e) {
   try {
     if (deviceEnabled.isSelected()) {
       ((RemoteOrderDisplay) service).setDeviceEnabled(true);
       setUpComboBoxes();
     } else {
       ((RemoteOrderDisplay) service).setDeviceEnabled(false);
     }
     RequiredStateChecker.invokeThis(this, service);
   } catch (JposException je) {
     JOptionPane.showMessageDialog(null, je.getMessage());
     je.printStackTrace();
   }
 }
 @FXML
 public void handleSetVideoMode(ActionEvent e) {
   if (videoMode.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service).setVideoMode(Integer.parseInt(videoMode.getText()));
     } catch (NumberFormatException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
 private void setUpRestoreVideoRegionBufferID() {
   restoreVideoRegion_bufferID.getItems().clear();
   try {
     for (int i = 0; i < ((RemoteOrderDisplay) service).getVideoSaveBuffers(); i++) {
       restoreVideoRegion_bufferID.getItems().add(i);
     }
   } catch (JposException e) {
     e.printStackTrace();
     JOptionPane.showMessageDialog(
         null,
         "Error occured when getting the BufferIDList",
         "Error occured!",
         JOptionPane.WARNING_MESSAGE);
   }
   restoreVideoRegion_bufferID.setValue(1);
 }
 private void setUpControlClockClockID() {
   controlClock_clockID.getItems().clear();
   try {
     for (int i = 0; i < ((RemoteOrderDisplay) service).getClocks(); i++) {
       controlClock_clockID.getItems().add(i);
     }
   } catch (JposException e) {
     e.printStackTrace();
     JOptionPane.showMessageDialog(
         null,
         "Error occured when getting the ClockList",
         "Error occured!",
         JOptionPane.WARNING_MESSAGE);
   }
   controlClock_clockID.setValue(1);
 }
 @FXML
 public void handleClearVideo(ActionEvent e) {
   if (clearVideo_attribute.getText().isEmpty()) {
     JOptionPane.showMessageDialog(null, "Every Field should have a value!");
   } else {
     try {
       ((RemoteOrderDisplay) service)
           .clearVideo(
               RemoteOrderDisplayConstantMapper.getConstantNumberFromString(
                   clearVideo_units.getSelectionModel().getSelectedItem()),
               Integer.parseInt(clearVideo_attribute.getText()));
     } catch (JposException e1) {
       JOptionPane.showMessageDialog(null, e1.getMessage());
       e1.printStackTrace();
     }
   }
 }
  /** Creates new form DeviceFiscalPrinterJavaPOSPanel */
  public DeviceFiscalPrinterJavaPOS(String sDeviceFiscalPrinterName) throws TicketPrinterException {
    m_sName = sDeviceFiscalPrinterName;

    m_fiscal = new FiscalPrinter();
    try {
      m_fiscal.open(m_sName);
      m_fiscal.claim(10000);
      m_fiscal.setDeviceEnabled(true);
      // m_printer.setMapMode(POSPrinterConst.PTR_MM_METRIC);  // unit = 1/100 mm - i.e. 1 cm = 10
      // mm = 10 * 100 units

      m_fiscal.setCheckTotal(false);

    } catch (JposException e) {
      throw new TicketPrinterException(e.getMessage(), e);
    }

    initComponents();
  }