示例#1
0
 /** Editable state must be set in ctor. */
 @Override
 public boolean isCellEditable(int row, int col) {
   if (col == ADDRESSCOL) {
     return false;
   }
   if (col == PROTOCOL) {
     return false;
   }
   if (col == DECODERCOL) {
     return false;
   }
   if (col == ICONCOL) {
     return false;
   }
   if (col == DATEUPDATECOL) {
     return false;
   }
   if (editable) {
     RosterEntry re = Roster.getDefault().getGroupEntry(rosterGroup, row);
     if (re != null) {
       return (!re.isOpen());
     }
   }
   return editable;
 }
示例#2
0
 @Override
 public void setValueAt(Object value, int row, int col) {
   // get roster entry for row
   RosterEntry re = Roster.getDefault().getGroupEntry(rosterGroup, row);
   if (re == null) {
     log.warn("roster entry is null!");
     return;
   }
   if (re.isOpen()) {
     log.warn("Entry is already open");
     return;
   }
   String valueToSet = (String) value;
   switch (col) {
     case IDCOL:
       if (re.getId().equals(valueToSet)) {
         return;
       }
       re.setId(valueToSet);
       break;
     case ROADNAMECOL:
       if (re.getRoadName().equals(valueToSet)) {
         return;
       }
       re.setRoadName(valueToSet);
       break;
     case ROADNUMBERCOL:
       if (re.getRoadNumber().equals(valueToSet)) {
         return;
       }
       re.setRoadNumber(valueToSet);
       break;
     case MFGCOL:
       if (re.getMfg().equals(valueToSet)) {
         return;
       }
       re.setMfg(valueToSet);
       break;
     case MODELCOL:
       if (re.getModel().equals(valueToSet)) {
         return;
       }
       re.setModel(valueToSet);
       break;
     case OWNERCOL:
       if (re.getOwner().equals(valueToSet)) {
         return;
       }
       re.setOwner(valueToSet);
       break;
     default:
       String attributeName = (getColumnName(col)).replaceAll("\\s", "");
       if (re.getAttribute(attributeName) != null
           && re.getAttribute(attributeName).equals(valueToSet)) {
         return;
       }
       if ((valueToSet == null) || valueToSet.isEmpty()) {
         re.deleteAttribute(attributeName);
       } else {
         re.putAttribute(attributeName, valueToSet);
       }
       break;
   }
   // need to mark as updated
   re.changeDateUpdated();
   re.updateFile();
 }