1 4 package org.oddjob.designer.model; 5 6 import org.oddjob.OddjobException; 7 import org.oddjob.arooa.reflect.IntrospectionHelper; 8 import org.oddjob.designer.DesignerXMLParser; 9 10 13 public class TransferComponentAction implements ComponentAction { 14 15 private final String name; 16 private final String xml; 17 private final DesignComponent designComponent; 18 private final String element; 19 20 public TransferComponentAction(DesignComponent designComponent, 21 String xml, String name, String element) { 22 if (name == null) { 23 throw new NullPointerException ("name!"); 24 } 25 if (xml == null) { 26 throw new NullPointerException ("xml!"); 27 } 28 if (designComponent == null) { 29 throw new NullPointerException ("designComponent!"); 30 } 31 if (element == null) { 32 throw new NullPointerException ("element!"); 33 } 34 this.name = name; 35 this.xml = xml; 36 this.designComponent = designComponent; 37 this.element = element; 38 } 39 40 43 public String getName() { 44 return name; 45 } 46 47 50 public void perform() { 51 DesignComponent child = null; 52 try { 53 child = DesignerXMLParser.buildComponent(xml); 54 } catch (Exception e) { 55 throw new OddjobException("Failed to transfer data [" + xml 56 + "] (" + e.getMessage() + ")", e); 57 } 58 IntrospectionHelper ih = IntrospectionHelper 59 .getHelper(designComponent.getClass()); 60 ih.storeComponent(designComponent, child, element); 61 } 62 } 63 | Popular Tags |