Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.spi / src / main / java / org / gvsig / exportto / swing / spi / AbstractExporttoProviderFactory.java @ 37887

History | View | Annotate | Download (3.37 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.exportto.swing.spi;
23

    
24
import org.gvsig.fmap.dal.DataTypes;
25
import org.gvsig.fmap.dal.feature.FeatureStore;
26
import org.gvsig.i18n.Messages;
27
import org.gvsig.tools.ToolsLocator;
28
import org.gvsig.tools.dynobject.DynClass;
29
import org.gvsig.tools.dynobject.DynObject;
30
import org.gvsig.tools.service.ServiceException;
31

    
32
/**
33
 * Abstract parent class for {@link ExporttoSwingProviderFactory} implementation
34
 * classes.
35
 * 
36
 * @author gvSIG Team
37
 * @version $Id$
38
 */
39
public abstract class AbstractExporttoProviderFactory implements
40
    ExporttoSwingProviderFactory {
41

    
42
    protected static final String PARAMETER_FEATURESTORE = "FeatureStore";
43
    protected static final String PARAMETER_PROJECTION = "Projection";
44
    protected DynClass parametersDefinition;
45
    protected int[] providerTypes = null;
46

    
47
    /**
48
     * Constructor.
49
     * 
50
     * @param providerTypes
51
     *            supported provider types
52
     */
53
    public AbstractExporttoProviderFactory(int[] providerTypes) {
54
        this.providerTypes = providerTypes;
55
    }
56

    
57
    public DynObject createParameters() {
58
        return ToolsLocator.getDynObjectManager().createDynObject(
59
            parametersDefinition);
60
    }
61

    
62
    public void initialize() {
63
        parametersDefinition =
64
            ToolsLocator.getDynObjectManager().createDynClass(getName(),
65
                getDescription());
66
        parametersDefinition.addDynField(PARAMETER_FEATURESTORE)
67
            .setType(DataTypes.OBJECT).setMandatory(true)
68
            .setClassOfValue(FeatureStore.class);
69
        parametersDefinition.addDynField(PARAMETER_PROJECTION)
70
            .setType(DataTypes.CRS).setMandatory(false);
71
    }
72

    
73
    public boolean support(int providerType) throws ServiceException {
74
        for (int i = 0; i < providerTypes.length; i++) {
75
            if (providerTypes[i] == providerType) {
76
                return true;
77
            }
78
        }
79
        return false;
80
    }
81

    
82
    public String getDescription() {
83
        return Messages.getText("general_exporter_description",
84
            new String[] { getName() });
85
    }
86

    
87
    public String getLabel() {
88
        return Messages.getText("general_exporter_label",
89
            new String[] { getName() });
90
    }
91

    
92
    @Override
93
    public String toString() {
94
        return getLabel();
95
    }
96

    
97
    public boolean isEnabled() {
98
        return ExporttoSwingProviderLocator.getManager().isProviderEnabled(this);
99
    }
100

    
101
    public void setEnabled(boolean value) {
102
        ExporttoSwingProviderLocator.getManager().enableProvider(this, value);
103
    }
104

    
105
}