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