Statistics
| Revision:

root / trunk / extensions / extAnimationGUI / src / com / iver / ai2 / animationgui / gui / document / ProjectAnimationDocument.java @ 20095

History | View | Annotate | Download (3.8 KB)

1
package com.iver.ai2.animationgui.gui.document;
2

    
3
import java.util.Iterator;
4

    
5
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
6
import com.iver.andami.messages.NotificationManager;
7
import com.iver.andami.ui.mdiManager.IWindow;
8
import com.iver.cit.gvsig.animation.AnimationContainer;
9
import com.iver.cit.gvsig.fmap.layers.XMLException;
10
import com.iver.cit.gvsig.project.Project;
11
import com.iver.cit.gvsig.project.documents.ProjectDocument;
12
import com.iver.cit.gvsig.project.documents.exceptions.OpenException;
13
import com.iver.cit.gvsig.project.documents.exceptions.SaveException;
14
import com.iver.utiles.IPersistence;
15
import com.iver.utiles.XMLEntity;
16

    
17
public class ProjectAnimationDocument extends ProjectDocument {
18

    
19
        AnimationContainer animationContainer;
20

    
21
        public ProjectAnimationDocument() {
22
                super();
23
                this.animationContainer = new AnimationContainer();
24
        }
25

    
26
        @Override
27
        public void afterAdd() {
28
                // TODO Auto-generated method stub
29

    
30
        }
31

    
32
        @Override
33
        public void afterRemove() {
34
                // TODO Auto-generated method stub
35

    
36
        }
37

    
38
        @Override
39
        public IWindow createWindow() {
40
                // TODO Auto-generated method stub
41
                // Introduce here the code to make the gui.
42
                return new Animation(this);
43
        }
44

    
45
        @Override
46
        public void exportToXML(XMLEntity root, Project project) {
47
                // TODO Auto-generated method stub
48
        }
49

    
50
        @Override
51
        public IWindow getProperties() {
52
                // TODO Auto-generated method stub
53
                // Introduce here the code to make the gui for the properties.
54
                return new AnimationProperties(this, false);
55
        }
56

    
57
        @Override
58
        public void importFromXML(XMLEntity root, XMLEntity typeRoot,
59
                        int elementIndex, Project project, boolean removeDocumentsFromRoot) {
60
                // TODO Auto-generated method stub
61

    
62
        }
63

    
64
        public AnimationContainer getAnimationContainer() {
65
                return animationContainer;
66
        }
67

    
68
        public void setAnimationContainer(AnimationContainer animationContainer) {
69
                this.animationContainer = animationContainer;
70
        }
71

    
72
        public XMLEntity getXMLEntity() {
73
                XMLEntity xml = null;
74
                try {
75
                        xml = super.getXMLEntity();
76
                        xml.addChild(this.animationContainer.getXMLEntity());
77
                } catch (SaveException e) {
78
                        // TODO Auto-generated catch block
79
                        e.printStackTrace();
80
                }
81
                return xml;
82
        }
83

    
84
        public void setXMLEntity(XMLEntity xml) {
85
                // Busqueda de un hijo a partir de su nombre.
86
                // Node AnimationContainer in the animation tree. Calling setXmlEntity()
87
                // methods.
88
                // Reconstruyendo el framework. Primer paso: nuevo container para
89
                // almacenar.
90
                try {
91
                        super.setXMLEntity(xml);
92

    
93
                        int animations = 0;
94
                        Iterator<XMLEntity> iterator = xml.findChildren(
95
                                        "animationContainer", "true");
96
                        if (iterator.hasNext()) {
97
                                XMLEntity xmlAC = iterator.next();
98
                                animations++;
99
                                        String classAC = xmlAC.getStringProperty("className");
100
                                        Class<?> clase = Class.forName(classAC);
101
                                        animationContainer = (AnimationContainer) clase
102
                                                        .newInstance();
103
                        }
104

    
105
                        // Crear objeto a partir de su clase.
106
                        Iterator<XMLEntity> iterXML = xml.findChildren("className",
107
                                        "com.iver.cit.gvsig.animation.AnimationContainer");
108
                        if (iterXML.hasNext()) {
109
                                ((IPersistence) animationContainer)
110
                                                .setXMLEntity((XMLEntity) iterXML.next());
111
                        }
112

    
113
                } catch (XMLException e1) {
114
                        // TODO Auto-generated catch block
115
                        e1.printStackTrace();
116
                } catch (OpenException e1) {
117
                        // TODO Auto-generated catch block
118
                        e1.printStackTrace();
119
                } catch (ReadDriverException e1) {
120
                        // TODO Auto-generated catch block
121
                        e1.printStackTrace();
122
                } catch (InstantiationException e) {
123
                        // TODO Auto-generated catch block
124
                        e.printStackTrace();
125
                } catch (IllegalAccessException e) {
126
                        // TODO Auto-generated catch block
127
                        e.printStackTrace();
128
                } catch (ClassNotFoundException e) {
129
                        // TODO Auto-generated catch block
130
                        e.printStackTrace();
131
                }
132

    
133
        }
134

    
135
}