1 16 17 package com.buchuki.ensmer.builtin; 18 19 import com.buchuki.ensmer.Area; 20 import com.buchuki.ensmer.AreaManager; 21 import com.buchuki.ensmer.EnsmerManager; 22 import com.buchuki.ensmer.object.Backend; 23 import com.buchuki.ensmer.object.Frontend; 24 import java.io.Serializable ; 25 import java.util.*; 26 import javax.swing.event.ChangeEvent ; 27 28 33 public class Configurator extends Backend { 34 35 42 public Configurator(Long id) { 43 properties = new Properties(); 44 this.id = id; 45 } 46 47 52 public Configurator(Serializable data) { 53 Object [] arr = (Object []) data; 54 properties = (Properties) arr[0]; 55 id = (Long ) arr[1]; 56 } 57 58 63 @Override 64 public Serializable getSerializable() { 65 return new Object [] {properties, id}; 66 } 67 68 74 public void setProperty(String key, String value) { 75 properties.setProperty(key, value); 76 AreaManager areaman = EnsmerManager.instance().getAreaManager(); 78 Long areaID = areaman.getAreaIDForObject(id); 79 if (areaID != null) { 80 Area area = areaman.getArea(areaID); 81 Frontend front = area.getFrontend(id); 82 if (front != null) { 83 front.stateChanged(new ChangeEvent (EnsmerManager.instance().getBackhoe().findBackend(id))); 84 } 85 } 86 fireChangeEvent(); 87 } 88 89 95 public String getProperty(String key) { 96 return properties.getProperty(key); 97 } 98 99 102 public List<String > getPropertyNames() { 103 Enumeration en = properties.propertyNames(); 104 List<String > retVal = new ArrayList<String >(); 105 while (en.hasMoreElements()) { 106 retVal.add((String ) en.nextElement()); 107 } 108 return retVal; 109 } 110 111 114 public void clearProperties() { 115 properties.clear(); 116 fireChangeEvent(); 117 } 118 119 122 private Properties properties; 123 124 127 private Long id; 128 129 } 130 | Popular Tags |