Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.downloader / org.gvsig.downloader.swing / org.gvsig.downloader.swing.impl / src / main / java / org / gvsig / downloader / swing / impl / DownloaderSwingManagerImpl.java @ 47821

History | View | Annotate | Download (2.9 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.downloader.swing.impl;
24

    
25
import java.net.URL;
26
import javax.swing.ImageIcon;
27
import org.apache.commons.io.FilenameUtils;
28
import org.gvsig.downloader.swing.DownloaderConfigPanel;
29
import org.gvsig.downloader.swing.DownloaderSwingManager;
30
import org.gvsig.downloader.swing.impl.config.DownloaderConfigPanelImpl;
31
import org.gvsig.tools.swing.api.Component;
32
import org.gvsig.tools.swing.api.ToolsSwingLocator;
33
import org.gvsig.tools.swing.icontheme.IconTheme;
34
import org.slf4j.Logger;
35
import org.slf4j.LoggerFactory;
36

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

    
73
    @Override
74
    public DownloaderConfigPanel createDownloaderConfigPanel() {
75
        DownloaderConfigPanelImpl c = new DownloaderConfigPanelImpl();
76
        return c;
77
    }
78
        
79
}