Search in sources :

Example 11 with NlPropertyItem

use of com.android.tools.idea.uibuilder.property.NlPropertyItem 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);
}
Also used : ModelBuilder(com.android.tools.idea.uibuilder.fixtures.ModelBuilder) NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) NlProperty(com.android.tools.idea.uibuilder.property.NlProperty) NlModel(com.android.tools.idea.uibuilder.model.NlModel) AttributeDefinition(org.jetbrains.android.dom.attrs.AttributeDefinition) NlPropertyItem(com.android.tools.idea.uibuilder.property.NlPropertyItem)

Example 12 with NlPropertyItem

use of com.android.tools.idea.uibuilder.property.NlPropertyItem 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);
}
Also used : ModelBuilder(com.android.tools.idea.uibuilder.fixtures.ModelBuilder) NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) NlProperty(com.android.tools.idea.uibuilder.property.NlProperty) NlModel(com.android.tools.idea.uibuilder.model.NlModel) AttributeDefinition(org.jetbrains.android.dom.attrs.AttributeDefinition) NlPropertyItem(com.android.tools.idea.uibuilder.property.NlPropertyItem)

Example 13 with NlPropertyItem

use of com.android.tools.idea.uibuilder.property.NlPropertyItem 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);
}
Also used : ModelBuilder(com.android.tools.idea.uibuilder.fixtures.ModelBuilder) NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) NlProperty(com.android.tools.idea.uibuilder.property.NlProperty) NlModel(com.android.tools.idea.uibuilder.model.NlModel) AttributeDefinition(org.jetbrains.android.dom.attrs.AttributeDefinition) NlPropertyItem(com.android.tools.idea.uibuilder.property.NlPropertyItem)

Example 14 with NlPropertyItem

use of com.android.tools.idea.uibuilder.property.NlPropertyItem in project android by JetBrains.

the class NlTableCellEditor method getDesignProperty.

@Nullable
public static NlProperty getDesignProperty(@NotNull JTable table, int row) {
    NlPropertyItem currentProperty = getPropertyAt(table, row);
    NlPropertyItem nextProperty = getPropertyAt(table, getNextPropertyRow(currentProperty, row));
    if (currentProperty != null && nextProperty != null && nextProperty.getName().equals(currentProperty.getName()) && !TOOLS_URI.equals(currentProperty.getNamespace()) && TOOLS_URI.equals(nextProperty.getNamespace())) {
        return nextProperty;
    }
    return null;
}
Also used : NlPropertyItem(com.android.tools.idea.uibuilder.property.NlPropertyItem) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

NlPropertyItem (com.android.tools.idea.uibuilder.property.NlPropertyItem)14 NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)7 NlProperty (com.android.tools.idea.uibuilder.property.NlProperty)7 AttributeDefinition (org.jetbrains.android.dom.attrs.AttributeDefinition)6 ModelBuilder (com.android.tools.idea.uibuilder.fixtures.ModelBuilder)5 NlModel (com.android.tools.idea.uibuilder.model.NlModel)5 NlComponentEditor (com.android.tools.idea.uibuilder.property.editors.NlComponentEditor)2 PTableModel (com.android.tools.idea.uibuilder.property.ptable.PTableModel)2 Nullable (org.jetbrains.annotations.Nullable)2 Matchers.anyString (org.mockito.Matchers.anyString)2 XmlFile (com.intellij.psi.xml.XmlFile)1 XmlTag (com.intellij.psi.xml.XmlTag)1 Language (org.intellij.lang.annotations.Language)1