svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extNormalization / src / org / gvsig / normalization / gui / NormalizationPanel.java @ 29238
History | View | Annotate | Download (60.3 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 Prodevelop S.L. main development
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.normalization.gui; |
29 |
|
30 |
import java.awt.Component; |
31 |
import java.awt.event.ActionEvent; |
32 |
import java.awt.event.ActionListener; |
33 |
import java.awt.event.KeyEvent; |
34 |
import java.awt.event.KeyListener; |
35 |
import java.awt.event.MouseEvent; |
36 |
import java.awt.event.MouseListener; |
37 |
import java.io.File; |
38 |
|
39 |
import javax.swing.BorderFactory; |
40 |
import javax.swing.ButtonGroup; |
41 |
import javax.swing.DefaultComboBoxModel; |
42 |
import javax.swing.DefaultListModel; |
43 |
import javax.swing.ImageIcon; |
44 |
import javax.swing.InputVerifier; |
45 |
import javax.swing.JButton; |
46 |
import javax.swing.JCheckBox; |
47 |
import javax.swing.JComboBox; |
48 |
import javax.swing.JComponent; |
49 |
import javax.swing.JLabel; |
50 |
import javax.swing.JList; |
51 |
import javax.swing.JPanel; |
52 |
import javax.swing.JRadioButton; |
53 |
import javax.swing.JScrollPane; |
54 |
import javax.swing.JTable; |
55 |
import javax.swing.JTextArea; |
56 |
import javax.swing.JTextField; |
57 |
import javax.swing.event.ChangeEvent; |
58 |
import javax.swing.event.ChangeListener; |
59 |
import javax.swing.table.DefaultTableModel; |
60 |
|
61 |
import org.gvsig.app.daltransform.gui.impl.AbstractDataTransformWizardPanel; |
62 |
import org.gvsig.normalization.pattern.Datevalue; |
63 |
import org.gvsig.normalization.pattern.Decimalvalue; |
64 |
import org.gvsig.normalization.pattern.Element; |
65 |
import org.gvsig.normalization.pattern.Fieldseparator; |
66 |
import org.gvsig.normalization.pattern.Fieldtype; |
67 |
import org.gvsig.normalization.pattern.Infieldseparators; |
68 |
import org.gvsig.normalization.pattern.Integervalue; |
69 |
import org.gvsig.normalization.pattern.Patternnormalization; |
70 |
import org.gvsig.normalization.pattern.Stringvalue; |
71 |
import org.gvsig.normalization.pattern.impl.DefaultDatevalue; |
72 |
import org.gvsig.normalization.pattern.impl.DefaultDecimalvalue; |
73 |
import org.gvsig.normalization.pattern.impl.DefaultFieldseparator; |
74 |
import org.gvsig.normalization.pattern.impl.DefaultFieldtype; |
75 |
import org.gvsig.normalization.pattern.impl.DefaultInfieldseparators; |
76 |
import org.gvsig.normalization.pattern.impl.DefaultIntegervalue; |
77 |
import org.gvsig.normalization.pattern.impl.DefaultStringvalue; |
78 |
import org.slf4j.Logger; |
79 |
import org.slf4j.LoggerFactory; |
80 |
|
81 |
import com.iver.andami.PluginServices; |
82 |
import com.iver.andami.ui.mdiManager.IWindow; |
83 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
84 |
|
85 |
/**
|
86 |
* Normalization main panel
|
87 |
*
|
88 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
|
89 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
|
90 |
*/
|
91 |
public class NormalizationPanel extends AbstractDataTransformWizardPanel |
92 |
implements ActionListener, ChangeListener { |
93 |
|
94 |
private static final long serialVersionUID = -2882235643001676017L; |
95 |
|
96 |
private static final Logger log = LoggerFactory |
97 |
.getLogger(NormalizationPanel.class); |
98 |
|
99 |
private NormalizationPanelController controller;
|
100 |
private PluginServices ps;
|
101 |
private boolean dirty = false; |
102 |
private int selectedField = 0; |
103 |
|
104 |
/* GUI */
|
105 |
private ButtonGroup butGroupDelimiter; |
106 |
private ButtonGroup butGroupFieldType; |
107 |
private JButton jButCancel; |
108 |
private JButton jButAddField; |
109 |
private JButton jButDownField; |
110 |
private JButton jButRemoveField; |
111 |
private JButton jButUpField; |
112 |
private JButton jButLoad; |
113 |
private JButton jButRun; |
114 |
private JButton jButSave; |
115 |
private JButton jButTest; |
116 |
private JCheckBox jCheckFirstRow; |
117 |
private JCheckBox jChkColon; |
118 |
private JCheckBox jChkDontImport; |
119 |
private JCheckBox jChkJoin; |
120 |
private JCheckBox jChkOther; |
121 |
private JCheckBox jChkSemicolon; |
122 |
private JCheckBox jChkSpace; |
123 |
private JCheckBox jChkTab; |
124 |
private JComboBox jComboDate; |
125 |
private JLabel jLabDecimal; |
126 |
private JLabel jLabFieldName; |
127 |
private JLabel jLabTextDel; |
128 |
private JLabel jLabThousand; |
129 |
private JLabel jLabelSelFields; |
130 |
private JList jListFieldList; |
131 |
private JList jListOriginalFields; |
132 |
private JPanel jPanApply; |
133 |
private JPanel jPanConsole; |
134 |
private JPanel jPanFieldList; |
135 |
private JPanel jPanFieldName; |
136 |
private JPanel jPanFieldSeparators; |
137 |
private JPanel jPanFieldSettings; |
138 |
private JPanel jPanFieldType; |
139 |
private JPanel jPanFields; |
140 |
private JPanel jPanFirstRow; |
141 |
private JPanel jPanInField; |
142 |
private JPanel jPanOutputOpt; |
143 |
private JPanel jPanSampleOutput; |
144 |
private JPanel jPanSeparators; |
145 |
private JPanel jPanSource; |
146 |
private JPanel jPanel1; |
147 |
private JRadioButton jRadioAlterTable; |
148 |
private JRadioButton jRadioCharacter; |
149 |
private JRadioButton jRadioDate; |
150 |
private JRadioButton jRadioDecimal; |
151 |
private JRadioButton jRadioFixed; |
152 |
private JRadioButton jRadioInteger; |
153 |
private JRadioButton jRadioNewTable; |
154 |
private JRadioButton jRadioString; |
155 |
private JScrollPane jScrollPane2; |
156 |
private JScrollPane jScrollPaneFieldList; |
157 |
private JScrollPane jScrollPaneSource; |
158 |
private JTable jTableResult; |
159 |
private JTable jTableSource; |
160 |
private JTextArea jTextAreaConsole; |
161 |
private JTextField jTextDecimal; |
162 |
private JTextField jTextNumberRows; |
163 |
private JLabel jLabelNumberRows; |
164 |
private JTextField jTextFieldName; |
165 |
private JTextField jTextFieldWidth; |
166 |
private JTextField jTextOther; |
167 |
private JTextField jTextTextDelimiter; |
168 |
private JTextField jTextThousand; |
169 |
|
170 |
/**
|
171 |
* Creates new form NormalizationPanel to normalize field of datastore
|
172 |
*
|
173 |
* @param control
|
174 |
* @return panel
|
175 |
*/
|
176 |
public NormalizationPanel(NormalizationPanelController control) {
|
177 |
this.controller = control;
|
178 |
init(); |
179 |
} |
180 |
|
181 |
/**
|
182 |
* This method sets the PluginServices and update the string and icons
|
183 |
*
|
184 |
* @param ps
|
185 |
* PluginServices
|
186 |
*/
|
187 |
public void setPs(PluginServices ps) { |
188 |
this.ps = ps;
|
189 |
if (ps != null) { |
190 |
setMessages(); |
191 |
setImages(); |
192 |
} |
193 |
} |
194 |
|
195 |
/**
|
196 |
* This method inserts the sample split strings into the Sample Table
|
197 |
*
|
198 |
* @param chains
|
199 |
* array with strings
|
200 |
*/
|
201 |
public void insertChainsInRowsTableSample(String[] chains) { |
202 |
|
203 |
DefaultTableModel dtm = new DefaultTableModel(); |
204 |
int nfil = dtm.getRowCount();
|
205 |
for (int i = 0; i < nfil; i++) { |
206 |
dtm.setValueAt(chains[0], i, 0); |
207 |
} |
208 |
jTableSource.setModel(dtm); |
209 |
} |
210 |
|
211 |
/**
|
212 |
* Insert in the console the message
|
213 |
*
|
214 |
* @param e
|
215 |
*/
|
216 |
public void stateChanged(ChangeEvent e) { |
217 |
String info = parseInfo(e.getSource().toString());
|
218 |
this.jTextAreaConsole.append(info);
|
219 |
} |
220 |
|
221 |
/**
|
222 |
* This method inserts the model in the list with the names of the fields of
|
223 |
* the original table
|
224 |
*
|
225 |
* @param fieldsNames
|
226 |
*/
|
227 |
public void insertFieldsCurrentTable(String[] fieldsNames) { |
228 |
DefaultListModel dcb = new DefaultListModel(); |
229 |
int cont = fieldsNames.length;
|
230 |
for (int i = 0; i < cont; i++) { |
231 |
dcb.addElement(fieldsNames[i]); |
232 |
} |
233 |
this.jListOriginalFields.setModel(dcb);
|
234 |
this.jListOriginalFields.setSelectedIndex(0); |
235 |
} |
236 |
|
237 |
/**
|
238 |
* getWindowInfo
|
239 |
*
|
240 |
* @return windows properties
|
241 |
*/
|
242 |
public WindowInfo getWindowInfo() {
|
243 |
WindowInfo info = new WindowInfo(WindowInfo.MODALDIALOG
|
244 |
| WindowInfo.RESIZABLE); |
245 |
info.setWidth(780);
|
246 |
info.setHeight(620);
|
247 |
info.setTitle(PluginServices.getText(this, "normalize")); |
248 |
return info;
|
249 |
} |
250 |
|
251 |
/**
|
252 |
* Initialize components and other custom code
|
253 |
*/
|
254 |
private void init() { |
255 |
|
256 |
/* Initialize components GUI */
|
257 |
initComponents(); |
258 |
|
259 |
/* Final initialize methods to set up the GUI */
|
260 |
updateGUI(); |
261 |
|
262 |
jListOriginalFields.setEnabled(false);
|
263 |
} |
264 |
|
265 |
/**
|
266 |
* This method creates the components of the GUI
|
267 |
*/
|
268 |
private void initComponents() { |
269 |
java.awt.GridBagConstraints gridBagConstraints; |
270 |
|
271 |
butGroupDelimiter = new javax.swing.ButtonGroup();
|
272 |
butGroupFieldType = new javax.swing.ButtonGroup();
|
273 |
jPanSampleOutput = new javax.swing.JPanel();
|
274 |
jScrollPane2 = new javax.swing.JScrollPane();
|
275 |
jTableResult = new javax.swing.JTable();
|
276 |
jPanSource = new javax.swing.JPanel();
|
277 |
jScrollPaneSource = new javax.swing.JScrollPane();
|
278 |
jTableSource = new javax.swing.JTable();
|
279 |
jPanFirstRow = new javax.swing.JPanel();
|
280 |
jCheckFirstRow = new javax.swing.JCheckBox();
|
281 |
jTextNumberRows = new javax.swing.JTextField();
|
282 |
jLabelNumberRows = new javax.swing.JLabel();
|
283 |
jPanFields = new javax.swing.JPanel();
|
284 |
jPanFieldList = new javax.swing.JPanel();
|
285 |
jScrollPaneFieldList = new javax.swing.JScrollPane();
|
286 |
jListFieldList = new javax.swing.JList();
|
287 |
jButAddField = new javax.swing.JButton();
|
288 |
jButRemoveField = new javax.swing.JButton();
|
289 |
jButUpField = new javax.swing.JButton();
|
290 |
jButDownField = new javax.swing.JButton();
|
291 |
jPanFieldSettings = new javax.swing.JPanel();
|
292 |
jPanFieldType = new javax.swing.JPanel();
|
293 |
jRadioString = new javax.swing.JRadioButton();
|
294 |
jRadioInteger = new javax.swing.JRadioButton();
|
295 |
jRadioDecimal = new javax.swing.JRadioButton();
|
296 |
jRadioDate = new javax.swing.JRadioButton();
|
297 |
jComboDate = new javax.swing.JComboBox();
|
298 |
jPanSeparators = new javax.swing.JPanel();
|
299 |
jPanFieldSeparators = new javax.swing.JPanel();
|
300 |
jChkTab = new javax.swing.JCheckBox();
|
301 |
jChkSpace = new javax.swing.JCheckBox();
|
302 |
jChkColon = new javax.swing.JCheckBox();
|
303 |
jChkSemicolon = new javax.swing.JCheckBox();
|
304 |
jChkOther = new javax.swing.JCheckBox();
|
305 |
jTextOther = new javax.swing.JTextField();
|
306 |
jChkJoin = new javax.swing.JCheckBox();
|
307 |
jRadioFixed = new javax.swing.JRadioButton();
|
308 |
jRadioCharacter = new javax.swing.JRadioButton();
|
309 |
jTextFieldWidth = new javax.swing.JTextField();
|
310 |
jPanFieldName = new javax.swing.JPanel();
|
311 |
jChkDontImport = new javax.swing.JCheckBox();
|
312 |
jLabFieldName = new javax.swing.JLabel();
|
313 |
jTextFieldName = new javax.swing.JTextField();
|
314 |
jPanel1 = new javax.swing.JPanel();
|
315 |
jPanApply = new javax.swing.JPanel();
|
316 |
jButTest = new javax.swing.JButton();
|
317 |
jPanInField = new javax.swing.JPanel();
|
318 |
jLabDecimal = new javax.swing.JLabel();
|
319 |
jTextDecimal = new javax.swing.JTextField();
|
320 |
jLabThousand = new javax.swing.JLabel();
|
321 |
jTextThousand = new javax.swing.JTextField();
|
322 |
jLabTextDel = new javax.swing.JLabel();
|
323 |
jTextTextDelimiter = new javax.swing.JTextField();
|
324 |
jPanOutputOpt = new javax.swing.JPanel();
|
325 |
jRadioAlterTable = new javax.swing.JRadioButton();
|
326 |
jRadioNewTable = new javax.swing.JRadioButton();
|
327 |
jLabelSelFields = new javax.swing.JLabel();
|
328 |
jListOriginalFields = new javax.swing.JList();
|
329 |
jPanConsole = new javax.swing.JPanel();
|
330 |
jTextAreaConsole = new javax.swing.JTextArea();
|
331 |
jButLoad = new javax.swing.JButton();
|
332 |
jButRun = new javax.swing.JButton();
|
333 |
jButCancel = new javax.swing.JButton();
|
334 |
jButSave = new javax.swing.JButton();
|
335 |
|
336 |
setMinimumSize(new java.awt.Dimension(600, 620)); |
337 |
setPreferredSize(new java.awt.Dimension(600, 620)); |
338 |
addFocusListener(new java.awt.event.FocusAdapter() {
|
339 |
public void focusGained(java.awt.event.FocusEvent evt) { |
340 |
mainPanelGetFocus(evt); |
341 |
} |
342 |
}); |
343 |
setLayout(new java.awt.GridBagLayout());
|
344 |
|
345 |
jPanSampleOutput.setBorder(javax.swing.BorderFactory |
346 |
.createTitledBorder("Sample output"));
|
347 |
jPanSampleOutput.setLayout(new java.awt.GridBagLayout());
|
348 |
|
349 |
jScrollPane2 |
350 |
.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
351 |
jScrollPane2.setAutoscrolls(true);
|
352 |
jScrollPane2.setMinimumSize(new java.awt.Dimension(100, 90)); |
353 |
jScrollPane2.setPreferredSize(new java.awt.Dimension(100, 90)); |
354 |
|
355 |
jTableResult.setFont(new java.awt.Font("Courier New", 0, 11)); |
356 |
jTableResult.setModel(new javax.swing.table.DefaultTableModel(
|
357 |
new Object[][] { {}, {}, {} }, new String[] { |
358 |
|
359 |
})); |
360 |
jTableResult.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); |
361 |
jTableResult.setEnabled(false);
|
362 |
jScrollPane2.setViewportView(jTableResult); |
363 |
|
364 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
365 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
366 |
gridBagConstraints.weightx = 1.0;
|
367 |
jPanSampleOutput.add(jScrollPane2, gridBagConstraints); |
368 |
|
369 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
370 |
gridBagConstraints.gridx = 0;
|
371 |
gridBagConstraints.gridy = 2;
|
372 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
373 |
gridBagConstraints.weightx = 1.0;
|
374 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5); |
375 |
add(jPanSampleOutput, gridBagConstraints); |
376 |
|
377 |
jPanSource.setBorder(javax.swing.BorderFactory |
378 |
.createTitledBorder("Source"));
|
379 |
jPanSource.setMinimumSize(new java.awt.Dimension(36, 125)); |
380 |
jPanSource.setLayout(new java.awt.GridBagLayout());
|
381 |
|
382 |
jScrollPaneSource.setMinimumSize(new java.awt.Dimension(100, 90)); |
383 |
jScrollPaneSource.setPreferredSize(new java.awt.Dimension(100, 90)); |
384 |
|
385 |
jTableSource.setFont(new java.awt.Font("Courier New", 0, 11)); |
386 |
jTableSource.setModel(new DefaultTableModel()); |
387 |
jTableSource.getTableHeader().setReorderingAllowed(false);
|
388 |
jScrollPaneSource.setViewportView(jTableSource); |
389 |
|
390 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
391 |
gridBagConstraints.gridx = 0;
|
392 |
gridBagConstraints.gridy = 0;
|
393 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
394 |
gridBagConstraints.weightx = 1.0;
|
395 |
gridBagConstraints.weighty = 1.0;
|
396 |
jPanSource.add(jScrollPaneSource, gridBagConstraints); |
397 |
|
398 |
jPanFirstRow.setLayout(new java.awt.GridBagLayout());
|
399 |
|
400 |
jCheckFirstRow.setText("Don't normalize the first row");
|
401 |
jCheckFirstRow.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); |
402 |
jCheckFirstRow.setSelected(false);
|
403 |
jCheckFirstRow.addActionListener(new java.awt.event.ActionListener() {
|
404 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
405 |
EvCheckFirstRow(evt); |
406 |
} |
407 |
}); |
408 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
409 |
gridBagConstraints.gridx = 0;
|
410 |
gridBagConstraints.gridy = 0;
|
411 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
412 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
413 |
gridBagConstraints.insets = new java.awt.Insets(3, 10, 0, 0); |
414 |
jPanFirstRow.add(jCheckFirstRow, gridBagConstraints); |
415 |
|
416 |
jTextNumberRows.setText("0");
|
417 |
jTextNumberRows.setEditable(false);
|
418 |
jTextNumberRows.setInputVerifier(new IntVerifier());
|
419 |
jTextNumberRows.setMaximumSize(new java.awt.Dimension(30, 18)); |
420 |
jTextNumberRows.setMinimumSize(new java.awt.Dimension(30, 18)); |
421 |
jTextNumberRows.setPreferredSize(new java.awt.Dimension(30, 18)); |
422 |
|
423 |
jTextNumberRows.addKeyListener(new java.awt.event.KeyAdapter() {
|
424 |
public void keyReleased(java.awt.event.KeyEvent evt) { |
425 |
firstRowsvalueChange(); |
426 |
} |
427 |
}); |
428 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
429 |
gridBagConstraints.gridx = 1;
|
430 |
gridBagConstraints.gridy = 0;
|
431 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
432 |
gridBagConstraints.insets = new java.awt.Insets(2, 3, 0, 5); |
433 |
jPanFirstRow.add(jTextNumberRows, gridBagConstraints); |
434 |
|
435 |
jLabelNumberRows.setText("rows");
|
436 |
jLabelNumberRows.setEnabled(false);
|
437 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
438 |
gridBagConstraints.gridx = 2;
|
439 |
gridBagConstraints.gridy = 0;
|
440 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
441 |
gridBagConstraints.weightx = 1.0;
|
442 |
gridBagConstraints.insets = new java.awt.Insets(3, 0, 0, 0); |
443 |
jPanFirstRow.add(jLabelNumberRows, gridBagConstraints); |
444 |
|
445 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
446 |
gridBagConstraints.gridx = 0;
|
447 |
gridBagConstraints.gridy = 1;
|
448 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
449 |
gridBagConstraints.weightx = 1.0;
|
450 |
jPanSource.add(jPanFirstRow, gridBagConstraints); |
451 |
|
452 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
453 |
gridBagConstraints.gridx = 0;
|
454 |
gridBagConstraints.gridy = 0;
|
455 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
456 |
gridBagConstraints.weightx = 1.0;
|
457 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); |
458 |
add(jPanSource, gridBagConstraints); |
459 |
|
460 |
jPanFields.setLayout(new java.awt.GridBagLayout());
|
461 |
|
462 |
jPanFieldList.setBorder(javax.swing.BorderFactory |
463 |
.createTitledBorder("Fields"));
|
464 |
jPanFieldList.setLayout(new java.awt.GridBagLayout());
|
465 |
|
466 |
jScrollPaneFieldList.setPreferredSize(new java.awt.Dimension(100, 150)); |
467 |
|
468 |
jListFieldList |
469 |
.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
470 |
jListFieldList.addMouseListener(new MouseListener() { |
471 |
public void mouseClicked(MouseEvent e) { |
472 |
} |
473 |
|
474 |
public void mouseEntered(MouseEvent e) { |
475 |
} |
476 |
|
477 |
public void mouseExited(MouseEvent e) { |
478 |
} |
479 |
|
480 |
public void mousePressed(MouseEvent e) { |
481 |
selectedField = jListFieldList.getSelectedIndex(); |
482 |
} |
483 |
|
484 |
public void mouseReleased(MouseEvent e) { |
485 |
} |
486 |
}); |
487 |
jListFieldList |
488 |
.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
489 |
public void valueChanged( |
490 |
javax.swing.event.ListSelectionEvent evt) { |
491 |
jListFieldListValueChanged(evt); |
492 |
} |
493 |
}); |
494 |
jScrollPaneFieldList.setViewportView(jListFieldList); |
495 |
|
496 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
497 |
gridBagConstraints.gridx = 0;
|
498 |
gridBagConstraints.gridy = 0;
|
499 |
gridBagConstraints.gridheight = 4;
|
500 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
501 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
502 |
gridBagConstraints.weightx = 1.0;
|
503 |
gridBagConstraints.weighty = 1.0;
|
504 |
jPanFieldList.add(jScrollPaneFieldList, gridBagConstraints); |
505 |
|
506 |
jButAddField.setBorderPainted(false);
|
507 |
jButAddField.setMargin(new java.awt.Insets(5, 5, 5, 5)); |
508 |
jButAddField.setMaximumSize(new java.awt.Dimension(30, 30)); |
509 |
jButAddField.setMinimumSize(new java.awt.Dimension(30, 30)); |
510 |
jButAddField.addActionListener(new java.awt.event.ActionListener() {
|
511 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
512 |
ActionButtonAddField(evt); |
513 |
} |
514 |
}); |
515 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
516 |
gridBagConstraints.gridx = 1;
|
517 |
gridBagConstraints.gridy = 2;
|
518 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; |
519 |
gridBagConstraints.weighty = 1.0;
|
520 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5); |
521 |
jPanFieldList.add(jButAddField, gridBagConstraints); |
522 |
|
523 |
jButRemoveField.setBorderPainted(false);
|
524 |
jButRemoveField.setMargin(new java.awt.Insets(5, 5, 5, 5)); |
525 |
jButRemoveField.setMaximumSize(new java.awt.Dimension(30, 30)); |
526 |
jButRemoveField.addActionListener(new java.awt.event.ActionListener() {
|
527 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
528 |
ActionButtonRemove(evt); |
529 |
} |
530 |
}); |
531 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
532 |
gridBagConstraints.gridx = 1;
|
533 |
gridBagConstraints.gridy = 3;
|
534 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; |
535 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5); |
536 |
jPanFieldList.add(jButRemoveField, gridBagConstraints); |
537 |
|
538 |
jButUpField.setForeground(java.awt.SystemColor.activeCaptionBorder); |
539 |
|
540 |
jButUpField.setBorderPainted(false);
|
541 |
jButUpField.setMargin(new java.awt.Insets(5, 5, 5, 5)); |
542 |
jButUpField.setMaximumSize(new java.awt.Dimension(30, 30)); |
543 |
jButUpField.addActionListener(new java.awt.event.ActionListener() {
|
544 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
545 |
ActionButtonUp(evt); |
546 |
} |
547 |
}); |
548 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
549 |
gridBagConstraints.gridx = 1;
|
550 |
gridBagConstraints.gridy = 0;
|
551 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; |
552 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5); |
553 |
jPanFieldList.add(jButUpField, gridBagConstraints); |
554 |
|
555 |
jButDownField.setBorderPainted(false);
|
556 |
jButDownField.setMargin(new java.awt.Insets(5, 5, 5, 5)); |
557 |
jButDownField.setMaximumSize(new java.awt.Dimension(30, 30)); |
558 |
jButDownField.setMinimumSize(new java.awt.Dimension(30, 30)); |
559 |
jButDownField.addActionListener(new java.awt.event.ActionListener() {
|
560 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
561 |
ActionButtonDown(evt); |
562 |
} |
563 |
}); |
564 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
565 |
gridBagConstraints.gridx = 1;
|
566 |
gridBagConstraints.gridy = 1;
|
567 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; |
568 |
gridBagConstraints.weighty = 1.0;
|
569 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5); |
570 |
jPanFieldList.add(jButDownField, gridBagConstraints); |
571 |
|
572 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
573 |
gridBagConstraints.gridx = 0;
|
574 |
gridBagConstraints.gridy = 1;
|
575 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
576 |
gridBagConstraints.weightx = 1.0;
|
577 |
jPanFields.add(jPanFieldList, gridBagConstraints); |
578 |
|
579 |
jPanFieldSettings.setBorder(javax.swing.BorderFactory |
580 |
.createTitledBorder("Field settings"));
|
581 |
jPanFieldSettings.setLayout(new java.awt.GridBagLayout());
|
582 |
|
583 |
jPanFieldType.setBorder(javax.swing.BorderFactory |
584 |
.createTitledBorder("Select field type"));
|
585 |
jPanFieldType.setLayout(new java.awt.GridBagLayout());
|
586 |
|
587 |
butGroupFieldType.add(jRadioString); |
588 |
jRadioString.setSelected(true);
|
589 |
jRadioString.setText("String");
|
590 |
jRadioString.setAlignmentY(1.0F);
|
591 |
jRadioString.addActionListener(new java.awt.event.ActionListener() {
|
592 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
593 |
updateStringType(evt); |
594 |
} |
595 |
}); |
596 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
597 |
gridBagConstraints.gridx = 0;
|
598 |
gridBagConstraints.gridy = 0;
|
599 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
600 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5); |
601 |
jPanFieldType.add(jRadioString, gridBagConstraints); |
602 |
|
603 |
butGroupFieldType.add(jRadioInteger); |
604 |
jRadioInteger.setText("Integer");
|
605 |
jRadioInteger.addActionListener(new java.awt.event.ActionListener() {
|
606 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
607 |
updateIntegerType(evt); |
608 |
} |
609 |
}); |
610 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
611 |
gridBagConstraints.gridx = 0;
|
612 |
gridBagConstraints.gridy = 1;
|
613 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
614 |
gridBagConstraints.weighty = 1.0;
|
615 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5); |
616 |
jPanFieldType.add(jRadioInteger, gridBagConstraints); |
617 |
|
618 |
butGroupFieldType.add(jRadioDecimal); |
619 |
jRadioDecimal.setText("Decimal");
|
620 |
jRadioDecimal.addActionListener(new java.awt.event.ActionListener() {
|
621 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
622 |
updateDecimalType(evt); |
623 |
} |
624 |
}); |
625 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
626 |
gridBagConstraints.gridx = 0;
|
627 |
gridBagConstraints.gridy = 2;
|
628 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
629 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5); |
630 |
jPanFieldType.add(jRadioDecimal, gridBagConstraints); |
631 |
|
632 |
butGroupFieldType.add(jRadioDate); |
633 |
jRadioDate.setText("Date");
|
634 |
jRadioDate.addItemListener(new java.awt.event.ItemListener() {
|
635 |
public void itemStateChanged(java.awt.event.ItemEvent evt) { |
636 |
dateStateChanged(evt); |
637 |
} |
638 |
}); |
639 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
640 |
gridBagConstraints.gridx = 0;
|
641 |
gridBagConstraints.gridy = 3;
|
642 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
643 |
gridBagConstraints.weighty = 1.0;
|
644 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5); |
645 |
jPanFieldType.add(jRadioDate, gridBagConstraints); |
646 |
|
647 |
jComboDate.setEditable(true);
|
648 |
jComboDate.setModel(new javax.swing.DefaultComboBoxModel(new String[] { |
649 |
"dd/MM/yy", "dd/MM/yyyy", "MM/dd/yyyy", "yyyy/MM/dd", |
650 |
"yy/MM/dd" }));
|
651 |
jComboDate.setEnabled(false);
|
652 |
jComboDate.addActionListener(new java.awt.event.ActionListener() {
|
653 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
654 |
ActionListDateFormat(evt); |
655 |
} |
656 |
}); |
657 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
658 |
gridBagConstraints.gridx = 0;
|
659 |
gridBagConstraints.gridy = 4;
|
660 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
661 |
gridBagConstraints.weightx = 1.0;
|
662 |
gridBagConstraints.weighty = 1.0;
|
663 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5); |
664 |
jPanFieldType.add(jComboDate, gridBagConstraints); |
665 |
|
666 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
667 |
gridBagConstraints.gridx = 0;
|
668 |
gridBagConstraints.gridy = 1;
|
669 |
gridBagConstraints.gridheight = 2;
|
670 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
671 |
jPanFieldSettings.add(jPanFieldType, gridBagConstraints); |
672 |
|
673 |
jPanSeparators.setBorder(javax.swing.BorderFactory |
674 |
.createTitledBorder("Set how field delimites with next one"));
|
675 |
jPanSeparators.setRequestFocusEnabled(false);
|
676 |
jPanSeparators.setLayout(new java.awt.GridBagLayout());
|
677 |
|
678 |
jPanFieldSeparators.setBorder(javax.swing.BorderFactory |
679 |
.createTitledBorder("Select field separators"));
|
680 |
jPanFieldSeparators.setEnabled(false);
|
681 |
jPanFieldSeparators.setLayout(new java.awt.GridBagLayout());
|
682 |
|
683 |
jChkTab.setText("Tab");
|
684 |
jChkTab.addActionListener(new java.awt.event.ActionListener() {
|
685 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
686 |
ActionTab(evt); |
687 |
} |
688 |
}); |
689 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
690 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
691 |
jPanFieldSeparators.add(jChkTab, gridBagConstraints); |
692 |
|
693 |
jChkSpace.setText("Space");
|
694 |
jChkSpace.addActionListener(new java.awt.event.ActionListener() {
|
695 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
696 |
ActionSpace(evt); |
697 |
} |
698 |
}); |
699 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
700 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
701 |
jPanFieldSeparators.add(jChkSpace, gridBagConstraints); |
702 |
|
703 |
jChkColon.setText("Colon");
|
704 |
jChkColon.addActionListener(new java.awt.event.ActionListener() {
|
705 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
706 |
ActionColon(evt); |
707 |
} |
708 |
}); |
709 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
710 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
711 |
jPanFieldSeparators.add(jChkColon, gridBagConstraints); |
712 |
|
713 |
jChkSemicolon.setText("Semicolon");
|
714 |
jChkSemicolon.addActionListener(new java.awt.event.ActionListener() {
|
715 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
716 |
ActionSemicolon(evt); |
717 |
} |
718 |
}); |
719 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
720 |
gridBagConstraints.gridy = 1;
|
721 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
722 |
jPanFieldSeparators.add(jChkSemicolon, gridBagConstraints); |
723 |
|
724 |
jChkOther.setText("Other");
|
725 |
jChkOther.addActionListener(new java.awt.event.ActionListener() {
|
726 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
727 |
enableOtherText(evt); |
728 |
} |
729 |
}); |
730 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
731 |
gridBagConstraints.gridy = 1;
|
732 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
733 |
jPanFieldSeparators.add(jChkOther, gridBagConstraints); |
734 |
|
735 |
jTextOther.setEditable(false);
|
736 |
jTextOther.setMinimumSize(new java.awt.Dimension(30, 20)); |
737 |
jTextOther.setPreferredSize(new java.awt.Dimension(30, 20)); |
738 |
jTextOther.addActionListener(new java.awt.event.ActionListener() {
|
739 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
740 |
ActionTextOther(evt); |
741 |
} |
742 |
}); |
743 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
744 |
gridBagConstraints.gridy = 1;
|
745 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
746 |
jPanFieldSeparators.add(jTextOther, gridBagConstraints); |
747 |
|
748 |
jChkJoin.setText("Join consecutive delimiters ");
|
749 |
jChkJoin.addActionListener(new java.awt.event.ActionListener() {
|
750 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
751 |
ActionJoinSep(evt); |
752 |
} |
753 |
}); |
754 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
755 |
gridBagConstraints.gridx = 0;
|
756 |
gridBagConstraints.gridy = 3;
|
757 |
gridBagConstraints.gridwidth = 3;
|
758 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
759 |
gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0); |
760 |
jPanFieldSeparators.add(jChkJoin, gridBagConstraints); |
761 |
|
762 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
763 |
gridBagConstraints.gridx = 0;
|
764 |
gridBagConstraints.gridy = 1;
|
765 |
gridBagConstraints.gridwidth = 3;
|
766 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
767 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
768 |
gridBagConstraints.weighty = 1.0;
|
769 |
jPanSeparators.add(jPanFieldSeparators, gridBagConstraints); |
770 |
|
771 |
butGroupDelimiter.add(jRadioFixed); |
772 |
jRadioFixed.setText("Fixed width");
|
773 |
jRadioFixed.addActionListener(new java.awt.event.ActionListener() {
|
774 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
775 |
fixedWidthEnable(evt); |
776 |
} |
777 |
}); |
778 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
779 |
gridBagConstraints.gridx = 1;
|
780 |
gridBagConstraints.gridy = 0;
|
781 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
782 |
jPanSeparators.add(jRadioFixed, gridBagConstraints); |
783 |
|
784 |
butGroupDelimiter.add(jRadioCharacter); |
785 |
jRadioCharacter.setSelected(true);
|
786 |
jRadioCharacter.setText("Character");
|
787 |
jRadioCharacter.addActionListener(new java.awt.event.ActionListener() {
|
788 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
789 |
charDelimitedEnable(evt); |
790 |
} |
791 |
}); |
792 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
793 |
gridBagConstraints.gridx = 0;
|
794 |
gridBagConstraints.gridy = 0;
|
795 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
796 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); |
797 |
jPanSeparators.add(jRadioCharacter, gridBagConstraints); |
798 |
|
799 |
jTextFieldWidth.setEditable(false);
|
800 |
jTextFieldWidth.setInputVerifier(new IntVerifier());
|
801 |
jTextFieldWidth.setMinimumSize(new java.awt.Dimension(40, 20)); |
802 |
jTextFieldWidth.setPreferredSize(new java.awt.Dimension(40, 20)); |
803 |
jTextFieldWidth.addKeyListener(new KeyListener() { |
804 |
public void keyPressed(KeyEvent evt) { |
805 |
} |
806 |
|
807 |
public void keyTyped(KeyEvent evt) { |
808 |
} |
809 |
|
810 |
public void keyReleased(KeyEvent e) { |
811 |
ActionTextFixedWidth(e); |
812 |
} |
813 |
}); |
814 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
815 |
gridBagConstraints.gridx = 2;
|
816 |
gridBagConstraints.gridy = 0;
|
817 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5); |
818 |
jPanSeparators.add(jTextFieldWidth, gridBagConstraints); |
819 |
|
820 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
821 |
gridBagConstraints.gridx = 1;
|
822 |
gridBagConstraints.gridy = 1;
|
823 |
gridBagConstraints.gridheight = 2;
|
824 |
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; |
825 |
jPanFieldSettings.add(jPanSeparators, gridBagConstraints); |
826 |
|
827 |
jPanFieldName.setLayout(new java.awt.GridBagLayout());
|
828 |
|
829 |
jChkDontImport.setText("Don't import");
|
830 |
jChkDontImport.addActionListener(new java.awt.event.ActionListener() {
|
831 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
832 |
ActionDontImport(evt); |
833 |
} |
834 |
}); |
835 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
836 |
gridBagConstraints.gridx = 3;
|
837 |
gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5); |
838 |
jPanFieldName.add(jChkDontImport, gridBagConstraints); |
839 |
|
840 |
jLabFieldName.setText("Field name:");
|
841 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
842 |
gridBagConstraints.gridx = 0;
|
843 |
gridBagConstraints.gridy = 0;
|
844 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); |
845 |
jPanFieldName.add(jLabFieldName, gridBagConstraints); |
846 |
|
847 |
jTextFieldName.setText("Field1");
|
848 |
jTextFieldName.setMinimumSize(new java.awt.Dimension(100, 20)); |
849 |
jTextFieldName.setPreferredSize(new java.awt.Dimension(100, 20)); |
850 |
jTextFieldName.addKeyListener(new KeyListener() { |
851 |
public void keyPressed(KeyEvent e) { |
852 |
} |
853 |
|
854 |
public void keyReleased(KeyEvent e) { |
855 |
KeyChangesFieldName(e); |
856 |
} |
857 |
|
858 |
public void keyTyped(KeyEvent e) { |
859 |
} |
860 |
}); |
861 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
862 |
gridBagConstraints.gridx = 1;
|
863 |
gridBagConstraints.gridy = 0;
|
864 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
865 |
gridBagConstraints.weightx = 1.0;
|
866 |
gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5); |
867 |
jPanFieldName.add(jTextFieldName, gridBagConstraints); |
868 |
|
869 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
870 |
gridBagConstraints.gridx = 0;
|
871 |
gridBagConstraints.gridy = 0;
|
872 |
gridBagConstraints.gridwidth = 3;
|
873 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
874 |
gridBagConstraints.weightx = 1.0;
|
875 |
jPanFieldSettings.add(jPanFieldName, gridBagConstraints); |
876 |
|
877 |
jPanel1.setLayout(new java.awt.GridBagLayout());
|
878 |
|
879 |
jPanApply.setLayout(new java.awt.GridBagLayout());
|
880 |
|
881 |
jButSave.setText("Save");
|
882 |
jButSave.addActionListener(new java.awt.event.ActionListener() {
|
883 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
884 |
jButSaveActionPerformed(evt); |
885 |
} |
886 |
}); |
887 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
888 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
889 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5); |
890 |
gridBagConstraints.gridx = 0;
|
891 |
gridBagConstraints.gridy = 0;
|
892 |
jPanApply.add(jButSave, gridBagConstraints); |
893 |
|
894 |
jButLoad.setText("Load");
|
895 |
jButLoad.addActionListener(new java.awt.event.ActionListener() {
|
896 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
897 |
jButLoadActionPerformed(evt); |
898 |
} |
899 |
}); |
900 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
901 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
902 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5); |
903 |
gridBagConstraints.gridx = 0;
|
904 |
gridBagConstraints.gridy = 1;
|
905 |
jPanApply.add(jButLoad, gridBagConstraints); |
906 |
|
907 |
jButTest.setText("Test");
|
908 |
jButTest.addActionListener(new java.awt.event.ActionListener() {
|
909 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
910 |
testNormalizer(evt); |
911 |
} |
912 |
}); |
913 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
914 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
915 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5); |
916 |
gridBagConstraints.gridx = 0;
|
917 |
gridBagConstraints.gridy = 2;
|
918 |
jPanApply.add(jButTest, gridBagConstraints); |
919 |
|
920 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
921 |
gridBagConstraints.gridx = 2;
|
922 |
gridBagConstraints.gridy = 2;
|
923 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
924 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; |
925 |
jPanel1.add(jPanApply, gridBagConstraints); |
926 |
|
927 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
928 |
gridBagConstraints.gridx = 2;
|
929 |
gridBagConstraints.gridy = 2;
|
930 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
931 |
jPanFieldSettings.add(jPanel1, gridBagConstraints); |
932 |
|
933 |
jPanInField.setBorder(javax.swing.BorderFactory |
934 |
.createTitledBorder("Set separators"));
|
935 |
jPanInField.setLayout(new java.awt.GridBagLayout());
|
936 |
|
937 |
jLabDecimal.setText("Decimal");
|
938 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
939 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
940 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
941 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 15); |
942 |
jPanInField.add(jLabDecimal, gridBagConstraints); |
943 |
|
944 |
jTextDecimal.setText(".");
|
945 |
jTextDecimal.setInputVerifier(new CharVerifier());
|
946 |
jTextDecimal.setMinimumSize(new java.awt.Dimension(30, 20)); |
947 |
jTextDecimal.setPreferredSize(new java.awt.Dimension(30, 20)); |
948 |
jTextDecimal.addFocusListener(new java.awt.event.FocusAdapter() {
|
949 |
public void focusLost(java.awt.event.FocusEvent evt) { |
950 |
ActionDecimal(evt); |
951 |
} |
952 |
}); |
953 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
954 |
gridBagConstraints.gridx = 1;
|
955 |
gridBagConstraints.gridy = 0;
|
956 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
957 |
gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 5); |
958 |
jPanInField.add(jTextDecimal, gridBagConstraints); |
959 |
|
960 |
jLabThousand.setText("Thousand");
|
961 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
962 |
gridBagConstraints.gridx = 0;
|
963 |
gridBagConstraints.gridy = 1;
|
964 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
965 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
966 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 15); |
967 |
jPanInField.add(jLabThousand, gridBagConstraints); |
968 |
|
969 |
jTextThousand.setText(null);
|
970 |
jTextThousand.setPreferredSize(new java.awt.Dimension(30, 20)); |
971 |
jTextThousand.addFocusListener(new java.awt.event.FocusAdapter() {
|
972 |
public void focusLost(java.awt.event.FocusEvent evt) { |
973 |
ActionThousand(evt); |
974 |
} |
975 |
}); |
976 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
977 |
gridBagConstraints.gridx = 1;
|
978 |
gridBagConstraints.gridy = 1;
|
979 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
980 |
gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 5); |
981 |
jPanInField.add(jTextThousand, gridBagConstraints); |
982 |
|
983 |
jLabTextDel.setText("Text:");
|
984 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
985 |
gridBagConstraints.gridx = 0;
|
986 |
gridBagConstraints.gridy = 2;
|
987 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
988 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
989 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 15); |
990 |
jPanInField.add(jLabTextDel, gridBagConstraints); |
991 |
|
992 |
jTextTextDelimiter.setHorizontalAlignment(javax.swing.JTextField.RIGHT); |
993 |
jTextTextDelimiter.setText("\"");
|
994 |
jTextTextDelimiter.setPreferredSize(new java.awt.Dimension(30, 20)); |
995 |
jTextTextDelimiter.addFocusListener(new java.awt.event.FocusAdapter() {
|
996 |
public void focusLost(java.awt.event.FocusEvent evt) { |
997 |
ActionTextText(evt); |
998 |
} |
999 |
}); |
1000 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1001 |
gridBagConstraints.gridx = 1;
|
1002 |
gridBagConstraints.gridy = 2;
|
1003 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
1004 |
gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 5); |
1005 |
jPanInField.add(jTextTextDelimiter, gridBagConstraints); |
1006 |
|
1007 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1008 |
gridBagConstraints.gridx = 2;
|
1009 |
gridBagConstraints.gridy = 1;
|
1010 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
1011 |
jPanFieldSettings.add(jPanInField, gridBagConstraints); |
1012 |
|
1013 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1014 |
gridBagConstraints.gridx = 1;
|
1015 |
gridBagConstraints.gridy = 1;
|
1016 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
1017 |
jPanFields.add(jPanFieldSettings, gridBagConstraints); |
1018 |
|
1019 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
1020 |
gridBagConstraints.gridx = 0;
|
1021 |
gridBagConstraints.gridy = 1;
|
1022 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
1023 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5); |
1024 |
add(jPanFields, gridBagConstraints); |
1025 |
|
1026 |
} |
1027 |
|
1028 |
// *****************************************
|
1029 |
// PANEL EVENTS
|
1030 |
|
1031 |
/**
|
1032 |
* This method runs when check FirstRow is selected or deselected
|
1033 |
*
|
1034 |
* @param evt
|
1035 |
*/
|
1036 |
private void EvCheckFirstRow(java.awt.event.ActionEvent evt) { |
1037 |
/* DON'T Normalize the first rows */
|
1038 |
if (jCheckFirstRow.isSelected()) {
|
1039 |
jTextNumberRows.setText("1");
|
1040 |
jTextNumberRows.setEditable(true);
|
1041 |
controller |
1042 |
.setFirstRows(Integer.parseInt(jTextNumberRows.getText()));
|
1043 |
this.jTextNumberRows.requestFocus();
|
1044 |
DefaultTableModel model = controller.getSamplesDataStore(controller.getFirstRows());
|
1045 |
jTableSource.setModel(model); |
1046 |
} |
1047 |
/* Normalize the first rows */
|
1048 |
else {
|
1049 |
jTextNumberRows.setText("0");
|
1050 |
jTextNumberRows.setEditable(false);
|
1051 |
controller.setFirstRows(0);
|
1052 |
DefaultTableModel model = controller.getSamplesDataStore(controller.getFirstRows());
|
1053 |
jTableSource.setModel(model); |
1054 |
} |
1055 |
} |
1056 |
|
1057 |
/**
|
1058 |
* This method runs when textField is modify
|
1059 |
*
|
1060 |
*/
|
1061 |
private void firstRowsvalueChange() { |
1062 |
try {
|
1063 |
controller |
1064 |
.setFirstRows(Integer.parseInt(jTextNumberRows.getText()));
|
1065 |
controller.getSamplesFromFile(controller.getFirstRows()); |
1066 |
jTableSource.setModel(getSourceData()); |
1067 |
jTableSource.validate(); |
1068 |
} catch (Exception e) { |
1069 |
jTextNumberRows.requestFocus(); |
1070 |
} |
1071 |
} |
1072 |
|
1073 |
/**
|
1074 |
* This method runs when check Don't Import is selected or deselected
|
1075 |
*
|
1076 |
* @param evt
|
1077 |
*/
|
1078 |
private void ActionDontImport(java.awt.event.ActionEvent evt) { |
1079 |
setDirty(true);
|
1080 |
} |
1081 |
|
1082 |
/**
|
1083 |
* This method runs when combo Date Format has changed
|
1084 |
*
|
1085 |
* @param evt
|
1086 |
*/
|
1087 |
private void ActionListDateFormat(java.awt.event.ActionEvent evt) { |
1088 |
setDirty(true);
|
1089 |
} |
1090 |
|
1091 |
/**
|
1092 |
* This method runs when text fixed width has changed
|
1093 |
*
|
1094 |
* @param evt
|
1095 |
*/
|
1096 |
private void ActionTextFixedWidth(java.awt.event.KeyEvent evt) { |
1097 |
|
1098 |
boolean vali = new IntVerifier().verify(jTextFieldWidth); |
1099 |
if (vali) {
|
1100 |
setDirty(true);
|
1101 |
} else {
|
1102 |
jTextFieldWidth.setText("1");
|
1103 |
setDirty(true);
|
1104 |
} |
1105 |
} |
1106 |
|
1107 |
/**
|
1108 |
* This method runs when check TAB is selected or deselected
|
1109 |
*
|
1110 |
* @param evt
|
1111 |
*/
|
1112 |
private void ActionTab(java.awt.event.ActionEvent evt) { |
1113 |
setDirty(true);
|
1114 |
} |
1115 |
|
1116 |
/**
|
1117 |
* This method runs when check SPACE is selected or deselected
|
1118 |
*
|
1119 |
* @param evt
|
1120 |
*/
|
1121 |
private void ActionSpace(java.awt.event.ActionEvent evt) { |
1122 |
setDirty(true);
|
1123 |
} |
1124 |
|
1125 |
/**
|
1126 |
* This method runs when check COLON is selected or deselected
|
1127 |
*
|
1128 |
* @param evt
|
1129 |
*/
|
1130 |
private void ActionColon(java.awt.event.ActionEvent evt) { |
1131 |
setDirty(true);
|
1132 |
} |
1133 |
|
1134 |
/**
|
1135 |
* This method runs when check SEMICOLON is selected or deselected
|
1136 |
*
|
1137 |
* @param evt
|
1138 |
*/
|
1139 |
private void ActionSemicolon(java.awt.event.ActionEvent evt) { |
1140 |
setDirty(true);
|
1141 |
} |
1142 |
|
1143 |
/**
|
1144 |
* This method runs when text Other has changed
|
1145 |
*
|
1146 |
* @param evt
|
1147 |
*/
|
1148 |
private void ActionTextOther(java.awt.event.ActionEvent evt) { |
1149 |
setDirty(true);
|
1150 |
} |
1151 |
|
1152 |
/**
|
1153 |
* This method runs when text Decimal has changed
|
1154 |
*
|
1155 |
* @param evt
|
1156 |
*/
|
1157 |
private void ActionDecimal(java.awt.event.FocusEvent evt) { |
1158 |
setDirty(true);
|
1159 |
} |
1160 |
|
1161 |
/**
|
1162 |
* This method runs when text Thousand has changed
|
1163 |
*
|
1164 |
* @param evt
|
1165 |
*/
|
1166 |
private void ActionThousand(java.awt.event.FocusEvent evt) { |
1167 |
setDirty(true);
|
1168 |
} |
1169 |
|
1170 |
/**
|
1171 |
* This method runs when text Text has changed
|
1172 |
*
|
1173 |
* @param evt
|
1174 |
*/
|
1175 |
private void ActionTextText(java.awt.event.FocusEvent evt) { |
1176 |
setDirty(true);
|
1177 |
} |
1178 |
|
1179 |
/**
|
1180 |
* This method runs when Field Name has changed
|
1181 |
*
|
1182 |
* @param evt
|
1183 |
*/
|
1184 |
private void KeyChangesFieldName(KeyEvent evt) { |
1185 |
// log.debug("#Key Pressed Field name# :" + this.selectedField);
|
1186 |
int pos = this.selectedField; |
1187 |
updateFieldToModel(pos); |
1188 |
updateGUI(); |
1189 |
setDirty(false);
|
1190 |
} |
1191 |
|
1192 |
/**
|
1193 |
*
|
1194 |
* @param evt
|
1195 |
*/
|
1196 |
private void mainPanelGetFocus(java.awt.event.FocusEvent evt) { |
1197 |
jTableSource.setModel(getSourceData()); |
1198 |
} |
1199 |
|
1200 |
/**
|
1201 |
* This method runs when check Join Separators is selected or deselected
|
1202 |
*
|
1203 |
* @param evt
|
1204 |
*/
|
1205 |
private void ActionJoinSep(java.awt.event.ActionEvent evt) { |
1206 |
setDirty(true);
|
1207 |
} |
1208 |
|
1209 |
/**
|
1210 |
* This method runs when check fixed width is selected or deselected
|
1211 |
*
|
1212 |
* @param evt
|
1213 |
*/
|
1214 |
private void fixedWidthEnable(java.awt.event.ActionEvent evt) { |
1215 |
this.jTextFieldWidth.setEditable(true); |
1216 |
Component[] comps = this.jPanFieldSeparators.getComponents(); |
1217 |
for (int i = 0; i < comps.length; i++) { |
1218 |
comps[i].setEnabled(false);
|
1219 |
} |
1220 |
this.jTextFieldWidth.requestFocus();
|
1221 |
setDirty(true);
|
1222 |
} |
1223 |
|
1224 |
/**
|
1225 |
* This method runs when radio character delimiters is selected or
|
1226 |
* deselected
|
1227 |
*
|
1228 |
* @param evt
|
1229 |
*/
|
1230 |
private void charDelimitedEnable(java.awt.event.ActionEvent evt) { |
1231 |
this.jTextFieldWidth.setEditable(false); |
1232 |
Component[] comps = this.jPanFieldSeparators.getComponents(); |
1233 |
for (int i = 0; i < comps.length; i++) { |
1234 |
comps[i].setEnabled(true);
|
1235 |
} |
1236 |
setDirty(true);
|
1237 |
} |
1238 |
|
1239 |
/**
|
1240 |
* This method runs when radio Field Date is selected or deselected
|
1241 |
*
|
1242 |
* @param evt
|
1243 |
*/
|
1244 |
private void dateStateChanged(java.awt.event.ItemEvent evt) { |
1245 |
updateSelectors(); |
1246 |
boolean enable = this.jRadioDate.isSelected(); |
1247 |
this.jComboDate.setEnabled(enable);
|
1248 |
if (enable) {
|
1249 |
this.jComboDate.requestFocus();
|
1250 |
} |
1251 |
setDirty(true);
|
1252 |
} |
1253 |
|
1254 |
/**
|
1255 |
* This method runs when Testing button is pressed
|
1256 |
*
|
1257 |
* @param evt
|
1258 |
*/
|
1259 |
private void testNormalizer(java.awt.event.ActionEvent evt) { |
1260 |
/* Save elements */
|
1261 |
if (isDirty()) {
|
1262 |
updateFieldToModel(jListFieldList.getSelectedIndex()); |
1263 |
} |
1264 |
/* Normalize */
|
1265 |
Object[][] data = this.controller.normalizeSamples(); |
1266 |
String[] nam = this.controller.getNewFieldNames(); |
1267 |
jTableResult.setModel(new DefaultTableModel(data, nam)); |
1268 |
} |
1269 |
|
1270 |
/**
|
1271 |
* This method runs when check OTHER TEXT is selected or deselected
|
1272 |
*
|
1273 |
* @param evt
|
1274 |
*/
|
1275 |
private void enableOtherText(java.awt.event.ActionEvent evt) { |
1276 |
this.jTextOther.setEditable(this.jChkOther.isSelected()); |
1277 |
if (this.jChkOther.isSelected()) { |
1278 |
jTextOther.requestFocus(); |
1279 |
} |
1280 |
setDirty(true);
|
1281 |
} |
1282 |
|
1283 |
/**
|
1284 |
* This method runs when Normalization button is pressed
|
1285 |
*
|
1286 |
* @param evt
|
1287 |
*/
|
1288 |
private void runNormalizer(java.awt.event.ActionEvent evt) { |
1289 |
|
1290 |
/* Save the pattern */
|
1291 |
if (isDirty()) {
|
1292 |
updateFieldToModel(this.selectedField);
|
1293 |
} |
1294 |
/* Get the relate fields of the list */
|
1295 |
if (!isFile) {
|
1296 |
String[] nam = null; |
1297 |
Object[] names = jListOriginalFields.getSelectedValues(); |
1298 |
|
1299 |
/* select all fields */
|
1300 |
if (jListOriginalFields.getSelectedIndex() == 1) { |
1301 |
|
1302 |
nam = this.controller.getFieldNamesMainTable();
|
1303 |
} |
1304 |
/* fields selected */
|
1305 |
if (jListOriginalFields.getSelectedIndex() != 0 |
1306 |
&& jListOriginalFields.getSelectedIndex() != 1) {
|
1307 |
|
1308 |
nam = new String[names.length]; |
1309 |
for (int i = 0; i < names.length; i++) { |
1310 |
nam[i] = (String) names[i];
|
1311 |
} |
1312 |
} |
1313 |
this.controller.setNameRelateFields(nam);
|
1314 |
} |
1315 |
/* RUN */
|
1316 |
this.controller.runModel(this); |
1317 |
|
1318 |
} |
1319 |
|
1320 |
/**
|
1321 |
* Update the type
|
1322 |
*
|
1323 |
* @param evt
|
1324 |
*/
|
1325 |
private void updateStringType(java.awt.event.ActionEvent evt) { |
1326 |
updateSelectors(); |
1327 |
setDirty(true);
|
1328 |
} |
1329 |
|
1330 |
/**
|
1331 |
* Update the type
|
1332 |
*
|
1333 |
* @param evt
|
1334 |
*/
|
1335 |
private void updateIntegerType(java.awt.event.ActionEvent evt) { |
1336 |
updateSelectors(); |
1337 |
setDirty(true);
|
1338 |
} |
1339 |
|
1340 |
/**
|
1341 |
* Update the type
|
1342 |
*
|
1343 |
* @param evt
|
1344 |
*/
|
1345 |
private void updateDecimalType(java.awt.event.ActionEvent evt) { |
1346 |
updateSelectors(); |
1347 |
setDirty(true);
|
1348 |
} |
1349 |
|
1350 |
/**
|
1351 |
* This method runs when UP button is pressed
|
1352 |
*
|
1353 |
* @param evt
|
1354 |
*/
|
1355 |
private void ActionButtonUp(java.awt.event.ActionEvent evt) { |
1356 |
// log.debug("#Up# Old selected field: " + this.selectedField);
|
1357 |
int pos = this.selectedField; |
1358 |
updateFieldToModel(pos); |
1359 |
setDirty(false);
|
1360 |
|
1361 |
this.controller.fieldUp(pos);
|
1362 |
DefaultListModel dlm = this.updateListModel(); |
1363 |
jListFieldList.setModel(dlm); |
1364 |
if (pos > 0 && dlm.getSize() > 1) { |
1365 |
this.selectedField = pos - 1; |
1366 |
jListFieldList.setSelectedIndex(pos - 1);
|
1367 |
} else {
|
1368 |
this.selectedField = pos;
|
1369 |
jListFieldList.setSelectedIndex(pos); |
1370 |
} |
1371 |
} |
1372 |
|
1373 |
/**
|
1374 |
* This method runs when ADD button is pressed
|
1375 |
*
|
1376 |
* @param evt
|
1377 |
*/
|
1378 |
private void ActionButtonAddField(java.awt.event.ActionEvent evt) { |
1379 |
// log.debug("#Add# Old selected field: " + this.selectedField);
|
1380 |
int pos = this.selectedField; |
1381 |
updateFieldToModel(pos); |
1382 |
setDirty(false);
|
1383 |
|
1384 |
controller.addField(); |
1385 |
DefaultListModel dlm = this.updateListModel(); |
1386 |
int siz = dlm.size();
|
1387 |
this.selectedField = siz - 1; |
1388 |
jListFieldList.setModel(dlm); |
1389 |
jListFieldList.setSelectedIndex(siz - 1);
|
1390 |
jTextOther.setEditable(false);
|
1391 |
} |
1392 |
|
1393 |
/**
|
1394 |
* This method runs when REMOVE button is pressed
|
1395 |
*
|
1396 |
* @param evt
|
1397 |
*/
|
1398 |
private void ActionButtonRemove(java.awt.event.ActionEvent evt) { |
1399 |
int siz = jListFieldList.getModel().getSize();
|
1400 |
// log.debug("#Remove# Old selected field: " + this.selectedField);
|
1401 |
int pos = this.selectedField; |
1402 |
if (siz > 0) { |
1403 |
updateFieldToModel(pos); |
1404 |
setDirty(false);
|
1405 |
controller.deleteField(pos); |
1406 |
DefaultListModel dlm = this.updateListModel(); |
1407 |
if (pos > 0) { |
1408 |
this.selectedField = pos - 1; |
1409 |
jListFieldList.setModel(dlm); |
1410 |
jListFieldList.setSelectedIndex(pos - 1);
|
1411 |
} else {
|
1412 |
this.selectedField = pos;
|
1413 |
jListFieldList.setModel(dlm); |
1414 |
jListFieldList.setSelectedIndex(pos); |
1415 |
} |
1416 |
} |
1417 |
} |
1418 |
|
1419 |
/**
|
1420 |
* This method runs when DOWN button is pressed
|
1421 |
*
|
1422 |
* @param evt
|
1423 |
*/
|
1424 |
private void ActionButtonDown(java.awt.event.ActionEvent evt) { |
1425 |
// log.debug("#Down# Ols selected field: " + this.selectedField);
|
1426 |
int pos = this.selectedField; |
1427 |
updateFieldToModel(pos); |
1428 |
setDirty(false);
|
1429 |
|
1430 |
controller.fieldDown(pos); |
1431 |
DefaultListModel dlm = this.updateListModel(); |
1432 |
jListFieldList.removeAll(); |
1433 |
jListFieldList.setModel(dlm); |
1434 |
int can = dlm.getSize();
|
1435 |
if (pos < can - 1 && can > 1) { |
1436 |
this.selectedField = pos + 1; |
1437 |
jListFieldList.setSelectedIndex(pos + 1);
|
1438 |
} else {
|
1439 |
jListFieldList.setSelectedIndex(pos); |
1440 |
} |
1441 |
} |
1442 |
|
1443 |
/**
|
1444 |
* When press the Load pattern button
|
1445 |
*
|
1446 |
* @param evt
|
1447 |
*/
|
1448 |
private void jButLoadActionPerformed(java.awt.event.ActionEvent evt) { |
1449 |
// log.debug("#Load# Selected field: " + this.selectedField);
|
1450 |
/* update the model from the view */
|
1451 |
updateFieldToModel(this.selectedField);
|
1452 |
setDirty(false);
|
1453 |
|
1454 |
/* load the model from xml file */
|
1455 |
Patternnormalization pat = controller.loadPatternXML(); |
1456 |
|
1457 |
/* update the panel */
|
1458 |
if (pat != null) { |
1459 |
/* save pattern in the model */
|
1460 |
controller.setPattern(pat); |
1461 |
|
1462 |
DefaultListModel dlm = this.updateListModel(); |
1463 |
jListFieldList.setModel(dlm); |
1464 |
jListFieldList.setSelectedIndex(0);
|
1465 |
jCheckFirstRow.setSelected(controller.getFirstRows() != 0);
|
1466 |
if (jCheckFirstRow.isSelected()) {
|
1467 |
jTextNumberRows.setEditable(true);
|
1468 |
jTextNumberRows.setText(controller.getFirstRows() + "");
|
1469 |
controller.getSamplesFromFile(controller.getFirstRows()); |
1470 |
jTableSource.setModel(getSourceData()); |
1471 |
} |
1472 |
setDirty(false);
|
1473 |
} |
1474 |
|
1475 |
} |
1476 |
|
1477 |
/**
|
1478 |
* When change the selected element
|
1479 |
*
|
1480 |
* @param evt
|
1481 |
*/
|
1482 |
private void jListFieldListValueChanged( |
1483 |
javax.swing.event.ListSelectionEvent evt) { |
1484 |
// log.debug("1. Fila seleccionada: " + this.selectedField);
|
1485 |
/* Save the parameters in the model */
|
1486 |
boolean dirty = isDirty();
|
1487 |
if (dirty) {
|
1488 |
updateFieldToModel(this.selectedField);
|
1489 |
} |
1490 |
if (!evt.getValueIsAdjusting()) {
|
1491 |
int pos = this.selectedField; |
1492 |
updateFieldToGUI(pos); |
1493 |
jListFieldList.setSelectedIndex(pos); |
1494 |
} |
1495 |
setDirty(false);
|
1496 |
} |
1497 |
|
1498 |
/**
|
1499 |
* When press the Save pattern button
|
1500 |
*
|
1501 |
* @param evt
|
1502 |
*/
|
1503 |
private void jButSaveActionPerformed(java.awt.event.ActionEvent evt) { |
1504 |
controller.setFirstRows(Integer.parseInt(jTextNumberRows.getText()));
|
1505 |
int pos = this.selectedField; |
1506 |
updateFieldToModel(pos); |
1507 |
setDirty(false);
|
1508 |
/* save the pattern */
|
1509 |
controller.savePatternXML(); |
1510 |
} |
1511 |
|
1512 |
/**
|
1513 |
* Method to update GUI values with the selected column
|
1514 |
*
|
1515 |
* @param id
|
1516 |
* column number
|
1517 |
*/
|
1518 |
private void updateFieldToGUI(int id) { |
1519 |
|
1520 |
Element elem = this.controller.getElement(id); |
1521 |
|
1522 |
/* name */
|
1523 |
this.jTextFieldName.setText(elem.getFieldname());
|
1524 |
|
1525 |
/* don't import */
|
1526 |
this.jChkDontImport.setSelected(!elem.getImportfield());
|
1527 |
|
1528 |
/* Update type */
|
1529 |
Fieldtype type = elem.getFieldtype(); |
1530 |
|
1531 |
if (type == null) { |
1532 |
type = new DefaultFieldtype();
|
1533 |
type.setStringvalue(new DefaultStringvalue());
|
1534 |
elem.setFieldtype(type); |
1535 |
} |
1536 |
|
1537 |
boolean flag = false; |
1538 |
if (type.getDatevalue() != null) { |
1539 |
jRadioDate.setSelected(true);
|
1540 |
String formato = type.getDatevalue().getDatevalueformat();
|
1541 |
DefaultComboBoxModel model = (DefaultComboBoxModel) jComboDate |
1542 |
.getModel(); |
1543 |
for (int i = 0; i < model.getSize(); i++) { |
1544 |
String nameformato = (String) model.getElementAt(i); |
1545 |
if (formato.compareToIgnoreCase(nameformato) == 0) { |
1546 |
jComboDate.setSelectedIndex(i); |
1547 |
flag = true;
|
1548 |
} |
1549 |
} |
1550 |
if (!flag) {
|
1551 |
model.addElement(formato); |
1552 |
jComboDate.setModel(model); |
1553 |
jComboDate.setSelectedItem(formato); |
1554 |
} |
1555 |
} else if (type.getStringvalue() != null) { |
1556 |
jRadioString.setSelected(true);
|
1557 |
} else if (type.getIntegervalue() != null) { |
1558 |
jRadioInteger.setSelected(true);
|
1559 |
} else if (type.getDecimalvalue() != null) { |
1560 |
jRadioDecimal.setSelected(true);
|
1561 |
} |
1562 |
|
1563 |
/* Update field separator */
|
1564 |
Fieldseparator seps = elem.getFieldseparator(); |
1565 |
if (seps == null) { |
1566 |
controller.getDefaultFieldseparators(); |
1567 |
} |
1568 |
|
1569 |
this.jTextFieldWidth.setText(Integer.toString(elem.getFieldwidth())); |
1570 |
boolean isFixedWidth = elem.getFieldwidth() > 0; |
1571 |
|
1572 |
this.jRadioFixed.setSelected(isFixedWidth);
|
1573 |
this.jRadioCharacter.setSelected(!isFixedWidth);
|
1574 |
|
1575 |
if (isFixedWidth) {
|
1576 |
this.fixedWidthEnable(null); |
1577 |
} else {
|
1578 |
this.charDelimitedEnable(null); |
1579 |
} |
1580 |
|
1581 |
this.jChkJoin.setSelected(seps.getJoinsep());
|
1582 |
|
1583 |
this.jChkTab.setSelected(seps.getTabsep());
|
1584 |
|
1585 |
this.jChkSpace.setSelected(seps.getSpacesep());
|
1586 |
|
1587 |
this.jChkColon.setSelected(seps.getColonsep());
|
1588 |
|
1589 |
this.jChkSemicolon.setSelected(seps.getSemicolonsep());
|
1590 |
|
1591 |
boolean other = seps.getOthersep() != null; |
1592 |
this.jChkOther.setSelected(other);
|
1593 |
|
1594 |
if (other) {
|
1595 |
this.jTextOther.setText(seps.getOthersep());
|
1596 |
} else {
|
1597 |
this.jTextOther.setEditable(false); |
1598 |
this.jTextOther.setText(null); |
1599 |
} |
1600 |
|
1601 |
/* Update field separator */
|
1602 |
|
1603 |
Infieldseparators insep = elem.getInfieldseparators(); |
1604 |
this.jTextDecimal.setText(insep.getDecimalseparator().trim());
|
1605 |
this.jTextThousand.setText(insep.getThousandseparator().trim());
|
1606 |
this.jTextTextDelimiter.setText(insep.getTextseparator().trim());
|
1607 |
|
1608 |
updateSelectors(); |
1609 |
|
1610 |
setDirty(false);
|
1611 |
} |
1612 |
|
1613 |
/**
|
1614 |
* Update the field values in the model
|
1615 |
*/
|
1616 |
private void updateFieldToModel(int pos) { |
1617 |
|
1618 |
Element elem = this.controller.getElement(pos); |
1619 |
|
1620 |
/* name */
|
1621 |
elem.setFieldname(this.jTextFieldName.getText());
|
1622 |
|
1623 |
/* don't import */
|
1624 |
elem.setImportfield(!this.jChkDontImport.isSelected());
|
1625 |
|
1626 |
/* Update type */
|
1627 |
Fieldtype type = new DefaultFieldtype();
|
1628 |
|
1629 |
if (jRadioString.isSelected()) {
|
1630 |
Stringvalue strval = new DefaultStringvalue();
|
1631 |
strval.setStringvaluewidth(50);
|
1632 |
type.setStringvalue(strval); |
1633 |
} else if (jRadioInteger.isSelected()) { |
1634 |
Integervalue intval = new DefaultIntegervalue();
|
1635 |
intval.setIntegervaluewidth(25);
|
1636 |
type.setIntegervalue(intval); |
1637 |
} else if (jRadioDecimal.isSelected()) { |
1638 |
Decimalvalue dec = new DefaultDecimalvalue();
|
1639 |
/* DECIMALES = 10 */
|
1640 |
dec.setDecimalvaluedec(10);
|
1641 |
dec.setDecimalvalueint(25);
|
1642 |
type.setDecimalvalue(dec); |
1643 |
} else {
|
1644 |
Datevalue date = new DefaultDatevalue();
|
1645 |
String form = jComboDate.getSelectedItem().toString();
|
1646 |
date.setDatevalueformat(form); |
1647 |
type.setDatevalue(date); |
1648 |
} |
1649 |
elem.setFieldtype(type); |
1650 |
|
1651 |
/* Update field separator */
|
1652 |
Fieldseparator seps = elem.getFieldseparator(); |
1653 |
|
1654 |
if (elem.getFieldseparator() == null) { |
1655 |
seps = new DefaultFieldseparator();
|
1656 |
} |
1657 |
|
1658 |
boolean isFixedWidth = this.jRadioFixed.isSelected(); |
1659 |
int val;
|
1660 |
if (isFixedWidth) {
|
1661 |
try {
|
1662 |
val = Integer.parseInt(jTextFieldWidth.getText());
|
1663 |
elem.setFieldwidth(val); |
1664 |
} catch (Exception e) { |
1665 |
jTextFieldWidth.requestFocus(); |
1666 |
} |
1667 |
|
1668 |
} else {
|
1669 |
elem.setFieldwidth(0);
|
1670 |
} |
1671 |
|
1672 |
seps.setJoinsep(this.jChkJoin.isSelected());
|
1673 |
seps.setSpacesep(this.jChkSpace.isSelected());
|
1674 |
seps.setColonsep(this.jChkColon.isSelected());
|
1675 |
seps.setSemicolonsep(this.jChkSemicolon.isSelected());
|
1676 |
seps.setTabsep(this.jChkTab.isSelected());
|
1677 |
|
1678 |
if (jChkOther.isSelected() && jTextOther.getText().length() == 1) { |
1679 |
seps.setOthersep(jTextOther.getText().trim()); |
1680 |
} else {
|
1681 |
seps.setOthersep(null);
|
1682 |
} |
1683 |
|
1684 |
/* Update In-field separator */
|
1685 |
Infieldseparators inseps = elem.getInfieldseparators(); |
1686 |
|
1687 |
if (elem.getInfieldseparators() == null) { |
1688 |
inseps = new DefaultInfieldseparators();
|
1689 |
} |
1690 |
|
1691 |
inseps.setThousandseparator(this.jTextThousand.getText().trim());
|
1692 |
inseps.setDecimalseparator(this.jTextDecimal.getText().trim());
|
1693 |
inseps.setTextseparator(this.jTextTextDelimiter.getText().trim());
|
1694 |
|
1695 |
} |
1696 |
|
1697 |
|
1698 |
|
1699 |
/**
|
1700 |
* Update GUI elements with model info
|
1701 |
*/
|
1702 |
private void updateGUI() { |
1703 |
|
1704 |
/* Source Samples values */
|
1705 |
jTableSource.setModel(getSourceData()); |
1706 |
|
1707 |
/* Fields List */
|
1708 |
jListFieldList.setModel(this.updateListModel());
|
1709 |
jListFieldList.setSelectedIndex(0);
|
1710 |
|
1711 |
/* Fields List in Original Table */
|
1712 |
if (!isFile) {
|
1713 |
DefaultListModel dlmot = controller.getAllOriginalFields();
|
1714 |
jListOriginalFields.setModel(dlmot); |
1715 |
jListOriginalFields.setSelectedIndex(0);
|
1716 |
} |
1717 |
/* Disable any controls */
|
1718 |
if (isFile) {
|
1719 |
jTableSource.setName(controller.getFileName()); |
1720 |
jCheckFirstRow.setEnabled(true);
|
1721 |
jLabelNumberRows.setEnabled(true);
|
1722 |
jCheckFirstRow.setSelected(controller.getFirstRows() != 0);
|
1723 |
jTextNumberRows.setText(controller.getFirstRows() + "");
|
1724 |
jRadioAlterTable.setEnabled(false);
|
1725 |
jListOriginalFields.removeAll(); |
1726 |
jRadioNewTable.setSelected(true);
|
1727 |
controller.setInNewTable(true);
|
1728 |
jListOriginalFields.setEnabled(false);
|
1729 |
} |
1730 |
} |
1731 |
|
1732 |
/**
|
1733 |
*
|
1734 |
* @author jsanz
|
1735 |
*
|
1736 |
*/
|
1737 |
class IntVerifier extends InputVerifier { |
1738 |
|
1739 |
public boolean verify(JComponent input) { |
1740 |
try {
|
1741 |
Integer.parseInt(((JTextField) input).getText()); |
1742 |
return true; |
1743 |
} catch (NumberFormatException e) { |
1744 |
log.error("Parsing the value");
|
1745 |
return false; |
1746 |
} |
1747 |
} |
1748 |
} |
1749 |
|
1750 |
/**
|
1751 |
*
|
1752 |
* @author jsanz
|
1753 |
*
|
1754 |
*/
|
1755 |
class CharVerifier extends InputVerifier { |
1756 |
|
1757 |
public boolean verify(JComponent input) { |
1758 |
String text = ((JTextField) input).getText(); |
1759 |
if (text != null && text.length() == 1) { |
1760 |
return true; |
1761 |
} else {
|
1762 |
return false; |
1763 |
} |
1764 |
} |
1765 |
} |
1766 |
|
1767 |
/**
|
1768 |
* Update the in separators
|
1769 |
*
|
1770 |
*/
|
1771 |
private void updateSelectors() { |
1772 |
boolean isDecimal = false; |
1773 |
boolean isThousand = false; |
1774 |
boolean isText = false; |
1775 |
|
1776 |
if (this.jRadioString.isSelected()) { |
1777 |
isText = true;
|
1778 |
} else if (this.jRadioInteger.isSelected()) { |
1779 |
isThousand = true;
|
1780 |
} else if (this.jRadioDecimal.isSelected()) { |
1781 |
isThousand = true;
|
1782 |
isDecimal = true;
|
1783 |
} else if (this.jRadioDate.isSelected()) { |
1784 |
|
1785 |
} |
1786 |
|
1787 |
this.jTextDecimal.setEditable(isDecimal);
|
1788 |
this.jTextThousand.setEditable(isThousand);
|
1789 |
this.jTextTextDelimiter.setEditable(isText);
|
1790 |
} |
1791 |
|
1792 |
/**
|
1793 |
* This method updates the labels
|
1794 |
*/
|
1795 |
private void setMessages() { |
1796 |
|
1797 |
if (this.ps == null) |
1798 |
return;
|
1799 |
|
1800 |
this.setName(ps.getText("normtitle")); |
1801 |
jPanSource.setBorder(BorderFactory.createTitledBorder(ps
|
1802 |
.getText("normsource")));
|
1803 |
jCheckFirstRow.setText(ps.getText("normfirstrows"));
|
1804 |
jLabelNumberRows.setText(ps.getText("normfirstnumberrows"));
|
1805 |
|
1806 |
jPanFieldList.setBorder(BorderFactory.createTitledBorder(ps
|
1807 |
.getText("normfields")));
|
1808 |
|
1809 |
jPanFieldSettings.setBorder(BorderFactory.createTitledBorder(ps
|
1810 |
.getText("normfieldsettings")));
|
1811 |
jLabFieldName.setText(ps.getText("normfieldname"));
|
1812 |
jChkDontImport.setText(ps.getText("normdontimport"));
|
1813 |
|
1814 |
jPanFieldType.setBorder(BorderFactory.createTitledBorder(ps
|
1815 |
.getText("normfieldtype")));
|
1816 |
jRadioString.setText(ps.getText("normfieldstring"));
|
1817 |
jRadioInteger.setText(ps.getText("normfieldinteger"));
|
1818 |
jRadioDecimal.setText(ps.getText("normfielddecimal"));
|
1819 |
jRadioDate.setText(ps.getText("normfielddate"));
|
1820 |
|
1821 |
jPanSeparators.setBorder(BorderFactory.createTitledBorder(ps
|
1822 |
.getText("normdelimetersnext")));
|
1823 |
jRadioCharacter.setText(ps.getText("normcharacter"));
|
1824 |
jRadioFixed.setText(ps.getText("normfixedwidth"));
|
1825 |
|
1826 |
jPanFieldSeparators.setBorder(BorderFactory.createTitledBorder(ps
|
1827 |
.getText("normfieldseparators")));
|
1828 |
jChkTab.setText(ps.getText("normtab"));
|
1829 |
jChkSpace.setText(ps.getText("normspace"));
|
1830 |
jChkColon.setText(ps.getText("normcolon"));
|
1831 |
jChkSemicolon.setText(ps.getText("normsemicolon"));
|
1832 |
jChkOther.setText(ps.getText("normother"));
|
1833 |
jChkJoin.setText(ps.getText("normjoin"));
|
1834 |
|
1835 |
jPanInField.setBorder(BorderFactory.createTitledBorder(ps
|
1836 |
.getText("norminfieldseparators")));
|
1837 |
jLabDecimal.setText(ps.getText("normdecimal"));
|
1838 |
jLabThousand.setText(ps.getText("normthousand"));
|
1839 |
jLabTextDel.setText(ps.getText("normtextdelimiter"));
|
1840 |
|
1841 |
jButTest.setText(ps.getText("normtest"));
|
1842 |
|
1843 |
jPanSampleOutput.setBorder(BorderFactory.createTitledBorder(ps
|
1844 |
.getText("normsampleout")));
|
1845 |
|
1846 |
jPanOutputOpt.setBorder(BorderFactory.createTitledBorder(ps
|
1847 |
.getText("normoutputopt")));
|
1848 |
jRadioAlterTable.setText(ps.getText("normaltertable"));
|
1849 |
jRadioNewTable.setText(ps.getText("normnewtable"));
|
1850 |
jLabelSelFields.setText(ps.getText("normjoinfield"));
|
1851 |
|
1852 |
jPanConsole.setBorder(BorderFactory.createTitledBorder(ps
|
1853 |
.getText("normconsole")));
|
1854 |
|
1855 |
jButLoad.setText(ps.getText("normload"));
|
1856 |
jButSave.setText(ps.getText("normsave"));
|
1857 |
jButRun.setText(ps.getText("normrun"));
|
1858 |
jButCancel.setText(ps.getText("normcancel"));
|
1859 |
} |
1860 |
|
1861 |
/**
|
1862 |
* this method says if the panel has changed any parameter
|
1863 |
*
|
1864 |
* @return the dirty
|
1865 |
*/
|
1866 |
private boolean isDirty() { |
1867 |
return dirty;
|
1868 |
} |
1869 |
|
1870 |
/**
|
1871 |
*
|
1872 |
* When the panel has changed any parameter (true)
|
1873 |
*
|
1874 |
* @param dirty
|
1875 |
* flag
|
1876 |
*/
|
1877 |
private void setDirty(boolean dirty) { |
1878 |
this.dirty = dirty;
|
1879 |
} |
1880 |
|
1881 |
/**
|
1882 |
* This method updates the images
|
1883 |
*/
|
1884 |
private void setImages() { |
1885 |
|
1886 |
if (this.ps == null) |
1887 |
return;
|
1888 |
|
1889 |
String bDir = ps.getClassLoader().getBaseDir();
|
1890 |
|
1891 |
jButUpField.setIcon(new ImageIcon(bDir + File.separator + "images" |
1892 |
+ File.separator + "icons16" + File.separator + "go-up.png")); |
1893 |
jButDownField.setIcon(new ImageIcon(bDir + File.separator + "images" |
1894 |
+ File.separator + "icons16" + File.separator + "go-down.png")); |
1895 |
jButAddField |
1896 |
.setIcon(new ImageIcon(bDir + File.separator + "images" |
1897 |
+ File.separator + "icons16" + File.separator |
1898 |
+ "list-add.png"));
|
1899 |
jButRemoveField.setIcon(new ImageIcon(bDir + File.separator + "images" |
1900 |
+ File.separator + "icons16" + File.separator |
1901 |
+ "list-remove.png"));
|
1902 |
} |
1903 |
|
1904 |
/**
|
1905 |
* This method parses the info
|
1906 |
*
|
1907 |
* @param info
|
1908 |
* @return
|
1909 |
*/
|
1910 |
private String parseInfo(String info) { |
1911 |
String value = ""; |
1912 |
String temp[] = info.split("\\."); |
1913 |
|
1914 |
if (temp[0].compareToIgnoreCase("INFO") == 0) { |
1915 |
value = "INFO: " + PluginServices.getText(null, temp[1]); |
1916 |
} else {
|
1917 |
value = "ERROR: " + PluginServices.getText(null, temp[1]); |
1918 |
} |
1919 |
|
1920 |
if (temp.length == 3) { |
1921 |
value = value + " " + temp[2]; |
1922 |
} |
1923 |
|
1924 |
return value + "\n"; |
1925 |
} |
1926 |
|
1927 |
/**
|
1928 |
* getWindowprofile
|
1929 |
*
|
1930 |
* @return
|
1931 |
*/
|
1932 |
public Object getWindowProfile() { |
1933 |
return null; |
1934 |
} |
1935 |
|
1936 |
/**
|
1937 |
* This method updates the model of the names FieldList
|
1938 |
*
|
1939 |
* @return list model
|
1940 |
*/
|
1941 |
private DefaultListModel updateListModel() { |
1942 |
|
1943 |
DefaultListModel dlmodel = new DefaultListModel(); |
1944 |
Element[] adr = controller.getPattern().getArrayElements(); |
1945 |
String name = ""; |
1946 |
for (int i = 0; i < adr.length; i++) { |
1947 |
name = adr[i].getFieldname(); |
1948 |
dlmodel.add(i, name); |
1949 |
} |
1950 |
return dlmodel;
|
1951 |
} |
1952 |
|
1953 |
public void actionPerformed(ActionEvent e) { |
1954 |
// TODO Auto-generated method stub
|
1955 |
|
1956 |
} |
1957 |
|
1958 |
} |