root / branches / v2_0_0_prep / libraries / org.gvsig.newlayer / org.gvsig.newlayer.lib / org.gvsig.newlayer.lib.impl / src / main / java / org / gvsig / newlayer / impl / TypeSelectorPanel.java @ 36022
History | View | Annotate | Download (1.87 KB)
1 |
package org.gvsig.newlayer.impl; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
|
5 |
import javax.swing.JList; |
6 |
import javax.swing.JPanel; |
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.gui.beans.wizard.panel.NotContinueWizardException; |
13 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
14 |
import org.gvsig.newlayer.NewLayerService; |
15 |
import org.gvsig.newlayer.NewLayerWizard; |
16 |
|
17 |
public class TypeSelectorPanel extends JPanel implements OptionPanel{ |
18 |
|
19 |
private NewLayerWizard wizard;
|
20 |
private String currentType; |
21 |
|
22 |
public TypeSelectorPanel(NewLayerWizard wizard){
|
23 |
this.wizard = wizard;
|
24 |
initializeComponents(); |
25 |
} |
26 |
|
27 |
public String getPanelTitle() { |
28 |
return "Type selector panel"; |
29 |
} |
30 |
|
31 |
public void nextPanel() throws NotContinueWizardException { |
32 |
this.wizard.setType(currentType);
|
33 |
} |
34 |
|
35 |
public void lastPanel() { |
36 |
// do nothing
|
37 |
|
38 |
} |
39 |
|
40 |
public void updatePanel() { |
41 |
initializeComponents(); |
42 |
} |
43 |
|
44 |
public JPanel getJPanel() { |
45 |
return this; |
46 |
} |
47 |
|
48 |
private void initializeComponents() { |
49 |
this.setLayout(new BorderLayout()); |
50 |
|
51 |
JList types = new JList(); |
52 |
ListModel model = new org.gvsig.utils.DefaultListModel(this.getService().getTypes()); |
53 |
types.setModel(model); |
54 |
|
55 |
types.addListSelectionListener(new ListSelectionListener() { |
56 |
public void valueChanged(ListSelectionEvent e) { |
57 |
if (e.getValueIsAdjusting() == false) { |
58 |
JList list = (JList) e.getSource(); |
59 |
|
60 |
if (list.getSelectedIndex() > -1) { |
61 |
currentType = (String) list.getSelectedValue();
|
62 |
} |
63 |
} |
64 |
} |
65 |
}); |
66 |
|
67 |
JScrollPane scrollPane = new JScrollPane(); |
68 |
scrollPane.setViewportView(types); |
69 |
this.add(scrollPane, BorderLayout.CENTER); |
70 |
} |
71 |
|
72 |
private NewLayerService getService() {
|
73 |
return this.wizard.getService(); |
74 |
} |
75 |
} |