| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
package org.homeunix.thecave.buddi.model.swing; |
| 5 | |
|
| 6 | |
import org.homeunix.thecave.buddi.i18n.keys.TransactionClearedFilterKeys; |
| 7 | |
import org.homeunix.thecave.buddi.i18n.keys.TransactionDateFilterKeys; |
| 8 | |
import org.homeunix.thecave.buddi.i18n.keys.TransactionReconciledFilterKeys; |
| 9 | |
import org.homeunix.thecave.buddi.model.Document; |
| 10 | |
import org.homeunix.thecave.buddi.model.Source; |
| 11 | |
import org.homeunix.thecave.buddi.model.Transaction; |
| 12 | |
import org.homeunix.thecave.buddi.model.impl.FilteredLists; |
| 13 | |
import org.homeunix.thecave.buddi.model.impl.FilteredLists.TransactionListFilteredBySearch; |
| 14 | |
|
| 15 | |
import ca.digitalcave.moss.swing.model.BackedListModel; |
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
public class TransactionListModel extends BackedListModel<Transaction> { |
| 25 | |
public static final long serialVersionUID = 0; |
| 26 | |
|
| 27 | |
private final FilteredLists.TransactionListFilteredBySearch transactions; |
| 28 | |
|
| 29 | |
public TransactionListModel(Document model, Source selectedSource) { |
| 30 | 0 | super(selectedSource == null ? |
| 31 | |
FilteredLists.getTransactionsBySearch(model, selectedSource, model.getTransactions()) : |
| 32 | |
FilteredLists.getTransactionsBySearch(model, selectedSource, model.getTransactions(selectedSource))); |
| 33 | |
|
| 34 | 0 | this.transactions = (TransactionListFilteredBySearch) listModel; |
| 35 | 0 | } |
| 36 | |
|
| 37 | |
public void setSearchText(String text){ |
| 38 | 0 | transactions.setSearchText(text); |
| 39 | 0 | transactions.updateFilteredList(); |
| 40 | 0 | update(); |
| 41 | 0 | } |
| 42 | |
|
| 43 | |
public void setDateFilter(TransactionDateFilterKeys key){ |
| 44 | 0 | transactions.setDateFilter(key); |
| 45 | 0 | transactions.updateFilteredList(); |
| 46 | 0 | update(); |
| 47 | 0 | } |
| 48 | |
|
| 49 | |
public void setClearedFilter(TransactionClearedFilterKeys key){ |
| 50 | 0 | transactions.setClearedFilter(key); |
| 51 | 0 | transactions.updateFilteredList(); |
| 52 | 0 | update(); |
| 53 | 0 | } |
| 54 | |
|
| 55 | |
public void setReconciledFilter(TransactionReconciledFilterKeys key){ |
| 56 | 0 | transactions.setReconciledFilter(key); |
| 57 | 0 | transactions.updateFilteredList(); |
| 58 | 0 | update(); |
| 59 | 0 | } |
| 60 | |
|
| 61 | |
public boolean isListFiltered(){ |
| 62 | 0 | return (transactions.isFiltered()); |
| 63 | |
} |
| 64 | |
|
| 65 | |
public void update(){ |
| 66 | 0 | transactions.updateFilteredList(); |
| 67 | 0 | fireContentsChanged(this, -1, -1); |
| 68 | 0 | } |
| 69 | |
} |