Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / ProjectDocumentFactory.java @ 7619

History | View | Annotate | Download (3.43 KB)

1
package com.iver.cit.gvsig.project.documents;
2

    
3
import com.iver.andami.PluginServices;
4

    
5
import com.iver.cit.gvsig.project.Project;
6

    
7
import com.iver.utiles.extensionPoints.ExtensionPoint;
8
import com.iver.utiles.extensionPoints.ExtensionPoints;
9
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
10
import com.iver.utiles.extensionPoints.IExtensionBuilder;
11

    
12
import java.security.KeyException;
13

    
14
import java.util.Map;
15

    
16
import javax.swing.ImageIcon;
17

    
18

    
19
/**
20
 * Factory of ProjectDocument.
21
 *
22
 * @author Vicente Caballero Navarro
23
 */
24
public abstract class ProjectDocumentFactory implements IExtensionBuilder {
25
    /**
26
     * Returns the priority of de ProjectDocument.
27
     *
28
     * @return Priority.
29
     */
30
    public int getPriority() {
31
        return 10;
32
    }
33

    
34
    /**
35
     * Returns image of button.
36
     *
37
     * @return Image button.
38
     */
39
    public abstract ImageIcon getButtonIcon();
40

    
41
    /**
42
     * Returns image of selected button.
43
     *
44
     * @return Image button.
45
     */
46
    public abstract ImageIcon getSelectedButtonIcon();
47

    
48
    /**
49
     * Returns the name of ProjectDocument.
50
     *
51
     * @return Name of ProjectDocument.
52
     */
53
    public String getNameType() {
54
        return PluginServices.getText(this, "documento");
55
    }
56

    
57
    /**
58
     * Create a new ProjectDocument.
59
     *
60
     * @param project Opened project.
61
     *
62
     * @return ProjectDocument.
63
     */
64
    public abstract ProjectDocument create(Project project);
65

    
66
    /**
67
     * Introdece a gui to be able from the characteristics that we want a ProjectDocument
68
     *
69
     * @param project present Project.
70
     *
71
     * @return new ProjectDocument.
72
     */
73
    public ProjectDocument createFromGUI(Project project) {
74
        return create(project);
75
    }
76

    
77
    /**
78
     * Returns the name of registration in the point of extension.
79
     *
80
     * @return Name of registration
81
     */
82
    public abstract String getRegisterName();
83

    
84
    /**
85
     * Create a ProjectDocumentFactory.
86
     *
87
     * @return ProjectDocumentFactory.
88
     */
89
    public Object create() {
90
        return this;
91
    }
92

    
93
    /**
94
     * Create a ProjectDocumentFactory.
95
     *
96
     * @param args
97
     *
98
     * @return ProjectDocumentFactory.
99
     */
100
    public Object create(Object[] args) {
101
        return this;
102
    }
103

    
104
    /**
105
     * Create a ProjectDocumentFactory.
106
     *
107
     * @param args
108
     *
109
     * @return ProjectDocumentFactory.
110
     */
111
    public Object create(Map args) {
112
        return this;
113
    }
114

    
115
    /**
116
     * Registers in the points of extension the Factory with alias.
117
     *
118
     * @param registerName Register name.
119
     * @param obj Class of register.
120
     * @param alias Alias.
121
     */
122
    public static void register(String registerName, Object obj, String alias) {
123
        ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
124
        extensionPoints.add("Documents", registerName, obj);
125

    
126
        ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints.get(
127
                "Documents"));
128

    
129
        try {
130
            extPoint.addAlias(registerName, alias);
131
        } catch (KeyException e) {
132
            e.printStackTrace();
133
        }
134
    }
135

    
136
    /**Registers in the points of extension the Factory
137
     *
138
     * @param registerName Register name.
139
     * @param obj Class of register.
140
     */
141
    public static void register(String registerName, Object obj) {
142
        ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
143
        extensionPoints.add("Documents", registerName, obj);
144
    }
145
}