mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-87157
This commit is contained in:
+29
-5
@@ -16,6 +16,7 @@
|
||||
package com.intellij.android.designer.model.morphing;
|
||||
|
||||
import com.intellij.android.designer.model.*;
|
||||
import com.intellij.android.designer.model.grid.GridInfo;
|
||||
import com.intellij.android.designer.model.layout.grid.RadGridLayoutComponent;
|
||||
import com.intellij.android.designer.model.layout.table.RadTableLayout;
|
||||
import com.intellij.android.designer.model.layout.table.RadTableLayoutComponent;
|
||||
@@ -24,24 +25,30 @@ import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class GridLayout {
|
||||
public static RadViewComponent TableLayout(RadViewComponent component, MetaModel target) throws Exception {
|
||||
final RadComponent[][] components = ((RadGridLayoutComponent)component).getGridComponents(false);
|
||||
final List<RadComponent>[][] components = getGridComponents((RadGridLayoutComponent)component);
|
||||
final MetaModel tableRowModel = ViewsMetaManager.getInstance(component.getTag().getProject()).getModelByTag("TableRow");
|
||||
|
||||
return new ComponentMorphingTool(component, new RadTableLayoutComponent(), target, new RadTableLayout()) {
|
||||
@Override
|
||||
protected void convertChildren() throws Exception {
|
||||
for (RadComponent[] rowComponents : components) {
|
||||
for (List<RadComponent>[] rowComponents : components) {
|
||||
RadViewComponent newRowComponent = ModelParser.createComponent(null, tableRowModel);
|
||||
ModelParser.addComponent(myNewComponent, newRowComponent, null);
|
||||
|
||||
for (RadComponent cellComponent : rowComponents) {
|
||||
if (cellComponent != null) {
|
||||
ModelParser.moveComponent(newRowComponent, (RadViewComponent)cellComponent, null);
|
||||
for (List<RadComponent> cellComponents : rowComponents) {
|
||||
if (cellComponents != null) {
|
||||
for (RadComponent cellComponent : cellComponents) {
|
||||
ModelParser.moveComponent(newRowComponent, (RadViewComponent)cellComponent, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,4 +79,21 @@ public class GridLayout {
|
||||
}
|
||||
}.result();
|
||||
}
|
||||
|
||||
private static List<RadComponent>[][] getGridComponents(RadGridLayoutComponent parent) {
|
||||
GridInfo gridInfo = parent.getGridInfo();
|
||||
List<RadComponent>[][] components = new List[gridInfo.rowCount][gridInfo.columnCount];
|
||||
|
||||
for (RadComponent child : parent.getChildren()) {
|
||||
Rectangle cellInfo = RadGridLayoutComponent.getCellInfo(child);
|
||||
List<RadComponent> cellComponents = components[cellInfo.y][cellInfo.x];
|
||||
if (cellComponents == null) {
|
||||
cellComponents = new ArrayList<RadComponent>();
|
||||
components[cellInfo.y][cellInfo.x] = cellComponents;
|
||||
}
|
||||
cellComponents.add(child);
|
||||
}
|
||||
|
||||
return components;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user