Search in sources :

Example 1 with GradleEditorEntityGroup

use of com.android.tools.idea.gradle.editor.entity.GradleEditorEntityGroup in project android by JetBrains.

the class GradleEditorComponent method setData.

/**
   * Configures current control to represent given groups (discarding all previously shown information).
   *
   * @param groups  groups to show
   */
public void setData(@NotNull List<GradleEditorEntityGroup> groups) {
    // Most likely use-case is that just table's data should be updated.
    boolean sameTables = groups.size() == myTablesByGroupName.size();
    for (GradleEditorEntityGroup group : groups) {
        GradleEditorEntityTable table = myTablesByGroupName.get(group.getName());
        if (table == null) {
            sameTables = false;
        } else {
            if (table.isEditing()) {
                table.getCellEditor().stopCellEditing();
            }
            table.getModel().setData(group.getEntities());
        }
    }
    if (sameTables) {
        return;
    }
    myCanvas.removeAll();
    Map<String, GradleEditorEntityTable> tablesByGroupName = Maps.newHashMap(myTablesByGroupName);
    myTablesByGroupName.clear();
    Map<String, JBPanel> panelsByGroupName = Maps.newHashMap(myPanelsByGroupName);
    myPanelsByGroupName.clear();
    for (GradleEditorEntityGroup group : groups) {
        JBPanel panel = panelsByGroupName.get(group.getName());
        GradleEditorEntityTable table = tablesByGroupName.get(group.getName());
        if (panel != null && table != null) {
            addUiForGroup(group.getName(), panel, table);
        } else {
            addUiForGroup(group);
        }
    }
    myCanvas.add(new JLabel(" "), new GridBag().weighty(1));
}
Also used : GradleEditorEntityGroup(com.android.tools.idea.gradle.editor.entity.GradleEditorEntityGroup) GridBag(com.intellij.util.ui.GridBag) JBPanel(com.intellij.ui.components.JBPanel)

Aggregations

GradleEditorEntityGroup (com.android.tools.idea.gradle.editor.entity.GradleEditorEntityGroup)1 JBPanel (com.intellij.ui.components.JBPanel)1 GridBag (com.intellij.util.ui.GridBag)1