View Javadoc

1   /*
2    * Copyright 1999-2006 Faculty of Mathematics, Physics
3    * and Informatics, Comenius University, Bratislava. This file is protected by
4    * the Mozilla Public License version 1.1 (the License); you may not use this
5    * file except in compliance with the License. You may obtain a copy of the
6    * License at http://euromath2.sourceforge.net/license.html Unless required by
7    * applicable law or agreed to in writing, software distributed under the
8    * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9    * OF ANY KIND, either express or implied. See the License for the specific
10   * language governing permissions and limitations under the License.
11   */
12  package sk.uniba.euromath.plugin.views.outline.items;
13  
14  import java.util.ArrayList;
15  import java.util.List;
16  
17  import org.w3c.dom.Node;
18  
19  /***
20   * Base outline item with children.
21   * @author Tomáš Studva
22   *         23.1.2006
23   */
24  public abstract class CompoundOutlineItem extends OutlineItem {
25      /***
26       * List of children.
27       */
28      protected final List<OutlineItem> children;
29  
30      protected boolean analyzed;
31  
32      /***
33       * Constructor.
34       * 
35       * @param model which represents this compound outline item
36       */
37      public CompoundOutlineItem(Node model) {
38          super(model);
39          this.children = new ArrayList<OutlineItem>();
40          setAnalyzed(false);
41      }
42  
43      @Override
44      public void addChild(OutlineItem child) {
45          getChildren().add(child);
46          child.setParent(this);
47          setAnalyzed(false);
48      }
49  
50      protected abstract void analyze();
51  
52      /*
53       * (non-Javadoc)
54       * 
55       * @see sk.uniba.euromath.plugin.views.outline.OutlineItem#getChildren()
56       */
57      @Override
58      public List<OutlineItem> getChildren() {
59          return this.children;
60      }
61  
62      @Override
63      public void removeChild(OutlineItem child) {
64          getChildren().remove(child);
65          child.setParent(null);
66          setAnalyzed(false);
67      }
68  
69      /***
70       * @return Returns the analyzed.
71       */
72      protected boolean isAnalyzed() {
73          return this.analyzed;
74      }
75  
76      /***
77       * @param analyzed
78       *            The analyzed to set.
79       */
80      protected void setAnalyzed(boolean analyzed) {
81          this.analyzed = analyzed;
82      }
83  
84  }