mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
GridLayout
This commit is contained in:
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.android.designer.designSurface.layout.caption;
|
||||
|
||||
import com.intellij.android.designer.designSurface.layout.GridLayoutOperation;
|
||||
import com.intellij.android.designer.model.ModelParser;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.model.grid.GridInfo;
|
||||
import com.intellij.android.designer.model.grid.RadCaptionColumn;
|
||||
import com.intellij.android.designer.model.layout.grid.RadGridLayoutComponent;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.designSurface.OperationContext;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class GridHorizontalCaptionOperation extends HorizontalCaptionFlowBaseOperation<RadGridLayoutComponent> {
|
||||
public GridHorizontalCaptionOperation(RadGridLayoutComponent mainContainer,
|
||||
RadComponent container,
|
||||
OperationContext context,
|
||||
EditableArea mainArea) {
|
||||
super(mainContainer, container, context, mainArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(@Nullable RadComponent insertBefore) throws Exception {
|
||||
RadComponent[][] components = myMainContainer.getGridComponents(false);
|
||||
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
RadComponent[] rowComponents = components[i];
|
||||
|
||||
List<RadViewComponent> editComponents = new ArrayList<RadViewComponent>();
|
||||
int count = 0;
|
||||
for (RadComponent component : myComponents) {
|
||||
int column = ((RadCaptionColumn)component).getIndex();
|
||||
RadViewComponent editComponent = (RadViewComponent)rowComponents[column];
|
||||
editComponents.add(editComponent);
|
||||
if (editComponent != null) {
|
||||
RadGridLayoutComponent.clearCellSpans(editComponent);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
RadViewComponent insertBeforeColumn = null;
|
||||
if (insertBefore != null) {
|
||||
int column = ((RadCaptionColumn)insertBefore).getIndex();
|
||||
for (int j = column; j < rowComponents.length; j++) {
|
||||
insertBeforeColumn = (RadViewComponent)rowComponents[j];
|
||||
if (insertBeforeColumn != null) {
|
||||
if (!editComponents.isEmpty() && insertBeforeColumn == editComponents.get(0)) {
|
||||
editComponents.remove(0);
|
||||
insertBeforeColumn = null;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (insertBefore == null || insertBeforeColumn != null) {
|
||||
for (RadViewComponent component : editComponents) {
|
||||
if (component != insertBeforeColumn) {
|
||||
ModelParser.moveComponent(myMainContainer, component, insertBeforeColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<RadComponent> rowList = new ArrayList<RadComponent>();
|
||||
Collections.addAll(rowList, rowComponents);
|
||||
rowList.removeAll(editComponents);
|
||||
|
||||
if (insertBefore == null) {
|
||||
rowList.addAll(editComponents);
|
||||
}
|
||||
else {
|
||||
rowList.addAll(((RadCaptionColumn)insertBefore).getIndex(), editComponents);
|
||||
}
|
||||
|
||||
for (RadViewComponent component : editComponents) {
|
||||
Rectangle cellIndex = RadGridLayoutComponent.getCellInfo(component);
|
||||
GridInfo.setNull(components, null, cellIndex.y, cellIndex.y + cellIndex.height, cellIndex.x, cellIndex.x + cellIndex.width);
|
||||
}
|
||||
|
||||
components[i] = rowList.toArray(new RadComponent[rowList.size()]);
|
||||
}
|
||||
|
||||
for (RadComponent component : myComponents) {
|
||||
component.removeFromParent();
|
||||
myContainer.add(component, insertBefore);
|
||||
}
|
||||
|
||||
GridLayoutOperation.validateLayoutParams(components);
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.android.designer.designSurface.layout.caption;
|
||||
|
||||
import com.intellij.android.designer.model.layout.grid.RadGridLayoutComponent;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.designSurface.FeedbackLayer;
|
||||
import com.intellij.designer.designSurface.OperationContext;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class GridVerticalCaptionOperation extends VerticalCaptionFlowBaseOperation<RadGridLayoutComponent> {
|
||||
public GridVerticalCaptionOperation(RadGridLayoutComponent mainContainer,
|
||||
RadComponent container,
|
||||
OperationContext context,
|
||||
EditableArea mainArea) {
|
||||
super(mainContainer, container, context, mainArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMainFeedbackWidth(FeedbackLayer layer, int mainXLocation) {
|
||||
return myMainContainer.getGridInfo().width;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(@Nullable RadComponent insertBefore) throws Exception {
|
||||
// TODO: Auto-generated method stub
|
||||
}
|
||||
}
|
||||
+6
-83
@@ -15,39 +15,33 @@
|
||||
*/
|
||||
package com.intellij.android.designer.designSurface.layout.caption;
|
||||
|
||||
import com.intellij.android.designer.model.ModelParser;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.model.layout.table.RadCaptionTableColumn;
|
||||
import com.intellij.android.designer.model.layout.table.RadTableLayoutComponent;
|
||||
import com.intellij.android.designer.model.layout.table.RadTableRowLayout;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.designSurface.FeedbackLayer;
|
||||
import com.intellij.designer.designSurface.FlowBaseOperation;
|
||||
import com.intellij.designer.designSurface.OperationContext;
|
||||
import com.intellij.designer.designSurface.feedbacks.LineInsertFeedback;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class HorizontalCaptionFlowBaseOperation extends FlowBaseOperation {
|
||||
private final RadTableLayoutComponent myTableComponent;
|
||||
public abstract class HorizontalCaptionFlowBaseOperation<T extends RadViewComponent> extends FlowBaseOperation {
|
||||
protected final T myMainContainer;
|
||||
private final EditableArea myMainArea;
|
||||
private LineInsertFeedback myMainInsertFeedback;
|
||||
private int myMainYLocation;
|
||||
|
||||
public HorizontalCaptionFlowBaseOperation(RadTableLayoutComponent tableComponent,
|
||||
public HorizontalCaptionFlowBaseOperation(T mainContainer,
|
||||
RadComponent container,
|
||||
OperationContext context,
|
||||
EditableArea mainArea) {
|
||||
super(container, context, true);
|
||||
myTableComponent = tableComponent;
|
||||
myMainContainer = mainContainer;
|
||||
myMainArea = mainArea;
|
||||
}
|
||||
|
||||
@@ -58,10 +52,10 @@ public class HorizontalCaptionFlowBaseOperation extends FlowBaseOperation {
|
||||
if (myMainInsertFeedback == null) {
|
||||
FeedbackLayer layer = myMainArea.getFeedbackLayer();
|
||||
|
||||
Rectangle bounds = myTableComponent.getBounds(layer);
|
||||
Rectangle bounds = myMainContainer.getBounds(layer);
|
||||
myMainYLocation = bounds.y;
|
||||
|
||||
List<RadComponent> children = myTableComponent.getChildren();
|
||||
List<RadComponent> children = myMainContainer.getChildren();
|
||||
Rectangle lastChildBounds = children.get(children.size() - 1).getBounds(layer);
|
||||
|
||||
myMainInsertFeedback = new LineInsertFeedback(Color.green, false);
|
||||
@@ -91,75 +85,4 @@ public class HorizontalCaptionFlowBaseOperation extends FlowBaseOperation {
|
||||
myMainInsertFeedback = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(@Nullable RadComponent insertBefore) throws Exception {
|
||||
List<RadComponent> rows = myTableComponent.getChildren();
|
||||
RadComponent[][] components = myTableComponent.getGridComponents(false);
|
||||
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
RadViewComponent container = (RadViewComponent)rows.get(i);
|
||||
|
||||
if (RadTableRowLayout.is(container)) {
|
||||
RadComponent[] rowComponents = components[i];
|
||||
|
||||
List<RadViewComponent> editComponents = new ArrayList<RadViewComponent>();
|
||||
for (RadComponent component : myComponents) {
|
||||
int column = ((RadCaptionTableColumn)component).getIndex();
|
||||
RadViewComponent editComponent = (RadViewComponent)rowComponents[column];
|
||||
if (editComponent != null) {
|
||||
editComponents.add(editComponent);
|
||||
}
|
||||
}
|
||||
|
||||
if (editComponents.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RadViewComponent insertBeforeColumn = null;
|
||||
if (insertBefore != null) {
|
||||
int column = ((RadCaptionTableColumn)insertBefore).getIndex();
|
||||
for (int j = column; j < rowComponents.length; j++) {
|
||||
insertBeforeColumn = (RadViewComponent)rowComponents[j];
|
||||
if (insertBeforeColumn != null) {
|
||||
if (!editComponents.isEmpty() && insertBeforeColumn == editComponents.get(0)) {
|
||||
editComponents.remove(0);
|
||||
insertBeforeColumn = null;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (insertBefore == null || insertBeforeColumn != null) {
|
||||
for (RadViewComponent component : editComponents) {
|
||||
if (component != insertBeforeColumn) {
|
||||
ModelParser.moveComponent(container, component, insertBeforeColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (RadComponent component : myComponents) {
|
||||
component.removeFromParent();
|
||||
myContainer.add(component, insertBefore);
|
||||
}
|
||||
|
||||
List<RadComponent> columns = myContainer.getChildren();
|
||||
int size = columns.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
int index = ((RadCaptionTableColumn)columns.get(i)).getIndex();
|
||||
|
||||
for (int j = 0; j < components.length; j++) {
|
||||
if (RadTableRowLayout.is(rows.get(j))) {
|
||||
RadComponent cellComponent = components[j][index];
|
||||
if (cellComponent != null) {
|
||||
RadTableLayoutComponent.setCellIndex(cellComponent, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.android.designer.designSurface.layout.caption;
|
||||
|
||||
import com.intellij.android.designer.model.ModelParser;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.model.layout.table.RadCaptionTableColumn;
|
||||
import com.intellij.android.designer.model.layout.table.RadTableLayoutComponent;
|
||||
import com.intellij.android.designer.model.layout.table.RadTableRowLayout;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.designSurface.OperationContext;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class TableHorizontalCaptionOperation extends HorizontalCaptionFlowBaseOperation<RadTableLayoutComponent> {
|
||||
public TableHorizontalCaptionOperation(RadTableLayoutComponent mainContainer,
|
||||
RadComponent container,
|
||||
OperationContext context,
|
||||
EditableArea mainArea) {
|
||||
super(mainContainer, container, context, mainArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(@Nullable RadComponent insertBefore) throws Exception {
|
||||
List<RadComponent> rows = myMainContainer.getChildren();
|
||||
RadComponent[][] components = myMainContainer.getGridComponents(false);
|
||||
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
RadViewComponent container = (RadViewComponent)rows.get(i);
|
||||
|
||||
if (RadTableRowLayout.is(container)) {
|
||||
RadComponent[] rowComponents = components[i];
|
||||
|
||||
List<RadViewComponent> editComponents = new ArrayList<RadViewComponent>();
|
||||
for (RadComponent component : myComponents) {
|
||||
int column = ((RadCaptionTableColumn)component).getIndex();
|
||||
RadViewComponent editComponent = (RadViewComponent)rowComponents[column];
|
||||
if (editComponent != null) {
|
||||
editComponents.add(editComponent);
|
||||
}
|
||||
}
|
||||
|
||||
if (editComponents.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RadViewComponent insertBeforeColumn = null;
|
||||
if (insertBefore != null) {
|
||||
int column = ((RadCaptionTableColumn)insertBefore).getIndex();
|
||||
for (int j = column; j < rowComponents.length; j++) {
|
||||
insertBeforeColumn = (RadViewComponent)rowComponents[j];
|
||||
if (insertBeforeColumn != null) {
|
||||
if (!editComponents.isEmpty() && insertBeforeColumn == editComponents.get(0)) {
|
||||
editComponents.remove(0);
|
||||
insertBeforeColumn = null;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (insertBefore == null || insertBeforeColumn != null) {
|
||||
for (RadViewComponent component : editComponents) {
|
||||
if (component != insertBeforeColumn) {
|
||||
ModelParser.moveComponent(container, component, insertBeforeColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (RadComponent component : myComponents) {
|
||||
component.removeFromParent();
|
||||
myContainer.add(component, insertBefore);
|
||||
}
|
||||
|
||||
List<RadComponent> columns = myContainer.getChildren();
|
||||
int size = columns.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
int index = ((RadCaptionTableColumn)columns.get(i)).getIndex();
|
||||
|
||||
for (int j = 0; j < components.length; j++) {
|
||||
if (RadTableRowLayout.is(rows.get(j))) {
|
||||
RadComponent cellComponent = components[j][index];
|
||||
if (cellComponent != null) {
|
||||
RadTableLayoutComponent.setCellIndex(cellComponent, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.android.designer.designSurface.layout.caption;
|
||||
|
||||
import com.intellij.android.designer.model.ModelParser;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.model.layout.table.RadCaptionTableRow;
|
||||
import com.intellij.android.designer.model.layout.table.RadTableLayoutComponent;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.designSurface.OperationContext;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class TableVerticalCaptionOperation extends VerticalCaptionFlowBaseOperation<RadTableLayoutComponent> {
|
||||
public TableVerticalCaptionOperation(RadTableLayoutComponent mainContainer,
|
||||
RadComponent container,
|
||||
OperationContext context,
|
||||
EditableArea mainArea) {
|
||||
super(mainContainer, container, context, mainArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(@Nullable RadComponent insertBefore) throws Exception {
|
||||
for (RadComponent component : myComponents) {
|
||||
component.removeFromParent();
|
||||
myContainer.add(component, insertBefore);
|
||||
}
|
||||
|
||||
RadViewComponent mainInsertBefore = insertBefore == null ? null : ((RadCaptionTableRow)insertBefore).getComponent();
|
||||
|
||||
for (RadComponent component : myComponents) {
|
||||
ModelParser.moveComponent(myMainContainer,
|
||||
((RadCaptionTableRow)component).getComponent(),
|
||||
mainInsertBefore);
|
||||
}
|
||||
}
|
||||
}
|
||||
+41
-53
@@ -15,89 +15,77 @@
|
||||
*/
|
||||
package com.intellij.android.designer.designSurface.layout.caption;
|
||||
|
||||
import com.intellij.android.designer.designSurface.AbstractEditOperation;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.model.layout.table.RadCaptionTableRow;
|
||||
import com.intellij.android.designer.model.layout.table.RadTableLayoutComponent;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.designSurface.FeedbackLayer;
|
||||
import com.intellij.designer.designSurface.FlowBaseOperation;
|
||||
import com.intellij.designer.designSurface.OperationContext;
|
||||
import com.intellij.designer.designSurface.feedbacks.LineInsertFeedback;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class VerticalCaptionFlowBaseOperation extends FlowBaseOperation {
|
||||
private final RadTableLayoutComponent myTableComponent;
|
||||
private final OperationContext myMainContext;
|
||||
private final FlowBaseOperation myMainOperation;
|
||||
public abstract class VerticalCaptionFlowBaseOperation<T extends RadViewComponent> extends FlowBaseOperation {
|
||||
protected final T myMainContainer;
|
||||
private final EditableArea myMainArea;
|
||||
private LineInsertFeedback myMainInsertFeedback;
|
||||
private int myMainXLocation;
|
||||
|
||||
public VerticalCaptionFlowBaseOperation(RadTableLayoutComponent tableComponent,
|
||||
public VerticalCaptionFlowBaseOperation(T mainContainer,
|
||||
RadComponent container,
|
||||
OperationContext context,
|
||||
EditableArea mainArea) {
|
||||
super(container, context, false);
|
||||
myTableComponent = tableComponent;
|
||||
myMainContext = new OperationContext(context.getType());
|
||||
myMainContext.setArea(mainArea);
|
||||
|
||||
myMainOperation = new FlowBaseOperation(tableComponent, myMainContext, false) {
|
||||
@Override
|
||||
protected void execute(@Nullable RadComponent insertBefore) throws Exception {
|
||||
}
|
||||
};
|
||||
myMainContainer = mainContainer;
|
||||
myMainArea = mainArea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComponents(List<RadComponent> components) {
|
||||
super.setComponents(components);
|
||||
myMainContext.setComponents(getRowComponents(components));
|
||||
protected void createFeedback() {
|
||||
super.createFeedback();
|
||||
|
||||
if (myMainInsertFeedback == null) {
|
||||
FeedbackLayer layer = myMainArea.getFeedbackLayer();
|
||||
|
||||
Rectangle bounds = myMainContainer.getBounds(layer);
|
||||
myMainXLocation = bounds.x;
|
||||
|
||||
myMainInsertFeedback = new LineInsertFeedback(Color.green, true);
|
||||
myMainInsertFeedback.size(getMainFeedbackWidth(layer, myMainXLocation), 0);
|
||||
|
||||
layer.add(myMainInsertFeedback);
|
||||
layer.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
protected int getMainFeedbackWidth(FeedbackLayer layer, int mainXLocation) {
|
||||
List<RadComponent> children = myMainContainer.getChildren();
|
||||
Rectangle lastChildBounds = children.get(children.size() - 1).getBounds(layer);
|
||||
return lastChildBounds.x + lastChildBounds.width - mainXLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showFeedback() {
|
||||
super.showFeedback();
|
||||
myMainContext.setLocation(SwingUtilities.convertPoint(myContext.getArea().getFeedbackLayer(),
|
||||
myContext.getLocation(),
|
||||
myMainContext.getArea().getFeedbackLayer()));
|
||||
myMainOperation.showFeedback();
|
||||
Point location = SwingUtilities.convertPoint(myInsertFeedback.getParent(),
|
||||
myInsertFeedback.getLocation(),
|
||||
myMainArea.getFeedbackLayer());
|
||||
myMainInsertFeedback.setLocation(myMainXLocation, location.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseFeedback() {
|
||||
super.eraseFeedback();
|
||||
myMainOperation.eraseFeedback();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(@Nullable RadComponent insertBefore) throws Exception {
|
||||
for (RadComponent component : myComponents) {
|
||||
component.removeFromParent();
|
||||
myContainer.add(component, insertBefore);
|
||||
if (myMainInsertFeedback != null) {
|
||||
FeedbackLayer layer = myMainArea.getFeedbackLayer();
|
||||
layer.remove(myMainInsertFeedback);
|
||||
layer.repaint();
|
||||
myMainInsertFeedback = null;
|
||||
}
|
||||
|
||||
AbstractEditOperation.execute(myMainContext,
|
||||
myTableComponent,
|
||||
getRowComponents(myComponents),
|
||||
getRowComponent(insertBefore));
|
||||
}
|
||||
|
||||
private static List<RadComponent> getRowComponents(List<RadComponent> components) {
|
||||
List<RadComponent> rowComponents = new ArrayList<RadComponent>();
|
||||
for (RadComponent component : components) {
|
||||
rowComponents.add(((RadCaptionTableRow)component).getComponent());
|
||||
}
|
||||
return rowComponents;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static RadViewComponent getRowComponent(@Nullable RadComponent component) {
|
||||
RadCaptionTableRow row = (RadCaptionTableRow)component;
|
||||
return row == null ? null : row.getComponent();
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ package com.intellij.android.designer.model.grid;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
@@ -68,7 +69,7 @@ public class GridInfo {
|
||||
}
|
||||
|
||||
public static void setNull(RadComponent[][] components1,
|
||||
RadComponent[][] components2,
|
||||
@Nullable RadComponent[][] components2,
|
||||
int startRow,
|
||||
int endRow,
|
||||
int startColumn,
|
||||
@@ -79,7 +80,9 @@ public class GridInfo {
|
||||
for (int i = startRow; i < endRow; i++) {
|
||||
for (int j = startColumn; j < endColumn; j++) {
|
||||
components1[i][j] = null;
|
||||
components2[i][j] = null;
|
||||
if (components2 != null) {
|
||||
components2[i][j] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+36
-4
@@ -16,10 +16,12 @@
|
||||
package com.intellij.android.designer.model.layout.grid;
|
||||
|
||||
import com.intellij.android.designer.designSurface.TreeDropToOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.grid.GridDecorator;
|
||||
import com.intellij.android.designer.designSurface.layout.GridLayoutOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.actions.LayoutSpanOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.actions.ResizeOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.caption.GridHorizontalCaptionOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.caption.GridVerticalCaptionOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.grid.GridDecorator;
|
||||
import com.intellij.android.designer.model.RadViewLayout;
|
||||
import com.intellij.android.designer.model.RadViewLayoutWithData;
|
||||
import com.intellij.android.designer.model.grid.GridInfo;
|
||||
@@ -185,10 +187,40 @@ public class RadGridLayout extends RadViewLayoutWithData implements ILayoutDecor
|
||||
return components;
|
||||
}
|
||||
|
||||
private RadLayout myCaptionColumnLayout;
|
||||
private RadLayout myCaptionRowLayout;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public RadLayout getCaptionLayout(EditableArea mainArea, boolean horizontal) {
|
||||
// XXX
|
||||
return RadViewLayout.INSTANCE;
|
||||
public RadLayout getCaptionLayout(final EditableArea mainArea, boolean horizontal) {
|
||||
if (horizontal) {
|
||||
if (myCaptionColumnLayout == null) {
|
||||
myCaptionColumnLayout = new RadViewLayout() {
|
||||
@Override
|
||||
public EditOperation processChildOperation(OperationContext context) {
|
||||
if (context.isMove()) {
|
||||
return new GridHorizontalCaptionOperation((RadGridLayoutComponent)RadGridLayout.this.myContainer,
|
||||
myContainer, context, mainArea);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
return myCaptionColumnLayout;
|
||||
}
|
||||
|
||||
if (myCaptionRowLayout == null) {
|
||||
myCaptionRowLayout = new RadViewLayout() {
|
||||
@Override
|
||||
public EditOperation processChildOperation(OperationContext context) {
|
||||
if (context.isMove()) {
|
||||
return new GridVerticalCaptionOperation((RadGridLayoutComponent)RadGridLayout.this.myContainer,
|
||||
myContainer, context, mainArea);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
return myCaptionRowLayout;
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -16,10 +16,10 @@
|
||||
package com.intellij.android.designer.model.layout.table;
|
||||
|
||||
import com.intellij.android.designer.designSurface.TreeDropToOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.*;
|
||||
import com.intellij.android.designer.designSurface.layout.TableLayoutOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.actions.ResizeOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.caption.HorizontalCaptionFlowBaseOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.caption.VerticalCaptionFlowBaseOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.caption.TableHorizontalCaptionOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.caption.TableVerticalCaptionOperation;
|
||||
import com.intellij.android.designer.designSurface.layout.grid.GridDecorator;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.model.RadViewLayout;
|
||||
@@ -175,8 +175,8 @@ public class RadTableLayout extends RadViewLayoutWithData implements ILayoutDeco
|
||||
@Override
|
||||
public EditOperation processChildOperation(OperationContext context) {
|
||||
if (context.isMove()) {
|
||||
return new HorizontalCaptionFlowBaseOperation((RadTableLayoutComponent)RadTableLayout.this.myContainer,
|
||||
myContainer, context, mainArea);
|
||||
return new TableHorizontalCaptionOperation((RadTableLayoutComponent)RadTableLayout.this.myContainer,
|
||||
myContainer, context, mainArea);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -190,8 +190,8 @@ public class RadTableLayout extends RadViewLayoutWithData implements ILayoutDeco
|
||||
@Override
|
||||
public EditOperation processChildOperation(OperationContext context) {
|
||||
if (context.isMove()) {
|
||||
return new VerticalCaptionFlowBaseOperation((RadTableLayoutComponent)RadTableLayout.this.myContainer,
|
||||
myContainer, context, mainArea);
|
||||
return new TableVerticalCaptionOperation((RadTableLayoutComponent)RadTableLayout.this.myContainer,
|
||||
myContainer, context, mainArea);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user