Exemplo n.º 1
0
  void populateStartDate() throws SQLException, Exception {
    startDateS.removeActionListener(this);
    startDateS.removeAllItems();
    dateRange.clear();
    if (sourceTable.sourceListModel.isSelectionEmpty() == false
        && sourceTable.getValueAt(sourceTable.getSelectedRow(), 0).toString() != null) {
      Statement MySQL_Statement = dbConn.createStatement();
      String getMinMaxSQL =
          "SELECT UNIX_TIMESTAMP(DATE_ADD(DATE(MIN(date_time)),INTERVAL 1 DAY)) AS min_date,UNIX_TIMESTAMP(DATE(MAX(date_time))) AS max_date FROM data_sa WHERE site_id = "
              + siteTable.getValueAt(siteTable.getSelectedRow(), 0)
              + " AND source_id = "
              + sourceTable.getValueAt(sourceTable.getSelectedRow(), 0);
      ResultSet minMaxResults = MySQL_Statement.executeQuery(getMinMaxSQL);
      if (minMaxResults.next()) {
        Calendar minCal = Calendar.getInstance();
        minCal.setTimeZone(TimeZone.getTimeZone("GMT+10"));
        minCal.setTimeInMillis(minMaxResults.getLong("min_date") * 1000);
        long maxCal = minMaxResults.getLong("max_date") * 1000;

        while (minCal.getTimeInMillis() <= maxCal) {
          dateRange.add(minCal.getTimeInMillis());
          startDateS.addItem(dateFormatter.format(minCal.getTimeInMillis()));
          minCal.add(Calendar.DATE, 1);
        }
        startDateS.setEnabled(true);
        populateEndDate();
      } else {
        throw new Exception("ERR:NoData");
      }
    } else { // This should never be able to happen
      throw new Exception("NoSource");
    }
    startDateS.addActionListener(this);
  }
Exemplo n.º 2
0
  @Override
  public void valueChanged(ListSelectionEvent lSE) {
    if (lSE.getSource().equals(siteTable.siteListModel) && lSE.getValueIsAdjusting() == false) {
      sourceTable.updateList(dbConn, siteTable.siteList.get(siteTable.getSelectedRow()));

      if (sourceTable.sourceListModel.isSelectionEmpty()) {
        plotButton.setEnabled(false);
        startDateS.removeAllItems();
        endDateS.removeAllItems();
      }
    } else if (lSE.getSource().equals(sourceTable.sourceListModel)
        && lSE.getValueIsAdjusting() == false) {

      if (sourceTable.sourceListModel.isSelectionEmpty() == false) {
        try {
          populateStartDate();
          if (startDateS.getItemCount() > 0 && endDateS.getItemCount() > 0) {
            plotButton.setEnabled(true);
          }
        } catch (SQLException e) {
          plotButton.setEnabled(false);
          startDateS.removeAllItems();
          endDateS.removeAllItems();
          startDateS.addItem("ERR:NoData");
          endDateS.addItem("ERR:NoData");
          e.printStackTrace();
        } catch (Exception e) {
          plotButton.setEnabled(false);
          startDateS.removeAllItems();
          endDateS.removeAllItems();
          startDateS.addItem(e.getMessage());
          endDateS.addItem(e.getMessage());
        }
      } else {
        plotButton.setEnabled(false);
        startDateS.removeAllItems();
        endDateS.removeAllItems();
      }
    }
  }
Exemplo n.º 3
0
  void buildGUI() {
    this.setLayout(new BorderLayout());

    // sites
    sitePanel.add(siteTitleP, BorderLayout.NORTH);
    siteTitleP.add(siteLabel);
    sitePanel.add(siteScroll, BorderLayout.CENTER);
    siteTable.siteListModel.addListSelectionListener(this);

    // sources
    sourcePanel.add(sourceTitleP, BorderLayout.NORTH);
    sourceTitleP.add(sourceLabel);
    sourcePanel.add(sourceScroll, BorderLayout.CENTER);
    sourceTable.sourceListModel.addListSelectionListener(this);

    // sourceSelectPanel.add(sitePanel);
    // sourceSelectPanel.add(sourcePanel);

    sourceSelectSplitPane.setOneTouchExpandable(true);
    sourceSelectSplitPane.setDividerLocation(150);

    // Provide minimum sizes for the two components in the split pane
    Dimension minimumSize = new Dimension(100, 50);
    sitePanel.setMinimumSize(minimumSize);
    sourcePanel.setMinimumSize(minimumSize);

    // Date Radio Panel
    ButtonGroup radios = new ButtonGroup();
    radios.add(week);
    radios.add(month);
    radios.add(thisMonth);
    radios.add(selection);
    dateRadioPanel.add(week);
    dateRadioPanel.add(month);
    dateRadioPanel.add(thisMonth);
    dateRadioPanel.add(selection);
    week.setSelected(true);

    // Date Selection Panel
    datePanel.add(startDateL);
    datePanel.add(startDateS);
    // datePanel.add(startTimeL);
    // datePanel.add(startHourS);
    // datePanel.add(new JLabel(" : "));
    // datePanel.add(startMinS);
    datePanel.add(endDateL);
    datePanel.add(endDateS);
    // datePanel.add(endTimeL);
    // datePanel.add(endHourS);
    // datePanel.add(new JLabel(" : "));
    // datePanel.add(endMinS);
    datePanel.add(inclusiveL);
    startDateS.addItemListener(this);

    plotButtonPanel.setLayout(new FlowLayout());
    plotButtonPanel.add(plotButton);
    plotButton.addActionListener(this);
    plotButton.setEnabled(false);

    middlePanel.add(dateRadioPanel);
    middlePanel.add(datePanel);
    middlePanel.add(plotButtonPanel);

    topPanel.add(sourceSelectSplitPane, BorderLayout.CENTER);
    topPanel.add(middlePanel, BorderLayout.SOUTH);

    mainPanel.add(topPanel);
    mainPanel.add(loadingLayer);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 50, 30, 50));

    siteTable.updateList(dbConn);
    this.add(mainPanel, BorderLayout.CENTER);
  }