01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jface.tests.performance;
11:
12: public class TestTreeElement extends TestElement {
13:
14: TestTreeElement parent;
15:
16: TestTreeElement[] children = new TestTreeElement[0];
17:
18: private static int index = 0;
19:
20: static String characters = "M1NqBwV2CeXrZ3LtKyJ4HuGiF5DoSpA6PaOsI7UdYfT8RgEhW9Qjk0DlWzMxUcsvfbwnm";
21:
22: /**
23: * Create a new instance of the receiver .
24: *
25: * @param index
26: * @param treeParent
27: */
28: public TestTreeElement(int index, TestTreeElement treeParent) {
29: super ();
30: this .parent = treeParent;
31: name = generateFirstEntry() + String.valueOf(index);
32: }
33:
34: /**
35: * Generate a random string.
36: *
37: * @return String
38: */
39: static String generateFirstEntry() {
40:
41: String next = characters.substring(index);
42: index++;
43: if (index > characters.length() - 2)
44: index = 0;
45: return next;
46: }
47:
48: /**
49: * Create count number of children in the receiver.
50: *
51: * @param count
52: */
53: public void createChildren(int count) {
54: children = new TestTreeElement[count];
55: for (int i = 0; i < count; i++) {
56: children[i] = new TestTreeElement(i, this);
57: }
58: }
59:
60: }
|