Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.impl / src / main / java / org / gvsig / exportto / swing / impl / wizard / ExporterSelectionWizard.java @ 38187

History | View | Annotate | Download (3.87 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.impl.wizard;
23

    
24
import javax.swing.JPanel;
25
import javax.swing.event.ListSelectionEvent;
26
import javax.swing.event.ListSelectionListener;
27

    
28
import org.slf4j.Logger;
29
import org.slf4j.LoggerFactory;
30

    
31
import org.gvsig.exportto.swing.ExporttoSwingLocator;
32
import org.gvsig.exportto.swing.ExporttoSwingManager;
33
import org.gvsig.exportto.swing.impl.DefaultJExporttoServicePanel;
34
import org.gvsig.exportto.swing.impl.panel.ProviderSelectionPanel;
35
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderFactory;
36
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderLocator;
37
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderManager;
38
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
39
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
40
import org.gvsig.tools.service.ServiceException;
41

    
42
/**
43
 * @author gvSIG Team
44
 * @version $Id$
45
 * 
46
 */
47
public class ExporterSelectionWizard extends ProviderSelectionPanel implements
48
    OptionPanel, ListSelectionListener {
49

    
50
    private static final long serialVersionUID = -2818813233378801919L;
51
    private static final ExporttoSwingManager EXPORTTO_SWING_MANAGER =
52
        ExporttoSwingLocator.getSwingManager();
53
    private static final ExporttoSwingProviderManager EXPORTTO_SWING_PROVIDER_MANAGER =
54
        ExporttoSwingProviderLocator.getManager();
55
    private static final Logger LOG = LoggerFactory
56
        .getLogger(ExporterSelectionWizard.class);
57

    
58
    public ExporterSelectionWizard(
59
        DefaultJExporttoServicePanel exporttoServicePanel, int[] providerTypes) {
60
        super(exporttoServicePanel, providerTypes);
61
        this.exporttoProviderList.addListSelectionListener(this);
62
    }
63

    
64
    public String getPanelTitle() {
65
        return exporttoServicePanel.getExporttoSwingManager().getTranslation(
66
            "select_format_to_export");
67
    }
68

    
69
    public void nextPanel() throws NotContinueWizardException {
70
        ExporttoSwingProviderFactory providerFactory = this.getSelectedProvider();
71

    
72
        if (providerFactory != null) {
73
            try {
74
                exporttoServicePanel.selectExporttoSwingProvider(providerFactory);
75
            } catch (ServiceException e) {
76
                LOG.error("Not possible to create a exporto swing provider", e);
77
                throw new NotContinueWizardException(
78
                    EXPORTTO_SWING_MANAGER
79
                        .getTranslation("execute_adding_error"),
80
                    e, this);
81
            }
82
        }
83
    }
84

    
85
    public void lastPanel() {
86
        // Nothing to do
87
    }
88

    
89
    public void updatePanel() {
90
        // Nothing to do
91
    }
92

    
93
    public JPanel getJPanel() {
94
        return this;
95
    }
96

    
97
    public void valueChanged(ListSelectionEvent e) {
98
        ExporttoSwingProviderFactory providerFactory = this.getSelectedProvider();
99

    
100
        if (providerFactory != null) {
101
            descriptionText.setText(EXPORTTO_SWING_PROVIDER_MANAGER
102
                .getDescription(providerFactory.getName()));
103

    
104
            exporttoServicePanel.setNextButtonEnabled(true);
105
        }
106
    }
107
}