@Override public void setValueAt(final Object value, final int row, final int col) { if ((col != NAME_COLUMN) && (col != DESCRIPTION_COLUMN)) { throw new IllegalStateException("IE01161: Column can not be edited"); } final INaviModule module = getModules().get(row); if (col == NAME_COLUMN) { try { module.getConfiguration().setName((String) value); } catch (final CouldntSaveDataException e) { CUtilityFunctions.logException(e); final String innerMessage = "E00156: " + "Could not save address space name"; final String innerDescription = CUtilityFunctions.createDescription( String.format( "The new name of the address space '%s' could not be saved.", m_addressSpace.getConfiguration().getName()), new String[] {"There was a problem with the database connection."}, new String[] {"The address space keeps its old name."}); NaviErrorDialog.show(null, innerMessage, innerDescription, e); } } else if (col == DESCRIPTION_COLUMN) { try { module.getConfiguration().setDescription((String) value); } catch (final CouldntSaveDataException e) { CUtilityFunctions.logException(e); final String innerMessage = "E00157: " + "Could not save address space description"; final String innerDescription = CUtilityFunctions.createDescription( String.format( "The new description of the address space '%s' could not be saved.", m_addressSpace.getConfiguration().getName()), new String[] {"There was a problem with the database connection."}, new String[] {"The address space keeps its old description."}); NaviErrorDialog.show(null, innerMessage, innerDescription, e); } } }
/** * Generates a name list from the names of the given address spaces. * * @param addressSpaces The address spaces that provide the names. * @return The generated name list. */ public static String getNameList(final INaviAddressSpace[] addressSpaces) { int count = 0; final StringBuilder list = new StringBuilder(); for (final INaviAddressSpace addressSpace : addressSpaces) { list.append("- "); list.append(addressSpace.getConfiguration().getName()); list.append('\n'); count++; if ((count == MAX_LIST_LENGTH) && (addressSpaces.length != MAX_LIST_LENGTH)) { list.append("\n... "); list.append(String.format("%d others ...", addressSpaces.length - count)); break; } } return list.toString(); }