View Javadoc
1   /*
2    * Tethys: GUI Utilities
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.tethys.core.pane;
18  
19  import java.util.ArrayList;
20  import java.util.Iterator;
21  import java.util.List;
22  
23  import io.github.tonywasher.joceanus.tethys.api.base.TethysUIComponent;
24  import io.github.tonywasher.joceanus.tethys.api.pane.TethysUIFlowPaneManager;
25  import io.github.tonywasher.joceanus.tethys.core.base.TethysUICoreComponent;
26  import io.github.tonywasher.joceanus.tethys.core.factory.TethysUICoreFactory;
27  import io.github.tonywasher.joceanus.tethys.core.factory.TethysUICoreFactory.TethysUIParentComponent;
28  
29  /**
30   * Core Flow Pane Manager.
31   */
32  public abstract class TethysUICoreFlowPaneManager
33          extends TethysUICoreComponent
34          implements TethysUIFlowPaneManager, TethysUIParentComponent {
35      /**
36       * The Factory.
37       */
38      private final TethysUICoreFactory<?> theFactory;
39  
40      /**
41       * The id.
42       */
43      private final Integer theId;
44  
45      /**
46       * Node List.
47       */
48      private final List<TethysUIComponent> theNodeList;
49  
50      /**
51       * Constructor.
52       *
53       * @param pFactory the factory
54       */
55      protected TethysUICoreFlowPaneManager(final TethysUICoreFactory<?> pFactory) {
56          theFactory = pFactory;
57          theId = theFactory.getNextId();
58          theNodeList = new ArrayList<>();
59      }
60  
61      @Override
62      public Integer getId() {
63          return theId;
64      }
65  
66      @Override
67      public void addNode(final TethysUIComponent pNode) {
68          theNodeList.add(pNode);
69          theFactory.registerChild(this, pNode);
70      }
71  
72      @Override
73      public void setEnabled(final boolean pEnabled) {
74          for (TethysUIComponent myNode : theNodeList) {
75              myNode.setEnabled(pEnabled);
76          }
77      }
78  
79      @Override
80      public Iterator<TethysUIComponent> iterator() {
81          return theNodeList.iterator();
82      }
83  }