Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.newlayer / org.gvsig.newlayer.lib / org.gvsig.newlayer.lib.impl / src / main / java / org / gvsig / newlayer / impl / AddNewLayerQuestionPanel.java @ 46873

History | View | Annotate | Download (2.77 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.newlayer.impl;
25

    
26
import java.awt.BorderLayout;
27

    
28
import javax.swing.JCheckBox;
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.newlayer.NewLayerService;
34
import org.gvsig.newlayer.NewLayerWizard;
35

    
36
public class AddNewLayerQuestionPanel extends JPanel implements OptionPanel {
37

    
38
    private static final long serialVersionUID = -5251910576017225307L;
39
    private final NewLayerWizard wizard;
40
    private JCheckBox questionCheckBox = null;
41
    private final String title;
42
    private final String label;
43

    
44
    public AddNewLayerQuestionPanel(NewLayerWizard wizard, String title, String label) {
45
        this.wizard = wizard;
46
        this.title = title;
47
        this.label = label;
48
        initializeComponents();
49
    }
50

    
51
    @Override
52
    public String getPanelTitle() {
53
        return this.title;
54
    }
55

    
56
    @Override
57
    public void nextPanel() throws NotContinueWizardException {
58
        getService().setAddTableToProject(getAddTableToProject());
59
    }
60

    
61
    @Override
62
    public void lastPanel() {
63
        // do nothing
64

    
65
    }
66

    
67
    @Override
68
    public void updatePanel() {
69
        initializeComponents();
70
    }
71

    
72
    @Override
73
    public JPanel getJPanel() {
74
        return this;
75
    }
76

    
77
    private void initializeComponents() {
78
        this.setLayout(new BorderLayout());
79
        this.add(getQuestionCheckBox(), BorderLayout.NORTH);
80
    }
81

    
82
    private JCheckBox getQuestionCheckBox() {
83
        if (this.questionCheckBox == null) {
84
            this.questionCheckBox = new JCheckBox(this.label, true);
85
        }
86
        return this.questionCheckBox;
87
    }
88

    
89
    private NewLayerService getService() {
90
        return this.wizard.getService();
91
    }
92

    
93
    public boolean getAddTableToProject() {
94
        return getQuestionCheckBox().isSelected();
95
    }
96
}