Beispiel #1
0
 @Override
 public void run() {
   Date d = new Date();
   while (true) {
     Date c = new Date();
     if ((c.getTime() - d.getTime()) > 5000) {
       d = c;
       try {
         logic3.reportePosicion();
         Logger.info2("Envio Posicion");
       } catch (Exception e) {
         Logger.info(e);
       }
     }
   }
 }
Beispiel #2
0
  @Override
  public void actionPerformed(ActionEvent event) {
    if ("revisar".equals(event.getActionCommand())) {
      if (logic.getId() != null) {
        try {
          logic2.getPedidoMovibus(logic.getId());
          if (logic2.getId() != null) {
            PedidoMovibusSerializable ped = logic2.getPedido();
            idPed2 = new JLabel("" + ped.getId());
            usNom2 = new JLabel(ped.getUsuario().getNombre());
            conNom2 = new JLabel(ped.getConductor().getNombre());
            idBus2 = new JLabel("" + ped.getMovibus().getId());
            cordDes2 = new JLabel(ped.getDireccionDestinoLA() + "," + ped.getDireccionDestinoLO());
            cordct2 =
                new JLabel(
                    ped.getMovibus().getPosicionLat() + "," + ped.getMovibus().getPosicionLong());
            kilom2 = new JLabel("" + ped.getMovibus().getKilometraje());
            info2 = new JPanel();
            info2.add(idPed2);
            info2.add(usNom2);
            info2.add(conNom2);
            info2.add(idBus2);
            info2.add(cordDes2);
            info2.add(cordct2);
            info2.add(kilom2);
            termP.add(info2, BorderLayout.EAST);
            termP.setVisible(true);
          } else {
            idPed2 = new JLabel("El movibus no tiene un pedido activo en el momento");
            info2 = new JPanel();
            info2.add(idPed2);
            termP.add(info2, BorderLayout.EAST);
            termP.setVisible(true);
          }
        } catch (Exception e) {
          Logger.info(e);
          success.setText("Operacion Fallida");
          termP.add(success, BorderLayout.CENTER);
        }
        termP.setVisible(true);
      } else {
        JOptionPane.showMessageDialog(
            this,
            "No se ha iniciado sesion con un movibus.",
            "Error de inicio de sesion.",
            JOptionPane.ERROR_MESSAGE);
      }
    }
    if ("darinfo".equals(event.getActionCommand())) {
      if (logic.getId() != null) {
        try {
          MovibusSerializable movibusss = logic.getMovi();
          idPed2 = new JLabel("No se ha revisado por pedido aún");
          usNom2 = new JLabel("No se ha revisado por pedido aún");
          conNom2 = new JLabel("No se ha revisado por pedido aún");
          idBus2 = new JLabel("" + movibusss.getId());
          cordDes2 = new JLabel("No se ha revisado por pedido aún");
          cordct2 = new JLabel(movibusss.getPosicionLat() + "," + movibusss.getPosicionLong());
          kilom2 = new JLabel("" + movibusss.getKilometraje());
          info2 = new JPanel();
          info2.add(idPed2);
          info2.add(usNom2);
          info2.add(conNom2);
          info2.add(idBus2);
          info2.add(cordDes2);
          info2.add(cordct2);
          info2.add(kilom2);
          termP.add(info2, BorderLayout.EAST);
          termP.setVisible(true);
        } catch (Exception e) {
          Logger.info(e);
          success.setText("Operacion Fallida");
          termP.add(success, BorderLayout.EAST);
        }
        this.termP.setVisible(true);
      } else {
        JOptionPane.showMessageDialog(
            this,
            "No se ha iniciado sesion con un movibus.",
            "Error de inicio de sesion.",
            JOptionPane.ERROR_MESSAGE);
      }
    }

    if ("terminar".equals(event.getActionCommand())) {
      if (logic2.getId() != null && !"".equals(input.getText()) && isNumeric(input2.getText())) {
        try {
          String tempoReal = input2.getText();
          int tiempo = Integer.parseInt(tempoReal);
          logic2.reportarTerminacion(tiempo);
          success.setText("Operacion Exitosa");
          termP.add(success, BorderLayout.EAST);
          JOptionPane.showMessageDialog(
              this,
              "No se ha iniciado sesion con un movibus.",
              "Error de inicio de sesion.",
              JOptionPane.ERROR_MESSAGE);
        } catch (Exception e) {
          Logger.info(e);
          success.setText("Operacion Fallida");
          termP.add(success, BorderLayout.EAST);
        }
        termP.setVisible(true);
      } else {
        JOptionPane.showMessageDialog(
            this,
            "Numero de identificacion invalido.",
            "Error de identificacion",
            JOptionPane.ERROR_MESSAGE);
      }
    }
    if ("verificar".equals(event.getActionCommand())) {
      if (!"".equals(input.getText()) && isNumeric(input.getText())) {
        try {
          String idMovibusT = input.getText();
          long idMovibusC = Long.parseLong(idMovibusT);
          logic.getMovibus(idMovibusC);
          success.setText("Movibus: " + input.getText());
          termP.add(success, BorderLayout.EAST);
        } catch (Exception e) {
          Logger.info(e);
          success.setText("Operacion Fallida");
          termP.add(success, BorderLayout.EAST);
        }
        termP.setVisible(true);
      } else {
        JOptionPane.showMessageDialog(
            this,
            "Numero de identificacion invalido.",
            "Error de identificacion",
            JOptionPane.ERROR_MESSAGE);
      }
    }
    this.repaint();
  }