Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/ECJClient/src/ec/util/ParameterDatabaseTreeModel.java @ 6152

Last change on this file since 6152 was 6152, checked in by bfarka, 13 years ago

added ecj and custom statistics to communicate with the okb services #1441

File size: 2.1 KB
Line 
1/*
2  Copyright 2006 by Sean Luke
3  Licensed under the Academic Free License version 3.0
4  See the file "LICENSE" for more information
5*/
6
7
8/*
9 * Created on Apr 6, 2005 7:12:32 PM
10 *
11 * By: spaus
12 */
13package ec.util;
14
15import java.util.Comparator;
16
17import javax.swing.tree.DefaultTreeModel;
18import javax.swing.tree.TreeNode;
19
20/**
21 * @author spaus
22 */
23public class ParameterDatabaseTreeModel
24    extends DefaultTreeModel {
25
26    private boolean visibleLeaves;
27   
28    /**
29     * @param root
30     */
31    public ParameterDatabaseTreeModel(TreeNode root) {
32        super(root);
33        visibleLeaves = true;
34        }
35
36    /**
37     * @param root
38     * @param asksAllowsChildren
39     */
40    public ParameterDatabaseTreeModel(TreeNode root, boolean asksAllowsChildren) {
41        super(root, asksAllowsChildren);
42        visibleLeaves = true;
43        }
44
45    /**
46     * @param visibleLeaves
47     */
48    public void setVisibleLeaves(boolean visibleLeaves) {
49        this.visibleLeaves = visibleLeaves;
50        }
51   
52    /**
53     * @return
54     */
55    public boolean getVisibleLeaves() {
56        return visibleLeaves;
57        }
58   
59    /* (non-Javadoc)
60     * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
61     */
62    public Object getChild(Object parent, int index) {
63        if (!visibleLeaves) {
64            if (parent instanceof ParameterDatabaseTreeNode) {
65                return ((ParameterDatabaseTreeNode)parent).getChildAt(index,visibleLeaves);
66                }
67            }
68       
69        return ((TreeNode)parent).getChildAt(index);
70        }
71   
72    /* (non-Javadoc)
73     * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
74     */
75    public int getChildCount(Object parent) {
76        if (!visibleLeaves) {
77            if (parent instanceof ParameterDatabaseTreeNode) {
78                return ((ParameterDatabaseTreeNode)parent).getChildCount(visibleLeaves);
79                }
80            }
81       
82        return ((TreeNode)parent).getChildCount();
83        }
84   
85    /**
86     * @param parent
87     * @param comp
88     */
89    public void sort(Object parent, Comparator comp) {
90        ((ParameterDatabaseTreeNode)parent).sort(comp);
91        }
92    }
Note: See TracBrowser for help on using the repository browser.