/** 当单击单元格出现CellEditor时应该显示什么值。由此方法决定, 返回单元格的当前值 返回某个属性的值 */
    public Object getValue(Object element, String property) {
      Object result = null;
      Station station = (Station) element;
      if (station == null) return null;

      // 使用别名的方法
      if (property.equals("name")) return station.getStation_name();
      else if (property.equals("down")) return String.valueOf(station.getStation_downnumber());
      else if (property.equals("up")) return String.valueOf(station.getStation_upnumber());
      else if (property.equals("map")) // ComboBoxCellEditor要求返回下拉框中的索引值
      return new Integer(getNameIndex(station.getStation_graph()));

      // 直接使用索引
      /*  List list = Arrays.asList(stationData.columnHeads);
               int columnIndex = list.indexOf(property);
               //再返回对应的数据
               switch (columnIndex) {
               case 0://id
      	return String.valueOf(station.getStation_id());
      case 1://name
      	return station.getStation_name();
      case 2://down
      	return String.valueOf(station.getStation_downnumber());
      case 3://up
      	return String.valueOf(station.getStation_upnumber());
      case 4://map ,因为用的是下拉框,所以要返回一个Integer表示当前选中的index
      	return new Integer(getNameIndex(station.getStation_graph()));
               }
               */
      return result;
    }
 /* 这里的element参数,其实就是我们二维数组中的每一个一维数组,其中保存的是
  * 每一行的所有数据,通过column这个参数依次写入到表格中的各个字段上。
  * column具体值是多少我们并不知道,因此需要我们来判断,并根据他里面的值
  * 来决定我们要将哪个数据返回。同样,该方法是不能返回NULL的。必须先检查数有效性。
  */
 public String getColumnText(Object element, int columnIndex) {
   Station station = (Station) element;
   if (station == null) // 解决表中空数据出现的错误
   return null;
   switch (columnIndex) {
     case 0:
       return station.getStation_name();
     case 1:
       return String.valueOf(station.getStation_downnumber());
     case 2:
       return String.valueOf(station.getStation_upnumber());
     case 3:
       return station.getStation_graph();
   }
   return null;
 }
 public int compare(Viewer viewer, Object e1, Object e2) {
   Station info1 = (Station) e1;
   Station info2 = (Station) e2;
   switch (propertyIndex) {
     case 0:
       // return info1.name.compareTo(info2.name);
       return direction
           ? info1.getStation_name().compareTo(info2.getStation_name())
           : info2.getStation_name().compareTo(info1.getStation_name());
       /*case 3:  对于checkcell
       if (bug1.isSolved == bug2.isSolved)
        return 0;
       if (bug1.isSolved)
        return 1;
       else
        return -1;*/
     default:
       return 0;
   }
 }
    // 当用户对单元格内容进行修改 时,此方法执行. 为某个属性赋值
    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);
    }