root / trunk / extensions / extSDE / src / com / iver / cit / gvsig / sde / gui / sdewizard / FieldSelection.java @ 11193
History | View | Annotate | Download (5.74 KB)
1 |
package com.iver.cit.gvsig.sde.gui.sdewizard; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
|
5 |
import javax.swing.DefaultListModel; |
6 |
import javax.swing.JLabel; |
7 |
import javax.swing.JList; |
8 |
import javax.swing.JPanel; |
9 |
import javax.swing.JScrollPane; |
10 |
|
11 |
import org.gvsig.gui.beans.swing.JButton; |
12 |
|
13 |
import com.iver.andami.PluginServices; |
14 |
import com.iver.utiles.swing.wizard.Step; |
15 |
import com.iver.utiles.swing.wizard.WizardControl; |
16 |
/**
|
17 |
* @author Fernando Gonz?lez Cort?s
|
18 |
*/
|
19 |
public class FieldSelection extends JPanel implements Step{ |
20 |
|
21 |
/**
|
22 |
* @uml.property name="jScrollPane"
|
23 |
*/
|
24 |
private JScrollPane jScrollPane = null; |
25 |
/**
|
26 |
* @uml.property name="lstCampos"
|
27 |
*/
|
28 |
private JList lstCampos = null; |
29 |
private DefaultListModel lstFieldsModel; |
30 |
private JLabel jLabel = null; |
31 |
/**
|
32 |
* @uml.property name="jPanel"
|
33 |
*/
|
34 |
private JPanel jPanel = null; |
35 |
/**
|
36 |
* @uml.property name="jButton"
|
37 |
*/
|
38 |
private JButton jButton = null; |
39 |
/**
|
40 |
* @uml.property name="jButton1"
|
41 |
*/
|
42 |
private JButton jButton1 = null; |
43 |
/**
|
44 |
* @uml.property name="jPanel1"
|
45 |
*/
|
46 |
private JPanel jPanel1 = null; // @jve:decl-index=0:visual-constraint="326,146" |
47 |
/**
|
48 |
* @uml.property name="jPanel2"
|
49 |
*/
|
50 |
private JPanel jPanel2 = null; // @jve:decl-index=0:visual-constraint="340,183" |
51 |
|
52 |
/**
|
53 |
* This is the default constructor
|
54 |
*/
|
55 |
public FieldSelection() {
|
56 |
super();
|
57 |
initialize(); |
58 |
} |
59 |
/**
|
60 |
* This method initializes this
|
61 |
*
|
62 |
* @return void
|
63 |
*/
|
64 |
private void initialize() { |
65 |
jLabel = new JLabel(); |
66 |
this.setLayout(new BorderLayout()); |
67 |
this.setSize(300, 231); |
68 |
jLabel.setText(PluginServices.getText(this, "seleccion_de_campos") + ":"); |
69 |
jLabel.setPreferredSize(new java.awt.Dimension(352,15)); |
70 |
jLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); |
71 |
jLabel.setName("jLabel");
|
72 |
this.add(getJPanel2(), java.awt.BorderLayout.WEST);
|
73 |
this.add(getJPanel1(), java.awt.BorderLayout.EAST);
|
74 |
this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
|
75 |
this.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
|
76 |
this.add(jLabel, java.awt.BorderLayout.NORTH);
|
77 |
} |
78 |
|
79 |
/**
|
80 |
* DOCUMENT ME!
|
81 |
*
|
82 |
* @param fields DOCUMENT ME!
|
83 |
*/
|
84 |
public void setFields(String[] fields) { |
85 |
lstFieldsModel = new DefaultListModel(); |
86 |
|
87 |
for (int i = 0; i < fields.length; i++) { |
88 |
lstFieldsModel.addElement(fields[i]); |
89 |
} |
90 |
|
91 |
getLstCampos().setModel(lstFieldsModel); |
92 |
} |
93 |
|
94 |
/**
|
95 |
* DOCUMENT ME!
|
96 |
*
|
97 |
* @return DOCUMENT ME!
|
98 |
*/
|
99 |
public String[] getFields() { |
100 |
Object[] selection = getLstCampos().getSelectedValues(); |
101 |
String[] ret = new String[selection.length]; |
102 |
for (int i = 0; i < selection.length; i++) { |
103 |
ret[i] = (String) selection[i];
|
104 |
} |
105 |
|
106 |
return ret;
|
107 |
} |
108 |
|
109 |
/**
|
110 |
* This method initializes jScrollPane
|
111 |
* @return javax.swing.JScrollPane
|
112 |
* @uml.property name="jScrollPane"
|
113 |
*/
|
114 |
private JScrollPane getJScrollPane() { |
115 |
if (jScrollPane == null) { |
116 |
jScrollPane = new JScrollPane(); |
117 |
jScrollPane.setPreferredSize(new java.awt.Dimension(200,110)); |
118 |
jScrollPane.setName("jScrollPane");
|
119 |
jScrollPane.setViewportView(getLstCampos()); |
120 |
} |
121 |
return jScrollPane;
|
122 |
} |
123 |
/**
|
124 |
* This method initializes lstCampos
|
125 |
* @return javax.swing.JList
|
126 |
* @uml.property name="lstCampos"
|
127 |
*/
|
128 |
private JList getLstCampos() { |
129 |
if (lstCampos == null) { |
130 |
lstCampos = new JList(); |
131 |
} |
132 |
return lstCampos;
|
133 |
} |
134 |
/**
|
135 |
* @see com.iver.utiles.swing.wizard.Step#init(com.iver.utiles.swing.wizard.WizardControl)
|
136 |
*/
|
137 |
public void init(WizardControl w) { |
138 |
} |
139 |
/**
|
140 |
* This method initializes jPanel
|
141 |
* @return javax.swing.JPanel
|
142 |
* @uml.property name="jPanel"
|
143 |
*/
|
144 |
private JPanel getJPanel() { |
145 |
if (jPanel == null) { |
146 |
jPanel = new JPanel(); |
147 |
jPanel.setPreferredSize(new java.awt.Dimension(350,30)); |
148 |
jPanel.setName("jPanel");
|
149 |
jPanel.add(getJButton(), null);
|
150 |
jPanel.add(getJButton1(), null);
|
151 |
} |
152 |
return jPanel;
|
153 |
} |
154 |
/**
|
155 |
* This method initializes jButton
|
156 |
* @return javax.swing.JButton
|
157 |
* @uml.property name="jButton"
|
158 |
*/
|
159 |
private JButton getJButton() { |
160 |
if (jButton == null) { |
161 |
jButton = new JButton(); |
162 |
jButton.setText(PluginServices.getText(this, "select_all")); |
163 |
//jButton.setPreferredSize(new java.awt.Dimension(140,18));
|
164 |
jButton.addActionListener(new java.awt.event.ActionListener() {
|
165 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
166 |
int[] indices = new int[lstCampos.getModel().getSize()]; |
167 |
for (int i = 0; i < indices.length; i++) { |
168 |
indices[i] = i; |
169 |
} |
170 |
lstCampos.setSelectedIndices(indices); |
171 |
} |
172 |
}); |
173 |
} |
174 |
return jButton;
|
175 |
} |
176 |
/**
|
177 |
* This method initializes jButton1
|
178 |
* @return javax.swing.JButton
|
179 |
* @uml.property name="jButton1"
|
180 |
*/
|
181 |
private JButton getJButton1() { |
182 |
if (jButton1 == null) { |
183 |
jButton1 = new JButton(); |
184 |
jButton1.setText(PluginServices.getText(this, "select_none")); |
185 |
//jButton1.setPreferredSize(new java.awt.Dimension(140,18));
|
186 |
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
187 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
188 |
lstCampos.setSelectedIndices(new int[0]); |
189 |
} |
190 |
}); |
191 |
} |
192 |
return jButton1;
|
193 |
} |
194 |
/**
|
195 |
* @return
|
196 |
*/
|
197 |
public boolean done() { |
198 |
return getLstCampos().getSelectedIndex() != -1; |
199 |
} |
200 |
/**
|
201 |
* This method initializes jPanel1
|
202 |
* @return javax.swing.JPanel
|
203 |
* @uml.property name="jPanel1"
|
204 |
*/
|
205 |
private JPanel getJPanel1() { |
206 |
if (jPanel1 == null) { |
207 |
jPanel1 = new JPanel(); |
208 |
jPanel1.setSize(56, 71); |
209 |
jPanel1.setPreferredSize(new java.awt.Dimension(70,10)); |
210 |
} |
211 |
return jPanel1;
|
212 |
} |
213 |
/**
|
214 |
* This method initializes jPanel2
|
215 |
* @return javax.swing.JPanel
|
216 |
* @uml.property name="jPanel2"
|
217 |
*/
|
218 |
private JPanel getJPanel2() { |
219 |
if (jPanel2 == null) { |
220 |
jPanel2 = new JPanel(); |
221 |
jPanel2.setSize(42, 60); |
222 |
jPanel2.setPreferredSize(new java.awt.Dimension(70,10)); |
223 |
} |
224 |
return jPanel2;
|
225 |
} |
226 |
} // @jve:decl-index=0:visual-constraint="10,10"
|