@Override
    public void showDialog(DialogAction dialogAction, int row, String code) {
        if (DialogAction.UPDATE.equals(dialogAction) && (row == BAD_ROW || code == null)) {
            throw new UnsupportedOperationException("You can not perform this action");
        }

        JDialogTeacher dialogTeacher = new JDialogTeacher(getParentForDialog());
        dialogTeacher.installEscapeCloseOperation();

        Teacher teacher;

        if (DialogAction.UPDATE.equals(dialogAction)) {
            teacher = teacherController.getByCode(code);
            dialogTeacher.setEntity(teacher);
        }

        dialogTeacher.setVisible(true);

        teacher = dialogTeacher.getEntity();
        if (teacher == null) {
            return;
        }

        switch (dialogAction) {
            case INSERT:
                addRow(teacher);
                break;

            case UPDATE:
                setRowValues(row, teacher);
                break;
        }
    }