コード例 #1
0
 @Override
 public Object getValueAt(int rowIndex, int columnIndex) {
   if (columnIndex == 0) { // RowNo.
     if (rowIndex == IS_SELECTED_ROW) {
       // return true for global column selection editor if at least one column is
       // selected.
       for (AttributeColumn col : reader.getAllAttributeColumns()) {
         if (col.isActivated()) {
           return true;
         }
       }
       return false;
     }
     return "";
   }
   columnIndex--;
   if (rowIndex == ATTRIBUTE_NAME_ROW) {
     return reader.getAttributeColumn(columnIndex).getName();
   }
   if (rowIndex == VALUE_TYPE_ROW) {
     return Ontology.VALUE_TYPE_NAMES[reader.getAttributeColumn(columnIndex).getValueType()];
   }
   if (rowIndex == IS_SELECTED_ROW) {
     return reader.getAttributeColumn(columnIndex).isActivated();
   }
   if (rowIndex == ROLE_ROW) {
     return reader.getAttributeColumn(columnIndex).getRole();
   }
   return null;
 }
コード例 #2
0
 @Override
 public void setValueAt(Object value, int row, int column) {
   if (column == 0) { // RowNo.
     if (row == IS_SELECTED_ROW) {
       for (AttributeColumn col : reader.getAllAttributeColumns()) {
         col.activateColumn((Boolean) value);
       }
       repaint();
     }
     return;
   }
   column--;
   if (row == ATTRIBUTE_NAME_ROW) {
     reader.setAttributeNamesDefinedByUser(true);
     reader.getAttributeColumn(column).setName((String) value);
   }
   if (row == VALUE_TYPE_ROW) {
     // update only if its not the same value
     if (reader.getAttributeColumn(column).getValueType()
         != Ontology.ATTRIBUTE_VALUE_TYPE.mapName(value.toString())) {
       reader
           .getAttributeColumn(column)
           .setValueType(Ontology.ATTRIBUTE_VALUE_TYPE.mapName(value.toString()));
     }
   }
   if (row == IS_SELECTED_ROW) {
     reader.getAttributeColumn(column).activateColumn((Boolean) value);
   }
   if (row == ROLE_ROW) {
     String role = (String) value;
     if (role.equals(AttributeColumn.REGULAR)) {
       reader.getAttributeColumn(column).setRole(role);
     } else {
       for (AttributeColumn attColumn : reader.getAllAttributeColumns()) {
         if (attColumn.getRole().equals(role)) {
           attColumn.setRole(AttributeColumn.REGULAR);
         }
       }
       reader.getAttributeColumn(column).setRole(role);
       fireTableDataChanged();
     }
   }
   repaint();
 }