Ejemplo n.º 1
0
 @Override
 public void setValueAt(Object value, int row, int col) {
   switch (col) {
     case USERNAMECOL:
       // Directly changing the username should only be possible if the username was previously
       // null or ""
       // check to see if user name already exists
       if (((String) value).equals("")) {
         value = null;
       } else {
         NamedBean nB = getByUserName((String) value);
         if (nB != null) {
           log.error("User name is not unique " + value);
           String msg = Bundle.getMessage("WarningUserName", new Object[] {("" + value)});
           JOptionPane.showMessageDialog(
               null, msg, Bundle.getMessage("WarningTitle"), JOptionPane.ERROR_MESSAGE);
           return;
         }
       }
       NamedBean nBean = getBySystemName(sysNameList.get(row));
       nBean.setUserName((String) value);
       if (nbMan.inUse(sysNameList.get(row), nBean)) {
         String msg =
             Bundle.getMessage(
                 "UpdateToUserName", new Object[] {getBeanType(), value, sysNameList.get(row)});
         int optionPane =
             JOptionPane.showConfirmDialog(
                 null, msg, Bundle.getMessage("UpdateToUserNameTitle"), JOptionPane.YES_NO_OPTION);
         if (optionPane == JOptionPane.YES_OPTION) {
           // This will update the bean reference from the systemName to the userName
           try {
             nbMan.updateBeanFromSystemToUser(nBean);
           } catch (JmriException ex) {
             // We should never get an exception here as we already check that the username is not
             // valid
           }
         }
       }
       fireTableRowsUpdated(row, row);
       break;
     case COMMENTCOL:
       getBySystemName(sysNameList.get(row)).setComment((String) value);
       fireTableRowsUpdated(row, row);
       break;
     case VALUECOL:
       // button fired, swap state
       NamedBean t = getBySystemName(sysNameList.get(row));
       clickOn(t);
       break;
     case DELETECOL:
       // button fired, delete Bean
       deleteBean(row, col);
       break;
     default:
       break;
   }
 }