private List<Station> getDataSet(String startTime, String endTime) { List<Station> listStation = new ArrayList<Station>(); try { // Connecting the database Connection cn = DB.getConn(); System.out.println("Searching.."); String sql = "select AVG(nbBikes) as vc,BIXI.station_id,BIXI_STATIONS.station_name,BIXI.datetime from BIXI INNER JOIN BIXI_STATIONS ON BIXI.station_id = BIXI_STATIONS.station_id WHERE BIXI.datetime >= timestamp('" + startTime + "') and BIXI.datetime <= timestamp('" + endTime + "')GROUP BY station_name order by vc desc limit 10"; PreparedStatement ps = cn.prepareStatement(sql); ResultSet rs = ps.executeQuery(); System.out.println("End"); while (rs.next()) { Station station = new Station(); station.setVc(rs.getInt(1)); station.setStation_id(rs.getInt(2)); station.setStation_name(rs.getString(3)); station.setDatatime(new java.util.Date(rs.getDate(4).getTime())); listStation.add(station); } } catch (Exception e) { e.printStackTrace(); } return listStation; }
// 当用户对单元格内容进行修改 时,此方法执行. 为某个属性赋值 public void modify(Object element, String property, Object value) { TableItem tableItem = (TableItem) element; if (tableItem == null) { // tableViewer.update(null, null); return; } Station station = (Station) tableItem.getData(); if (station == null) { // tableViewer.update(null, null); return; } if (property.equals("name")) { String name = (String) value; station.setStation_name(name); } else if (property.equals("down")) { String down = (String) value; if (down.length() > 0) { station.setStation_downnumber(Integer.parseInt(down)); } } else if (property.equals("up")) { String up = (String) value; if (up.length() > 0) { station.setStation_upnumber(Integer.parseInt(up)); } } else if (property.equals("map")) { Integer comboIndex = (Integer) value; if (comboIndex.intValue() != -1) { String mapName = StationData.MAPS[comboIndex.intValue()]; station.setStation_graph(mapName); } } // System.out.println("Modiy:" + value +"::"+columnIndex); /*List list = Arrays.asList(stationData.columnHeads); int columnIndex = list.indexOf(property); switch (columnIndex) { case 0: String id = (String) value; if (id.length() > 0) { station.setStation_id(Integer.parseInt(id)); } break; case 1: String name = (String) value; if (name.length() > 0) { station.setStation_name(name); } break; case 2: String down = (String) value; if (down.length() > 0) { station.setStation_downnumber(Integer.parseInt(down)); } break; case 3: String up = (String) value; if (up.length() > 0) { station.setStation_upnumber(Integer.parseInt(up)); } break; case 4: Integer comboIndex = (Integer) value; if(comboIndex.intValue() != -1){ String mapName = StationData.MAPS[comboIndex.intValue()]; station.setStation_graph(mapName); } break; } */ tableViewer.update(station, null); }