@Override
    protected void done() {
      final TargetProductSelectorModel model = getTargetProductSelector().getModel();
      try {
        final Date now = Calendar.getInstance().getTime();
        final long diff = (now.getTime() - executeStartTime.getTime()) / 1000;
        if (diff > 120) {
          final float minutes = diff / 60f;
          statusLabel.setText("Processing completed in " + minutes + " minutes");
        } else {
          statusLabel.setText("Processing completed in " + diff + " seconds");
        }

        final Product targetProduct = get();
        if (model.isOpenInAppSelected()) {
          appContext.getProductManager().addProduct(targetProduct);
          // showSaveAndOpenInAppInfo(saveTime);
        } else {
          // showSaveInfo(saveTime);
        }
      } catch (InterruptedException e) {
        // ignore
      } catch (ExecutionException e) {
        handleProcessingError(e.getCause());
      } catch (Throwable t) {
        handleProcessingError(t);
      }
    }
 public static void sleep(long milliseconds) {
   Date d;
   long start, now;
   d = new Date();
   start = d.getTime();
   do {
     d = new Date();
     now = d.getTime();
   } while ((now - start) < milliseconds);
 }
示例#3
0
 /**
  * Implementing the Observer interface. Receiving the response from the Pdu.
  *
  * @param obs the UpSincePdu variable
  * @param ov the date
  * @see uk.co.westhawk.snmp.pdu.UpSincePdu
  */
 public void update(Observable obs, Object ov) {
   Pdu pdu = (Pdu) obs;
   if (pdu.getErrorStatus() == AsnObject.SNMP_ERR_NOERROR) {
     Date dres = (Date) ov;
     if (dres != null) {
       // TODO: invokeLater
       v.setText(dres.toString());
     }
   } else {
     // TODO: invokeLater
     v.setText(pdu.getErrorStatusString());
   }
 }
示例#4
0
  /**
   * Disables/Enables history arrow buttons depending on whether the current page is the first, the
   * last page or a middle page.
   *
   * @param chatPanel the <tt>ChatPanel</tt> which has provoked the change.
   */
  public void changeHistoryButtonsState(ChatPanel chatPanel) {
    ChatConversationPanel convPanel = chatPanel.getChatConversationPanel();

    long firstMsgInHistory = chatPanel.getFirstHistoryMsgTimestamp().getTime();
    long lastMsgInHistory = chatPanel.getLastHistoryMsgTimestamp().getTime();
    Date firstMsgInPage = convPanel.getPageFirstMsgTimestamp();
    Date lastMsgInPage = convPanel.getPageLastMsgTimestamp();

    if (firstMsgInHistory == 0 || lastMsgInHistory == 0) {
      previousButton.setEnabled(false);
      nextButton.setEnabled(false);
      return;
    }

    previousButton.setEnabled(firstMsgInHistory < firstMsgInPage.getTime());

    nextButton.setEnabled(
        (lastMsgInPage.getTime() > 0) && (lastMsgInHistory > lastMsgInPage.getTime()));
  }
 public void run() {
   System.out.println("ReminderServiceOld: Starting at " + new Date());
   while (!l.isEmpty()) {
     Date d = new Date();
     Item i = (Item) l.get(0);
     long interval = i.due.getTime() - d.getTime();
     if (interval > 0) {
       System.out.println("Sleeping until " + i.due);
       try {
         Thread.sleep(interval);
       } catch (InterruptedException e) {
         System.exit(1); // unexpected intr
       }
       message(i.due + ": " + i.message);
     } else message("MISSED " + i.message + " at " + i.due);
     l.remove(0);
   }
   System.exit(0);
 }
  /** Updates all train data and refreshes the GUI. */
  public static void timeTick(Date date, int delta) {
    if (!isPaused) {
      refreshUI += delta;
      double time = date.getHours() * 60 * 60 + date.getMinutes() * 60 + date.getSeconds();

      for (int i = 0; i < trainList.size(); i++) {
        // Update the data for each train.
        boolean isSelectedByTNC = false;
        if (!isSolo) {
          isSelectedByTNC = tncUI.uiSelect(trainList.get(i).id);
        }
        trainList.get(i).timeTick(time, ((double) (delta)) / 1000.0, isSolo, isSelectedByTNC);
      }

      if (refreshUI >= 1000) {
        // Refresh the train module GUI.

        if (isSolo) {
          // If TNM is running solo, figure out the new time.
          soloTime += 1;
          if (soloTime >= 24 * 60 * 60) {
            soloTime = soloTime % (24 * 60 * 60);
          }
          int hrs = (int) soloTime / (60 * 60);
          int min = ((int) soloTime / 60) % 60;
          int sec = (int) soloTime - (hrs * 60 * 60 + min * 60);
          soloDate = new Date(93, 2, 2, hrs, min, sec);
        } else {
          soloTime = time;
        }

        refreshUI = refreshUI % 1000;
        setSelectedId(selectedId);
      }
    }
  }
  /** Creates new form frmAsignarTransporte */
  public frmAsignarTransporte() {
    initComponents();
    gestorH.actualizarUsuario(labelusuario);
    txtFecha.setEditable(false);
    txtFecha.setEnabled(false);
    txtHora.setEditable(false);
    txtHora.setEnabled(false);
    // setear el campo de fecha con la del sistema
    GregorianCalendar gc = new GregorianCalendar();
    GregorianCalendar.getInstance();
    gc.setTimeZone(TimeZone.getTimeZone("GMT-3"));
    gc.get(Calendar.DAY_OF_WEEK);
    gc.get(Calendar.MONTH);
    gc.get(Calendar.YEAR);
    SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy");
    txtFecha.setText(formateador.format(gc.getTime()));
    // setear el campo de hora con la del sistema
    GregorianCalendar calendario = new GregorianCalendar();
    GregorianCalendar.getInstance();
    gc.setTimeZone(TimeZone.getTimeZone("GMT-3"));
    calendario.get(Calendar.HOUR);
    calendario.get(Calendar.MINUTE);
    SimpleDateFormat formateadorHora = new SimpleDateFormat("HH:mm");
    txtHora.setText(formateadorHora.format(calendario.getTime()));

    // Las siguientes lineas son para dar a la pantalla el tamaño requerido y luego centrarla en la
    // pantalla.
    Toolkit kit = Toolkit.getDefaultToolkit();
    Dimension tamanioPantalla = kit.getScreenSize();
    int ancho = 820;
    int alto = 570;
    //        int posX = (int) ((tamanioPantalla.width - ancho) / 2);
    //        int posY = (int) ((tamanioPantalla.height - alto) / 2);
    this.setSize(ancho, alto);
    this.setLocation(260, 30);

    // redimensionar columnas tabla
    tblViaje.getColumnModel().getColumn(0).setPreferredWidth(50);
    tblViaje.getColumnModel().getColumn(1).setPreferredWidth(50);
    tblViaje.getColumnModel().getColumn(2).setPreferredWidth(100);
    tblVehiculo.getColumnModel().getColumn(0).setPreferredWidth(100);
    tblVehiculo.getColumnModel().getColumn(1).setPreferredWidth(100);
    // centrar cabecera jtable
    DefaultTableCellRenderer renderer =
        (DefaultTableCellRenderer) tblVehiculo.getTableHeader().getDefaultRenderer();
    renderer.setHorizontalAlignment(0);
    DefaultTableCellRenderer renderer2 =
        (DefaultTableCellRenderer) tblViaje.getTableHeader().getDefaultRenderer();
    renderer2.setHorizontalAlignment(0);

    Iterator ite = gestorH.listarClase(Viaje.class).iterator();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");
    SimpleDateFormat sdfguion = new SimpleDateFormat("dd-MM-yyyy");
    while (ite.hasNext()) {
      Viaje viaje = (Viaje) ite.next();
      Date fecha1 = sdf.parse(viaje.getFecha(), new ParsePosition(0));
      Date fecha3 = sdfguion.parse(txtFecha.getText(), new ParsePosition(0));
      if (viaje.getEstado().equalsIgnoreCase("En Proceso")
          && (viaje.getTipoViaje().getNombreTipoViaje().equalsIgnoreCase("Traslado a Puerto")
              || viaje
                  .getTipoViaje()
                  .getNombreTipoViaje()
                  .equalsIgnoreCase("Traslado a Establecimiento"))) {
        if (fecha1.before(fecha3)) {
          viaje.setEstado("Finalizado");
          viaje.getVehiculo().setEstado("Disponible");
        }
      }
    }

    gestorA.RellenarTablaViajes(tblViaje);
  }
 public static boolean bombExplodes(Bombed bombedAnnotation) {
   Date now = new Date();
   return now.after(raidDate(bombedAnnotation));
 }
 private long timediff(Date start, Date end) {
   return end.getTime() - start.getTime();
 }