More type safety.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4244 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-07-05 00:51:22 +00:00
parent a89473d1b5
commit 94b79826d4
9 changed files with 59 additions and 54 deletions
@@ -17,7 +17,7 @@ import com.threerings.presents.dobj.Subscriber;
public class ConfigObjectManager implements AdminService.ConfigInfoListener
{
public ConfigObjectManager(Client client) {
_serverconfig = new HashMap();
_serverconfig = new HashMap<String,ConfigObject>();
_client = client;
_client.addClientObserver(new SessionObserver() {
// documentation inherited from interface SessionObserver
@@ -63,21 +63,21 @@ public class ConfigObjectManager implements AdminService.ConfigInfoListener
// documentation inherited from interface AdminService.ConfigInfoListener
public void requestFailed (String reason) {
Log.warning("Oh bugger, we didn't get the config data because " + reason);
Log.warning("Oh bugger, we didn't get the config data: " + reason);
}
/**
* Returns the ConfigObject identified by the given key
*/
public ConfigObject getServerConfig (String key) {
return (ConfigObject)_serverconfig.get(key);
return _serverconfig.get(key);
}
/**
* This class takes care of the details of subscribing to and placing
* an individual ConfigObject that the server knows about into a HashMap
*/
protected class ConfigObjectSubscriber implements Subscriber
protected class ConfigObjectSubscriber implements Subscriber<ConfigObject>
{
/**
* This method requests that we place a subscription to the
@@ -91,8 +91,8 @@ public class ConfigObjectManager implements AdminService.ConfigInfoListener
}
// documentation inherited from interface Subscriber
public void objectAvailable (DObject object) {
_cobj = (ConfigObject)object;
public void objectAvailable (ConfigObject object) {
_cobj = object;
_serverconfig.put(_key, _cobj);
}
@@ -126,7 +126,7 @@ public class ConfigObjectManager implements AdminService.ConfigInfoListener
protected ConfigObjectSubscriber[] _csubscribers;
/** Our local copy of the server-side runtime configuration */
protected HashMap _serverconfig;
protected HashMap<String,ConfigObject> _serverconfig;
/** Our distributed object manager */
protected DObjectManager _dobjmgr;
@@ -124,7 +124,7 @@ public class DSetEditor extends JPanel
*/
public DSet.Entry getSelectedEntry ()
{
return (DSet.Entry) _table.getSelectedObject();
return (DSet.Entry)_table.getSelectedObject();
}
// documentation inherited
@@ -159,7 +159,9 @@ public class DSetEditor extends JPanel
{
if (event.getName().equals(_setName)) {
DSet.Entry entry = event.getEntry();
int index = _keys.insertSorted(entry.getKey());
@SuppressWarnings("unchecked") Comparable<Object> key =
(Comparable<Object>)entry.getKey();
int index = _keys.insertSorted(key);
_table.insertDatum(entry, index);
}
}
@@ -204,11 +206,13 @@ public class DSetEditor extends JPanel
protected void refreshData ()
{
_keys = new ComparableArrayList();
_keys = new ComparableArrayList<Comparable<Object>>();
DSet.Entry[] entries = new DSet.Entry[_set.size()];
_set.toArray(entries);
for (int ii=0; ii < entries.length; ii++) {
_keys.insertSorted(entries[ii].getKey());
for (int ii = 0; ii < entries.length; ii++) {
@SuppressWarnings("unchecked") Comparable<Object> key =
(Comparable<Object>)entries[ii].getKey();
_keys.insertSorted(key);
}
_table.setData(entries); // this works because DSet itself is sorted
}
@@ -220,10 +224,10 @@ public class DSetEditor extends JPanel
protected String _setName;
/** The set itself. */
protected DSet _set;
protected DSet<?> _set;
/** An array we use to track our entries' positions by key. */
protected ComparableArrayList _keys;
protected ComparableArrayList<Comparable<Object>> _keys;
/** The table used to edit. */
protected ObjectEditorTable _table;
@@ -51,7 +51,7 @@ import com.threerings.admin.data.ConfigObject;
* @see ConfigEditorPanel
*/
public class ObjectEditorPanel extends ScrollablePanel
implements Subscriber
implements Subscriber<ConfigObject>
{
/**
* Creates an object editor panel for the specified configuration
@@ -69,7 +69,7 @@ public class ObjectEditorPanel extends ScrollablePanel
// we'll use this to safely subscribe to and unsubscribe from the
// config object
_safesub = new SafeSubscriber(oid, this);
_safesub = new SafeSubscriber<ConfigObject>(oid, this);
_safesub.subscribe(_ctx.getDObjectManager());
}
@@ -94,10 +94,10 @@ public class ObjectEditorPanel extends ScrollablePanel
}
// documentation inherited from interface
public void objectAvailable (DObject object)
public void objectAvailable (ConfigObject object)
{
// keep this for later
_object = (ConfigObject)object;
_object = object;
// create our field editors
try {
@@ -125,6 +125,6 @@ public class ObjectEditorPanel extends ScrollablePanel
protected PresentsContext _ctx;
protected String _key;
protected SafeSubscriber _safesub;
protected SafeSubscriber<ConfigObject> _safesub;
protected ConfigObject _object;
}