PageRenderTime 24ms CodeModel.GetById 17ms app.highlight 6ms RepoModel.GetById 0ms app.codeStats 0ms

/bundles/plugins-trunk/SideKick/sidekick/ExpansionModel.java

#
Java | 48 lines | 20 code | 6 blank | 22 comment | 0 complexity | 451bde5fa7a973d5fde5e1e35f960ce7 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
 1package sidekick;
 2
 3import java.util.ArrayList;
 4import java.util.List;
 5
 6/**
 7 * An expansion model for trees.  This essentially just wraps a list of 
 8 * integers that represent the row numbers in the tree that should be 
 9 * expanded.  It is not necessary to use this model, but it is convenient
10 * when creating the list of row numbers.  The value returned by <code>
11 * getModel</code> is suitable for setting in the <code>expansionModel</code>
12 * field in SideKickParsedData.
13 */
14public class ExpansionModel {
15    private List<Integer> model = new ArrayList<Integer>();
16    private int row = 0;
17
18    /**
19     * @return The expansion model, set this in SideKickParsedData.        
20     */
21    public List<Integer> getModel() {
22        return model;
23    }
24
25    /**
26     * Call this for each row in the tree that should be visible and expanded.
27     * This will add the current row number to the model and automatically
28     * inc().
29     */
30    public void add() {
31        model.add( row );
32        inc();
33    }
34
35    /**
36     * Call this for each row in the tree that should be visible.
37     */
38    public void inc() {
39        ++row;
40    }
41
42    /**
43     * @return The current row value.        
44     */
45    public int getRow() {
46        return row;
47    }
48}