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:
@@ -30,6 +30,8 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import com.samskivert.util.Comparators;
|
||||
import com.samskivert.util.ObjectUtil;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.samskivert.swing.HGroupLayout;
|
||||
@@ -83,7 +85,6 @@ public class ObjectEditorDialog extends EditorDialog
|
||||
zations.add(_tertiary = new JComboBox(NO_CHOICES));
|
||||
zations.add(_quaternary = new JComboBox(NO_CHOICES));
|
||||
panel.add(zations);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +155,7 @@ public class ObjectEditorDialog extends EditorDialog
|
||||
return null;
|
||||
}
|
||||
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++) {
|
||||
czations[ii + 1] = new ZationChoice(crecs[ii].colorId, crecs[ii].name);
|
||||
}
|
||||
@@ -204,7 +205,6 @@ public class ObjectEditorDialog extends EditorDialog
|
||||
public void cancelled ()
|
||||
{
|
||||
_panel.objectEditorDismissed();
|
||||
|
||||
}
|
||||
|
||||
/** Used to display colorization choices. */
|
||||
@@ -214,20 +214,19 @@ public class ObjectEditorDialog extends EditorDialog
|
||||
public byte colorId;
|
||||
public String name;
|
||||
|
||||
public ZationChoice (int colorId, String name)
|
||||
{
|
||||
public ZationChoice (int colorId, String name) {
|
||||
this.colorId = (byte)colorId;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int compareTo (ZationChoice other)
|
||||
{
|
||||
return colorId - other.colorId;
|
||||
public int compareTo (ZationChoice that) {
|
||||
return Comparators.combine(
|
||||
ObjectUtil.compareTo(this.name, that.name),
|
||||
Comparators.compare(this.colorId, that.colorId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
public String toString () {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -238,5 +237,5 @@ public class ObjectEditorDialog extends EditorDialog
|
||||
protected JComboBox _primary, _secondary, _tertiary, _quaternary;
|
||||
|
||||
protected static final ZationChoice[] NO_CHOICES = new ZationChoice[] { new ZationChoice(0,
|
||||
"none") };
|
||||
"<none>") };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user