View Javadoc
1   /*
2    * MoneyWise: Finance Application
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.moneywise.ui.dialog;
18  
19  import io.github.tonywasher.joceanus.metis.data.MetisDataItem.MetisDataFieldId;
20  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseAssetBase;
21  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseBasicDataType;
22  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseBasicResource;
23  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseDeposit;
24  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseDeposit.MoneyWiseDepositList;
25  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseDepositCategory;
26  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWiseDepositCategory.MoneyWiseDepositCategoryList;
27  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWisePayee;
28  import io.github.tonywasher.joceanus.moneywise.data.basic.MoneyWisePayee.MoneyWisePayeeList;
29  import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWiseAccountInfoClass;
30  import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWiseAssetCategory;
31  import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWiseCurrency;
32  import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWiseCurrency.MoneyWiseCurrencyList;
33  import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWiseDepositCategoryClass;
34  import io.github.tonywasher.joceanus.moneywise.data.statics.MoneyWiseStaticDataType;
35  import io.github.tonywasher.joceanus.moneywise.ui.MoneyWiseIcon;
36  import io.github.tonywasher.joceanus.moneywise.ui.MoneyWiseUIResource;
37  import io.github.tonywasher.joceanus.moneywise.ui.base.MoneyWiseUIAssetTable;
38  import io.github.tonywasher.joceanus.moneywise.views.MoneyWiseView;
39  import io.github.tonywasher.joceanus.oceanus.base.OceanusException;
40  import io.github.tonywasher.joceanus.oceanus.date.OceanusDate;
41  import io.github.tonywasher.joceanus.oceanus.decimal.OceanusMoney;
42  import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataResource;
43  import io.github.tonywasher.joceanus.prometheus.ui.fieldset.PrometheusFieldSet;
44  import io.github.tonywasher.joceanus.prometheus.ui.fieldset.PrometheusFieldSetEvent;
45  import io.github.tonywasher.joceanus.prometheus.views.PrometheusEditSet;
46  import io.github.tonywasher.joceanus.tethys.api.control.TethysUIControl.TethysUIIconMapSet;
47  import io.github.tonywasher.joceanus.tethys.api.factory.TethysUIFactory;
48  import io.github.tonywasher.joceanus.tethys.api.field.TethysUIDataEditField.TethysUICharArrayEditField;
49  import io.github.tonywasher.joceanus.tethys.api.field.TethysUIDataEditField.TethysUICharArrayTextAreaField;
50  import io.github.tonywasher.joceanus.tethys.api.field.TethysUIDataEditField.TethysUIDateButtonField;
51  import io.github.tonywasher.joceanus.tethys.api.field.TethysUIDataEditField.TethysUIIconButtonField;
52  import io.github.tonywasher.joceanus.tethys.api.field.TethysUIDataEditField.TethysUIMoneyEditField;
53  import io.github.tonywasher.joceanus.tethys.api.field.TethysUIDataEditField.TethysUIScrollButtonField;
54  import io.github.tonywasher.joceanus.tethys.api.field.TethysUIDataEditField.TethysUIStringEditField;
55  import io.github.tonywasher.joceanus.tethys.api.field.TethysUIFieldFactory;
56  import io.github.tonywasher.joceanus.tethys.api.menu.TethysUIScrollItem;
57  import io.github.tonywasher.joceanus.tethys.api.menu.TethysUIScrollMenu;
58  import io.github.tonywasher.joceanus.tethys.api.menu.TethysUIScrollMenu.TethysUIScrollSubMenu;
59  
60  import java.util.HashMap;
61  import java.util.Iterator;
62  import java.util.Map;
63  
64  /**
65   * Panel to display/edit/create a Deposit.
66   */
67  public class MoneyWiseUIDepositDialog
68          extends MoneyWiseUIAssetDialog<MoneyWiseDeposit> {
69      /**
70       * Rates Tab Title.
71       */
72      private static final String TAB_RATES = MoneyWiseUIResource.DEPOSITPANEL_TAB_RATES.getValue();
73  
74      /**
75       * The fieldSet.
76       */
77      private final PrometheusFieldSet<MoneyWiseDeposit> theFieldSet;
78  
79      /**
80       * DepositRate Table.
81       */
82      private final MoneyWiseUIDepositRateTable theRates;
83  
84      /**
85       * The Closed State.
86       */
87      private Boolean theClosedState = Boolean.FALSE;
88  
89      /**
90       * Constructor.
91       *
92       * @param pFactory the GUI factory
93       * @param pView    the data view
94       * @param pEditSet the edit set
95       * @param pOwner   the owning table
96       */
97      public MoneyWiseUIDepositDialog(final TethysUIFactory<?> pFactory,
98                                      final MoneyWiseView pView,
99                                      final PrometheusEditSet pEditSet,
100                                     final MoneyWiseUIAssetTable<MoneyWiseDeposit> pOwner) {
101         /* Initialise the panel */
102         super(pFactory, pEditSet, pOwner);
103 
104         /* Access the fieldSet */
105         theFieldSet = getFieldSet();
106         theFieldSet.setReporter(pOwner::showValidateError);
107 
108         /* Build the main panel */
109         buildMainPanel(pFactory);
110 
111         /* Build the account panel */
112         buildAccountPanel(pFactory);
113 
114         /* Build the notes panel */
115         buildNotesPanel(pFactory);
116 
117         /* Create the DepositRates table and add to fieldSet */
118         theRates = new MoneyWiseUIDepositRateTable(pView, getEditSet(), pOwner.getErrorPanel());
119         theFieldSet.newTable(TAB_RATES, theRates);
120 
121         /* Create the listeners */
122         theRates.getEventRegistrar().addEventListener(e -> {
123             updateActions();
124             fireStateChanged();
125         });
126     }
127 
128     /**
129      * Build Main subPanel.
130      *
131      * @param pFactory the GUI factory
132      */
133     private void buildMainPanel(final TethysUIFactory<?> pFactory) {
134         /* Create the text fields */
135         final TethysUIFieldFactory myFields = pFactory.fieldFactory();
136         final TethysUIStringEditField myName = myFields.newStringField();
137         final TethysUIStringEditField myDesc = myFields.newStringField();
138 
139         /* Create the buttons */
140         final TethysUIScrollButtonField<MoneyWiseAssetCategory> myCategoryButton = myFields.newScrollField(MoneyWiseAssetCategory.class);
141         final TethysUIScrollButtonField<MoneyWisePayee> myParentButton = myFields.newScrollField(MoneyWisePayee.class);
142         final TethysUIScrollButtonField<MoneyWiseCurrency> myCurrencyButton = myFields.newScrollField(MoneyWiseCurrency.class);
143         final TethysUIIconButtonField<Boolean> myClosedButton = myFields.newIconField(Boolean.class);
144 
145         /* Assign the fields to the panel */
146         theFieldSet.addField(PrometheusDataResource.DATAITEM_FIELD_NAME, myName, MoneyWiseDeposit::getName);
147         theFieldSet.addField(PrometheusDataResource.DATAITEM_FIELD_DESC, myDesc, MoneyWiseDeposit::getDesc);
148         theFieldSet.addField(MoneyWiseBasicResource.CATEGORY_NAME, myCategoryButton, MoneyWiseDeposit::getCategory);
149         theFieldSet.addField(MoneyWiseBasicResource.ASSET_PARENT, myParentButton, MoneyWiseDeposit::getParent);
150         theFieldSet.addField(MoneyWiseStaticDataType.CURRENCY, myCurrencyButton, MoneyWiseDeposit::getAssetCurrency);
151         theFieldSet.addField(MoneyWiseBasicResource.ASSET_CLOSED, myClosedButton, MoneyWiseDeposit::isClosed);
152 
153         /* Configure the menuBuilders */
154         myCategoryButton.setMenuConfigurator(c -> buildCategoryMenu(c, getItem()));
155         myParentButton.setMenuConfigurator(c -> buildParentMenu(c, getItem()));
156         myCurrencyButton.setMenuConfigurator(c -> buildCurrencyMenu(c, getItem()));
157         final Map<Boolean, TethysUIIconMapSet<Boolean>> myMapSets = MoneyWiseIcon.configureLockedIconButton(pFactory);
158         myClosedButton.setIconMapSet(() -> myMapSets.get(theClosedState));
159 
160         /* Configure validation checks */
161         myName.setValidator(this::isValidName);
162         myDesc.setValidator(this::isValidDesc);
163     }
164 
165     /**
166      * Build account subPanel.
167      *
168      * @param pFactory the GUI factory
169      */
170     private void buildAccountPanel(final TethysUIFactory<?> pFactory) {
171         /* Create a new panel */
172         theFieldSet.newPanel(TAB_ACCOUNT);
173 
174         /* Allocate fields */
175         final TethysUIFieldFactory myFields = pFactory.fieldFactory();
176         final TethysUIDateButtonField myMaturity = myFields.newDateField();
177         final TethysUICharArrayEditField mySortCode = myFields.newCharArrayField();
178         final TethysUICharArrayEditField myAccount = myFields.newCharArrayField();
179         final TethysUICharArrayEditField myReference = myFields.newCharArrayField();
180         final TethysUIMoneyEditField myOpening = myFields.newMoneyField();
181 
182         /* Assign the fields to the panel */
183         theFieldSet.addField(MoneyWiseAccountInfoClass.MATURITY, myMaturity, MoneyWiseDeposit::getMaturity);
184         theFieldSet.addField(MoneyWiseAccountInfoClass.SORTCODE, mySortCode, MoneyWiseDeposit::getSortCode);
185         theFieldSet.addField(MoneyWiseAccountInfoClass.ACCOUNT, myAccount, MoneyWiseDeposit::getAccount);
186         theFieldSet.addField(MoneyWiseAccountInfoClass.REFERENCE, myReference, MoneyWiseDeposit::getReference);
187         theFieldSet.addField(MoneyWiseAccountInfoClass.OPENINGBALANCE, myOpening, MoneyWiseDeposit::getOpeningBalance);
188 
189         /* Configure the currency */
190         myOpening.setDeemedCurrency(() -> getItem().getCurrency());
191 
192         /* Configure validation checks */
193         mySortCode.setValidator(this::isValidSortCode);
194         myAccount.setValidator(this::isValidAccount);
195         myReference.setValidator(this::isValidReference);
196     }
197 
198     /**
199      * Build Notes subPanel.
200      *
201      * @param pFactory the GUI factory
202      */
203     private void buildNotesPanel(final TethysUIFactory<?> pFactory) {
204         /* Allocate fields */
205         final TethysUIFieldFactory myFields = pFactory.fieldFactory();
206         final TethysUICharArrayTextAreaField myNotes = myFields.newCharArrayAreaField();
207 
208         /* Assign the fields to the panel */
209         theFieldSet.newTextArea(TAB_NOTES, MoneyWiseAccountInfoClass.NOTES, myNotes, MoneyWiseDeposit::getNotes);
210 
211         /* Configure validation checks */
212         myNotes.setValidator(this::isValidNotes);
213     }
214 
215     @Override
216     public void refreshData() {
217         /* If we have an item */
218         final MoneyWiseDeposit myItem = getItem();
219         if (myItem != null) {
220             final MoneyWiseDepositList myDeposits = getDataList(MoneyWiseBasicDataType.DEPOSIT, MoneyWiseDepositList.class);
221             setItem(myDeposits.findItemById(myItem.getIndexedId()));
222         }
223 
224         /* Refresh the rates */
225         theRates.refreshData();
226 
227         /* Make sure that the item is not editable */
228         setEditable(false);
229     }
230 
231     @Override
232     protected void adjustFields(final boolean isEditable) {
233         /* Access the item */
234         final MoneyWiseDeposit myDeposit = getItem();
235         final boolean bIsClosed = myDeposit.isClosed();
236         final boolean bIsActive = myDeposit.isActive();
237         final boolean bIsRelevant = myDeposit.isRelevant();
238         final boolean bIsChangeable = !bIsActive && isEditable;
239 
240         /* Determine whether the closed button should be visible */
241         final boolean bShowClosed = bIsClosed || (bIsActive && !bIsRelevant);
242         theFieldSet.setFieldVisible(MoneyWiseBasicResource.ASSET_CLOSED, bShowClosed);
243 
244         /* Determine the state of the closed button */
245         final boolean bEditClosed = bIsClosed
246                 ? !myDeposit.getParent().isClosed()
247                 : !bIsRelevant;
248         theFieldSet.setFieldEditable(MoneyWiseBasicResource.ASSET_CLOSED, isEditable && bEditClosed);
249         theClosedState = bEditClosed;
250 
251         /* Determine whether the description field should be visible */
252         final boolean bShowDesc = isEditable || myDeposit.getDesc() != null;
253         theFieldSet.setFieldVisible(PrometheusDataResource.DATAITEM_FIELD_DESC, bShowDesc);
254 
255         /* Determine whether the account details should be visible */
256         final boolean bShowSortCode = isEditable || myDeposit.getSortCode() != null;
257         theFieldSet.setFieldVisible(MoneyWiseAccountInfoClass.SORTCODE, bShowSortCode);
258         final boolean bShowAccount = isEditable || myDeposit.getAccount() != null;
259         theFieldSet.setFieldVisible(MoneyWiseAccountInfoClass.ACCOUNT, bShowAccount);
260         final boolean bShowReference = isEditable || myDeposit.getReference() != null;
261         theFieldSet.setFieldVisible(MoneyWiseAccountInfoClass.REFERENCE, bShowReference);
262         final boolean bHasOpening = myDeposit.getOpeningBalance() != null;
263         final boolean bShowOpening = bIsChangeable || bHasOpening;
264         theFieldSet.setFieldVisible(MoneyWiseAccountInfoClass.OPENINGBALANCE, bShowOpening);
265         final boolean bShowNotes = isEditable || myDeposit.getNotes() != null;
266         theFieldSet.setFieldVisible(MoneyWiseAccountInfoClass.NOTES, bShowNotes);
267 
268         /* Maturity is only visible if the item is a bond */
269         final boolean bShowMaturity = MoneyWiseDepositCategoryClass.BOND.equals(myDeposit.getCategoryClass());
270         theFieldSet.setFieldVisible(MoneyWiseAccountInfoClass.MATURITY, bShowMaturity);
271         theFieldSet.setFieldEditable(MoneyWiseAccountInfoClass.MATURITY, isEditable && !bIsClosed);
272 
273         /* Category, Currency, and OpeningBalance cannot be changed if the item is active */
274         theFieldSet.setFieldEditable(MoneyWiseBasicResource.CATEGORY_NAME, bIsChangeable);
275         theFieldSet.setFieldEditable(MoneyWiseStaticDataType.CURRENCY, bIsChangeable && !bHasOpening);
276         theFieldSet.setFieldEditable(MoneyWiseAccountInfoClass.OPENINGBALANCE, bIsChangeable);
277 
278         /* Set editable value for parent */
279         theFieldSet.setFieldEditable(MoneyWiseBasicResource.ASSET_PARENT, isEditable && !bIsClosed);
280     }
281 
282     @Override
283     protected void updateField(final PrometheusFieldSetEvent pUpdate) throws OceanusException {
284         /* Access the field */
285         final MetisDataFieldId myField = pUpdate.getFieldId();
286         final MoneyWiseDeposit myDeposit = getItem();
287 
288         /* Process updates */
289         if (PrometheusDataResource.DATAITEM_FIELD_NAME.equals(myField)) {
290             /* Update the Name */
291             myDeposit.setName(pUpdate.getValue(String.class));
292         } else if (PrometheusDataResource.DATAITEM_FIELD_DESC.equals(myField)) {
293             /* Update the Description */
294             myDeposit.setDescription(pUpdate.getValue(String.class));
295         } else if (MoneyWiseBasicResource.CATEGORY_NAME.equals(myField)) {
296             /* Update the Category */
297             myDeposit.setCategory(pUpdate.getValue(MoneyWiseDepositCategory.class));
298             myDeposit.autoCorrect();
299         } else if (MoneyWiseBasicResource.ASSET_PARENT.equals(myField)) {
300             /* Update the Parent */
301             myDeposit.setParent(pUpdate.getValue(MoneyWisePayee.class));
302         } else if (MoneyWiseStaticDataType.CURRENCY.equals(myField)) {
303             /* Update the Currency */
304             myDeposit.setAssetCurrency(pUpdate.getValue(MoneyWiseCurrency.class));
305         } else if (MoneyWiseBasicResource.ASSET_CLOSED.equals(myField)) {
306             /* Update the Closed indication */
307             myDeposit.setClosed(pUpdate.getValue(Boolean.class));
308         } else if (MoneyWiseAccountInfoClass.MATURITY.equals(myField)) {
309             /* Update the Maturity */
310             myDeposit.setMaturity(pUpdate.getValue(OceanusDate.class));
311         } else if (MoneyWiseAccountInfoClass.SORTCODE.equals(myField)) {
312             /* Update the SortCode */
313             myDeposit.setSortCode(pUpdate.getValue(char[].class));
314         } else if (MoneyWiseAccountInfoClass.ACCOUNT.equals(myField)) {
315             /* Update the Account */
316             myDeposit.setAccount(pUpdate.getValue(char[].class));
317         } else if (MoneyWiseAccountInfoClass.REFERENCE.equals(myField)) {
318             /* Update the Reference */
319             myDeposit.setReference(pUpdate.getValue(char[].class));
320         } else if (MoneyWiseAccountInfoClass.OPENINGBALANCE.equals(myField)) {
321             /* Update the OpeningBalance */
322             myDeposit.setOpeningBalance(pUpdate.getValue(OceanusMoney.class));
323         } else if (MoneyWiseAccountInfoClass.NOTES.equals(myField)) {
324             /* Update the Notes */
325             myDeposit.setNotes(pUpdate.getValue(char[].class));
326         }
327     }
328 
329     @Override
330     protected void declareGoToItems(final boolean pUpdates) {
331         final MoneyWiseDeposit myItem = getItem();
332         final MoneyWiseAssetBase myParent = myItem.getParent();
333         if (!pUpdates) {
334             final MoneyWiseDepositCategory myCategory = myItem.getCategory();
335             final MoneyWiseCurrency myCurrency = myItem.getAssetCurrency();
336             declareGoToItem(myCategory);
337             declareGoToItem(myCurrency);
338         }
339         declareGoToItem(myParent);
340     }
341 
342     @Override
343     public void setEditable(final boolean isEditable) {
344         /* Update the rates */
345         theRates.setEditable(isEditable);
346 
347         /* Pass call onwards */
348         super.setEditable(isEditable);
349     }
350 
351     @Override
352     protected void refreshAfterUpdate() {
353         /* Pass call onwards */
354         super.refreshAfterUpdate();
355 
356         /* Refresh the rates */
357         theRates.refreshAfterUpdate();
358     }
359 
360     /**
361      * Build the category type menu for an item.
362      *
363      * @param pMenu    the menu
364      * @param pDeposit the deposit to build for
365      */
366     public void buildCategoryMenu(final TethysUIScrollMenu<MoneyWiseAssetCategory> pMenu,
367                                   final MoneyWiseDeposit pDeposit) {
368         /* Clear the menu */
369         pMenu.removeAllItems();
370 
371         /* Record active item */
372         final MoneyWiseDepositCategory myCurr = pDeposit.getCategory();
373         TethysUIScrollItem<MoneyWiseAssetCategory> myActive = null;
374 
375         /* Access Deposit Categories */
376         final MoneyWiseDepositCategoryList myCategories = getDataList(MoneyWiseBasicDataType.DEPOSITCATEGORY, MoneyWiseDepositCategoryList.class);
377 
378         /* Create a simple map for top-level categories */
379         final Map<String, TethysUIScrollSubMenu<MoneyWiseAssetCategory>> myMap = new HashMap<>();
380 
381         /* Loop through the available category values */
382         final Iterator<MoneyWiseDepositCategory> myIterator = myCategories.iterator();
383         while (myIterator.hasNext()) {
384             final MoneyWiseDepositCategory myCategory = myIterator.next();
385 
386             /* Ignore deleted or parent */
387             final boolean bIgnore = myCategory.isDeleted() || myCategory.isCategoryClass(MoneyWiseDepositCategoryClass.PARENT);
388             if (bIgnore) {
389                 continue;
390             }
391 
392             /* Determine menu to add to */
393             final MoneyWiseDepositCategory myParent = myCategory.getParentCategory();
394             final String myParentName = myParent.getName();
395             final TethysUIScrollSubMenu<MoneyWiseAssetCategory> myMenu = myMap.computeIfAbsent(myParentName, pMenu::addSubMenu);
396 
397             /* Create a new MenuItem and add it to the popUp */
398             final TethysUIScrollItem<MoneyWiseAssetCategory> myItem = myMenu.getSubMenu().addItem(myCategory, myCategory.getSubCategory());
399 
400             /* Note active category */
401             if (myCategory.equals(myCurr)) {
402                 myActive = myItem;
403             }
404         }
405 
406         /* Ensure active item is visible */
407         if (myActive != null) {
408             myActive.scrollToItem();
409         }
410     }
411 
412     /**
413      * Build the parent menu for an item.
414      *
415      * @param pMenu    the menu
416      * @param pDeposit the deposit to build for
417      */
418     public void buildParentMenu(final TethysUIScrollMenu<MoneyWisePayee> pMenu,
419                                 final MoneyWiseDeposit pDeposit) {
420         /* Clear the menu */
421         pMenu.removeAllItems();
422 
423         /* Record active item */
424         final MoneyWiseDepositCategoryClass myType = pDeposit.getCategoryClass();
425         final MoneyWisePayee myCurr = pDeposit.getParent();
426         TethysUIScrollItem<MoneyWisePayee> myActive = null;
427 
428         /* Access Payees */
429         final MoneyWisePayeeList myPayees = getDataList(MoneyWiseBasicDataType.PAYEE, MoneyWisePayeeList.class);
430 
431         /* Loop through the Payees */
432         final Iterator<MoneyWisePayee> myIterator = myPayees.iterator();
433         while (myIterator.hasNext()) {
434             final MoneyWisePayee myPayee = myIterator.next();
435 
436             /* Ignore deleted or non-owner */
437             boolean bIgnore = myPayee.isDeleted() || !myPayee.getCategoryClass().canParentDeposit(myType);
438             bIgnore |= myPayee.isClosed();
439             if (bIgnore) {
440                 continue;
441             }
442 
443             /* Create a new action for the payee */
444             final TethysUIScrollItem<MoneyWisePayee> myItem = pMenu.addItem(myPayee);
445 
446             /* If this is the active parent */
447             if (myPayee.equals(myCurr)) {
448                 /* Record it */
449                 myActive = myItem;
450             }
451         }
452 
453         /* Ensure active item is visible */
454         if (myActive != null) {
455             myActive.scrollToItem();
456         }
457     }
458 
459     /**
460      * Build the currency menu for an item.
461      *
462      * @param pMenu    the menu
463      * @param pDeposit the deposit to build for
464      */
465     public void buildCurrencyMenu(final TethysUIScrollMenu<MoneyWiseCurrency> pMenu,
466                                   final MoneyWiseDeposit pDeposit) {
467         /* Clear the menu */
468         pMenu.removeAllItems();
469 
470         /* Record active item */
471         final MoneyWiseCurrency myCurr = pDeposit.getAssetCurrency();
472         TethysUIScrollItem<MoneyWiseCurrency> myActive = null;
473 
474         /* Access Currencies */
475         final MoneyWiseCurrencyList myCurrencies = getDataList(MoneyWiseStaticDataType.CURRENCY, MoneyWiseCurrencyList.class);
476 
477         /* Loop through the AccountCurrencies */
478         final Iterator<MoneyWiseCurrency> myIterator = myCurrencies.iterator();
479         while (myIterator.hasNext()) {
480             final MoneyWiseCurrency myCurrency = myIterator.next();
481 
482             /* Ignore deleted or disabled */
483             final boolean bIgnore = myCurrency.isDeleted() || !myCurrency.getEnabled();
484             if (bIgnore) {
485                 continue;
486             }
487 
488             /* Create a new action for the currency */
489             final TethysUIScrollItem<MoneyWiseCurrency> myItem = pMenu.addItem(myCurrency);
490 
491             /* If this is the active currency */
492             if (myCurrency.equals(myCurr)) {
493                 /* Record it */
494                 myActive = myItem;
495             }
496         }
497 
498         /* Ensure active item is visible */
499         if (myActive != null) {
500             myActive.scrollToItem();
501         }
502     }
503 }