Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.xml2db / org.gvsig.xml2db.swing / org.gvsig.xml2db.swing.impl / src / main / java / org / gvsig / xml2db / swing / impl / Xml2dbSwingManagerImpl.java @ 47245

History | View | Annotate | Download (3.16 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright (c) 2007-2020 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.xml2db.swing.impl;
24

    
25
import java.net.URL;
26
import javax.swing.ImageIcon;
27
import org.apache.commons.io.FilenameUtils;
28
import org.gvsig.tools.swing.api.ToolsSwingLocator;
29
import org.gvsig.tools.swing.icontheme.IconTheme;
30
import org.gvsig.xml2db.swing.Xml2dbPanel;
31
import org.gvsig.xml2db.swing.Xml2dbSwingManager;
32
import org.gvsig.xml2db.swing.impl.copyxml2db.CopyXml2dbPanel;
33
import org.gvsig.xml2db.swing.impl.createdbfromxml.CreatedbFromXmlPanel;
34
import org.gvsig.xml2db.swing.impl.importxml2db.ImportXML2dbPanel;
35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

    
38
/**
39
 * @author gvSIG Team
40
 *
41
 */
42
public class Xml2dbSwingManagerImpl implements Xml2dbSwingManager {
43
    
44
    private static final Logger LOGGER = LoggerFactory.getLogger(Xml2dbSwingManagerImpl.class);
45
    
46
    public static final String ICON_GROUP_NAME = "Xml2db";
47
    public static final String ICON_PROVIDER_NAME = "Xml2db";
48
    
49
    public Xml2dbSwingManagerImpl() {
50
    }
51
    
52
    public static void registerIcons(String[][] iconsInfo) {
53
        IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent();
54
        for (String[] icon : iconsInfo) {
55
            // 0 - Provider, 1 - Group, 2 - Name
56
            URL url = Xml2dbSwingManagerImpl.class.getResource("images/"+ icon[2] + ".png");
57
            theme.registerDefault(icon[0], icon[1], icon[2], null, url);
58
        }
59
    }
60
    
61
    public static ImageIcon loadImage(String imageName) {
62
        String name = FilenameUtils.getBaseName(imageName);
63
        IconTheme theme = ToolsSwingLocator.getIconThemeManager().getDefault();
64
        if (theme.exists(name)) {
65
            return theme.get(name);
66
        }
67
        URL url = Xml2dbSwingManagerImpl.class.getResource("images/"+name + ".png");
68
        if (url == null) {
69
            return null;
70
        }
71
        return new ImageIcon(url);
72
    }    
73

    
74
    @Override
75
    public Xml2dbPanel createCreatedbPanel() {
76
        Xml2dbPanel x = new CreatedbFromXmlPanel();
77
        return x;
78
    }
79

    
80
    @Override
81
    public Xml2dbPanel createImportXml2dbPanel() {
82
        Xml2dbPanel x = new ImportXML2dbPanel();
83
        return x;
84
    }
85

    
86
    @Override
87
    public Xml2dbPanel createCopyXml2dbPanel() {
88
        Xml2dbPanel x = new CopyXml2dbPanel();
89
        return x;
90
    }
91
        
92
}