| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
package org.homeunix.thecave.buddi.plugin.builtin.preference; |
| 5 | |
|
| 6 | |
import java.awt.FlowLayout; |
| 7 | |
|
| 8 | |
import javax.swing.Box; |
| 9 | |
import javax.swing.BoxLayout; |
| 10 | |
import javax.swing.JCheckBox; |
| 11 | |
import javax.swing.JPanel; |
| 12 | |
|
| 13 | |
import org.homeunix.thecave.buddi.i18n.BuddiKeys; |
| 14 | |
import org.homeunix.thecave.buddi.model.prefs.PrefsModel; |
| 15 | |
import org.homeunix.thecave.buddi.plugin.api.BuddiPreferencePlugin; |
| 16 | |
import org.homeunix.thecave.buddi.plugin.api.util.TextFormatter; |
| 17 | |
|
| 18 | |
public class ViewPreferences extends BuddiPreferencePlugin { |
| 19 | |
public static final long serialVersionUID = 0; |
| 20 | |
|
| 21 | |
private final JCheckBox showDeleted; |
| 22 | |
private final JCheckBox showClear; |
| 23 | |
private final JCheckBox showAutoComplete; |
| 24 | |
private final JCheckBox showReconcile; |
| 25 | |
private final JCheckBox showFlatAccounts; |
| 26 | |
private final JCheckBox showFlatBudget; |
| 27 | |
private final JCheckBox showFlatBudgetInSourceCombobox; |
| 28 | |
private final JCheckBox showOverdraftLimit; |
| 29 | |
private final JCheckBox showCreditLimit; |
| 30 | |
private final JCheckBox showInterestRate; |
| 31 | |
private final JCheckBox showTooltips; |
| 32 | |
|
| 33 | |
|
| 34 | 695 | public ViewPreferences() { |
| 35 | 695 | showDeleted = new JCheckBox(TextFormatter.getTranslation(BuddiKeys.PREFERENCE_SHOW_DELETED)); |
| 36 | 695 | showAutoComplete = new JCheckBox(TextFormatter.getTranslation(BuddiKeys.PREFERENCE_AUTO_COMPLETE_TRANSACTION_INFORMATION)); |
| 37 | 695 | showClear = new JCheckBox(TextFormatter.getTranslation(BuddiKeys.PREFERENCE_SHOW_CLEAR)); |
| 38 | 695 | showReconcile = new JCheckBox(TextFormatter.getTranslation(BuddiKeys.PREFERENCE_SHOW_RECONCILE)); |
| 39 | 695 | showFlatAccounts = new JCheckBox(TextFormatter.getTranslation(BuddiKeys.PREFERENCE_SHOW_FLAT_ACCOUNTS)); |
| 40 | 695 | showFlatBudget = new JCheckBox(TextFormatter.getTranslation(BuddiKeys.PREFERENCE_SHOW_FLAT_BUDGET)); |
| 41 | 695 | showFlatBudgetInSourceCombobox = new JCheckBox(TextFormatter.getTranslation(BuddiKeys.PREFERENCE_SHOW_FLAT_BUDGET_IN_SOURCE_COMBOBOX)); |
| 42 | 695 | showOverdraftLimit = new JCheckBox(TextFormatter.getTranslation(BuddiKeys.PREFERENCE_SHOW_OVERDRAFT_LIMIT)); |
| 43 | 695 | showCreditLimit = new JCheckBox(TextFormatter.getTranslation(BuddiKeys.PREFERENCE_SHOW_CREDIT_LIMIT)); |
| 44 | 695 | showInterestRate = new JCheckBox(TextFormatter.getTranslation(BuddiKeys.PREFERENCE_SHOW_INTEREST_RATE)); |
| 45 | 695 | showTooltips = new JCheckBox(TextFormatter.getTranslation(BuddiKeys.PREFERENCE_SHOW_TOOLTIPS)); |
| 46 | 695 | } |
| 47 | |
|
| 48 | |
@Override |
| 49 | |
public JPanel getPreferencesPanel() { |
| 50 | 695 | JPanel panel = new JPanel(); |
| 51 | 695 | panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); |
| 52 | |
|
| 53 | 695 | JPanel deletePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 54 | 695 | JPanel autoCompletePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 55 | 695 | JPanel clearPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 56 | 695 | JPanel reconcilePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 57 | 695 | JPanel flatAccountsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 58 | 695 | JPanel flatBudgetPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 59 | 695 | JPanel flatBudgetPanelInSourceCombobox = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 60 | 695 | JPanel overdraftPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 61 | 695 | JPanel creditLimitPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 62 | 695 | JPanel interestRatePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 63 | 695 | JPanel tooltipPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
| 64 | |
|
| 65 | 695 | deletePanel.add(showDeleted); |
| 66 | 695 | autoCompletePanel.add(showAutoComplete); |
| 67 | 695 | clearPanel.add(showClear); |
| 68 | 695 | reconcilePanel.add(showReconcile); |
| 69 | 695 | flatAccountsPanel.add(showFlatAccounts); |
| 70 | 695 | flatBudgetPanel.add(showFlatBudget); |
| 71 | 695 | flatBudgetPanelInSourceCombobox.add(showFlatBudgetInSourceCombobox); |
| 72 | 695 | overdraftPanel.add(showOverdraftLimit); |
| 73 | 695 | creditLimitPanel.add(showCreditLimit); |
| 74 | 695 | interestRatePanel.add(showInterestRate); |
| 75 | 695 | tooltipPanel.add(showTooltips); |
| 76 | |
|
| 77 | 695 | panel.add(autoCompletePanel); |
| 78 | 695 | panel.add(clearPanel); |
| 79 | 695 | panel.add(reconcilePanel); |
| 80 | 695 | panel.add(deletePanel); |
| 81 | 695 | panel.add(flatAccountsPanel); |
| 82 | 695 | panel.add(flatBudgetPanel); |
| 83 | 695 | panel.add(flatBudgetPanelInSourceCombobox); |
| 84 | 695 | panel.add(overdraftPanel); |
| 85 | 695 | panel.add(creditLimitPanel); |
| 86 | 695 | panel.add(interestRatePanel); |
| 87 | 695 | panel.add(tooltipPanel); |
| 88 | 695 | panel.add(Box.createVerticalGlue()); |
| 89 | |
|
| 90 | 695 | return panel; |
| 91 | |
} |
| 92 | |
|
| 93 | |
public void load() { |
| 94 | 695 | showDeleted.setSelected(PrefsModel.getInstance().isShowDeleted()); |
| 95 | 695 | showAutoComplete.setSelected(PrefsModel.getInstance().isShowAutoComplete()); |
| 96 | 695 | showClear.setSelected(PrefsModel.getInstance().isShowCleared()); |
| 97 | 695 | showReconcile.setSelected(PrefsModel.getInstance().isShowReconciled()); |
| 98 | 695 | showFlatAccounts.setSelected(PrefsModel.getInstance().isShowFlatAccounts()); |
| 99 | 695 | showFlatBudget.setSelected(PrefsModel.getInstance().isShowFlatBudget()); |
| 100 | 695 | showFlatBudgetInSourceCombobox.setSelected(PrefsModel.getInstance().isShowFlatBudgetInSourceCombobox()); |
| 101 | 695 | showOverdraftLimit.setSelected(PrefsModel.getInstance().isShowOverdraft()); |
| 102 | 695 | showCreditLimit.setSelected(PrefsModel.getInstance().isShowCreditRemaining()); |
| 103 | 695 | showInterestRate.setSelected(PrefsModel.getInstance().isShowInterestRates()); |
| 104 | 695 | showTooltips.setSelected(PrefsModel.getInstance().isShowTooltips()); |
| 105 | 695 | } |
| 106 | |
|
| 107 | |
public boolean save() { |
| 108 | 43 | boolean restart = false; |
| 109 | |
|
| 110 | 43 | PrefsModel.getInstance().setShowDeleted(showDeleted.isSelected()); |
| 111 | 43 | PrefsModel.getInstance().setShowAutoComplete(showAutoComplete.isSelected()); |
| 112 | 43 | PrefsModel.getInstance().setShowCleared(showClear.isSelected()); |
| 113 | 43 | PrefsModel.getInstance().setShowReconciled(showReconcile.isSelected()); |
| 114 | 43 | PrefsModel.getInstance().setShowFlatAccounts(showFlatAccounts.isSelected()); |
| 115 | 43 | PrefsModel.getInstance().setShowFlatBudget(showFlatBudget.isSelected()); |
| 116 | 43 | PrefsModel.getInstance().setShowFlatBudgetInSourceCombobox(showFlatBudgetInSourceCombobox.isSelected()); |
| 117 | 43 | PrefsModel.getInstance().setShowOverdraft(showOverdraftLimit.isSelected()); |
| 118 | 43 | PrefsModel.getInstance().setShowCreditRemaining(showCreditLimit.isSelected()); |
| 119 | 43 | PrefsModel.getInstance().setShowInterestRates(showInterestRate.isSelected()); |
| 120 | 43 | PrefsModel.getInstance().setShowTooltips(showTooltips.isSelected()); |
| 121 | |
|
| 122 | 43 | return restart; |
| 123 | |
} |
| 124 | |
|
| 125 | |
public String getName() { |
| 126 | 695 | return BuddiKeys.VIEW.toString(); |
| 127 | |
} |
| 128 | |
} |