KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > discRack > presentation > Discs


1 package discRack.presentation;
2
3 import discRack.presentation.delements.*;
4 import discRack.presentation.dpanels.*;
5 import discRack.business.disc.DiscFactory;
6
7 import java.util.*;
8 import java.io.*;
9 import javax.swing.*;
10
11
12 /**
13  * Used to manage collection of Disc DO data.
14  *
15  * @author Sasa Bojanic
16  * @version 1.0
17  */

18 public class Discs extends DCollection {
19
20    private discRack.business.person.Person myPerson;
21
22    public Discs (discRack.business.person.Person person) {
23       super("Disc management");
24       this.myPerson=person;
25       fillCollection();
26    }
27
28    /**
29      * Generates a new element of the class which instances
30      * are members of collection of this class.
31      *
32      * return The generated instance of class that makes collection.
33      */

34    public DSimpleElement generateNewElement() {
35       Disc d=null;
36       try {
37          discRack.business.disc.Disc db=new discRack.business.disc.Disc();
38          db.setOwner(myPerson);
39          d=new Disc(this,db);
40          d.setRequired(true);
41       } catch (Exception JavaDoc ex) {}
42       return d;
43    }
44
45    private void fillCollection () {
46       try {
47          discRack.business.disc.Disc[] discs=DiscFactory.findDiscsForPerson(myPerson);
48          if (discs!=null && discs.length>0) {
49             for (int i=0; i<discs.length; i++) {
50                Disc d=new Disc(this,discs[i]);
51                add(d);
52             }
53          }
54       } catch (Exception JavaDoc ex) {}
55    }
56
57    public void onElementDeleted (DSimpleElement del) throws Exception JavaDoc {
58       ((Disc)del).getMyDisc().delete();
59    }
60
61 }
62
63
Popular Tags