Exemple #1
0
 @Override
 public void mouseClicked(MouseEvent e) {
   ArrayList list = getSelectedMessages();
   if (list.size() == 0) {
     deleteBut.setVisible(false);
     restoreBut.setVisible(false);
   } else {
     deleteBut.setVisible(true);
     if (Home.titlePan.getTitle().equals("Trash")) {
       restoreBut.setVisible(true);
       System.out.println("Here inside");
     }
   }
 }
  /**
   * Instantiate and populate a pems object from the next item in the result set of a pems query.
   *
   * @param query string
   * @return PeMS
   */
  protected PeMS pemsFromQueryRS(String query) throws DatabaseException {
    PeMS pems = null;

    if (dbr.psRSNext(query)) {
      // String columns = org.apache.commons.lang.StringUtils.join(dbr.psRSColumnNames(query), ",
      // ");
      // System.out.println("columns: [" + columns + "]");

      pems = new PeMS();

      Long vdsId = dbr.psRSGetBigInt(query, "VDS_ID");
      edu.berkeley.path.model_elements.DateTime timeMeasured =
          new edu.berkeley.path.model_elements.DateTime(
              dbr.psRSGetTimestampMilliseconds(query, "MEASURE_DT"));

      Double flow = dbr.psRSGetDouble(query, "FLOW");
      Double density = dbr.psRSGetDouble(query, "DENSITY");
      Double densityError = dbr.psRSGetDouble(query, "DENSITY_ERR");
      Double speed = dbr.psRSGetDouble(query, "SPEED");
      Double speedError = dbr.psRSGetDouble(query, "SPEED_ERROR");
      Double ffSpeed = dbr.psRSGetDouble(query, "FF_SPEED");
      Double funcLoopFact = dbr.psRSGetDouble(query, "FUNC_LOOP_FACT");

      ArrayList<Double> gFactorLane = new ArrayList<Double>();

      for (int i = 0; i <= 9; i++) {
        gFactorLane.add(dbr.psRSGetDouble(query, "G_FACTOR_LANE_" + i));
      }

      pems.setVdsId(vdsId);
      pems.setTimeMeasured(timeMeasured);
      pems.setFlow(flow);
      pems.setDensity(density);
      pems.setDensityError(densityError);
      pems.setSpeed(speed);
      pems.setSpeedError(speedError);
      pems.setFreeFlowSpeed(ffSpeed);
      pems.setFuncLoopFact(funcLoopFact);
      pems.setGFactorLane(gFactorLane);
    }

    return pems;
  }
Exemple #3
0
  @Override
  public void actionPerformed(ActionEvent axnEve) {
    Object obj = axnEve.getSource();

    if (obj == selectAllCB) {
      Boolean state;
      if (selectAllCB.isSelected()) {
        state = true;
        deleteBut.setVisible(true);
        if (Home.titlePan.getTitle().equals("Trash")) {
          restoreBut.setVisible(true);
        }
      } else {
        state = false;
        deleteBut.setVisible(false);
        if (Home.titlePan.getTitle().equals("Trash")) {
          restoreBut.setVisible(false);
        }
      }
      for (int i = 0; i < table.getRowCount(); i++) {
        table.setValueAt(state, i, 0);
      }
    } else if (obj == refreshBut || obj == backBut) {
      setContent(Home.titlePan.getTitle());
      backBut.setVisible(false);
    } else if (obj == deleteBut) {
      ArrayList selectedMessages = getSelectedMessages();
      if (selectedMessages.isEmpty()) {
        FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE);
      } else {
        int option =
            JOptionPane.showConfirmDialog(
                Home.home.homeFrame,
                "Are You Sure?",
                "DELETE",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (option == 0) {
          Database.deleteMessages(selectedMessages, Home.titlePan.getTitle());
          setContent(Home.titlePan.getTitle());
        }
      }
    } else if (obj == restoreBut) {
      ArrayList selectedMessages = getSelectedMessages();
      if (selectedMessages.isEmpty()) {
        FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE);
      } else {
        int option =
            JOptionPane.showConfirmDialog(
                Home.home.homeFrame,
                "Are You Sure?",
                "RESTORE",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (option == 0) {
          Database.restoreMessages(selectedMessages);
          setContent(Home.titlePan.getTitle());
        }
      }
    }
  }
Exemple #4
-8
 public ArrayList getSelectedMessages() {
   ArrayList list = new ArrayList();
   for (int i = 0; i < table.getRowCount(); i++) {
     if (((Boolean) table.getValueAt(i, 0)) == true) {
       list.add(msgID[i]);
     }
   }
   return list;
 }