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 @ 37891
History | View | Annotate | Download (2.21 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.NewLayerProviderFactory; |
15 |
import org.gvsig.newlayer.NewLayerService; |
16 |
import org.gvsig.newlayer.NewLayerWizard; |
17 |
|
18 |
public class TypeSelectorPanel extends JPanel implements OptionPanel{ |
19 |
|
20 |
/**
|
21 |
*
|
22 |
*/
|
23 |
private static final long serialVersionUID = 419873365484240927L; |
24 |
private NewLayerWizard wizard;
|
25 |
private NewLayerProviderFactory currentType;
|
26 |
|
27 |
public TypeSelectorPanel(NewLayerWizard wizard){
|
28 |
this.wizard = wizard;
|
29 |
initializeComponents(); |
30 |
} |
31 |
|
32 |
public String getPanelTitle() { |
33 |
return "Type selector panel"; |
34 |
} |
35 |
|
36 |
public void nextPanel() throws NotContinueWizardException { |
37 |
if (currentType!=null){ |
38 |
this.wizard.setType(currentType);
|
39 |
return;
|
40 |
} |
41 |
throw new NotContinueWizardException("", null, false); |
42 |
} |
43 |
|
44 |
public void lastPanel() { |
45 |
// do nothing
|
46 |
|
47 |
} |
48 |
|
49 |
public void updatePanel() { |
50 |
initializeComponents(); |
51 |
} |
52 |
|
53 |
public JPanel getJPanel() { |
54 |
return this; |
55 |
} |
56 |
|
57 |
private void initializeComponents() { |
58 |
this.setLayout(new BorderLayout()); |
59 |
|
60 |
JList types = new JList(); |
61 |
ListModel model =
|
62 |
new org.gvsig.utils.DefaultListModel(this.getService() |
63 |
.getProviderFactories()); |
64 |
types.setModel(model); |
65 |
|
66 |
types.addListSelectionListener(new ListSelectionListener() { |
67 |
public void valueChanged(ListSelectionEvent e) { |
68 |
if (e.getValueIsAdjusting() == false) { |
69 |
JList list = (JList) e.getSource(); |
70 |
|
71 |
if (list.getSelectedIndex() > -1) { |
72 |
currentType = |
73 |
(NewLayerProviderFactory) list.getSelectedValue(); |
74 |
} |
75 |
} |
76 |
} |
77 |
}); |
78 |
|
79 |
JScrollPane scrollPane = new JScrollPane(); |
80 |
scrollPane.setViewportView(types); |
81 |
this.add(scrollPane, BorderLayout.CENTER); |
82 |
} |
83 |
|
84 |
private NewLayerService getService() {
|
85 |
return this.wizard.getService(); |
86 |
} |
87 |
} |