001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.form.layoutdesign;
043:
044: import java.awt.Dimension;
045: import java.awt.Point;
046: import java.awt.Rectangle;
047: import java.io.File;
048: import java.io.IOException;
049: import java.util.*;
050: import org.openide.filesystems.FileUtil;
051:
052: // Unlike test 15, this one makes sure that the fixed gaps are preserved if the
053: // component between other components is moved without parallel align.
054: public class ALT_ParallelPosition16Test extends LayoutTestCase {
055:
056: public ALT_ParallelPosition16Test(String name) {
057: super (name);
058: try {
059: className = this .getClass().getName();
060: className = className.substring(
061: className.lastIndexOf('.') + 1, className.length());
062: startingFormFile = FileUtil.toFileObject(new File(url
063: .getFile()
064: + goldenFilesPath
065: + className
066: + "-StartingForm.form").getCanonicalFile());
067: } catch (IOException ioe) {
068: fail(ioe.toString());
069: }
070: }
071:
072: // Move jButton to snap left of jButton2.
073: public void doChanges0() {
074: ld.externalSizeChangeHappened();
075: // > UPDATE CURRENT STATE
076: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
077: compBounds
078: .put("jToggleButton1", new Rectangle(10, 11, 179, 23));
079: baselinePosition.put("jToggleButton1-179-23", new Integer(15));
080: compPrefSize.put("jToggleButton1", new Dimension(179, 23));
081: compBounds.put("jLabel1", new Rectangle(10, 44, 34, 14));
082: baselinePosition.put("jLabel1-34-14", new Integer(11));
083: compPrefSize.put("jLabel1", new Dimension(34, 14));
084: compBounds.put("jButton1", new Rectangle(92, 40, 75, 23));
085: baselinePosition.put("jButton1-75-23", new Integer(15));
086: compPrefSize.put("jButton1", new Dimension(75, 23));
087: compBounds.put("jButton2", new Rectangle(225, 40, 75, 23));
088: baselinePosition.put("jButton2-75-23", new Integer(15));
089: compPrefSize.put("jButton2", new Dimension(75, 23));
090: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
091: compBounds
092: .put("jToggleButton1", new Rectangle(10, 11, 179, 23));
093: baselinePosition.put("jToggleButton1-179-23", new Integer(15));
094: compBounds.put("jLabel1", new Rectangle(10, 44, 34, 14));
095: baselinePosition.put("jLabel1-34-14", new Integer(11));
096: compBounds.put("jButton1", new Rectangle(92, 40, 75, 23));
097: baselinePosition.put("jButton1-75-23", new Integer(15));
098: compBounds.put("jButton2", new Rectangle(225, 40, 75, 23));
099: baselinePosition.put("jButton2-75-23", new Integer(15));
100: ld.updateCurrentState();
101: // < UPDATE CURRENT STATE
102: // > START MOVING
103: baselinePosition.put("jButton1-75-23", new Integer(15));
104: {
105: String[] compIds = new String[] { "jButton1" };
106: Rectangle[] bounds = new Rectangle[] { new Rectangle(92,
107: 40, 75, 23) };
108: Point hotspot = new Point(139, 54);
109: ld.startMoving(compIds, bounds, hotspot);
110: }
111: // < START MOVING
112: prefPaddingInParent.put("Form-jButton1-1-0", new Integer(11)); // parentId-compId-dimension-compAlignment
113: prefPaddingInParent.put("Form-jButton1-1-1", new Integer(11)); // parentId-compId-dimension-compAlignment
114: prefPadding
115: .put("jToggleButton1-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
116: prefPadding
117: .put("jButton1-jToggleButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
118: prefPadding.put("jLabel1-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
119: prefPadding.put("jButton1-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
120: prefPadding.put("jButton2-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
121: prefPadding.put("jButton1-jLabel1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
122: prefPadding.put("jButton1-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
123: prefPadding.put("jButton1-jButton2-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
124: prefPaddingInParent.put("Form-jButton1-0-0", new Integer(10)); // parentId-compId-dimension-compAlignment
125: prefPaddingInParent.put("Form-jButton1-0-1", new Integer(10)); // parentId-compId-dimension-compAlignment
126: prefPadding.put("jLabel1-jButton1-0-0-0", new Integer(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
127: prefPadding.put("jButton1-jLabel1-0-0-0", new Integer(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
128: prefPadding.put("jButton2-jButton1-0-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
129: prefPadding.put("jButton1-jButton2-0-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
130: prefPadding.put("jToggleButton1-jButton1-0-0-2",
131: new Integer(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
132: // > MOVE
133: {
134: Point p = new Point(187, 56);
135: String containerId = "Form";
136: boolean autoPositioning = true;
137: boolean lockDimension = false;
138: Rectangle[] bounds = new Rectangle[] { new Rectangle(144,
139: 40, 75, 23) };
140: ld.move(p, containerId, autoPositioning, lockDimension,
141: bounds);
142: }
143: // < MOVE
144: prefPaddingInParent.put("Form-jButton1-1-0", new Integer(11)); // parentId-compId-dimension-compAlignment
145: prefPaddingInParent.put("Form-jButton1-1-1", new Integer(11)); // parentId-compId-dimension-compAlignment
146: prefPadding
147: .put("jToggleButton1-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
148: prefPadding
149: .put("jButton1-jToggleButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
150: prefPadding.put("jLabel1-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
151: prefPadding.put("jButton1-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
152: prefPadding.put("jButton2-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
153: prefPadding.put("jButton1-jLabel1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
154: prefPadding.put("jButton1-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
155: prefPadding.put("jButton1-jButton2-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
156: prefPaddingInParent.put("Form-jButton1-0-0", new Integer(10)); // parentId-compId-dimension-compAlignment
157: prefPaddingInParent.put("Form-jButton1-0-1", new Integer(10)); // parentId-compId-dimension-compAlignment
158: prefPadding.put("jLabel1-jButton1-0-0-0", new Integer(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
159: prefPadding.put("jButton1-jLabel1-0-0-0", new Integer(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
160: prefPadding.put("jButton2-jButton1-0-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
161: prefPadding.put("jButton1-jButton2-0-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
162: prefPadding.put("jToggleButton1-jButton1-0-0-2",
163: new Integer(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
164: // > MOVE
165: {
166: Point p = new Point(188, 56);
167: String containerId = "Form";
168: boolean autoPositioning = true;
169: boolean lockDimension = false;
170: Rectangle[] bounds = new Rectangle[] { new Rectangle(144,
171: 40, 75, 23) };
172: ld.move(p, containerId, autoPositioning, lockDimension,
173: bounds);
174: }
175: // < MOVE
176: // > END MOVING
177: prefPadding.put("jLabel1-jButton1-0-0-0", new Integer(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
178: ld.endMoving(true);
179: // < END MOVING
180: ld.externalSizeChangeHappened();
181: // > UPDATE CURRENT STATE
182: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
183: compBounds
184: .put("jToggleButton1", new Rectangle(10, 11, 179, 23));
185: baselinePosition.put("jToggleButton1-179-23", new Integer(15));
186: compPrefSize.put("jToggleButton1", new Dimension(179, 23));
187: compBounds.put("jLabel1", new Rectangle(10, 44, 34, 14));
188: baselinePosition.put("jLabel1-34-14", new Integer(11));
189: compPrefSize.put("jLabel1", new Dimension(34, 14));
190: compBounds.put("jButton2", new Rectangle(225, 40, 75, 23));
191: baselinePosition.put("jButton2-75-23", new Integer(15));
192: compPrefSize.put("jButton2", new Dimension(75, 23));
193: compBounds.put("jButton1", new Rectangle(144, 40, 75, 23));
194: baselinePosition.put("jButton1-75-23", new Integer(15));
195: compPrefSize.put("jButton1", new Dimension(75, 23));
196: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
197: compBounds
198: .put("jToggleButton1", new Rectangle(10, 11, 179, 23));
199: baselinePosition.put("jToggleButton1-179-23", new Integer(15));
200: compBounds.put("jLabel1", new Rectangle(10, 44, 34, 14));
201: baselinePosition.put("jLabel1-34-14", new Integer(11));
202: compBounds.put("jButton2", new Rectangle(225, 40, 75, 23));
203: baselinePosition.put("jButton2-75-23", new Integer(15));
204: compBounds.put("jButton1", new Rectangle(144, 40, 75, 23));
205: baselinePosition.put("jButton1-75-23", new Integer(15));
206: ld.updateCurrentState();
207: // < UPDATE CURRENT STATE
208: }
209:
210: }
|