1 package org.netbeans.modules.xml.xam; 2 3 import java.util.List ; 4 5 9 public class TestComponent extends AbstractComponent<TestComponent> implements NamedReferenceable<TestComponent>, Cloneable { 10 int index; 11 String value; 12 13 public TestComponent(TestModel model, int index) { 14 super(model); 15 this.index = index; 16 } 17 18 public String toString() { return getName(); } 19 public String getName() { return "test"; } 20 21 protected void populateChildren(List <TestComponent> children) { 22 children.add(new A(getModel(), 1)); 23 children.add(new A(getModel(), 2)); 24 children.add(new A(getModel(), 3)); 25 } 26 27 public void setValue(String v) { 28 String old = value; 29 this.value = v; 30 super.firePropertyChange("value", old, value); 31 super.fireValueChanged(); 32 } 33 public String getValue() { 34 return value; 35 } 36 37 public void setIndex(int index) { 38 this.index = index; 39 } 40 public int getIndex() { 41 return index; 42 } 43 44 public static class A extends TestComponent { 45 public A(TestModel model, int i) { 46 super(model, i); 47 this.index = i; 48 } 49 public String getName() { return "a"+index; } 50 } 51 52 public static class B extends TestComponent { 53 public B(TestModel model, int i) { 54 super(model, i); 55 this.index = i; 56 } 57 public String getName() { return "b"+index; } 58 } 59 60 public static class C extends TestComponent { 61 public C(TestModel model, int i) { 62 super(model, i); 63 this.index = i; 64 } 65 public String getName() { return "c"+index; } 66 } 67 68 public TestModel getModel() { 69 return (TestModel) super.getModel(); 70 } 71 72 protected void insertAtIndexQuietly(TestComponent newComponent, List <TestComponent> children, int index) { 73 children.add(index, newComponent); 74 } 75 76 public Component copy(TestComponent parent) { 77 try { 78 return (Component) this.clone(); 79 } catch(CloneNotSupportedException ex) { 80 return null; 81 } 82 } 83 84 protected void removeChildQuietly(TestComponent component, List <TestComponent> children) { 85 children.remove(component); 86 } 87 88 protected void appendChildQuietly(TestComponent component, List <TestComponent> children) { 89 children.add(component); 90 } 91 92 } 93 | Popular Tags |