Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / packagebuilder / options / PackageInfoOption.java @ 42528

History | View | Annotate | Download (3.68 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.installer.swing.impl.packagebuilder.options;
25

    
26

    
27
import java.io.File;
28
import javax.swing.JOptionPane;
29
import javax.swing.JPanel;
30

    
31
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
32
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
33
import org.gvsig.i18n.Messages;
34
import org.gvsig.installer.swing.api.SwingInstallerLocator;
35
import org.gvsig.installer.swing.api.SwingInstallerManager;
36
import org.gvsig.installer.swing.api.creation.JPackageInfoPanel;
37
import org.gvsig.installer.swing.impl.packagebuilder.BasePackageWizard;
38
import org.gvsig.tools.ToolsLocator;
39
import org.gvsig.tools.packageutils.PackageManager;
40
import org.slf4j.Logger;
41
import org.slf4j.LoggerFactory;
42

    
43

    
44
public class PackageInfoOption implements OptionPanel {
45

    
46
    private static final Logger logger = LoggerFactory.getLogger(PackageInfoOption.class);
47
    
48
    private final JPackageInfoPanel packageInfoPanel;
49

    
50
    private final BasePackageWizard wizard;
51

    
52
    public PackageInfoOption(BasePackageWizard wizard) {
53
        super();
54
        this.wizard = wizard;
55
        SwingInstallerManager installerManager = SwingInstallerLocator.getSwingInstallerManager();
56

    
57
        this.packageInfoPanel = installerManager.createPackageInfoPanel();
58
    }
59

    
60
    private String getText(String msg) {
61
        return Messages.getText(msg);
62
    }
63

    
64
    @Override
65
    public JPanel getJPanel() {
66
        return this.packageInfoPanel;
67
    }
68

    
69
    @Override
70
    public String getPanelTitle() {
71
        return getText("_package_description");
72
    }
73

    
74
    @Override
75
    public void lastPanel() {
76
        // TODO Auto-generated method stub
77

    
78
    }
79

    
80
    @Override
81
    public void nextPanel() throws NotContinueWizardException {
82
        if (!this.packageInfoPanel.validatePanel()) {
83
            throw new NotContinueWizardException("", null, false);
84
        }
85
        this.packageInfoPanel.panelToPackageInfo(this.wizard.getPackageInfo());
86
        PackageManager pkgmgr = ToolsLocator.getPackageManager();
87
        File fileout = new File(wizard.getFolderToPackaging(),"package.info");
88
        try {
89
            pkgmgr.writePacakgeInfo(
90
                    (org.gvsig.tools.packageutils.PackageInfo)(wizard.getPackageInfo()),
91
                    fileout
92
            );
93
        } catch (Exception ex) {
94
            logger.warn("Can't save package information (file="+fileout.getAbsolutePath()+").",ex);
95
            JOptionPane.showMessageDialog(
96
                    null, 
97
                    Messages.getText("_cant_save_package_information_in_the_selected_folder"),
98
                    Messages.getText("_Warning"),
99
                    JOptionPane.INFORMATION_MESSAGE
100
            );
101
        }
102
    }
103

    
104
    @Override
105
    public void updatePanel() {
106
        this.packageInfoPanel.packageInfoToPanel(this.wizard.getPackageInfo());
107
    }
108

    
109
}