root / branches / v2_0_0_prep / libraries / org.gvsig.newlayer / org.gvsig.newlayer.prov / org.gvsig.newlayer.prov.generic / src / main / java / org / gvsig / newlayer / prov / generic / panels / SelectExplorerPanel.java @ 36721
History | View | Annotate | Download (1.87 KB)
1 |
package org.gvsig.newlayer.prov.generic.panels; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.util.List; |
5 |
|
6 |
import javax.swing.JList; |
7 |
import javax.swing.JScrollPane; |
8 |
import javax.swing.ListModel; |
9 |
import javax.swing.event.ListSelectionEvent; |
10 |
import javax.swing.event.ListSelectionListener; |
11 |
|
12 |
import org.gvsig.i18n.Messages; |
13 |
import org.gvsig.newlayer.NewLayerProvider; |
14 |
import org.gvsig.newlayer.prov.generic.NewLayerGenericProviderPanel; |
15 |
import org.gvsig.utils.DefaultListModel; |
16 |
|
17 |
public class SelectExplorerPanel extends NewLayerGenericProviderPanel{ |
18 |
|
19 |
/**
|
20 |
*
|
21 |
*/
|
22 |
private static final long serialVersionUID = 4479935798588252685L; |
23 |
|
24 |
private JScrollPane scrollPane = null; |
25 |
private String currentExplorerName = null; |
26 |
|
27 |
public SelectExplorerPanel(NewLayerProvider provider) {
|
28 |
super(provider);
|
29 |
initializeComponents(); |
30 |
} |
31 |
|
32 |
private void initializeComponents() { |
33 |
this.setLayout(new BorderLayout()); |
34 |
|
35 |
JList explorerNames = new JList(); |
36 |
ListModel model = new DefaultListModel(this.getProvider().getExplorerNames()); |
37 |
explorerNames.setModel(model); |
38 |
|
39 |
explorerNames.addListSelectionListener(new ListSelectionListener() { |
40 |
public void valueChanged(ListSelectionEvent e) { |
41 |
if (e.getValueIsAdjusting() == false) { |
42 |
JList list = (JList) e.getSource(); |
43 |
|
44 |
if (list.getSelectedIndex() > -1) { |
45 |
currentExplorerName = (String) list.getSelectedValue();
|
46 |
} |
47 |
} |
48 |
} |
49 |
}); |
50 |
|
51 |
scrollPane = new JScrollPane(); |
52 |
scrollPane.setViewportView(explorerNames); |
53 |
|
54 |
this.add(scrollPane, BorderLayout.CENTER); |
55 |
} |
56 |
|
57 |
@Override
|
58 |
public String getTitle() { |
59 |
return Messages.getText("select_dataexplorer"); |
60 |
} |
61 |
|
62 |
@Override
|
63 |
public boolean isValidPanel() { |
64 |
if (currentExplorerName != null){ |
65 |
getProvider().setExplorerName(currentExplorerName); |
66 |
return true; |
67 |
} |
68 |
return false; |
69 |
} |
70 |
|
71 |
public void update() { |
72 |
initializeComponents(); |
73 |
} |
74 |
|
75 |
@Override
|
76 |
public void updatePanel() { |
77 |
initializeComponents(); |
78 |
} |
79 |
|
80 |
} |