Commit dea242fe authored by Evan W. Patton's avatar Evan W. Patton

Allow component properties to specify accepted type

For the Internet of Things update, we want to allow extensions to
specify restrictions on designer properties. Specifically, we want IOT
extensions with a BluetoothDevice property to be able to restrict the
component list to the BluetoothLE extension. This commit extends the
behavior of the component property type by allowing an extension
author to include a colon (":") followed by the fully-qualified class
name of the component type to accept.

Change-Id: I6c38890fde99fe947bb1a305412d662694246463
parent c57f6917
......@@ -241,6 +241,10 @@ public class PropertiesUtil {
return new ScalingChoicePropertyEditor();
} else if (editorType.equals(PropertyTypeConstants.PROPERTY_TYPE_FIREBASE_URL)) {
return new YoungAndroidDefaultURLPropertyEditor("DEFAULT");
} else if (editorType.startsWith(PropertyTypeConstants.PROPERTY_TYPE_COMPONENT + ":")) {
String type = editorType.substring(PropertyTypeConstants.PROPERTY_TYPE_COMPONENT.length() + 2);
type = type.substring(type.lastIndexOf('.') + 1);
return new YoungAndroidComponentSelectorPropertyEditor(editor, Collections.singleton(type));
} else {
return new TextPropertyEditor();
}
......
......@@ -792,7 +792,7 @@ public abstract class ComponentProcessor extends AbstractProcessor {
}
// If we already processed this component, return early.
String longComponentName = element.asType().toString();
String longComponentName = ((TypeElement) element).getQualifiedName().toString();
if (components.containsKey(longComponentName)) {
return;
}
......@@ -806,6 +806,8 @@ public abstract class ComponentProcessor extends AbstractProcessor {
// Only look at the first one. Later ones would be interfaces,
// which we don't care about.
String parentName = directSupertypes.get(0).toString();
Element e = ((DeclaredType) directSupertypes.get(0)).asElement();
parentName = ((TypeElement) e).getQualifiedName().toString();
ComponentInfo parentComponent = components.get(parentName);
if (parentComponent == null) {
// Try to process the parent component now.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment