private void initComponents() { accountCombo = new AccountListComboBox(); helpPane = new JTextPane(); helpPane.setEditable(false); helpPane.setEditorKit(new StyledEditorKit()); helpPane.setBackground(getBackground()); helpPane.setText(TextResource.getString("QifOne.txt")); /* Create the combo for date format selection */ String[] formats = {QifUtils.US_FORMAT, QifUtils.EU_FORMAT}; dateFormatCombo = new JComboBox<>(formats); dateFormatCombo.addActionListener(this); dateFormatCombo.setSelectedIndex(pref.getInt(DATE_FORMAT, 0)); accountCombo.addActionListener(this); /* Try a set the combobox to the last selected account */ String lastAccount = pref.get(LAST_ACCOUNT, ""); Account last = EngineFactory.getEngine(EngineFactory.DEFAULT).getAccountByUuid(lastAccount); if (last != null) { setAccount(last); } }
@Override public boolean isPageValid() { // an account was selected, make sure that the destination is valid if (destinationAccount == null) { destinationAccount = accountCombo.getSelectedAccount(); } return true; }
private void accountAction() { destinationAccount = accountCombo.getSelectedAccount(); /* Save the id of the selected account */ if (destinationAccount != null) { pref.put(LAST_ACCOUNT, destinationAccount.getUuid()); pref.putInt(DATE_FORMAT, dateFormatCombo.getSelectedIndex()); } }
void setAccount(Account account) { destinationAccount = account; accountCombo.setSelectedAccount(destinationAccount); }
public Account getAccount() { if (destinationAccount == null) { destinationAccount = accountCombo.getSelectedAccount(); } return destinationAccount; }