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.lethe.ui.controls;
18  
19  import io.github.tonywasher.joceanus.moneywise.lethe.data.analysis.data.MoneyWiseAnalysis;
20  import io.github.tonywasher.joceanus.moneywise.lethe.views.MoneyWiseAnalysisFilter;
21  import io.github.tonywasher.joceanus.moneywise.lethe.views.MoneyWiseAnalysisFilter.MoneyWiseAnalysisAllFilter;
22  import io.github.tonywasher.joceanus.tethys.api.base.TethysUIComponent;
23  import io.github.tonywasher.joceanus.tethys.api.factory.TethysUIFactory;
24  import io.github.tonywasher.joceanus.tethys.api.pane.TethysUIBoxPaneManager;
25  
26  /**
27   * All transactions Selection.
28   */
29  public class MoneyWiseAllSelect
30          implements MoneyWiseAnalysisFilterSelection {
31      /**
32       * The panel.
33       */
34      private final TethysUIBoxPaneManager thePanel;
35  
36      /**
37       * The filter.
38       */
39      private final MoneyWiseAnalysisAllFilter theFilter;
40  
41      /**
42       * Constructor.
43       *
44       * @param pFactory the GUI factory
45       */
46      protected MoneyWiseAllSelect(final TethysUIFactory<?> pFactory) {
47          /* Create the filter */
48          thePanel = pFactory.paneFactory().newHBoxPane();
49          theFilter = new MoneyWiseAnalysisAllFilter();
50      }
51  
52      @Override
53      public TethysUIComponent getUnderlying() {
54          return thePanel;
55      }
56  
57      @Override
58      public MoneyWiseAnalysisAllFilter getFilter() {
59          return theFilter;
60      }
61  
62      @Override
63      public boolean isAvailable() {
64          return true;
65      }
66  
67      /**
68       * Create SavePoint.
69       */
70      protected void createSavePoint() {
71          /* Nothing to do */
72      }
73  
74      /**
75       * Restore SavePoint.
76       */
77      protected void restoreSavePoint() {
78          /* Nothing to do */
79      }
80  
81      /**
82       * Set analysis.
83       *
84       * @param pAnalysis the analysis.
85       */
86      public void setAnalysis(final MoneyWiseAnalysis pAnalysis) {
87          theFilter.setDateRange(pAnalysis.getDateRange());
88      }
89  
90      @Override
91      public void setFilter(final MoneyWiseAnalysisFilter<?, ?> pFilter) {
92          /* If this is the correct filter type */
93          if (pFilter instanceof MoneyWiseAnalysisAllFilter) {
94              /* Access filter */
95              final MoneyWiseAnalysisAllFilter myFilter = (MoneyWiseAnalysisAllFilter) pFilter;
96  
97              /* Set the dateRange */
98              theFilter.setDateRange(myFilter.getDateRange());
99          }
100     }
101 }