Statistics
| Revision:

root / trunk / extensions / extAnimationGUI / src / com / iver / ai2 / animationgui / gui / document / ProjectAnimationDocumentFactory.java @ 22809

History | View | Annotate | Download (3.07 KB)

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

    
3
import java.text.DateFormat;
4
import java.util.Date;
5
import java.util.Hashtable;
6

    
7
import javax.swing.ImageIcon;
8

    
9
import com.iver.andami.PluginServices;
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.ProjectDocumentFactory;
13
import com.iver.utiles.XMLEntity;
14

    
15
public class ProjectAnimationDocumentFactory extends ProjectDocumentFactory {
16

    
17
        public static String registerName = "ProjectAnimationDocument";
18
        private int numViews = 0;
19
        private boolean createFromGUI;
20
        
21
        public ProjectDocument createFromGUI(Project project) {
22
                createFromGUI = true;
23
                ProjectDocument doc = create(project);
24
                createFromGUI = false;
25
                return doc;
26
        }
27

    
28
        @Override
29
        public ProjectDocument create(Project project) {
30
                String viewName = "";
31
        String aux = PluginServices.getText(this, "untitled");
32
               viewName = aux + " - " + numViews ++;
33

    
34
        if (project != null) {
35
            while (existName(project, viewName)) {
36
                viewName = aux + " - " + numViews++;
37
            }
38
        }
39
//       ProjectDocument.NUMS.put(registerName,new Integer(numViews));
40
       ProjectAnimationDocument Animation = createAnimation(viewName);
41
                
42
                if (Animation != null)
43
                        Animation.setProject(project, 0);
44

    
45
                return Animation;
46
        }
47
        
48

    
49
        /**
50
         * This method creates a new instance of animation
51
         * @param animationName
52
         * @return
53
         */
54
        private ProjectAnimationDocument createAnimation(String animationName) {
55
                 ProjectAnimationDocument animation = new ProjectAnimationDocument();
56
                 animation.setName(animationName);
57
                 animation.setCreationDate(DateFormat.getInstance().format(new Date()));
58
                return animation;
59
        }
60

    
61
        @Override
62
        public ImageIcon getButtonIcon() {
63
                return new ImageIcon(this.getClass().getClassLoader().getResource(
64
                "images/animation.png"));
65
        }
66

    
67
        @Override
68
        public String getRegisterName() {
69
                // TODO Auto-generated method stub
70
                return this.registerName;
71
        }
72

    
73
        @Override
74
        public ImageIcon getSelectedButtonIcon() {
75
                return new ImageIcon(this.getClass().getClassLoader().getResource(
76
                "images/animation_sel.png"));
77
        }
78

    
79
        @Override
80
        public boolean resolveImportXMLConflicts(XMLEntity root, Project project,
81
                        Hashtable conflicts) {
82
                // TODO Auto-generated method stub
83
                return false;
84
        }
85
        
86
        /**
87
         * Registers in the points of extension the Factory with alias.
88
         * 
89
         */
90
        public static void register() {
91
                register(registerName , new ProjectAnimationDocumentFactory());
92
        }
93
        
94
        /**
95
         * Returns the priority of de ProjectDocument.
96
         * 
97
         * @return Priority.
98
         */
99
        public int getPriority() {
100
                return 40;
101
        }
102

    
103
        /**
104
         * Returns the priority of the Document in the ProjectWindow list.
105
         * 
106
         * @return Priority.
107
         */
108
        public int getListPriority() {
109
                return 40; // so the 3D View appears before other document types
110
        }
111
        
112

    
113
        /**
114
         * Returns the name of ProjectDocument.
115
         * 
116
         * @return Name of ProjectDocument.
117
         */
118
        public String getNameType() {
119
                return "Animation";
120
        }
121

    
122
}