}
);
settingsTable.getFieldDescriptor("property").setUpdatable(false);
final GridApplication app = new GridApplication(settingsTable){
public void onClose(){
Instance[] recs = getInstances();
Properties settings = new Properties();
for(int i=0; i<recs.length; i++){
String k = (String)recs[i].getFieldValue("property");
String v = (String)recs[i].getFieldValue("value");
if(k==null) continue;
if(v==null) v="";
settings.setProperty(k, v);
System.setProperty(k, v);
}
try{
settings.list(System.out);
/*PrintStream out = new PrintStream(new FileOutputStream(GlobalContext.SETTING_FILE));
settings.list(out);*/
settings.store(new FileOutputStream(GlobalContext.SETTING_FILE), null);
}catch(Exception e){
e.printStackTrace();
}
}
};
app.runDialog(this);
try{
Properties settings = loadProperties();
new File(GlobalContext.SETTING_FILE).mkdirs();
settings.store(new FileOutputStream(GlobalContext.SETTING_FILE), null);
for(Enumeration enumeration = settings.keys(); enumeration.hasMoreElements(); ){
String k = (String)enumeration.nextElement();
Instance rec = settingsTable.createInstance();
rec.setFieldValue("property", k);
rec.setFieldValue("value", settings.get(k));
app.addInstance(rec);
}
}catch(Exception e){
e.printStackTrace();
}
}