Handle DSet fields being updated wholesale.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3127 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DSetEditor.java,v 1.6 2004/08/27 02:12:23 mdb Exp $
|
// $Id: DSetEditor.java,v 1.7 2004/09/29 04:04:20 mdb Exp $
|
||||||
//
|
//
|
||||||
// Narya library - tools for developing networked games
|
// Narya library - tools for developing networked games
|
||||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||||
@@ -42,6 +42,8 @@ import com.samskivert.util.SortableArrayList;
|
|||||||
import com.threerings.media.SafeScrollPane;
|
import com.threerings.media.SafeScrollPane;
|
||||||
|
|
||||||
import com.threerings.presents.Log;
|
import com.threerings.presents.Log;
|
||||||
|
import com.threerings.presents.dobj.AttributeChangeListener;
|
||||||
|
import com.threerings.presents.dobj.AttributeChangedEvent;
|
||||||
import com.threerings.presents.dobj.DObject;
|
import com.threerings.presents.dobj.DObject;
|
||||||
import com.threerings.presents.dobj.DSet;
|
import com.threerings.presents.dobj.DSet;
|
||||||
import com.threerings.presents.dobj.EntryAddedEvent;
|
import com.threerings.presents.dobj.EntryAddedEvent;
|
||||||
@@ -53,7 +55,7 @@ import com.threerings.presents.dobj.SetListener;
|
|||||||
* Allows simple editing of DSets withing a distributed object.
|
* Allows simple editing of DSets withing a distributed object.
|
||||||
*/
|
*/
|
||||||
public class DSetEditor extends JPanel
|
public class DSetEditor extends JPanel
|
||||||
implements SetListener, ActionListener
|
implements AttributeChangeListener, SetListener, ActionListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Construct a DSet editor to merely display the specified set.
|
* Construct a DSet editor to merely display the specified set.
|
||||||
@@ -142,12 +144,7 @@ public class DSetEditor extends JPanel
|
|||||||
_table.addActionListener(this);
|
_table.addActionListener(this);
|
||||||
|
|
||||||
// populate the table
|
// populate the table
|
||||||
DSet.Entry[] entries = new DSet.Entry[_set.size()];
|
refreshData();
|
||||||
_set.toArray(entries);
|
|
||||||
for (int ii=0; ii < entries.length; ii++) {
|
|
||||||
_keys.insertSorted(entries[ii].getKey());
|
|
||||||
}
|
|
||||||
_table.setData(entries); // this works because DSet itself is sorted
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
@@ -189,6 +186,14 @@ public class DSetEditor extends JPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface SetListener
|
||||||
|
public void attributeChanged (AttributeChangedEvent event)
|
||||||
|
{
|
||||||
|
if (event.getName().equals(_setName)) {
|
||||||
|
refreshData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited from interface ActionListener
|
// documentation inherited from interface ActionListener
|
||||||
public void actionPerformed (ActionEvent event)
|
public void actionPerformed (ActionEvent event)
|
||||||
{
|
{
|
||||||
@@ -196,6 +201,17 @@ public class DSetEditor extends JPanel
|
|||||||
_setter.updateSet(_setName, (DSet.Entry) ce.getArgument());
|
_setter.updateSet(_setName, (DSet.Entry) ce.getArgument());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void refreshData ()
|
||||||
|
{
|
||||||
|
_keys = new SortableArrayList();
|
||||||
|
DSet.Entry[] entries = new DSet.Entry[_set.size()];
|
||||||
|
_set.toArray(entries);
|
||||||
|
for (int ii=0; ii < entries.length; ii++) {
|
||||||
|
_keys.insertSorted(entries[ii].getKey());
|
||||||
|
}
|
||||||
|
_table.setData(entries); // this works because DSet itself is sorted
|
||||||
|
}
|
||||||
|
|
||||||
/** The object that contains the set we're displaying. */
|
/** The object that contains the set we're displaying. */
|
||||||
protected DObject _setter;
|
protected DObject _setter;
|
||||||
|
|
||||||
@@ -206,7 +222,7 @@ public class DSetEditor extends JPanel
|
|||||||
protected DSet _set;
|
protected DSet _set;
|
||||||
|
|
||||||
/** An array we use to track our entries' positions by key. */
|
/** An array we use to track our entries' positions by key. */
|
||||||
protected SortableArrayList _keys = new SortableArrayList();
|
protected SortableArrayList _keys;
|
||||||
|
|
||||||
/** The table used to edit. */
|
/** The table used to edit. */
|
||||||
protected ObjectEditorTable _table;
|
protected ObjectEditorTable _table;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ConfObjRegistry.java,v 1.11 2004/08/27 02:12:24 mdb Exp $
|
// $Id: ConfObjRegistry.java,v 1.12 2004/09/29 04:04:20 mdb Exp $
|
||||||
//
|
//
|
||||||
// Narya library - tools for developing networked games
|
// Narya library - tools for developing networked games
|
||||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||||
@@ -40,6 +40,7 @@ import com.threerings.io.Streamable;
|
|||||||
import com.threerings.presents.dobj.AttributeChangeListener;
|
import com.threerings.presents.dobj.AttributeChangeListener;
|
||||||
import com.threerings.presents.dobj.AttributeChangedEvent;
|
import com.threerings.presents.dobj.AttributeChangedEvent;
|
||||||
import com.threerings.presents.dobj.DObject;
|
import com.threerings.presents.dobj.DObject;
|
||||||
|
import com.threerings.presents.dobj.DSet;
|
||||||
import com.threerings.presents.dobj.EntryAddedEvent;
|
import com.threerings.presents.dobj.EntryAddedEvent;
|
||||||
import com.threerings.presents.dobj.EntryRemovedEvent;
|
import com.threerings.presents.dobj.EntryRemovedEvent;
|
||||||
import com.threerings.presents.dobj.EntryUpdatedEvent;
|
import com.threerings.presents.dobj.EntryUpdatedEvent;
|
||||||
@@ -196,6 +197,8 @@ public class ConfObjRegistry
|
|||||||
config.setValue(key, (int[])value);
|
config.setValue(key, (int[])value);
|
||||||
} else if (value instanceof String[]) {
|
} else if (value instanceof String[]) {
|
||||||
config.setValue(key, (String[])value);
|
config.setValue(key, (String[])value);
|
||||||
|
} else if (value instanceof DSet) {
|
||||||
|
serializeAttribute(event.getName());
|
||||||
} else {
|
} else {
|
||||||
Log.info("Unable to flush config object change " +
|
Log.info("Unable to flush config object change " +
|
||||||
"[cobj=" + confObj.getClass().getName() +
|
"[cobj=" + confObj.getClass().getName() +
|
||||||
@@ -320,7 +323,7 @@ public class ConfObjRegistry
|
|||||||
try {
|
try {
|
||||||
value = confObj.getAttribute(attributeName);
|
value = confObj.getAttribute(attributeName);
|
||||||
} catch (ObjectAccessException oae) {
|
} catch (ObjectAccessException oae) {
|
||||||
Log.warning("Exception getting dset [setname=" + attributeName +
|
Log.warning("Exception getting field [name=" + attributeName +
|
||||||
"exception=" + oae + "].");
|
"exception=" + oae + "].");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user