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 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 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 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 ex) {} 55 } 56 57 public void onElementDeleted (DSimpleElement del) throws Exception { 58 ((Disc)del).getMyDisc().delete(); 59 } 60 61 } 62 63 | Popular Tags |