1 33 34 package edu.rice.cs.util.swing; 35 36 import java.util.EventObject ; 37 import java.io.File ; 38 39 public class FileSelectionEvent extends EventObject { 40 41 protected File [] _changed; 42 protected boolean[] _areNew; 43 protected File _newLead; 44 protected File _oldLead; 45 46 public FileSelectionEvent(Object source, File changed, boolean isNew, File newLead, File oldLead) { 47 this(source, new File []{changed}, new boolean[]{isNew}, newLead, oldLead); 48 } 49 50 public FileSelectionEvent(Object source, File [] changed, boolean[] areNew, File newLead, File oldLead) { 51 super(source); 52 _changed = changed; 53 _areNew = areNew; 54 _newLead = newLead; 55 _oldLead = oldLead; 56 } 57 58 public File getOldLeadSelectionFile() { return _oldLead; } 59 60 public File getNewLeadSelectionFile() { return _newLead; } 61 62 public File getFile() { return _changed[0]; } 63 64 public File [] getFiles() { return _changed; } 65 66 public boolean isAddedFile() { return _areNew[0]; } 67 68 public boolean isAddedFile(int i) { return _areNew[i]; } 69 70 public boolean isAddedFile(File f) { 71 for (int i = 0; i < _changed.length; i++) { 72 if (f.equals(_changed[i])) return _areNew[i]; 73 } 74 throw new IllegalArgumentException ("File, " + f + ", not found in changed files"); 75 } 76 } | Popular Tags |