示例#1
0
  @Override
  public void setVisible(boolean b) {
    //
    // Only do this if 1 entry and can add...
    //
    ListFacade<InfoFacade> availableList = chooser.getAvailableList();
    if ((availableList != null)
        && (availableList.getSize() == 1)
        && (listModel.getSize() == 0)
        && b
        && !chooser.isUserInput()) {
      final int method = UIPropertyContext.getSingleChoiceAction();

      if (method != Constants.CHOOSER_SINGLE_CHOICE_METHOD_NONE) {
        chooser.addSelected(availableList.getElementAt(0));

        if (method == Constants.CHOOSER_SINGLE_CHOICE_METHOD_SELECT_EXIT) {
          chooser.commit();
          committed = true;
          return;
        }
      }
    }

    super.setVisible(b);
  }
示例#2
0
  /**
   * Create a new instance of ChooserDialog for selecting from the data supplied in the
   * chooserFacade.
   *
   * @param frame The window we are opening relative to.
   * @param chooser The definition of what should be displayed.
   */
  public ChooserDialog(Frame frame, ChooserFacade chooser) {
    super(frame, true);
    this.chooser = chooser;
    if (chooser.isUserInput()) {
      this.availTable = null;
      this.availInput = new JTextField(20);
    } else {
      this.availTable = new JTreeViewTable<>();
      this.availInput = null;
    }
    this.remainingLabel = new JLabel();
    this.treeViewModel = new GeneralTreeViewModel();
    this.list = new JListEx();
    this.listModel = new FacadeListModel<>();
    this.infoPane = new InfoPane();

    treeViewModel.setDelegate(chooser.getAvailableList());
    listModel.setListFacade(chooser.getSelectedList());
    chooser.getRemainingSelections().addReferenceListener(this);
    overridePrefs();
    initComponents();
    pack();
  }