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