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