diff --git a/core/src/main/java/com/threerings/admin/client/ObjectEditorPanel.java b/core/src/main/java/com/threerings/admin/client/ObjectEditorPanel.java index 69c20717d..251cc3494 100644 --- a/core/src/main/java/com/threerings/admin/client/ObjectEditorPanel.java +++ b/core/src/main/java/com/threerings/admin/client/ObjectEditorPanel.java @@ -21,6 +21,7 @@ import com.threerings.presents.util.PresentsContext; import com.threerings.presents.util.SafeSubscriber; import com.threerings.admin.data.ConfigObject; +import com.threerings.admin.data.ToolTipText; import static com.threerings.admin.Log.log; @@ -113,25 +114,11 @@ public class ObjectEditorPanel extends ScrollablePanel */ protected static JPanel applyTip (ConfigObject object, Field field, JPanel editor) { - String tipName = toUpperSnake(field.getName()) + "_TIP"; - try { - Field tipField = object.getClass().getField(tipName); - if (tipField.getType() == String.class && - Modifier.isStatic(tipField.getModifiers())) { - editor.setToolTipText((String) tipField.get(null)); - } - } catch (NoSuchFieldException | IllegalAccessException e) { - // no tip constant for this field - } + ToolTipText tipAnno = field.getAnnotation(ToolTipText.class); + if (tipAnno != null) editor.setToolTipText(tipAnno.value()); return editor; } - /** Converts a {@code lowerCamelCase} name to {@code UPPER_SNAKE_CASE}. */ - private static String toUpperSnake (String name) - { - return name.replaceAll("([a-z0-9])([A-Z])", "$1_$2").toUpperCase(); - } - protected PresentsContext _ctx; protected String _key; protected SafeSubscriber _safesub; diff --git a/core/src/main/java/com/threerings/admin/data/ToolTipText.java b/core/src/main/java/com/threerings/admin/data/ToolTipText.java new file mode 100644 index 000000000..daed580d6 --- /dev/null +++ b/core/src/main/java/com/threerings/admin/data/ToolTipText.java @@ -0,0 +1,18 @@ +package com.threerings.admin.data; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.FIELD }) +public @interface ToolTipText +{ + /** + * The tool tip text to show an admin when they're editing a field. + */ + String value (); +}