Make this other batch of colorizations sort on the name

since it's a major PITA to have it inconsistent between the UI for
scene colors and object colors.

For the record, I will admit to feeling a bit dirty using 
Comparators.combine only ~2.5 hours after Ray sent out email talking
about how awesome guava's ComparisonChain is, but I'm really not in
the mood to muck with pulling in the guava dependency.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@886 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Dave Hoover
2010-01-05 21:59:15 +00:00
parent 2b8f68df8b
commit c3fce4be77
@@ -30,6 +30,8 @@ import javax.swing.JPanel;
import javax.swing.JSlider; import javax.swing.JSlider;
import javax.swing.JTextField; import javax.swing.JTextField;
import com.samskivert.util.Comparators;
import com.samskivert.util.ObjectUtil;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.samskivert.swing.HGroupLayout; import com.samskivert.swing.HGroupLayout;
@@ -83,7 +85,6 @@ public class ObjectEditorDialog extends EditorDialog
zations.add(_tertiary = new JComboBox(NO_CHOICES)); zations.add(_tertiary = new JComboBox(NO_CHOICES));
zations.add(_quaternary = new JComboBox(NO_CHOICES)); zations.add(_quaternary = new JComboBox(NO_CHOICES));
panel.add(zations); panel.add(zations);
} }
/** /**
@@ -154,7 +155,7 @@ public class ObjectEditorDialog extends EditorDialog
return null; return null;
} }
Object[] czations = new Object[crecs.length + 1]; Object[] czations = new Object[crecs.length + 1];
czations[0] = new ZationChoice(0, "none"); czations[0] = new ZationChoice(0, "<none>");
for (int ii = 0; ii < crecs.length; ii++) { for (int ii = 0; ii < crecs.length; ii++) {
czations[ii + 1] = new ZationChoice(crecs[ii].colorId, crecs[ii].name); czations[ii + 1] = new ZationChoice(crecs[ii].colorId, crecs[ii].name);
} }
@@ -204,7 +205,6 @@ public class ObjectEditorDialog extends EditorDialog
public void cancelled () public void cancelled ()
{ {
_panel.objectEditorDismissed(); _panel.objectEditorDismissed();
} }
/** Used to display colorization choices. */ /** Used to display colorization choices. */
@@ -214,20 +214,19 @@ public class ObjectEditorDialog extends EditorDialog
public byte colorId; public byte colorId;
public String name; public String name;
public ZationChoice (int colorId, String name) public ZationChoice (int colorId, String name) {
{
this.colorId = (byte)colorId; this.colorId = (byte)colorId;
this.name = name; this.name = name;
} }
public int compareTo (ZationChoice other) public int compareTo (ZationChoice that) {
{ return Comparators.combine(
return colorId - other.colorId; ObjectUtil.compareTo(this.name, that.name),
Comparators.compare(this.colorId, that.colorId));
} }
@Override @Override
public String toString () public String toString () {
{
return name; return name;
} }
} }
@@ -238,5 +237,5 @@ public class ObjectEditorDialog extends EditorDialog
protected JComboBox _primary, _secondary, _tertiary, _quaternary; protected JComboBox _primary, _secondary, _tertiary, _quaternary;
protected static final ZationChoice[] NO_CHOICES = new ZationChoice[] { new ZationChoice(0, protected static final ZationChoice[] NO_CHOICES = new ZationChoice[] { new ZationChoice(0,
"none") }; "<none>") };
} }