1    /*
2    Copyright 2001 by Ralph Hartley
3    This software is licenced under the terms of the
4    Gnu Public Licence
5    */
6    import java.util.*;
7    import java.awt.*;
8    import java.awt.event.*;
9    import javax.swing.*;
10   import javax.swing.event.*;
11   
12   public class LayerSet extends Layer {
13   
14     private static final long serialVersionUID = Version.getSUID();
15   
16     public HashSet members;
17   
18     public LayerSet(Collection members) {
19       name = "A Set ("+members.size()+" members)";
20       this.members = new HashSet(members);
21     }
22   
23     public LayerSet(Collection members,String name) {
24       this.name = name;
25       this.members = new HashSet(members);
26   //    System.out.println("Set "+this+" members = "+this.members+" from "+members);    
27     }
28   
29     public Object clone() {
30       LayerSet res = new LayerSet(members,(name.charAt(0)=='c'?name:"copy of "+name));
31   //    System.out.println("Set "+res+" members = "+members+" copy of "+this);    
32       return((Object)res);
33     }
34   
35     public void copy(FileDefaultable thatitem) {
36       super.copy(thatitem);
37       members = (HashSet)((LayerList)thatitem).members.clone();
38     }
39   
40     public boolean isMember(Object target) {
41   //    System.out.println("Set "+this+(members.contains(target)?" contains ":" does not contain ")+target);
42       return(members.contains(target));
43     }
44   
45     public boolean edit(JFrame owner) {
46       JOptionPane.showMessageDialog(owner,
47           			 name+" can not be edited."+
48           			 "\nEditing sets is not implemented yet"+
49           			 "\nYou can get some of the same effect"+ 
50           			 "\nby combining sets in lists.", 
51           			 "No Edit",
52           			 JOptionPane.ERROR_MESSAGE);
53       return(false);
54     }
55   }
56