Search in sources :

Example 1 with NlPropertyItem

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

the class NlTableCellEditor method removeDesignProperty.

public static void removeDesignProperty(@NotNull JTable table, int row) {
    NlPropertyItem designProperty = getPropertyAt(table, row);
    assert designProperty != null && TOOLS_URI.equals(designProperty.getNamespace());
    int previousRow = getPreviousPropertyRow(designProperty, table, row);
    PTableModel model = (PTableModel) table.getModel();
    designProperty.setValue(null);
    designProperty.delete();
    model.collapse(row);
    model.deleteRow(row);
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(() -> table.editCellAt(previousRow, 1));
}
Also used : PTableModel(com.android.tools.idea.uibuilder.property.ptable.PTableModel) NlPropertyItem(com.android.tools.idea.uibuilder.property.NlPropertyItem)

Example 2 with NlPropertyItem

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

the class NlTableCellEditor method getRuntimeProperty.

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

Example 3 with NlPropertyItem

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

the class NlTableCellEditor method addDesignProperty.

public static void addDesignProperty(@NotNull JTable table, int row) {
    NlPropertyItem property = getPropertyAt(table, row);
    assert property != null && !TOOLS_URI.equals(property.getNamespace());
    assert getDesignProperty(table, row) == null;
    PTableModel model = (PTableModel) table.getModel();
    int nextRow = getNextPropertyRow(property, row);
    model.insertRow(nextRow, property.getDesignTimeProperty());
    if (property.isExpanded()) {
        model.expand(nextRow);
    }
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(() -> table.editCellAt(row + 1, 1));
}
Also used : PTableModel(com.android.tools.idea.uibuilder.property.ptable.PTableModel) NlPropertyItem(com.android.tools.idea.uibuilder.property.NlPropertyItem)

Example 4 with NlPropertyItem

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

the class IdAnalyzerTest method testButton1And2.

public void testButton1And2() {
    ModelBuilder modelBuilder = createRelativeLayout();
    NlModel model = modelBuilder.build();
    NlComponent button1 = findById(model, "button1");
    NlComponent button2 = findById(model, "button2");
    NlProperty accessibility = new NlPropertyItem(ImmutableList.of(button1, button2), ANDROID_URI, new AttributeDefinition(ATTR_ACCESSIBILITY_TRAVERSAL_BEFORE));
    IdAnalyzer analyzer = new IdAnalyzer(accessibility);
    List<String> ids = analyzer.findIds();
    assertEquals(ImmutableList.of("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 5 with NlPropertyItem

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

the class IdAnalyzerTest method testRadioGroup.

public void testRadioGroup() {
    ModelBuilder modelBuilder = createRelativeLayout();
    NlModel model = modelBuilder.build();
    NlComponent group = findById(model, "group1");
    NlProperty property = new NlPropertyItem(ImmutableList.of(group), ANDROID_URI, new AttributeDefinition(ATTR_CHECKED_BUTTON));
    IdAnalyzer analyzer = new IdAnalyzer(property);
    List<String> ids = analyzer.findIds();
    assertEquals(ImmutableList.of("radio_button1", "radio_button2", "radio_button3"), 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)

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