List of usage examples for java.beans.beancontext BeanContextSupport BeanContextSupport
public BeanContextSupport()
From source file:MembershipTest.java
public static void main(String[] args) { BeanContextSupport context = new BeanContextSupport(); // the context MyMembershipListener listener = new MyMembershipListener(); BeanContextChildSupport bean = new BeanContextChildSupport(); // a JavaBean context.addBeanContextMembershipListener(listener); // now listening! context.add(bean);//from ww w. ja va2 s . com context.remove(bean); }
From source file:Example3.java
public static void main(String[] args) { BeanContextSupport context = new BeanContextSupport(); System.out.println("Number of children nested into the context: " + context.size()); BeanContextChildSupport child = null; try {/*from www . ja v a 2 s . c o m*/ child = (BeanContextChildSupport) context .instantiateChild("java.beans.beancontext.BeanContextChildSupport"); } catch (IOException e) { System.out.println("IOException occurred: " + e.getMessage()); } catch (ClassNotFoundException e) { System.out.println("Class not found: " + e.getMessage()); } System.out.println("Number of children nested into the context: " + context.size()); }
From source file:MembershipTest.java
public static void main(String[] args) { BeanContextSupport context = new BeanContextSupport(); // the context MyMembershipListener listener = new MyMembershipListener(); BeanContextChildSupport bean = new BeanContextChildSupport(); // a // JavaBean/*from w w w.ja v a 2 s . co m*/ context.addBeanContextMembershipListener(listener); // now listening! context.add(bean); context.remove(bean); }
From source file:Example2.java
public static void main(String[] args) { // A BeanContext BeanContextSupport context = new BeanContextSupport(); // Many JavaBeans BeanContextChildSupport[] beans = new BeanContextChildSupport[100]; System.out.println("Number of children in the context: " + context.size()); // Create the beans and add them to the context for (int i = 0; i < beans.length; i++) { beans[i] = new BeanContextSupport(); context.add(beans[i]);//from ww w. j ava 2 s. c o m } System.out.println("Number of children in the context: " + context.size()); // Context now has 100 beans in it, get references to them all Object[] children = context.toArray(); System.out.println("Number of objects retrieved from the context: " + children.length); }
From source file:net.team2xh.crt.gui.entities.EntityTree.java
public void loadScene(Scene scene) { // Entities/* w ww . jav a2s . c o m*/ List<Node> entities = new LinkedList<>(); for (Entity e : scene.getEntities()) { try { // TODO: Some way of differentiating similar objects in a scene // Counter ? maybe keep track of named variables entities.add(new DynamicNode(e) { @Override public String getHtmlDisplayName() { return getDisplayName() + " <font color='!controlShadow'><i>" + StringEscapeUtils.escapeHtml3(e.getCenter().toString()) + "</i></font>"; } }); } catch (IntrospectionException ex) { Exceptions.printStackTrace(ex); } } Children entitiesChildren = new Children.Array(); entitiesChildren.add(entities.toArray(new Node[0])); for (Node n : entitiesChildren.getNodes()) { } Node entitiesNode = createNode(entitiesChildren, ICON_ENTITIES); entitiesNode.setDisplayName("Entities"); entitiesNode.setShortDescription("The entities present in the compiled scene."); // Lights BeanContext lights = new BeanContextSupport(); for (Light l : scene.getLights()) { lights.add(l); } Children lightsChildren = new BeanChildren(lights); Node lightsNode = createNode(lightsChildren, ICON_LIGHTS); lightsNode.setDisplayName("Lights"); lightsNode.setShortDescription("The lights present in the compiled scene."); // Scene Children sceneChildren = new Children.Array(); sceneChildren.add(new Node[] { lightsNode, entitiesNode }); Node root = createNode(sceneChildren, ICON_SCENE); root.setDisplayName("Scene"); root.setShortDescription("The current scene after execution of the script."); manager.setRootContext(root); SwingUtilities.invokeLater(() -> { tree.expandAll(); }); }