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: // Test for parallel same size with "next to" gesture.
053: public class ALT_ParallelPosition03Test extends LayoutTestCase {
054:
055: public ALT_ParallelPosition03Test(String name) {
056: super (name);
057: try {
058: className = this .getClass().getName();
059: className = className.substring(
060: className.lastIndexOf('.') + 1, className.length());
061: startingFormFile = FileUtil.toFileObject(new File(url
062: .getFile()
063: + goldenFilesPath
064: + className
065: + "-StartingForm.form").getCanonicalFile());
066: } catch (IOException ioe) {
067: fail(ioe.toString());
068: }
069: }
070:
071: // Create the layout - toggle button, text area, button (right-aligned with
072: // togle button).
073: public void doChanges0() {
074: ld.externalSizeChangeHappened();
075: // > UPDATE CURRENT STATE
076: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
077: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
078: ld.updateCurrentState();
079: // < UPDATE CURRENT STATE
080: lc = new LayoutComponent("jToggleButton1", false);
081: // > START ADDING
082: baselinePosition.put("jToggleButton1-105-23", new Integer(15));
083: {
084: LayoutComponent[] comps = new LayoutComponent[] { lc };
085: Rectangle[] bounds = new Rectangle[] { new Rectangle(0, 0,
086: 105, 23) };
087: String defaultContId = null;
088: Point hotspot = new Point(48, 11);
089: ld.startAdding(comps, bounds, hotspot, defaultContId);
090: }
091: // < START ADDING
092: prefPaddingInParent.put("Form-jToggleButton1-1-0", new Integer(
093: 11)); // parentId-compId-dimension-compAlignment
094: prefPaddingInParent.put("Form-jToggleButton1-1-1", new Integer(
095: 11)); // parentId-compId-dimension-compAlignment
096: prefPaddingInParent.put("Form-jToggleButton1-0-0", new Integer(
097: 10)); // parentId-compId-dimension-compAlignment
098: prefPaddingInParent.put("Form-jToggleButton1-0-1", new Integer(
099: 10)); // parentId-compId-dimension-compAlignment
100: // > MOVE
101: {
102: Point p = new Point(61, 27);
103: String containerId = "Form";
104: boolean autoPositioning = true;
105: boolean lockDimension = false;
106: Rectangle[] bounds = new Rectangle[] { new Rectangle(10,
107: 11, 105, 23) };
108: ld.move(p, containerId, autoPositioning, lockDimension,
109: bounds);
110: }
111: // < MOVE
112: prefPaddingInParent.put("Form-jToggleButton1-1-0", new Integer(
113: 11)); // parentId-compId-dimension-compAlignment
114: prefPaddingInParent.put("Form-jToggleButton1-1-1", new Integer(
115: 11)); // parentId-compId-dimension-compAlignment
116: prefPaddingInParent.put("Form-jToggleButton1-0-0", new Integer(
117: 10)); // parentId-compId-dimension-compAlignment
118: prefPaddingInParent.put("Form-jToggleButton1-0-1", new Integer(
119: 10)); // parentId-compId-dimension-compAlignment
120: // > MOVE
121: {
122: Point p = new Point(60, 27);
123: String containerId = "Form";
124: boolean autoPositioning = true;
125: boolean lockDimension = false;
126: Rectangle[] bounds = new Rectangle[] { new Rectangle(10,
127: 11, 105, 23) };
128: ld.move(p, containerId, autoPositioning, lockDimension,
129: bounds);
130: }
131: // < MOVE
132: // > END MOVING
133: compPrefSize.put("jToggleButton1", new Dimension(105, 23));
134: compPrefSize.put("jToggleButton1", new Dimension(105, 23));
135: prefPaddingInParent.put("Form-jToggleButton1-0-1", new Integer(
136: 10)); // parentId-compId-dimension-compAlignment
137: prefPaddingInParent.put("Form-jToggleButton1-1-1", new Integer(
138: 10)); // parentId-compId-dimension-compAlignment
139: ld.endMoving(true);
140: // < END MOVING
141: ld.externalSizeChangeHappened();
142: // > UPDATE CURRENT STATE
143: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
144: compBounds
145: .put("jToggleButton1", new Rectangle(10, 11, 105, 23));
146: baselinePosition.put("jToggleButton1-105-23", new Integer(15));
147: compPrefSize.put("jToggleButton1", new Dimension(105, 23));
148: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
149: compBounds
150: .put("jToggleButton1", new Rectangle(10, 11, 105, 23));
151: baselinePosition.put("jToggleButton1-105-23", new Integer(15));
152: ld.updateCurrentState();
153: // < UPDATE CURRENT STATE
154: lc = new LayoutComponent("jScrollPane1", false);
155: // > START ADDING
156: baselinePosition.put("jScrollPane1-104-64", new Integer(0));
157: {
158: LayoutComponent[] comps = new LayoutComponent[] { lc };
159: Rectangle[] bounds = new Rectangle[] { new Rectangle(0, 0,
160: 104, 64) };
161: String defaultContId = null;
162: Point hotspot = new Point(48, 32);
163: ld.startAdding(comps, bounds, hotspot, defaultContId);
164: }
165: // < START ADDING
166: prefPaddingInParent.put("Form-jScrollPane1-1-0",
167: new Integer(11)); // parentId-compId-dimension-compAlignment
168: prefPaddingInParent.put("Form-jScrollPane1-1-1",
169: new Integer(11)); // parentId-compId-dimension-compAlignment
170: prefPaddingInParent.put("Form-jScrollPane1-0-0",
171: new Integer(10)); // parentId-compId-dimension-compAlignment
172: prefPaddingInParent.put("Form-jScrollPane1-0-1",
173: new Integer(10)); // parentId-compId-dimension-compAlignment
174: prefPadding.put("jToggleButton1-jScrollPane1-0-0-0",
175: new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
176: prefPadding.put("jScrollPane1-jToggleButton1-0-0-0",
177: new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
178: // > MOVE
179: {
180: Point p = new Point(172, 47);
181: String containerId = "Form";
182: boolean autoPositioning = true;
183: boolean lockDimension = false;
184: Rectangle[] bounds = new Rectangle[] { new Rectangle(121,
185: 11, 104, 64) };
186: ld.move(p, containerId, autoPositioning, lockDimension,
187: bounds);
188: }
189: // < MOVE
190: prefPaddingInParent.put("Form-jScrollPane1-1-0",
191: new Integer(11)); // parentId-compId-dimension-compAlignment
192: prefPaddingInParent.put("Form-jScrollPane1-1-1",
193: new Integer(11)); // parentId-compId-dimension-compAlignment
194: prefPaddingInParent.put("Form-jScrollPane1-0-0",
195: new Integer(10)); // parentId-compId-dimension-compAlignment
196: prefPaddingInParent.put("Form-jScrollPane1-0-1",
197: new Integer(10)); // parentId-compId-dimension-compAlignment
198: prefPadding.put("jToggleButton1-jScrollPane1-0-0-0",
199: new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
200: prefPadding.put("jScrollPane1-jToggleButton1-0-0-0",
201: new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
202: // > MOVE
203: {
204: Point p = new Point(172, 46);
205: String containerId = "Form";
206: boolean autoPositioning = true;
207: boolean lockDimension = false;
208: Rectangle[] bounds = new Rectangle[] { new Rectangle(121,
209: 11, 104, 64) };
210: ld.move(p, containerId, autoPositioning, lockDimension,
211: bounds);
212: }
213: // < MOVE
214: // > END MOVING
215: compPrefSize.put("jScrollPane1", new Dimension(104, 64));
216: compPrefSize.put("jScrollPane1", new Dimension(104, 64));
217: prefPaddingInParent.put("Form-jScrollPane1-0-1",
218: new Integer(10)); // parentId-compId-dimension-compAlignment
219: prefPaddingInParent.put("Form-jScrollPane1-1-1",
220: new Integer(10)); // parentId-compId-dimension-compAlignment
221: ld.endMoving(true);
222: // < END MOVING
223: ld.externalSizeChangeHappened();
224: // > UPDATE CURRENT STATE
225: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
226: compBounds
227: .put("jToggleButton1", new Rectangle(10, 11, 105, 23));
228: baselinePosition.put("jToggleButton1-105-23", new Integer(15));
229: compPrefSize.put("jToggleButton1", new Dimension(105, 23));
230: compBounds.put("jScrollPane1", new Rectangle(121, 11, 104, 64));
231: baselinePosition.put("jScrollPane1-104-64", new Integer(0));
232: compPrefSize.put("jScrollPane1", new Dimension(104, 64));
233: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
234: compBounds
235: .put("jToggleButton1", new Rectangle(10, 11, 105, 23));
236: baselinePosition.put("jToggleButton1-105-23", new Integer(15));
237: compBounds.put("jScrollPane1", new Rectangle(121, 11, 104, 64));
238: baselinePosition.put("jScrollPane1-104-64", new Integer(0));
239: ld.updateCurrentState();
240: // < UPDATE CURRENT STATE
241: lc = new LayoutComponent("jButton1", false);
242: // > START ADDING
243: baselinePosition.put("jButton1-75-23", new Integer(15));
244: {
245: LayoutComponent[] comps = new LayoutComponent[] { lc };
246: Rectangle[] bounds = new Rectangle[] { new Rectangle(0, 0,
247: 75, 23) };
248: String defaultContId = null;
249: Point hotspot = new Point(33, 11);
250: ld.startAdding(comps, bounds, hotspot, defaultContId);
251: }
252: // < START ADDING
253: prefPaddingInParent.put("Form-jButton1-1-0", new Integer(11)); // parentId-compId-dimension-compAlignment
254: prefPaddingInParent.put("Form-jButton1-1-1", new Integer(11)); // parentId-compId-dimension-compAlignment
255: prefPadding
256: .put("jToggleButton1-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
257: prefPadding
258: .put("jButton1-jToggleButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
259: prefPaddingInParent.put("Form-jButton1-0-0", new Integer(10)); // parentId-compId-dimension-compAlignment
260: prefPaddingInParent.put("Form-jButton1-0-1", new Integer(10)); // parentId-compId-dimension-compAlignment
261: prefPadding.put("jScrollPane1-jButton1-0-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
262: prefPadding.put("jButton1-jScrollPane1-0-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
263: prefPadding.put("jToggleButton1-jButton1-0-0-2",
264: new Integer(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
265: // > MOVE
266: {
267: Point p = new Point(70, 48);
268: String containerId = "Form";
269: boolean autoPositioning = true;
270: boolean lockDimension = false;
271: Rectangle[] bounds = new Rectangle[] { new Rectangle(40,
272: 40, 75, 23) };
273: ld.move(p, containerId, autoPositioning, lockDimension,
274: bounds);
275: }
276: // < MOVE
277: prefPaddingInParent.put("Form-jButton1-1-0", new Integer(11)); // parentId-compId-dimension-compAlignment
278: prefPaddingInParent.put("Form-jButton1-1-1", new Integer(11)); // parentId-compId-dimension-compAlignment
279: prefPadding
280: .put("jToggleButton1-jButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
281: prefPadding
282: .put("jButton1-jToggleButton1-1-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
283: prefPaddingInParent.put("Form-jButton1-0-0", new Integer(10)); // parentId-compId-dimension-compAlignment
284: prefPaddingInParent.put("Form-jButton1-0-1", new Integer(10)); // parentId-compId-dimension-compAlignment
285: prefPadding.put("jScrollPane1-jButton1-0-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
286: prefPadding.put("jButton1-jScrollPane1-0-0-0", new Integer(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
287: prefPadding.put("jToggleButton1-jButton1-0-0-2",
288: new Integer(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
289: // > MOVE
290: {
291: Point p = new Point(71, 48);
292: String containerId = "Form";
293: boolean autoPositioning = true;
294: boolean lockDimension = false;
295: Rectangle[] bounds = new Rectangle[] { new Rectangle(40,
296: 40, 75, 23) };
297: ld.move(p, containerId, autoPositioning, lockDimension,
298: bounds);
299: }
300: // < MOVE
301: // > END MOVING
302: compPrefSize.put("jButton1", new Dimension(75, 23));
303: compPrefSize.put("jButton1", new Dimension(75, 23));
304: prefPaddingInParent.put("Form-jToggleButton1-0-0", new Integer(
305: 10)); // parentId-compId-dimension-compAlignment
306: prefPaddingInParent.put("Form-jButton1-0-0", new Integer(10)); // parentId-compId-dimension-compAlignment
307: ld.endMoving(true);
308: // < END MOVING
309: ld.externalSizeChangeHappened();
310: // > UPDATE CURRENT STATE
311: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
312: compBounds
313: .put("jToggleButton1", new Rectangle(10, 11, 105, 23));
314: baselinePosition.put("jToggleButton1-105-23", new Integer(15));
315: compPrefSize.put("jToggleButton1", new Dimension(105, 23));
316: compBounds.put("jScrollPane1", new Rectangle(121, 11, 104, 64));
317: baselinePosition.put("jScrollPane1-104-64", new Integer(0));
318: compPrefSize.put("jScrollPane1", new Dimension(104, 64));
319: compBounds.put("jButton1", new Rectangle(40, 40, 75, 23));
320: baselinePosition.put("jButton1-75-23", new Integer(15));
321: compPrefSize.put("jButton1", new Dimension(75, 23));
322: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
323: compBounds
324: .put("jToggleButton1", new Rectangle(10, 11, 105, 23));
325: baselinePosition.put("jToggleButton1-105-23", new Integer(15));
326: compBounds.put("jScrollPane1", new Rectangle(121, 11, 104, 64));
327: baselinePosition.put("jScrollPane1-104-64", new Integer(0));
328: compBounds.put("jButton1", new Rectangle(40, 40, 75, 23));
329: baselinePosition.put("jButton1-75-23", new Integer(15));
330: ld.updateCurrentState();
331: // < UPDATE CURRENT STATE
332: }
333:
334: // Resize the button to the left to have same size as the toggle button.
335: // Fixed parallel group with both buttons resizing should be created.
336: public void doChanges1() {
337: // > START RESIZING
338: baselinePosition.put("jButton1-75-23", new Integer(15));
339: compPrefSize.put("jButton1", new Dimension(75, 23));
340: {
341: String[] compIds = new String[] { "jButton1" };
342: Rectangle[] bounds = new Rectangle[] { new Rectangle(40,
343: 40, 75, 23) };
344: Point hotspot = new Point(36, 49);
345: int[] resizeEdges = new int[] { 0, -1 };
346: boolean inLayout = true;
347: ld.startResizing(compIds, bounds, hotspot, resizeEdges,
348: inLayout);
349: }
350: // < START RESIZING
351: prefPaddingInParent.put("Form-jButton1-0-0", new Integer(10)); // parentId-compId-dimension-compAlignment
352: prefPadding.put("jToggleButton1-jButton1-0-0-2",
353: new Integer(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
354: // > MOVE
355: {
356: Point p = new Point(10, 49);
357: String containerId = "Form";
358: boolean autoPositioning = true;
359: boolean lockDimension = false;
360: Rectangle[] bounds = new Rectangle[] { new Rectangle(10,
361: 40, 105, 23) };
362: ld.move(p, containerId, autoPositioning, lockDimension,
363: bounds);
364: }
365: // < MOVE
366: prefPaddingInParent.put("Form-jButton1-0-0", new Integer(10)); // parentId-compId-dimension-compAlignment
367: prefPadding.put("jToggleButton1-jButton1-0-0-2",
368: new Integer(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
369: // > MOVE
370: {
371: Point p = new Point(9, 49);
372: String containerId = "Form";
373: boolean autoPositioning = true;
374: boolean lockDimension = false;
375: Rectangle[] bounds = new Rectangle[] { new Rectangle(10,
376: 40, 105, 23) };
377: ld.move(p, containerId, autoPositioning, lockDimension,
378: bounds);
379: }
380: // < MOVE
381: // > END MOVING
382: compPrefSize.put("jButton1", new Dimension(75, 23));
383: ld.endMoving(true);
384: // < END MOVING
385: ld.externalSizeChangeHappened();
386: // > UPDATE CURRENT STATE
387: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
388: compBounds
389: .put("jToggleButton1", new Rectangle(10, 11, 105, 23));
390: baselinePosition.put("jToggleButton1-105-23", new Integer(15));
391: compPrefSize.put("jToggleButton1", new Dimension(105, 23));
392: compBounds.put("jScrollPane1", new Rectangle(121, 11, 104, 64));
393: baselinePosition.put("jScrollPane1-104-64", new Integer(0));
394: compPrefSize.put("jScrollPane1", new Dimension(104, 64));
395: compBounds.put("jButton1", new Rectangle(10, 40, 105, 23));
396: baselinePosition.put("jButton1-105-23", new Integer(15));
397: compPrefSize.put("jButton1", new Dimension(75, 23));
398: contInterior.put("Form", new Rectangle(0, 0, 400, 300));
399: compBounds
400: .put("jToggleButton1", new Rectangle(10, 11, 105, 23));
401: baselinePosition.put("jToggleButton1-105-23", new Integer(15));
402: compBounds.put("jScrollPane1", new Rectangle(121, 11, 104, 64));
403: baselinePosition.put("jScrollPane1-104-64", new Integer(0));
404: compBounds.put("jButton1", new Rectangle(10, 40, 105, 23));
405: baselinePosition.put("jButton1-105-23", new Integer(15));
406: ld.updateCurrentState();
407: // < UPDATE CURRENT STATE
408: }
409:
410: }
|