update copyright
[fedora-idea.git] / plugins / ui-designer / src / com / intellij / uiDesigner / designSurface / FormFirstComponentInsertLocation.java
blobad3629d155788ce830e888b9cbc3688e3fc1303e
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.intellij.uiDesigner.designSurface;
19 import com.intellij.uiDesigner.core.GridConstraints;
20 import com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager;
21 import com.intellij.uiDesigner.radComponents.RadComponent;
22 import com.intellij.uiDesigner.radComponents.RadContainer;
23 import com.jgoodies.forms.layout.ColumnSpec;
24 import com.jgoodies.forms.layout.FormLayout;
25 import com.jgoodies.forms.layout.RowSpec;
27 import java.awt.*;
29 /**
30 * FirstComponentInsertLocation customized for JGoodies Forms.
32 * @author yole
34 public class FormFirstComponentInsertLocation extends FirstComponentInsertLocation {
35 public FormFirstComponentInsertLocation(final RadContainer container, final Point targetPoint, final Rectangle cellRect) {
36 super(container, targetPoint, cellRect);
40 public FormFirstComponentInsertLocation(RadContainer container, Rectangle cellRect, int xPart, int yPart) {
41 super(container, cellRect, xPart, yPart);
44 @Override
45 protected FirstComponentInsertLocation createAdjacentLocation(final int xPart, final int yPart) {
46 return new FormFirstComponentInsertLocation(myContainer, myCellRect, xPart, yPart);
49 @Override
50 public void processDrop(final GuiEditor editor, final RadComponent[] components, final GridConstraints[] constraintsToAdjust,
51 final ComponentDragObject dragObject) {
52 RadAbstractGridLayoutManager gridLayout = myContainer.getGridLayoutManager();
53 if (myContainer.getGridRowCount() == 0) {
54 gridLayout.insertGridCells(myContainer, 0, true, true, true);
56 if (myContainer.getGridColumnCount() == 0) {
57 gridLayout.insertGridCells(myContainer, 0, false, true, true);
59 dropIntoGrid(myContainer, components, myRow, myColumn, dragObject);
61 FormLayout formLayout = (FormLayout) myContainer.getDelegee().getLayout();
62 if (myXPart == 0) {
63 formLayout.setColumnSpec(1, new ColumnSpec("d"));
65 else if (myXPart == 2) {
66 gridLayout.insertGridCells(myContainer, 0, false, true, true);
68 if (myYPart == 0) {
69 formLayout.setRowSpec(1, new RowSpec("d"));
71 else if (myYPart == 2) {
72 gridLayout.insertGridCells(myContainer, 0, true, true, true);