Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.newlayer / org.gvsig.newlayer.prov / org.gvsig.newlayer.prov.generic / src / main / java / org / gvsig / newlayer / prov / generic / panels / SelectStoreTypePanel.java @ 40560

History | View | Annotate | Download (2.8 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.prov.generic.panels;
25

    
26
import java.awt.BorderLayout;
27
import java.util.List;
28

    
29
import javax.swing.JList;
30
import javax.swing.JScrollPane;
31
import javax.swing.ListModel;
32
import javax.swing.event.ListSelectionEvent;
33
import javax.swing.event.ListSelectionListener;
34

    
35
import org.gvsig.i18n.Messages;
36
import org.gvsig.newlayer.NewLayerProvider;
37
import org.gvsig.newlayer.prov.generic.NewLayerGenericProviderPanel;
38
import org.gvsig.utils.DefaultListModel;
39

    
40
public class SelectStoreTypePanel extends NewLayerGenericProviderPanel{
41

    
42
        /**
43
         * 
44
         */
45
        private static final long serialVersionUID = -2269115175530699282L;
46
        private JScrollPane scrollPane = null;
47
        private String currentStoreType = null;
48

    
49
        public SelectStoreTypePanel(NewLayerProvider provider) {
50
                super(provider);
51
                initializeComponents();
52
        }
53

    
54
        private void initializeComponents() {
55
                this.removeAll();
56
                this.setLayout(new BorderLayout());
57

    
58
                JList storeNames = new JList();
59
                ListModel model = new DefaultListModel(this.getProvider().getStoreNames());
60
                storeNames.setModel(model);
61

    
62
                storeNames.addListSelectionListener(new ListSelectionListener() {
63
                        public void valueChanged(ListSelectionEvent e) {
64
                                if (e.getValueIsAdjusting() == false) {
65
                                        JList list = (JList) e.getSource();
66

    
67
                                        if (list.getSelectedIndex() > -1) {
68
                                                currentStoreType = (String) list.getSelectedValue();
69
                                        }
70
                                }
71
                        }
72
                });
73

    
74
                scrollPane = new JScrollPane();
75
                scrollPane.setViewportView(storeNames);
76

    
77
                this.add(scrollPane, BorderLayout.CENTER);    
78
        }
79

    
80
        @Override
81
        public String getTitle() {
82
                return Messages.getText("select_datastore");
83
        }
84

    
85
        @Override
86
        public boolean isValidPanel() {
87
                if (currentStoreType != null){
88
                        getProvider().setStoreName(currentStoreType);
89
                        return true;
90
                }
91
                return false;
92
        }
93
        
94
        public void update() {
95
                initializeComponents();
96
        }
97

    
98
        @Override
99
        public void updatePanel() {
100
                initializeComponents();
101
        }
102

    
103
}