Search in sources :

Example 1 with InfoWrapper

use of pcgen.core.chooser.InfoWrapper in project pcgen by PCGen.

the class ChooserDialog method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (availTable != null && (e.getActionCommand().equals("ADD") || e.getSource() == availTable)) {
        List<Object> data = availTable.getSelectedData();
        if (!data.isEmpty()) {
            for (Object object : data) {
                if (object instanceof InfoFacade) {
                    chooser.addSelected((InfoFacade) object);
                }
            }
        }
        return;
    }
    if (availInput != null && (e.getActionCommand().equals("ADD") || e.getSource() == availInput)) {
        String data = availInput.getText();
        if (StringUtils.isNotBlank(data)) {
            chooser.addSelected(new InfoWrapper(data));
        }
        availInput.setText("");
        return;
    }
    if (e.getActionCommand().equals("REMOVE") || e.getSource() == list) {
        Object value = list.getSelectedValue();
        if (value != null && value instanceof InfoFacade) {
            chooser.removeSelected((InfoFacade) value);
            if (availInput != null) {
                availInput.setText(value.toString());
            }
        }
        return;
    }
    if (e.getActionCommand().equals("OK")) {
        if (chooser.isRequireCompleteSelection() && chooser.getRemainingSelections().get() > 0) {
            JOptionPane.showMessageDialog(this, //$NON-NLS-1$
            LanguageBundle.getFormattedString(//$NON-NLS-1$
            "in_chooserRequireComplete", chooser.getRemainingSelections().get()), chooser.getName(), JOptionPane.INFORMATION_MESSAGE);
            return;
        } else {
            chooser.commit();
        }
    } else {
        chooser.rollback();
    }
    committed = e.getActionCommand().equals("OK");
    dispose();
}
Also used : InfoFacade(pcgen.facade.core.InfoFacade) InfoWrapper(pcgen.core.chooser.InfoWrapper)

Aggregations

InfoWrapper (pcgen.core.chooser.InfoWrapper)1 InfoFacade (pcgen.facade.core.InfoFacade)1