KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > tree > DefaultDeleteNodeModel


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.tree;
14
15 import java.util.Comparator JavaDoc;
16 import java.util.HashSet JavaDoc;
17 import java.util.Set JavaDoc;
18 import java.util.TreeSet JavaDoc;
19
20 /**
21  * @author av
22  */

23 public class DefaultDeleteNodeModel implements DeleteNodeModel {
24   Set JavaDoc deleted;
25   NodeFilter deletableFilter;
26   
27  /**
28   * creates a NodeDeleter that uses a HashSet for the deleted nodes
29   */

30   public DefaultDeleteNodeModel() {
31     deleted = new HashSet JavaDoc();
32   }
33
34   /**
35    * creates a NodeDeleter that uses a TreeSet with
36    * <code>comp</code> for the deleted nodes
37    */

38   public DefaultDeleteNodeModel(Comparator JavaDoc comp) {
39     deleted = new TreeSet JavaDoc(comp);
40   }
41
42   public boolean isDeletable(Object JavaDoc node) {
43     return deletableFilter != null && deletableFilter.accept(node);
44   }
45
46   public void delete(Object JavaDoc node) {
47     deleted.add(node);
48   }
49
50   public Set JavaDoc getDeleted() {
51     return deleted;
52   }
53
54   /**
55    * gets the filter for isDeletable()
56    */

57   public NodeFilter getDeletableFilter() {
58     return deletableFilter;
59   }
60
61   /**
62    * sets the filter for isDeletable()
63    */

64   public void setDeletableFilter(NodeFilter filter) {
65     deletableFilter = filter;
66   }
67
68 }
69
Popular Tags