@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);
      }
    }
Exemplo n.º 2
0
  public void makeSessionList() {

    sessionList = new List(5, false);
    Vector theSessions = theAR.getSessions();
    int size = theSessions.size();

    for (int j = 0; j < size; j++) {
      Date d = (Date) theSessions.elementAt(j);
      sessionList.addItem(d.toString());
    }
  }
Exemplo n.º 3
0
 private int compareDates(Date d1, Date d2) {
   if (d1 == d2) {
     return 0;
   }
   if (d1 == null) {
     return -1;
   }
   if (d2 == null) {
     return 1;
   }
   return compareLong(d1.getTime(), d2.getTime());
 }
Exemplo n.º 4
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());
   }
 }
  // =====================================================
  // setEXIFpictureMetadaten()
  //
  // Aus dem Image-Original werden die EXIF-Daten f�r die
  // PM_PictureMetadatenX geholt und eingetragen
  // =====================================================
  public static void setEXIFpictureMetadaten(PM_Picture picture) {

    PM_PictureImageMetadaten imageMetadaten = picture.getImageMetadaten();

    // ----------------------------------------------------
    // FujiFilm Makernote:  SequenceNummer --> virtPicture
    // ----------------------------------------------------

    // -------------------------------------------------------
    // Date
    // ------------------------------------------------------

    String tagDatum = "Date/Time Original";
    String description = "";
    if (imageMetadaten.hasTag(tagDatum)) {
      description = imageMetadaten.getDescription(tagDatum);
    }

    // ----------------------------------------------------
    // Datum nicht vorhanden oder ung�ltig
    // ----------------------------------------------------
    Date myDate = null;
    if (description.length() == 0 || description.equals("0000:00:00 00:00:00")) {
      //			  System.out.println("......  Datum = " + description + " kann nicht konvertiert
      // werden");
      File f = picture.getFileOriginal();
      Date date = new Date(f.lastModified());
      picture.meta.setDateImport(date);
      picture.meta.setDateCurrent(new Date(date.getTime()));
      return;
    }

    // ----------------------------------------------------
    // g�ltiges Datum gefunden
    // ----------------------------------------------------
    DateFormat df = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
    try {
      myDate = df.parse(description);
    } catch (ParseException e) {
      //           System.out.println("ParseException fuer Datum = " + description);
      myDate = new Date(System.currentTimeMillis()); // default
    }
    picture.meta.setDateImport(myDate);
    picture.meta.setDateCurrent(new Date(myDate.getTime()));
  }
Exemplo n.º 6
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()));
  }
    @CalledInAwt
    public void updateData(@NotNull Map<Integer, LastRevision> revisions) {
      myRevisions = revisions;

      Date newestDate = null;
      int maxDateLength = 0;

      for (LastRevision revision : myRevisions.values()) {
        Date date = revision.getDate();
        if (newestDate == null || date.after(newestDate)) {
          newestDate = date;
        }
        int length = DateFormatUtil.formatPrettyDate(date).length();
        if (length > maxDateLength) {
          maxDateLength = length;
        }
      }

      myNewestDate = newestDate;
      myMaxDateLength = maxDateLength;
    }
Exemplo n.º 8
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);
      }
    }
  }
Exemplo n.º 9
0
  int doSMTPTransaction(SMTPInputStream in, SMTPOutputStream out) throws IOException {
    int replyCode;
    Date today = new Date();
    // GET SERVER RESPONSE on CONNECTION ESTABLISHMENT
    // WAIT FOR RESPONSE (WAIT_TIMEOUT) millis
    //      NOT RESPONSE ON CONNECT ERROR CODE 1
    replyCode = waitForTimeout(in);
    if (replyCode == 0) {
      infoArea.Println("NOT RESPONSE ON CONNECT ERROR CODE 1");
      return 1;
    }
    if (replyCode == -1) {
      infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4");
      return 4;
    }

    if (replyCode != SMTP_RCODE_READY) {
      infoArea.Println("UNSUCCESS CONNECTION ");
      return replyCode;
    }

    infoArea.Println("connection response is OK");
    infoArea.Println("request HELO");

    // SEND HELO CRLF
    out.WriteToStream(SMTPCommand[SMTP_CMD_HELO]);
    out.WriteToStream(SMTPCommand[SMTP_CMD_SPC]);
    out.WriteToStream("127.0.0.1");
    out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);

    // WAIT FOR RESPONSE ON HELO
    replyCode = waitForTimeout(in);
    if (replyCode == 0) {
      infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2");
      return 2;
    }
    if (replyCode == -1) {
      infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4");
      return 4;
    }
    if (replyCode != SMTP_RCODE_COMPLETED) {
      infoArea.Println("UNABLE TO COMPLETE REPLY");
      return replyCode;
    }
    infoArea.Println("HELO response is OK");
    infoArea.Println("request MAIL FROM");

    // SEND MAIL FROM: SPC <sender> CRLF
    out.WriteToStream(SMTPCommand[SMTP_CMD_MAIL_FROM]);
    out.WriteToStream(SMTPCommand[SMTP_CMD_SPC]);
    out.WriteToStream(senderMail.getText());
    out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);

    // WAIT FOR RESPONSE ON MAIL FROM
    replyCode = waitForTimeout(in);
    if (replyCode == 0) {
      infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2");
      return 2;
    }
    if (replyCode == -1) {
      infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4");
      return 4;
    }
    if (replyCode != SMTP_RCODE_COMPLETED) {
      infoArea.Println("UNABLE TO COMPLETE REPLY");
      return replyCode;
    }
    infoArea.Println("MAIL FROM response is OK");
    infoArea.Println("request RCPT TO");

    // SEND RCPT TO: SPC <sender> CRLF
    out.WriteToStream(SMTPCommand[SMTP_CMD_RCPT_TO]);
    out.WriteToStream(SMTPCommand[SMTP_CMD_SPC]);
    out.WriteToStream(reciverMail.getText());
    out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);

    // WAIT FOR RESPONSE ON RCPT TO
    replyCode = waitForTimeout(in);
    if (replyCode == 0) {
      infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2");
      return 2;
    }
    if (replyCode == -1) {
      infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4");
      return 4;
    }
    if ((replyCode != SMTP_RCODE_COMPLETED) && (replyCode != SMTP_RCODE_FORWARD)) {
      infoArea.Println("UNABLE TO COMPLETE REPLY");
      return replyCode;
    }
    infoArea.Println("RCPT TO response is OK");
    // TRY TO SEND TO CC
    if ((ccMail.getText().length()) > 0) {
      infoArea.Println("request CC RCPT TO");
      // SEND RCPT TO: SPC <sender> CRLF
      out.WriteToStream(SMTPCommand[SMTP_CMD_RCPT_TO]);
      out.WriteToStream(SMTPCommand[SMTP_CMD_SPC]);
      out.WriteToStream(ccMail.getText());
      out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);

      // WAIT FOR RESPONSE ON RCPT TO
      replyCode = waitForTimeout(in);
      if (replyCode == 0) {
        infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2");
        return 2;
      }
      if (replyCode == -1) {
        infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4");
        return 4;
      }
      if ((replyCode != SMTP_RCODE_COMPLETED) && (replyCode != SMTP_RCODE_FORWARD)) {
        infoArea.Println("UNABLE TO COMPLETE CC");
      } else {
        infoArea.Println("CC.RCPT TO response is OK");
      }
    }
    // TRY TO SEND TO BCC
    if ((bccMail.getText().length()) > 0) {
      // SEND RCPT TO: SPC <sender> CRLF
      out.WriteToStream(SMTPCommand[SMTP_CMD_RCPT_TO]);
      out.WriteToStream(SMTPCommand[SMTP_CMD_SPC]);
      out.WriteToStream(bccMail.getText());
      out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);

      // WAIT FOR RESPONSE ON RCPT TO
      replyCode = waitForTimeout(in);
      if (replyCode == 0) {
        infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2");
        return 2;
      }
      if (replyCode == -1) {
        infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4");
        return 4;
      }
      if ((replyCode != SMTP_RCODE_COMPLETED) && (replyCode != SMTP_RCODE_FORWARD)) {
        infoArea.Println("UNABLE TO COMPLETE BCC");
      } else {
        infoArea.Println("BCC.RCPT TO response is OK");
      }
    }
    infoArea.Println("request DATA");

    // SEND DATA CRLF
    out.WriteToStream(SMTPCommand[SMTP_CMD_DATA]);
    out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);

    // WAIT FOR RESPONSE ON DATA
    replyCode = waitForTimeout(in);
    if (replyCode == 0) {
      infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2");
      return 2;
    }
    if (replyCode == -1) {
      infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4");
      return 4;
    }
    if (replyCode != SMTP_RCODE_MAIL_START) {
      infoArea.Println("UNABLE TO COMPLETE REPLY");
      return replyCode;
    }
    infoArea.Println("DATA response is OK");
    infoArea.Println("request DATA");

    // SEND mail content CRLF.CRLF
    out.WriteToStream("Subject: " + subjectMail.getText());
    out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);
    out.WriteToStream("From: " + senderMail.getText());
    out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);
    out.WriteToStream("To: " + reciverMail.getText());
    out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);
    out.WriteToStream("Date: " + today.toString());
    out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);
    out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);
    out.WriteToStream(bodyMail.getText());
    out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF_CRLF]);

    // WAIT FOR RESPONSE ON mail content CRLF.CRLF
    replyCode = waitForTimeout(in);
    if (replyCode == 0) {
      infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2");
      return 2;
    }
    if (replyCode == -1) {
      infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4");
      return 4;
    }
    if (replyCode != SMTP_RCODE_COMPLETED) {
      infoArea.Println("UNABLE TO COMPLETE REPLY");
      return replyCode;
    }
    infoArea.Println("mail content response is OK");
    infoArea.Println("request QUIT");

    // SEND QUIT CRLF
    out.WriteToStream(SMTPCommand[SMTP_CMD_QUIT]);
    out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]);

    // WAIT FOR RESPONSE (WAIT_TIMEOUT) millis
    //      NOT RESPONSE TO QUIT ERROR CODE 3
    replyCode = waitForTimeout(in);
    if (replyCode == 0) {
      infoArea.Println("NOT RESPONSE TO QUIT ERROR CODE 3");
      return 3;
    }
    if (replyCode == -1) {
      infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4");
      return 4;
    }
    if (replyCode != SMTP_RCODE_CLOSING) {
      infoArea.Println("UNCLOSED CONNECTION REPLY");
      return replyCode;
    }
    infoArea.Println("QUIT response is BYE");
    infoArea.Println("end of SMTP transaction");

    //  TRANSACTION OK ERROR CODE 0
    return 0;
  }
Exemplo n.º 10
0
  private void addData(
      JFreeChart chart,
      DSLAMSource source,
      Timeinterval time,
      Serializable filter,
      Properties properties,
      Map<String, Object> colorScheme,
      Properties outputProperties)
      throws IOException {
    if (chart != null) {
      PerformanceCounterDataCollection cData = null;

      long dataSize = 0;

      try {
        cData =
            getPerformanceCounterDataCollection(source, time, filter, properties, outputProperties);
        Collection<PerformanceCounterData> data = null;

        Date d0 = null; // first timestamp for data
        Date d1 = null; // last timestamp for data
        RegularTimePeriod time0 = null;

        if (cData != null) {
          data = cData.getData();

          {
            int l = data.size();
            outputProperties.setProperty("data.count", Integer.toString(l));
          }

          if (data != null && data.size() > 0) {
            dataSize = data.size();

            // Set 'd0':
            {
              // TODO: Avoid assumption "data is sorted"!
              PerformanceCounterData e = data.iterator().next();
              d0 = e.getTimestamp();
            }

            // Set 'd1':
            {
              // TODO: Avoid assumption "data is sorted"!
              for (PerformanceCounterData e : data) {
                d1 = e.getTimestamp();
              }
            }

            time0 = createRegularTimePeriod(d0);
          }
        }

        XYPlot plot = chart.getXYPlot();

        // Set the first dataset:
        {
          TimeSeriesCollection dataset = new TimeSeriesCollection();

          List<Paint> seriesPaint = new ArrayList<Paint>();
          List<Stroke> seriesStroke = new ArrayList<Stroke>();

          // Add series 'ES':
          {
            if (data != null && data.size() > 0) {
              TimeSeries series = new TimeSeries("ES", time0.getClass());

              for (PerformanceCounterData e : data) {
                Date d = e.getTimestamp();
                RegularTimePeriod timePeriod = createRegularTimePeriod(d);

                // Add point:
                {
                  int value = getES(e);

                  addOrUpdate(series, timePeriod, (double) value);
                }
              }

              seriesPaint.add((Paint) colorScheme.get("color.counter.es"));
              seriesStroke.add(STROKE_COUNTER_ES);

              dataset.addSeries(series);
            }
          }

          // Add series 'SES':
          {
            if (data != null && data.size() > 0) {
              TimeSeries series = new TimeSeries("SES", time0.getClass());

              for (PerformanceCounterData e : data) {
                Date d = e.getTimestamp();
                RegularTimePeriod timePeriod = createRegularTimePeriod(d);

                // Add point:
                {
                  int value = getSES(e);

                  addOrUpdate(series, timePeriod, (double) value);
                }
              }

              seriesPaint.add((Paint) colorScheme.get("color.counter.ses"));
              seriesStroke.add(STROKE_COUNTER_SES);

              dataset.addSeries(series);
            }
          }

          // Add series 'US':
          {
            if (data != null && data.size() > 0) {
              TimeSeries series = new TimeSeries("US", time0.getClass());

              for (PerformanceCounterData e : data) {
                Date d = e.getTimestamp();
                RegularTimePeriod timePeriod = createRegularTimePeriod(d);

                // Add point:
                {
                  int value = getUS(e);

                  addOrUpdate(series, timePeriod, (double) value);
                }
              }

              seriesPaint.add((Paint) colorScheme.get("color.counter.us"));
              seriesStroke.add(STROKE_COUNTER_US);

              dataset.addSeries(series);
            }
          }

          // superspeed
          {
            if (data != null && data.size() > 0) {
              TimeSeries series = new TimeSeries("LEFTRS", time0.getClass());
              for (PerformanceCounterData e : data) {
                Date d = e.getTimestamp();
                RegularTimePeriod timePeriod = createRegularTimePeriod(d);
                {
                  int value = getPreviousLEFTRS(e);
                  addOrUpdate(series, timePeriod, (double) value);
                }
              }
              seriesPaint.add((Paint) colorScheme.get("color.counter.previousleftrs"));
              seriesStroke.add(STROKE_COUNTER_US);
              dataset.addSeries(series);
            }
          }
          // ends
          {
            if (data != null && data.size() > 0) {
              boolean showLinearCurve = getShowLinearCurve();

              if (showLinearCurve) {
                // Add series for a linear curve:
                {
                  TimeSeries series = new TimeSeries("Linear", time0.getClass());

                  long t0 = d0.getTime();
                  long t1 = d1.getTime();

                  if (t0 < t1) {
                    long timeX = 15 * 60 * 1000; // 15 minutes intervals
                    // TODO: Read length of intervals from obtained data!

                    double value0 = 0;
                    double value1 = 900;
                    // TODO: Read '900' from obtained data!

                    long timeDelta = t1 - t0;
                    double valueDelta = value1 - value0;

                    long t = t0;
                    int i = 0;

                    while (t <= t1) {
                      Date d = new Date(t);

                      RegularTimePeriod timePeriod = createRegularTimePeriod(d);
                      double value = value0 + ((t - t0) * valueDelta) / timeDelta;

                      // Add point:
                      {
                        addOrUpdate(series, timePeriod, (double) value);
                      }

                      t += timeX;
                      i += 1;
                    }
                  }

                  seriesPaint.add(Color.red);
                  seriesStroke.add(STROKE_COUNTER_DEFAULT);

                  dataset.addSeries(series);
                }
              }
            }
          }

          setDefaultRenderer(chart, colorScheme, 0, seriesPaint, seriesStroke);
          plot.setDataset(0, dataset);
          plot.mapDatasetToRangeAxis(0, 0);
        }
      } finally {
        if (cData != null) {
          cData.dispose();
          cData = null;
        }
      }

      if (outputProperties != null) {
        outputProperties.setProperty("data.count", Long.toString(dataSize));
      }
    }
  }
 public static boolean bombExplodes(Bombed bombedAnnotation) {
   Date now = new Date();
   return now.after(raidDate(bombedAnnotation));
 }
Exemplo n.º 12
0
 private long timediff(Date start, Date end) {
   return end.getTime() - start.getTime();
 }