1 4 package org.oddjob.designer.model; 5 6 import java.io.File ; 7 import java.util.Observable ; 8 import java.util.Observer ; 9 10 11 15 public class FileSelection extends Observable 16 implements DesignDefinition, FormDefinition { 17 18 private final String heading; 19 private final SimpleAttribute designElement; 20 21 public FileSelection(String heading, SimpleAttribute de) { 22 this.heading = heading; 23 this.designElement = de; 24 designElement.addObserver(new Observer () { 25 public void update(Observable o, Object arg) { 26 setChanged(); 27 notifyObservers(); 28 } 29 }); 30 } 31 32 public String getTitle() { 33 return heading; 34 } 35 36 41 public void setFile(File file) { 42 if (file == null) { 43 designElement.attribute(null); 44 } 45 else { 46 designElement.attribute(file.getPath()); 47 } 48 } 49 50 55 public File getFile() { 56 if (designElement.attribute() == null) { 57 return null; 58 } 59 return new File (designElement.attribute()); 60 } 61 62 65 public void accept(DesignProcessor processor) { 66 processor.onFileSelection(this); 67 } 68 69 72 public boolean isPopulated() { 73 return designElement.attribute() != null; 74 } 75 } 76 | Popular Tags |