/** * Gets the Student instance from this listblock line. The instance is updated with the displayed * cell values before returning. * * @return the displayed object */ protected Student getDisplayedStudent() { Student singleStudent = (Student) roleNameToObject.get("Student"); if (singleStudent == null) { return null; } DomainObjectProxy proxy = controller.getProxy(singleStudent, "Student"); int rowNumber = getLineNumber(); int colNumber; Object value; colNumber = controller.listblockMethodschooseStudentsListBloack.getColumnIndex("Student.age"); value = controller.view.chooseStudentsListBloack_table.getValueAt(rowNumber, colNumber); proxy.setAttribute("age", value); colNumber = controller.listblockMethodschooseStudentsListBloack.getColumnIndex("Student.name"); value = controller.view.chooseStudentsListBloack_table.getValueAt(rowNumber, colNumber); proxy.setAttribute("name", value); colNumber = controller.listblockMethodschooseStudentsListBloack.getColumnIndex("Student.studentNr"); value = controller.view.chooseStudentsListBloack_table.getValueAt(rowNumber, colNumber); proxy.setAttribute("studentNr", value); colNumber = controller.listblockMethodschooseStudentsListBloack.getColumnIndex("Student.id"); value = controller.view.chooseStudentsListBloack_table.getValueAt(rowNumber, colNumber); proxy.setAttribute("id", value); return (Student) proxy.getObject(); }
/** * Internal use. * * @param column Internal use. */ void fromCellToListblockLine(int column) { DomainObjectProxy objectProxy = domainProxy.getProxy(newStudent, "Student"); /** Column Match ? */ if (controller.view.chooseStudentsListBloack_indexes.indexOf(new Integer(0)) == column) { Object workValue = null; // Object convert = TypeTool.convert(newStudent.getAge()); if (cellValueColumn0 instanceof JComboBox) { workValue = ((JComboBox) cellValueColumn0).getSelectedItem(); } else if (cellValueColumn0 instanceof JCheckBox) { workValue = new Boolean(((JCheckBox) cellValueColumn0).isSelected()); } else { workValue = cellValueColumn0; } /* Convert the Genova enumerator from a text string to the * int value as a string */ if (TypeTool.isEnumeratorMethod(newStudent, "age")) { String enumName = TypeTool.getAttributeClassNameMethod(newStudent, "age"); if (enumName == null) { System.out.println("Failed to name class for Student.getAge()."); workValue = ""; } else { if (workValue != null) { int intVal = controller.applicationEnums.toValue(enumName, (String) workValue); workValue = "" + intVal; } } } if (workValue != null) { objectProxy = domainProxy.getProxy(newStudent, "Student"); objectProxy.setAttribute("age", workValue.toString()); } fromListblockLineToCell(column, false); } /** Column Match ? */ if (controller.view.chooseStudentsListBloack_indexes.indexOf(new Integer(1)) == column) { Object workValue = null; // Object convert = TypeTool.convert(newStudent.getName()); if (cellValueColumn1 instanceof JComboBox) { workValue = ((JComboBox) cellValueColumn1).getSelectedItem(); } else if (cellValueColumn1 instanceof JCheckBox) { workValue = new Boolean(((JCheckBox) cellValueColumn1).isSelected()); } else { workValue = cellValueColumn1; } /* Convert the Genova enumerator from a text string to the * int value as a string */ if (TypeTool.isEnumeratorMethod(newStudent, "name")) { String enumName = TypeTool.getAttributeClassNameMethod(newStudent, "name"); if (enumName == null) { System.out.println("Failed to name class for Student.getName()."); workValue = ""; } else { if (workValue != null) { int intVal = controller.applicationEnums.toValue(enumName, (String) workValue); workValue = "" + intVal; } } } if (workValue != null) { objectProxy = domainProxy.getProxy(newStudent, "Student"); objectProxy.setAttribute("name", workValue.toString()); } fromListblockLineToCell(column, false); } /** Column Match ? */ if (controller.view.chooseStudentsListBloack_indexes.indexOf(new Integer(2)) == column) { Object workValue = null; // Object convert = TypeTool.convert(newStudent.getStudentNr()); if (cellValueColumn2 instanceof JComboBox) { workValue = ((JComboBox) cellValueColumn2).getSelectedItem(); } else if (cellValueColumn2 instanceof JCheckBox) { workValue = new Boolean(((JCheckBox) cellValueColumn2).isSelected()); } else { workValue = cellValueColumn2; } /* Convert the Genova enumerator from a text string to the * int value as a string */ if (TypeTool.isEnumeratorMethod(newStudent, "studentNr")) { String enumName = TypeTool.getAttributeClassNameMethod(newStudent, "studentNr"); if (enumName == null) { System.out.println("Failed to name class for Student.getStudentNr()."); workValue = ""; } else { if (workValue != null) { int intVal = controller.applicationEnums.toValue(enumName, (String) workValue); workValue = "" + intVal; } } } if (workValue != null) { objectProxy = domainProxy.getProxy(newStudent, "Student"); objectProxy.setAttribute("studentNr", workValue.toString()); } fromListblockLineToCell(column, false); } /** Column Match ? */ if (controller.view.chooseStudentsListBloack_indexes.indexOf(new Integer(3)) == column) { Object workValue = null; // Object convert = TypeTool.convert(newStudent.getId()); if (cellValueColumn3 instanceof JComboBox) { workValue = ((JComboBox) cellValueColumn3).getSelectedItem(); } else if (cellValueColumn3 instanceof JCheckBox) { workValue = new Boolean(((JCheckBox) cellValueColumn3).isSelected()); } else { workValue = cellValueColumn3; } /* Convert the Genova enumerator from a text string to the * int value as a string */ if (TypeTool.isEnumeratorMethod(newStudent, "id")) { String enumName = TypeTool.getAttributeClassNameMethod(newStudent, "id"); if (enumName == null) { System.out.println("Failed to name class for Student.getId()."); workValue = ""; } else { if (workValue != null) { int intVal = controller.applicationEnums.toValue(enumName, (String) workValue); workValue = "" + intVal; } } } if (workValue != null) { objectProxy = domainProxy.getProxy(newStudent, "Student"); objectProxy.setAttribute("id", workValue.toString()); } fromListblockLineToCell(column, false); } }