use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class TextInspectorProviderTest method propertyPanelHasAllComponents.
private static void propertyPanelHasAllComponents(@NotNull InspectorPanel panel, @NotNull String propertyName, @NotNull Map<String, NlProperty> properties, @NotNull List<NlBooleanIconEditor> editors) {
List<Component> components = editors.stream().map(NlBooleanIconEditor::getComponent).collect(Collectors.toList());
ArgumentCaptor<JPanel> panelCaptor = ArgumentCaptor.forClass(JPanel.class);
NlProperty property = properties.get(propertyName);
verify(panel).addComponent(eq(propertyName), eq(property.getTooltipText()), panelCaptor.capture());
JPanel propertyPanel = panelCaptor.getValue();
assertThat(propertyPanel.getComponents()).asList().containsAllIn(components);
}
use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class IdAnalyzerTest method testConstraintLayout.
public void testConstraintLayout() {
ModelBuilder modelBuilder = createConstraintLayout();
NlModel model = modelBuilder.build();
NlComponent button2 = findById(model, "button3");
NlProperty property = new NlPropertyItem(ImmutableList.of(button2), AUTO_URI, new AttributeDefinition(ATTR_LAYOUT_TOP_TO_TOP_OF));
IdAnalyzer analyzer = new IdAnalyzer(property);
List<String> ids = analyzer.findIds();
assertEquals(ImmutableList.of("button4", "button5"), ids);
}
use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class IdAnalyzerTest method testRelativeLayout.
public void testRelativeLayout() {
ModelBuilder modelBuilder = createRelativeLayout();
NlModel model = modelBuilder.build();
NlComponent button2 = findById(model, "button3");
NlProperty property = new NlPropertyItem(ImmutableList.of(button2), ANDROID_URI, new AttributeDefinition(ATTR_LAYOUT_ALIGN_START));
IdAnalyzer analyzer = new IdAnalyzer(property);
List<String> ids = analyzer.findIds();
assertEquals(ImmutableList.of("button4", "button5", "group1"), ids);
}
use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class IdAnalyzerTest method testButton1.
public void testButton1() {
ModelBuilder modelBuilder = createRelativeLayout();
NlModel model = modelBuilder.build();
NlComponent button1 = findById(model, "button1");
NlProperty labelFor = new NlPropertyItem(ImmutableList.of(button1), ANDROID_URI, new AttributeDefinition(ATTR_LABEL_FOR));
IdAnalyzer analyzer = new IdAnalyzer(labelFor);
List<String> ids = analyzer.findIds();
assertEquals(ImmutableList.of("button2", "button3", "button4", "button5", "group1", "radio_button1", "radio_button2", "radio_button3", "text_view1"), ids);
}
use of com.android.tools.idea.uibuilder.property.NlProperty in project android by JetBrains.
the class InspectorPanel method setComponent.
public void setComponent(@NotNull List<NlComponent> components, @NotNull Table<String, String, ? extends NlProperty> properties, @NotNull NlPropertiesManager propertiesManager) {
myInspector.setLayout(null);
myInspector.removeAll();
mySource2GroupMap.clear();
myLabel2GroupMap.clear();
myLabel2ComponentMap.clear();
myRow = 0;
if (!components.isEmpty()) {
Map<String, NlProperty> propertiesByName = Maps.newHashMapWithExpectedSize(properties.size());
for (NlProperty property : properties.row(ANDROID_URI).values()) {
propertiesByName.put(property.getName(), property);
}
for (NlProperty property : properties.row(AUTO_URI).values()) {
propertiesByName.put(property.getName(), property);
}
for (NlProperty property : properties.row("").values()) {
propertiesByName.put(property.getName(), property);
}
// Add access to known design properties
for (NlProperty property : myDesignProperties.getKnownProperties(components)) {
propertiesByName.putIfAbsent(property.getName(), property);
}
myInspectors = myProviders.createInspectorComponents(components, propertiesByName, propertiesManager);
int rows = 0;
for (InspectorComponent inspector : myInspectors) {
rows += inspector.getMaxNumberOfRows();
}
// 1 row for each divider (including 1 after the last property)
rows += myInspectors.size();
// 1 Line with a link to all properties + 1 row with a spacer on the bottom
rows += 2;
myInspector.setLayout(createLayoutManager(rows, 2));
for (InspectorComponent inspector : myInspectors) {
addSeparator();
inspector.attachToInspector(this);
}
endGroup();
addSeparator();
// Add a vertical spacer
myInspector.add(new Spacer(), new GridConstraints(myRow++, 0, 1, 2, ANCHOR_CENTER, FILL_HORIZONTAL, SIZEPOLICY_CAN_GROW, SIZEPOLICY_CAN_GROW | SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
// Add link to all properties table
addLineComponent(myAllPropertiesLink, myRow++);
}
// These are both important to render the controls correctly the first time:
ApplicationManager.getApplication().invokeLater(() -> {
updateAfterFilterChange();
if (myActivateEditorAfterLoad) {
activatePreferredEditor(myPropertyNameForActivation);
}
});
}
Aggregations