예제 #1
0
파일: ViewData.java 프로젝트: schugabe/FWS
  /** Load the data of the selected parameter into the table */
  private void list_selected() {
    String key;
    try {
      key = getCurrentKey();
    } catch (Exception e1) {
      return;
    }
    MeasurementHistoryController hist = master.getHistoryController();
    MeasurementHistory data;
    try {
      if (getCurrentTimeBase().equals("hours")) data = hist.getDataHours().get(key);
      else data = hist.getDataDays().get(key);
    } catch (Exception ex) {
      return;
    }

    Vector<MeasurementHistoryEntry> newData =
        new Vector<MeasurementHistoryEntry>(data.getValues().size());
    newData.addAll(data.getValues());

    Collections.sort(newData);
    Collections.reverse(newData);
    dataTable.removeAll();

    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);

    for (MeasurementHistoryEntry e : newData) {
      TableItem item = new TableItem(dataTable, SWT.NONE);
      item.setText(new String[] {sdf.format(e.getTimestamp()), "" + e.getValue()});
    }
  }
예제 #2
0
파일: ViewData.java 프로젝트: schugabe/FWS
  /** Load all available data from the master into the list */
  private void fillList() {
    MeasurementHistoryController hist = master.getHistoryController();
    this.dataList.removeAll();
    Vector<String> tmp = new Vector<String>();
    tmp.addAll(hist.getDataHours().keySet());
    this.addKeys(tmp, "hours");

    tmp.removeAllElements();
    tmp.addAll(hist.getDataDays().keySet());
    this.addKeys(tmp, "days");
  }
예제 #3
0
파일: ViewData.java 프로젝트: schugabe/FWS
  /**
   * Delete Values from the history
   *
   * @param all when true the whole history of the selected parameter is deleted
   */
  private void delete(boolean all) {

    MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO | SWT.ICON_QUESTION);
    messageBox.setMessage("Are you shure you want to delete these entries?");
    messageBox.setText("Delete History?");

    if (messageBox.open() == SWT.NO) return;

    String key, timebase;
    try {
      key = getCurrentKey();
      timebase = getCurrentTimeBase();
    } catch (Exception e) {
      return;
    }
    MeasurementHistoryController hist = master.getHistoryController();
    MeasurementHistory measurements;

    if (timebase.equals("hours")) measurements = hist.getDataHours().get(key);
    else measurements = hist.getDataDays().get(key);

    if (all) {
      measurements.removeAll();
    } else {
      for (TableItem item : this.dataTable.getSelection()) {
        String date = item.getText(0);
        String value = item.getText(1);

        SimpleDateFormat bla = new SimpleDateFormat(DATE_FORMAT);
        Date tmpdate;
        try {
          tmpdate = bla.parse(date);
        } catch (ParseException e) {
          e.printStackTrace();
          continue;
        }

        MeasurementHistoryEntry tmp =
            new MeasurementHistoryEntry(Double.parseDouble(value), tmpdate);
        measurements.removeEntry(tmp);
      }
    }
    this.list_selected();
  }