@Override
  public void setReadOnly(boolean readOnly) {
    super.setReadOnly(readOnly);

    tableComponent.setReadOnly(readOnly);
    tableComponent.setUserSelectable(!readOnly);
  }
  @Override
  public void dataBind() {
    tableComponent.setParentModel(department);

    tableComponent.setModel(department.getDivisions());

    tableComponent.dataBind();

    if (getModel() != null) tableComponent.setSelectedValue(getModel().getBean());
  }
  @Override
  protected void setupLocalizedCaptions(Locale locale) {
    super.setupLocalizedCaptions(locale);

    setCaption(getLocalizedString("DIALOG_CAPTION"));
    tableComponent.setCaption(getLocalizedString("TABLE_CAPTION"));
  }
  public ChooseDivisionDialog(Department department) {
    if (department == null)
      throw new IllegalArgumentException("Argument 'department' must not be null.");

    this.department = department;

    tableComponent = new DivisionsTableComponent();

    tableComponent.setSizeFull();

    addComponent(tableComponent);

    getOkCancelView()
        .addExecuteListener(
            new IListener<CommandExecutionVote>() {
              @Override
              public void onEvent(CommandExecutionVote event) {
                onAccept();
              }
            });
  }
 protected void onAccept() {
   setModel(tableComponent.getSelectedItem());
 }