svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.newlayer / org.gvsig.newlayer.lib / org.gvsig.newlayer.lib.impl / src / main / java / org / gvsig / newlayer / impl / TypeSelectorPanel.java @ 40950
History | View | Annotate | Download (3.47 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.impl; |
25 |
|
26 |
import java.awt.BorderLayout; |
27 |
|
28 |
import javax.swing.DefaultListSelectionModel; |
29 |
import javax.swing.JList; |
30 |
import javax.swing.JPanel; |
31 |
import javax.swing.JScrollPane; |
32 |
import javax.swing.ListModel; |
33 |
import javax.swing.event.ListSelectionEvent; |
34 |
import javax.swing.event.ListSelectionListener; |
35 |
|
36 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
37 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
38 |
import org.gvsig.i18n.Messages; |
39 |
import org.gvsig.newlayer.NewLayerProviderFactory; |
40 |
import org.gvsig.newlayer.NewLayerService; |
41 |
import org.gvsig.newlayer.NewLayerWizard; |
42 |
|
43 |
public class TypeSelectorPanel extends JPanel implements OptionPanel{ |
44 |
|
45 |
/**
|
46 |
*
|
47 |
*/
|
48 |
private static final long serialVersionUID = 419873365484240927L; |
49 |
private NewLayerWizard wizard;
|
50 |
private NewLayerProviderFactory currentType;
|
51 |
|
52 |
public TypeSelectorPanel(NewLayerWizard wizard){
|
53 |
this.wizard = wizard;
|
54 |
initializeComponents(); |
55 |
} |
56 |
|
57 |
public String getPanelTitle() { |
58 |
return Messages.getText("_Output_format"); |
59 |
} |
60 |
|
61 |
public void nextPanel() throws NotContinueWizardException { |
62 |
if (currentType!=null){ |
63 |
this.wizard.setType(currentType);
|
64 |
return;
|
65 |
} |
66 |
throw new NotContinueWizardException("", null, false); |
67 |
} |
68 |
|
69 |
public void lastPanel() { |
70 |
// do nothing
|
71 |
|
72 |
} |
73 |
|
74 |
public void updatePanel() { |
75 |
initializeComponents(); |
76 |
} |
77 |
|
78 |
public JPanel getJPanel() { |
79 |
return this; |
80 |
} |
81 |
|
82 |
private void initializeComponents() { |
83 |
this.setLayout(new BorderLayout()); |
84 |
|
85 |
JList types = new JList(); |
86 |
ListModel model =
|
87 |
new org.gvsig.utils.DefaultListModel(this.getService() |
88 |
.getProviderFactories()); |
89 |
|
90 |
types.setModel(model); |
91 |
types.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
|
92 |
|
93 |
types.addListSelectionListener(new ListSelectionListener() { |
94 |
public void valueChanged(ListSelectionEvent e) { |
95 |
if (e.getValueIsAdjusting() == false) { |
96 |
JList list = (JList) e.getSource(); |
97 |
|
98 |
if (list.getSelectedIndex() > -1) { |
99 |
currentType = |
100 |
(NewLayerProviderFactory) list.getSelectedValue(); |
101 |
|
102 |
wizard.setNextButtonEnabled(true);
|
103 |
} else {
|
104 |
wizard.setNextButtonEnabled(false);
|
105 |
} |
106 |
} |
107 |
} |
108 |
}); |
109 |
|
110 |
JScrollPane scrollPane = new JScrollPane(); |
111 |
scrollPane.setViewportView(types); |
112 |
this.add(scrollPane, BorderLayout.CENTER); |
113 |
} |
114 |
|
115 |
private NewLayerService getService() {
|
116 |
return this.wizard.getService(); |
117 |
} |
118 |
} |