Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.impl / src / main / java / org / gvsig / featureform / swing / impl / dynformfield / ImageFile / JDynFormFieldImageFileFactory.java @ 44644

History | View | Annotate | Download (2.64 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.featureform.swing.impl.dynformfield.ImageFile;
25

    
26
import java.net.URL;
27
import org.gvsig.featureform.swing.impl.DefaultJFeaturesForm;
28
import org.gvsig.tools.dataTypes.DataTypes;
29
import org.gvsig.tools.dynform.DynFormFieldDefinition;
30
import org.gvsig.tools.dynform.JDynFormField;
31
import org.gvsig.tools.dynform.spi.DynFormSPILocator;
32
import org.gvsig.tools.dynform.spi.DynFormSPIManager;
33
import org.gvsig.tools.dynform.spi.dynformfield.AbstractJDynFormFieldFactory;
34
import org.gvsig.tools.swing.api.ToolsSwingLocator;
35
import org.gvsig.tools.swing.icontheme.IconTheme;
36

    
37
public class JDynFormFieldImageFileFactory extends AbstractJDynFormFieldFactory {
38

    
39
    public JDynFormFieldImageFileFactory() {
40
        super("IMAGE_FILE", DataTypes.FILE, "Image");
41
    }
42

    
43
    @Override
44
    public JDynFormField create(
45
            DynFormSPIManager serviceManager,
46
            DynFormSPIManager.ComponentsFactory componentsFactory,
47
            DynFormFieldDefinition fieldDefinition,
48
            Object value
49
    ) {
50
        return new JDynFormFieldImageFile(serviceManager, componentsFactory, this, fieldDefinition, value);
51
    }
52
    
53
    public static void selfRegister() {
54
        DynFormSPIManager manager = DynFormSPILocator.getDynFormSPIManager();
55
        manager.registerDynFieldFactory(new JDynFormFieldImageFileFactory());
56
        String[][] iconNames = new String[][]{
57
            new String[]{"dalswing", "form-open-image"}
58
        };
59
        IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent();
60
        for (String[] icon : iconNames) {
61
            URL url = DefaultJFeaturesForm.class.getResource(icon[1] + ".png");
62
            theme.registerDefault("DALSwing", icon[0], icon[1], null, url);
63
        }
64
    }
65
}