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 / SelectExplorerPanel.java @ 40560

History | View | Annotate | Download (2.81 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 SelectExplorerPanel extends NewLayerGenericProviderPanel{
41

    
42
        /**
43
         * 
44
         */
45
        private static final long serialVersionUID = 4479935798588252685L;
46

    
47
    private JScrollPane scrollPane = null;
48
        private String currentExplorerName = null;
49

    
50
        public SelectExplorerPanel(NewLayerProvider provider) {
51
                super(provider);
52
                initializeComponents();
53
        }
54

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

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

    
62
                explorerNames.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
                                                currentExplorerName = (String) list.getSelectedValue();
69
                                        }
70
                                }
71
                        }
72
                });
73

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

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

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

    
85
        @Override
86
        public boolean isValidPanel() {
87
                if (currentExplorerName != null){
88
                        getProvider().setExplorerName(currentExplorerName);
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
}