/** * Installs a factory * @param factory the new factory */ public void addFactory( DockablePropertyFactory factory ){ factories.put( factory.getID(), factory ); }
throw new IOException( "Unknown factory-id: " + id ); DockableProperty temp = factory.createProperty();
throw new IOException( "Unknown factory-id: " + id ); DockableProperty temp = factory.createProperty();
/** * Installs a factory * @param factory the new factory */ public void addFactory( DockablePropertyFactory factory ){ factories.put( factory.getID(), factory ); }
/** * Reads a {@link DockableProperty} and its successors from an xml element. * @param element the element to read from * @return the property or <code>null</code> if <code>element</code> is empty * @throws IllegalArgumentException if a {@link DockablePropertyFactory} is missing. */ public DockableProperty readXML( XElement element ){ DockableProperty base = null; DockableProperty property = null; for (XElement xnode : element.getElements( "property" )) { DockablePropertyFactory factory = factories.get( xnode.getString( "factory" ) ); if (factory == null) throw new IllegalArgumentException( "Missing factory: " + xnode.getString( "factory" ) ); DockableProperty next = factory.createProperty(); next.load( xnode ); if (property == null) { property = next; base = next; } else { property.setSuccessor( next ); property = next; } } return base; } }
/** * Creates a new transformer and installs <code>factories</code>. * @param factories a list of factories to install * @param controller the controller in whose realm this transformer is used */ public PropertyTransformer( DockController controller, DockablePropertyFactory... factories ){ for (DockablePropertyFactory factory : factories){ this.factories.put( factory.getID(), factory ); } List<DockablePropertyFactory> extensions = controller.getExtensions().load( new ExtensionName<DockablePropertyFactory>( FACTORY_EXTENSION, DockablePropertyFactory.class, FACTORY_EXTENSION_PARAMETER, this ) ); for( DockablePropertyFactory factory : extensions ){ this.factories.put( factory.getID(), factory ); } }
/** * Reads a {@link DockableProperty} and its successors from an xml element. * @param element the element to read from * @return the property or <code>null</code> if <code>element</code> is empty * @throws IllegalArgumentException if a {@link DockablePropertyFactory} is missing. */ public DockableProperty readXML( XElement element ){ DockableProperty base = null; DockableProperty property = null; for (XElement xnode : element.getElements( "property" )) { DockablePropertyFactory factory = factories.get( xnode.getString( "factory" ) ); if (factory == null) throw new IllegalArgumentException( "Missing factory: " + xnode.getString( "factory" ) ); DockableProperty next = factory.createProperty(); next.load( xnode ); if (property == null) { property = next; base = next; } else { property.setSuccessor( next ); property = next; } } return base; } }
/** * Creates a new transformer and installs <code>factories</code>. * @param factories a list of factories to install * @param controller the controller in whose realm this transformer is used */ public PropertyTransformer( DockController controller, DockablePropertyFactory... factories ){ for (DockablePropertyFactory factory : factories){ this.factories.put( factory.getID(), factory ); } List<DockablePropertyFactory> extensions = controller.getExtensions().load( new ExtensionName<DockablePropertyFactory>( FACTORY_EXTENSION, DockablePropertyFactory.class, FACTORY_EXTENSION_PARAMETER, this ) ); for( DockablePropertyFactory factory : extensions ){ this.factories.put( factory.getID(), factory ); } }