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