KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > designer > model > TransferComponentAction


1 /*
2  * (c) Rob Gordon 2005
3  */

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 /**
11  *
12  */

13 public class TransferComponentAction implements ComponentAction {
14
15     private final String JavaDoc name;
16     private final String JavaDoc xml;
17     private final DesignComponent designComponent;
18     private final String JavaDoc element;
19     
20     public TransferComponentAction(DesignComponent designComponent,
21             String JavaDoc xml, String JavaDoc name, String JavaDoc element) {
22         if (name == null) {
23             throw new NullPointerException JavaDoc("name!");
24         }
25         if (xml == null) {
26             throw new NullPointerException JavaDoc("xml!");
27         }
28         if (designComponent == null) {
29             throw new NullPointerException JavaDoc("designComponent!");
30         }
31         if (element == null) {
32             throw new NullPointerException JavaDoc("element!");
33         }
34         this.name = name;
35         this.xml = xml;
36         this.designComponent = designComponent;
37         this.element = element;
38     }
39     
40     /* (non-Javadoc)
41      * @see org.oddjob.designer.model.ComponentAction#getName()
42      */

43     public String JavaDoc getName() {
44         return name;
45     }
46     
47     /* (non-Javadoc)
48      * @see org.oddjob.designer.model.ComponentAction#perform()
49      */

50     public void perform() {
51         DesignComponent child = null;
52         try {
53             child = DesignerXMLParser.buildComponent(xml);
54         } catch (Exception JavaDoc 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