Keep track of when we have unsaved preference changes

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2502 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Tom Morris 2012-06-02 21:06:46 +00:00
parent a0812c5751
commit 8872c1b0a1

View File

@ -1,6 +1,6 @@
/* /*
Copyright 2010, Google Inc. Copyright 2010,2012 Google Inc.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@ -48,6 +48,7 @@ import com.google.refine.Jsonizable;
import com.google.refine.RefineServlet; import com.google.refine.RefineServlet;
public class PreferenceStore implements Jsonizable { public class PreferenceStore implements Jsonizable {
private boolean dirty = false;
protected Map<String, Object> _prefs = new HashMap<String, Object>(); protected Map<String, Object> _prefs = new HashMap<String, Object>();
public void put(String key, Object value) { public void put(String key, Object value) {
@ -56,6 +57,7 @@ public class PreferenceStore implements Jsonizable {
} else { } else {
_prefs.put(key, value); _prefs.put(key, value);
} }
dirty = true;
} }
public Object get(String key) { public Object get(String key) {
@ -85,6 +87,14 @@ public class PreferenceStore implements Jsonizable {
writer.endObject(); writer.endObject();
writer.endObject(); writer.endObject();
dirty = false;
}
/**
* @return true if the preference store has unsaved changes
*/
public boolean isDirty() {
return dirty;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -100,6 +110,7 @@ public class PreferenceStore implements Jsonizable {
_prefs.put(key, loadObject(o)); _prefs.put(key, loadObject(o));
} }
} }
dirty = false; // internal puts don't count
} }
} }