Revision 28183

View differences:

branches/v10/extensions/extNormalization/about/normabout.htm
6 6
	</head>
7 7
	<body>	
8 8
		<h2>Extensi?n de normalizaci&oacute;n de cadenas de texto</h2>	
9
		<p><a href="http://www.prodevelop.es">Prodevelop S.L.</a> ha creado esta nueva extensi&oacute; de gvSIG que permite normalizar cadenas de texto desde un fichero de texto plano o desde un campo de una tabla de datos.</p>
9
		<p><a href="http://www.prodevelop.es">Prodevelop S.L.</a> ha creado esta nueva extensi&oacute;n de gvSIG que permite normalizar cadenas de texto desde un fichero de texto plano o desde un campo de una tabla de datos.</p>
10 10
					
11 11
		<p>Director del proyecto:</p>
12 12
		<ul>
13 13
			<li>Miguel Montesinos Lajara</li>
14
		</ul>		
14
		</ul>
15
		<p>Desarrollado:</p>
16
		<ul>
17
			<li>Equipo GIS</li>
18
		</ul>			
15 19

  
16 20
		<p>extNormalization 1.0 - bn: #build.number#</p>		
17 21
	</body>
branches/v10/extensions/extNormalization/.classpath
15 15
	<classpathentry kind="lib" path="/_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/lib/gdbms-0.8-SNAPSHOT.jar"/>
16 16
	<classpathentry kind="lib" path="/_fwAndami/lib/log4j-1.2.8.jar"/>
17 17
	<classpathentry kind="lib" path="lib/org.gvsig.geocoding.normalization.jar" sourcepath="/libGeocoding"/>
18
	<classpathentry combineaccessrules="false" kind="src" path="/libGeocoding"/>
18 19
	<classpathentry kind="output" path="bin"/>
19 20
</classpath>
branches/v10/extensions/extNormalization/config/text.properties
81 81

  
82 82
gdbmsdbfdriver=Driver dbf
83 83

  
84
file_exists=El fichero ya existe, ?desea sobreexcribirlo?
84
file_exists=El fichero ya existe, ?desea sobreescribirlo?
85 85
filenotfound=Fichero no se ha encontrado
86 86
parsingpatternxml=Leyendo el patr?n de normalizaci?n
87
loadsuccess=cargado correctamente
88
savesuccess=guardado correctamente
87
loadsuccess=Patr?n cargado correctamente
88
savesuccess=Patr?n guardado correctamente
89 89
savingpat=Guardando el patr?n de normalizaci?n
90 90
fileexists= El fichero ya existe, proceso de normalizaci?n cancelado
91 91
finishprocess=Proceso de normalizaci?n terminado
......
112 112

  
113 113
noload=Cancelada la carga del patr?n
114 114
nosave=Cancelado el guardado del patr?n
115
noformatok=El patr?n no tiene el formato correcto
115 116

  
116 117
pref_title_folder=Carpeta para almacenar patrones de normalizaci?n
117 118
pref_change_folder=Cambiar carpeta
branches/v10/extensions/extNormalization/config/text_en.properties
84 84
file_exists=file already exists, you wish to overwrite it?
85 85
filenotfound=File not found
86 86
parsingpatternxml=Reading the normalization pattern
87
loadsuccess= loaded OK
88
savesuccess= saved OK
87
loadsuccess= Pattern loaded OK
88
savesuccess= Pattern saved OK
89 89
savingpat=Saving the normalization pattern
90 90
fileexists= File exists, process canceled
91 91
finishprocess=Process finished
......
112 112

  
113 113
noload=Loading pattern canceled
114 114
nosave=Saving pattern canceled
115
noformatok=Pattern hasn't correct format 
115 116

  
116 117
pref_title_folder=Normalization patterns folder
117 118
pref_change_folder=Change folder
branches/v10/extensions/extNormalization/build.number
1 1
#Build number for ANT. Do not edit!
2
#Thu Feb 19 09:09:52 CET 2009
3
build.number=28
2
#Mon Apr 27 08:27:14 CEST 2009
3
build.number=38
branches/v10/extensions/extNormalization/src/org/gvsig/normalization/extensions/NormalizationFileExtension.java
76 76

  
77 77
			/* Load and read the normalization file */
78 78
			File file = null;
79
			List arr = null;
79
			List arr = new ArrayList();
80 80
			boolean isFile = true;
81 81

  
82 82
			try {
83 83
				/* load file */
84 84
				file = loadFile();
85
				log.debug("File loaded");
86 85
			} catch (Exception e) {
87 86
				file = null;
88 87
				String mes = PluginServices.getText(this,
......
97 96
				try {
98 97
					/* read file */
99 98
					arr = readTextFile(file);
100
					log.debug("File read");
101 99
				} catch (Exception e) {
102 100
					arr = null;
103 101
					String mes = PluginServices.getText(this,
......
108 106
					log.error("ERROR, Reading the strings file");
109 107
				}
110 108

  
111
				if (arr != null || arr.size() > 0) {
109
				if (arr != null && arr.size() > 0) {
112 110

  
113 111
					INormPanelModel model = NormPanelModel.getInstance();
114 112
					model.setNameFile(file.getName());
......
180 178
				}
181 179
			} catch (Exception e) {
182 180
				e.printStackTrace();
183
				log.debug("ERROR reading a file");
184 181
			}
185 182
		}
186 183
		return arr;
......
204 201

  
205 202
		if (returnval == JFileChooser.APPROVE_OPTION) {
206 203
			thefile = jfc.getSelectedFile();
207
			log.debug("Open file: " + thefile.toString());
208 204
		} else {
209 205
			return null;
210 206
		}
branches/v10/extensions/extNormalization/src/org/gvsig/normalization/extensions/AboutExtension.java
29 29

  
30 30
import java.io.File;
31 31

  
32
import org.apache.log4j.Logger;
33

  
34 32
import com.iver.andami.PluginServices;
35 33
import com.iver.andami.plugins.Extension;
36 34
import com.iver.cit.gvsig.About;
......
42 40
 * @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
43 41
 */
44 42
public class AboutExtension extends Extension {
45
	private static Logger logger = Logger.getLogger(AboutExtension.class);
46 43

  
47 44
	/**
48 45
	 * @see com.iver.andami.plugins.Extension#inicializar()
49 46
	 */
50 47
	public void initialize() {
51
		logger.debug("AboutExtension initialize");
52 48
		About classAbout = (About) PluginServices
53 49
				.getExtension(com.iver.cit.gvsig.About.class);
54 50
		ClassLoader classLoader = getClass().getClassLoader();
55 51
		java.net.URL aboutURL2 = classLoader.getResource("about"
56 52
				+ File.separator + "normabout.htm");
57
		classAbout.getAboutPanel().addAboutUrl("Normalization", aboutURL2);
53
		String title = PluginServices.getText(null, "pref_normalization");
54
		classAbout.getAboutPanel().addAboutUrl(title, aboutURL2);
58 55
	}
59 56

  
60 57
	/**
branches/v10/extensions/extNormalization/src/org/gvsig/normalization/preferences/NormPreferences.java
150 150
	}
151 151

  
152 152
	public String getTitle() {
153
		return PluginServices.getText(this, "pref_normalization");
153
		String title = PluginServices.getText(this, "pref_normalization");
154
		return title;
154 155
	}
155 156

  
156 157
	public void initializeDefaults() {
branches/v10/extensions/extNormalization/src/org/gvsig/normalization/gui/INormPanelModel.java
125 125
	public boolean runModel(ChangeListener normalizationPanel);
126 126

  
127 127
	/**
128
	 * This method update the list of the new fields
129
	 * 
130
	 * @return
131
	 */
132
	public DefaultListModel updateListModel();
133

  
134
	/**
135 128
	 * This method up one place in the list of the new fields
136 129
	 * 
137 130
	 * @param pos
......
154 147
	public void setPattern(Patternnormalization pat);
155 148

  
156 149
	/**
150
	 * @return the pattern
151
	 */
152
	public Patternnormalization getPattern();
153

  
154
	/**
157 155
	 * Load the pattern from xml file
158 156
	 * 
159 157
	 * @return pattern
......
169 167
	public void setInNewTable(boolean inNewTable);
170 168

  
171 169
	/**
172
	 * Return the selected field index in the list of the new Fields
173
	 * 
174
	 * @param index
175
	 */
176
	public void setSelectedFieldInList(int index);
177

  
178
	/**
179 170
	 * Return the selected Element in the list of the new Fields
180 171
	 * 
181 172
	 * @param index
......
191 182
	public void savePatternXML();
192 183

  
193 184
	/**
194
	 * Get the selected element in the list
195
	 * 
196
	 * @return list position
197
	 */
198
	public int getSelectedFieldInList();
199

  
200
	/**
201 185
	 * Get all the fields names of the original table
202 186
	 * 
203 187
	 * @return list model
branches/v10/extensions/extNormalization/src/org/gvsig/normalization/gui/NormalizationPanel.java
28 28
package org.gvsig.normalization.gui;
29 29

  
30 30
import java.awt.Component;
31
import java.awt.event.KeyEvent;
32
import java.awt.event.KeyListener;
33
import java.awt.event.MouseEvent;
34
import java.awt.event.MouseListener;
31 35
import java.io.File;
32 36

  
33 37
import javax.swing.BorderFactory;
......
85 89
	private boolean isEdit;
86 90
	private PluginServices ps;
87 91
	private boolean dirty = false;
92
	private int selectedField = 0;
88 93

  
89 94
	/* GUI */
90 95
	private ButtonGroup butGroupDelimiter;
91 96
	private ButtonGroup butGroupFieldType;
92 97
	private ButtonGroup butGroupOutput;
93 98
	private JButton jButCancel;
94
	private JButton jButFieldsAdd;
95
	private JButton jButFieldsDown;
96
	private JButton jButFieldsRem;
97
	private JButton jButFieldsUp;
99
	private JButton jButAddField;
100
	private JButton jButDownField;
101
	private JButton jButRemoveField;
102
	private JButton jButUpField;
98 103
	private JButton jButLoad;
99 104
	private JButton jButRun;
100 105
	private JButton jButSave;
......
231 236
	 * @param fieldsNames
232 237
	 */
233 238
	public void insertFieldsCurrentTable(String[] fieldsNames) {
234

  
235 239
		DefaultListModel dcb = new DefaultListModel();
236 240
		int cont = fieldsNames.length;
237 241
		for (int i = 0; i < cont; i++) {
......
249 253
	public WindowInfo getWindowInfo() {
250 254
		WindowInfo info = new WindowInfo(WindowInfo.MODALDIALOG
251 255
				| WindowInfo.RESIZABLE);
252

  
253
		// info.setMinimumSize(this.getMinimumSize());
254 256
		info.setWidth(780);
255 257
		info.setHeight(620);
256 258
		info.setTitle(PluginServices.getText(this, "normalize"));
257

  
258 259
		return info;
259 260
	}
260 261

  
......
307 308
		jPanFieldList = new javax.swing.JPanel();
308 309
		jScrollPaneFieldList = new javax.swing.JScrollPane();
309 310
		jListFieldList = new javax.swing.JList();
310
		jButFieldsAdd = new javax.swing.JButton();
311
		jButFieldsRem = new javax.swing.JButton();
312
		jButFieldsUp = new javax.swing.JButton();
313
		jButFieldsDown = new javax.swing.JButton();
311
		jButAddField = new javax.swing.JButton();
312
		jButRemoveField = new javax.swing.JButton();
313
		jButUpField = new javax.swing.JButton();
314
		jButDownField = new javax.swing.JButton();
314 315
		jPanFieldSettings = new javax.swing.JPanel();
315 316
		jPanFieldType = new javax.swing.JPanel();
316 317
		jRadioString = new javax.swing.JRadioButton();
......
491 492

  
492 493
		jListFieldList
493 494
				.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
495
		jListFieldList.addMouseListener(new MouseListener() {
496
			public void mouseClicked(MouseEvent e) {
497
			}
498

  
499
			public void mouseEntered(MouseEvent e) {
500
			}
501

  
502
			public void mouseExited(MouseEvent e) {
503
			}
504

  
505
			public void mousePressed(MouseEvent e) {
506
				selectedField = jListFieldList.getSelectedIndex();
507
			}
508

  
509
			public void mouseReleased(MouseEvent e) {
510
			}
511
		});
494 512
		jListFieldList
495 513
				.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
496 514
					public void valueChanged(
......
510 528
		gridBagConstraints.weighty = 1.0;
511 529
		jPanFieldList.add(jScrollPaneFieldList, gridBagConstraints);
512 530

  
513
		jButFieldsAdd.setBorderPainted(false);
514
		jButFieldsAdd.setMargin(new java.awt.Insets(5, 5, 5, 5));
515
		jButFieldsAdd.setMaximumSize(new java.awt.Dimension(30, 30));
516
		jButFieldsAdd.setMinimumSize(new java.awt.Dimension(30, 30));
517
		jButFieldsAdd.addActionListener(new java.awt.event.ActionListener() {
531
		jButAddField.setBorderPainted(false);
532
		jButAddField.setMargin(new java.awt.Insets(5, 5, 5, 5));
533
		jButAddField.setMaximumSize(new java.awt.Dimension(30, 30));
534
		jButAddField.setMinimumSize(new java.awt.Dimension(30, 30));
535
		jButAddField.addActionListener(new java.awt.event.ActionListener() {
518 536
			public void actionPerformed(java.awt.event.ActionEvent evt) {
519
				ActionButtonAdd(evt);
537
				ActionButtonAddField(evt);
520 538
			}
521 539
		});
522 540
		gridBagConstraints = new java.awt.GridBagConstraints();
......
525 543
		gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
526 544
		gridBagConstraints.weighty = 1.0;
527 545
		gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
528
		jPanFieldList.add(jButFieldsAdd, gridBagConstraints);
546
		jPanFieldList.add(jButAddField, gridBagConstraints);
529 547

  
530
		jButFieldsRem.setBorderPainted(false);
531
		jButFieldsRem.setMargin(new java.awt.Insets(5, 5, 5, 5));
532
		jButFieldsRem.setMaximumSize(new java.awt.Dimension(30, 30));
533
		jButFieldsRem.addActionListener(new java.awt.event.ActionListener() {
548
		jButRemoveField.setBorderPainted(false);
549
		jButRemoveField.setMargin(new java.awt.Insets(5, 5, 5, 5));
550
		jButRemoveField.setMaximumSize(new java.awt.Dimension(30, 30));
551
		jButRemoveField.addActionListener(new java.awt.event.ActionListener() {
534 552
			public void actionPerformed(java.awt.event.ActionEvent evt) {
535 553
				ActionButtonRemove(evt);
536 554
			}
......
540 558
		gridBagConstraints.gridy = 3;
541 559
		gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
542 560
		gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
543
		jPanFieldList.add(jButFieldsRem, gridBagConstraints);
561
		jPanFieldList.add(jButRemoveField, gridBagConstraints);
544 562

  
545
		jButFieldsUp.setForeground(java.awt.SystemColor.activeCaptionBorder);
563
		jButUpField.setForeground(java.awt.SystemColor.activeCaptionBorder);
546 564

  
547
		jButFieldsUp.setBorderPainted(false);
548
		jButFieldsUp.setMargin(new java.awt.Insets(5, 5, 5, 5));
549
		jButFieldsUp.setMaximumSize(new java.awt.Dimension(30, 30));
550
		jButFieldsUp.addActionListener(new java.awt.event.ActionListener() {
565
		jButUpField.setBorderPainted(false);
566
		jButUpField.setMargin(new java.awt.Insets(5, 5, 5, 5));
567
		jButUpField.setMaximumSize(new java.awt.Dimension(30, 30));
568
		jButUpField.addActionListener(new java.awt.event.ActionListener() {
551 569
			public void actionPerformed(java.awt.event.ActionEvent evt) {
552 570
				ActionButtonUp(evt);
553 571
			}
......
557 575
		gridBagConstraints.gridy = 0;
558 576
		gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
559 577
		gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
560
		jPanFieldList.add(jButFieldsUp, gridBagConstraints);
578
		jPanFieldList.add(jButUpField, gridBagConstraints);
561 579

  
562
		jButFieldsDown.setBorderPainted(false);
563
		jButFieldsDown.setMargin(new java.awt.Insets(5, 5, 5, 5));
564
		jButFieldsDown.setMaximumSize(new java.awt.Dimension(30, 30));
565
		jButFieldsDown.setMinimumSize(new java.awt.Dimension(30, 30));
566
		jButFieldsDown.addActionListener(new java.awt.event.ActionListener() {
580
		jButDownField.setBorderPainted(false);
581
		jButDownField.setMargin(new java.awt.Insets(5, 5, 5, 5));
582
		jButDownField.setMaximumSize(new java.awt.Dimension(30, 30));
583
		jButDownField.setMinimumSize(new java.awt.Dimension(30, 30));
584
		jButDownField.addActionListener(new java.awt.event.ActionListener() {
567 585
			public void actionPerformed(java.awt.event.ActionEvent evt) {
568 586
				ActionButtonDown(evt);
569 587
			}
......
574 592
		gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
575 593
		gridBagConstraints.weighty = 1.0;
576 594
		gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5);
577
		jPanFieldList.add(jButFieldsDown, gridBagConstraints);
595
		jPanFieldList.add(jButDownField, gridBagConstraints);
578 596

  
579 597
		gridBagConstraints = new java.awt.GridBagConstraints();
580 598
		gridBagConstraints.gridx = 0;
......
807 825
		jTextFieldWidth.setInputVerifier(new IntVerifier());
808 826
		jTextFieldWidth.setMinimumSize(new java.awt.Dimension(40, 20));
809 827
		jTextFieldWidth.setPreferredSize(new java.awt.Dimension(40, 20));
810
		jTextFieldWidth.addActionListener(new java.awt.event.ActionListener() {
811
			public void actionPerformed(java.awt.event.ActionEvent evt) {
812
				ActionTextFixedWidth(evt);
828
		jTextFieldWidth.addKeyListener(new KeyListener() {
829
			public void keyPressed(KeyEvent evt) {
813 830
			}
831

  
832
			public void keyTyped(KeyEvent evt) {
833
			}
834

  
835
			public void keyReleased(KeyEvent e) {
836
				ActionTextFixedWidth(e);
837
			}
814 838
		});
815 839
		gridBagConstraints = new java.awt.GridBagConstraints();
816 840
		gridBagConstraints.gridx = 2;
......
848 872
		jTextFieldName.setText("Field1");
849 873
		jTextFieldName.setMinimumSize(new java.awt.Dimension(100, 20));
850 874
		jTextFieldName.setPreferredSize(new java.awt.Dimension(100, 20));
851
		jTextFieldName.addFocusListener(new java.awt.event.FocusAdapter() {
852
			public void focusLost(java.awt.event.FocusEvent evt) {
853
				ActionFieldName(evt);
875
		jTextFieldName.addKeyListener(new KeyListener() {
876
			public void keyPressed(KeyEvent e) {
854 877
			}
878

  
879
			public void keyReleased(KeyEvent e) {
880
				KeyChangesFieldName(e);
881
			}
882

  
883
			public void keyTyped(KeyEvent e) {
884
			}
855 885
		});
856 886
		gridBagConstraints = new java.awt.GridBagConstraints();
857 887
		gridBagConstraints.gridx = 1;
......
1216 1246
	 * 
1217 1247
	 * @param evt
1218 1248
	 */
1219
	private void ActionTextFixedWidth(java.awt.event.ActionEvent evt) {
1220
		setDirty(true);
1249
	private void ActionTextFixedWidth(java.awt.event.KeyEvent evt) {
1250

  
1251
		boolean vali = new IntVerifier().verify(jTextFieldWidth);
1252
		if (vali) {
1253
			setDirty(true);
1254
		} else {
1255
			jTextFieldWidth.setText("1");
1256
			setDirty(true);
1257
		}
1221 1258
	}
1222 1259

  
1223 1260
	/**
......
1297 1334
	 * 
1298 1335
	 * @param evt
1299 1336
	 */
1300
	private void ActionFieldName(java.awt.event.FocusEvent evt) {
1301
		updateFieldSettingsModel();
1337
	private void KeyChangesFieldName(KeyEvent evt) {
1338
		//log.debug("#Key Pressed Field name# :" + this.selectedField);
1339
		int pos = this.selectedField;
1340
		updateFieldToModel(pos);
1302 1341
		updateGUI();
1303 1342
		setDirty(false);
1304
		jListFieldList.setSelectedIndex(this.model.getSelectedFieldInList());
1305 1343
	}
1306 1344

  
1307 1345
	/**
......
1373 1411
	private void testNormalizer(java.awt.event.ActionEvent evt) {
1374 1412
		/* Save elements */
1375 1413
		if (isDirty()) {
1376
			updateFieldSettingsModel();
1414
			updateFieldToModel(jListFieldList.getSelectedIndex());
1377 1415
		}
1378 1416
		/* Normalize */
1379 1417
		Object[][] data = this.model.normalizeSamples();
......
1400 1438
	 * @param evt
1401 1439
	 */
1402 1440
	private void runNormalizer(java.awt.event.ActionEvent evt) {
1441

  
1403 1442
		/* Save the pattern */
1404 1443
		if (isDirty()) {
1405
			updateFieldSettingsModel();
1444
			updateFieldToModel(this.selectedField);
1406 1445
		}
1407 1446
		/* Get the relate fields of the list */
1408 1447
		if (!isFile) {
......
1466 1505
	 * @param evt
1467 1506
	 */
1468 1507
	private void ActionButtonUp(java.awt.event.ActionEvent evt) {
1469
		updateFieldSettingsModel();
1508
		//log.debug("#Up# Old selected field: " + this.selectedField);
1509
		int pos = this.selectedField;
1510
		updateFieldToModel(pos);
1470 1511
		setDirty(false);
1471
		int pos = jListFieldList.getSelectedIndex();
1512

  
1472 1513
		this.model.fieldUp(pos);
1473
		DefaultListModel dlm = model.updateListModel();
1474
		jListFieldList.removeAll();
1514
		DefaultListModel dlm = this.updateListModel();
1475 1515
		jListFieldList.setModel(dlm);
1476
		jListFieldList.setSelectedIndex(pos);
1477 1516
		if (pos > 0 && dlm.getSize() > 1) {
1517
			this.selectedField = pos - 1;
1478 1518
			jListFieldList.setSelectedIndex(pos - 1);
1479
			model.setSelectedFieldInList(pos - 1);
1480 1519
		} else {
1520
			this.selectedField = pos;
1481 1521
			jListFieldList.setSelectedIndex(pos);
1482
			model.setSelectedFieldInList(pos);
1483 1522
		}
1484 1523
	}
1485 1524

  
......
1488 1527
	 * 
1489 1528
	 * @param evt
1490 1529
	 */
1491
	private void ActionButtonAdd(java.awt.event.ActionEvent evt) {
1492
		updateFieldSettingsModel();
1530
	private void ActionButtonAddField(java.awt.event.ActionEvent evt) {
1531
		//log.debug("#Add# Old selected field: " + this.selectedField);
1532
		int pos = this.selectedField;
1533
		updateFieldToModel(pos);
1493 1534
		setDirty(false);
1535

  
1494 1536
		model.addField();
1495
		DefaultListModel dlm = model.updateListModel();
1537
		DefaultListModel dlm = this.updateListModel();
1538
		int siz = dlm.size();
1539
		this.selectedField = siz - 1;
1496 1540
		jListFieldList.setModel(dlm);
1497
		int si = dlm.size();
1498
		model.setSelectedFieldInList(si - 1);
1499
		jListFieldList.setSelectedIndex(model.getSelectedFieldInList());
1541
		jListFieldList.setSelectedIndex(siz - 1);
1500 1542
		jTextOther.setEditable(false);
1501 1543
	}
1502 1544

  
......
1506 1548
	 * @param evt
1507 1549
	 */
1508 1550
	private void ActionButtonRemove(java.awt.event.ActionEvent evt) {
1509
		int pos = jListFieldList.getSelectedIndex();
1510
		if (pos > 0) {
1511
			updateFieldSettingsModel();
1551
		int siz = jListFieldList.getModel().getSize();
1552
		//log.debug("#Remove# Old selected field: " + this.selectedField);
1553
		int pos = this.selectedField;
1554
		if (siz > 0) {
1555
			updateFieldToModel(pos);
1512 1556
			setDirty(false);
1513 1557
			model.deleteField(pos);
1514
			DefaultListModel dlm = model.updateListModel();
1515
			jListFieldList.setModel(dlm);
1558
			DefaultListModel dlm = this.updateListModel();
1516 1559
			if (pos > 0) {
1560
				this.selectedField = pos - 1;
1561
				jListFieldList.setModel(dlm);
1517 1562
				jListFieldList.setSelectedIndex(pos - 1);
1518
				model.setSelectedFieldInList(pos - 1);
1519 1563
			} else {
1564
				this.selectedField = pos;
1565
				jListFieldList.setModel(dlm);
1520 1566
				jListFieldList.setSelectedIndex(pos);
1521
				model.setSelectedFieldInList(pos);
1522 1567
			}
1523 1568
		}
1524 1569
	}
......
1529 1574
	 * @param evt
1530 1575
	 */
1531 1576
	private void ActionButtonDown(java.awt.event.ActionEvent evt) {
1532
		int pos = jListFieldList.getSelectedIndex();
1533
		updateFieldSettingsModel();
1577
		//log.debug("#Down# Ols selected field: " + this.selectedField);
1578
		int pos = this.selectedField;
1579
		updateFieldToModel(pos);
1534 1580
		setDirty(false);
1581

  
1535 1582
		model.fieldDown(pos);
1536
		DefaultListModel dlm = model.updateListModel();
1583
		DefaultListModel dlm = this.updateListModel();
1537 1584
		jListFieldList.removeAll();
1538 1585
		jListFieldList.setModel(dlm);
1539
		jListFieldList.setSelectedIndex(pos);
1540 1586
		int can = dlm.getSize();
1541

  
1542 1587
		if (pos < can - 1 && can > 1) {
1588
			this.selectedField = pos + 1;
1543 1589
			jListFieldList.setSelectedIndex(pos + 1);
1544
			model.setSelectedFieldInList(pos + 1);
1545 1590
		} else {
1546 1591
			jListFieldList.setSelectedIndex(pos);
1547
			model.setSelectedFieldInList(pos);
1548 1592
		}
1549 1593
	}
1550 1594

  
......
1578 1622
	 * @param evt
1579 1623
	 */
1580 1624
	private void jButLoadActionPerformed(java.awt.event.ActionEvent evt) {
1625
		//log.debug("#Load# Selected field: " + this.selectedField);
1581 1626
		/* update the model from the view */
1582
		updateFieldSettingsModel();
1627
		updateFieldToModel(this.selectedField);
1583 1628
		setDirty(false);
1584 1629

  
1585 1630
		/* load the model from xml file */
......
1590 1635
			/* save pattern in the model */
1591 1636
			model.setPattern(pat);
1592 1637

  
1593
			DefaultListModel dlm = model.updateListModel();
1638
			DefaultListModel dlm = this.updateListModel();
1594 1639
			jListFieldList.setModel(dlm);
1595 1640
			jListFieldList.setSelectedIndex(0);
1596 1641
			jCheckFirstRow.setSelected(model.getFirstRows() != 0);
......
1602 1647
			}
1603 1648
			setDirty(false);
1604 1649
		}
1650

  
1605 1651
	}
1606 1652

  
1607 1653
	/**
......
1611 1657
	 */
1612 1658
	private void jListFieldListValueChanged(
1613 1659
			javax.swing.event.ListSelectionEvent evt) {
1660
		//log.debug("1. Fila seleccionada: " + this.selectedField);
1614 1661
		/* Save the parameters in the model */
1615

  
1616
		if (isDirty()) {
1617
			updateFieldSettingsModel();
1618
			jListFieldList.setModel(model.updateListModel());
1662
		boolean dirty = isDirty();
1663
		if (dirty) {
1664
			updateFieldToModel(this.selectedField);
1665
		}		
1666
		if (!evt.getValueIsAdjusting()) {
1667
			int pos = this.selectedField;
1668
			updateFieldToGUI(pos);
1669
			jListFieldList.setSelectedIndex(pos);
1619 1670
		}
1620
		int pos = (int) jListFieldList.getSelectedIndex();
1621
		if (pos != -1 && !evt.getValueIsAdjusting()) {
1622
			model.setSelectedFieldInList(pos);
1623
			updateFieldSettingsValuesGUI(pos);
1624
		}
1625 1671
		setDirty(false);
1626 1672
	}
1627 1673

  
......
1648 1694
	 */
1649 1695
	private void jButSaveActionPerformed(java.awt.event.ActionEvent evt) {
1650 1696
		model.setFirstRows(Integer.parseInt(jTextNumberRows.getText()));
1651
		updateFieldSettingsModel();
1697
		int pos = this.selectedField;
1698
		updateFieldToModel(pos);
1652 1699
		setDirty(false);
1653 1700
		/* save the pattern */
1654 1701
		model.savePatternXML();
......
1660 1707
	 * @param id
1661 1708
	 *            column number
1662 1709
	 */
1663
	private void updateFieldSettingsValuesGUI(int id) {
1710
	private void updateFieldToGUI(int id) {
1664 1711

  
1665 1712
		Element elem = this.model.getElement(id);
1666 1713

  
......
1746 1793
		/* Update field separator */
1747 1794

  
1748 1795
		Infieldseparators insep = elem.getInfieldseparators();
1749

  
1750 1796
		this.jTextDecimal.setText(insep.getDecimalseparator().trim());
1751
		log.debug("DECIMAL:" + insep.getDecimalseparator().trim());
1752 1797
		this.jTextThousand.setText(insep.getThousandseparator().trim());
1753
		log.debug("THOUSAND:" + insep.getThousandseparator().trim());
1754 1798
		this.jTextTextDelimiter.setText(insep.getTextseparator().trim());
1755
		log.debug("TEXT:" + insep.getTextseparator().trim());
1756 1799

  
1757 1800
		updateSelectors();
1801

  
1802
		setDirty(false);
1758 1803
	}
1759 1804

  
1760 1805
	/**
1761 1806
	 * Update the field values in the model
1762 1807
	 */
1763
	private void updateFieldSettingsModel() {
1764
		log.debug("Updating field in the model");
1765
		int pos = model.getSelectedFieldInList();
1808
	private void updateFieldToModel(int pos) {
1809

  
1766 1810
		Element elem = this.model.getElement(pos);
1767 1811

  
1768 1812
		/* name */
......
1824 1868
		seps.setTabsep(this.jChkTab.isSelected());
1825 1869

  
1826 1870
		if (jChkOther.isSelected() && jTextOther.getText().length() == 1) {
1827
			seps.setOthersep(jTextOther.getText());
1871
			seps.setOthersep(jTextOther.getText().trim());
1828 1872
		} else {
1829 1873
			seps.setOthersep(null);
1830 1874
		}
......
1848 1892
	 * @return table model
1849 1893
	 */
1850 1894
	private DefaultTableModel getSourceData() {
1851
		log.debug("getting data");
1852 1895
		if (this.model == null) {
1853 1896
			return null;
1854 1897
		}
......
1871 1914
					.getFieldToNormalize() }) {
1872 1915

  
1873 1916
				private static final long serialVersionUID = -7429493540158414622L;
1874
				boolean[] canEdit = new boolean[] { false };
1875 1917

  
1876 1918
				public boolean isCellEditable(int rowIndex, int columnIndex) {
1877
					return canEdit[columnIndex];
1919
					return false;
1878 1920
				}
1879 1921
			};
1880 1922
		} else {
......
1889 1931
	 * Update GUI elements with model info
1890 1932
	 */
1891 1933
	private void updateGUI() {
1892
		log.debug("Updating main GUI");
1893 1934

  
1894 1935
		/* Source Samples values */
1895 1936
		jTableSource.setModel(getSourceData());
1896 1937

  
1897 1938
		/* Fields List */
1898
		jListFieldList.setModel(model.updateListModel());
1939
		jListFieldList.setModel(this.updateListModel());
1899 1940
		jListFieldList.setSelectedIndex(0);
1900 1941

  
1901 1942
		/* Fields List in Original Table */
......
1916 1957
			jRadioNewTable.setSelected(true);
1917 1958
			model.setInNewTable(true);
1918 1959
			jListOriginalFields.setEnabled(false);
1919

  
1920 1960
		}
1921

  
1922 1961
	}
1923 1962

  
1924 1963
	/**
......
1935 1974
			} catch (NumberFormatException e) {
1936 1975
				log.error("Parsing the value");
1937 1976
				return false;
1938
				// this.errorIntMessage
1939 1977
			}
1940 1978
		}
1941 1979
	}
......
1952 1990
			if (text != null && text.length() == 1) {
1953 1991
				return true;
1954 1992
			} else {
1955

  
1956 1993
				return false;
1957 1994
			}
1958 1995
		}
......
2080 2117

  
2081 2118
		String bDir = ps.getClassLoader().getBaseDir();
2082 2119

  
2083
		jButFieldsUp.setIcon(new ImageIcon(bDir + File.separator + "images"
2120
		jButUpField.setIcon(new ImageIcon(bDir + File.separator + "images"
2084 2121
				+ File.separator + "icons16" + File.separator + "go-up.png"));
2085
		jButFieldsDown.setIcon(new ImageIcon(bDir + File.separator + "images"
2122
		jButDownField.setIcon(new ImageIcon(bDir + File.separator + "images"
2086 2123
				+ File.separator + "icons16" + File.separator + "go-down.png"));
2087
		jButFieldsAdd
2124
		jButAddField
2088 2125
				.setIcon(new ImageIcon(bDir + File.separator + "images"
2089 2126
						+ File.separator + "icons16" + File.separator
2090 2127
						+ "list-add.png"));
2091
		jButFieldsRem.setIcon(new ImageIcon(bDir + File.separator + "images"
2128
		jButRemoveField.setIcon(new ImageIcon(bDir + File.separator + "images"
2092 2129
				+ File.separator + "icons16" + File.separator
2093 2130
				+ "list-remove.png"));
2094 2131
	}
......
2125 2162
		return null;
2126 2163
	}
2127 2164

  
2165
	/**
2166
	 * This method updates the model of the names FieldList
2167
	 * 
2168
	 * @return list model
2169
	 */
2170
	private DefaultListModel updateListModel() {
2171

  
2172
		DefaultListModel dlmodel = new DefaultListModel();
2173
		Element[] adr = model.getPattern().getArrayElements();
2174
		String name = "";
2175
		for (int i = 0; i < adr.length; i++) {
2176
			name = adr[i].getFieldname();
2177
			dlmodel.add(i, name);
2178
		}
2179
		return dlmodel;
2180
	}
2181

  
2128 2182
}
branches/v10/extensions/extNormalization/src/org/gvsig/normalization/gui/NormalizationTask.java
27 27

  
28 28
package org.gvsig.normalization.gui;
29 29

  
30
import org.apache.log4j.Logger;
30 31
import org.gvsig.normalization.operations.Normalization;
31 32

  
32 33
import com.iver.andami.PluginServices;
......
40 41
 */
41 42
public class NormalizationTask extends AbstractMonitorableTask {
42 43

  
44
	private Logger logger = PluginServices.getLogger();
43 45
	private Normalization normalization;
44 46
	private long finalStep;
45 47

  
......
74 76
			if (!isCanceled()) {
75 77
				setCurrentStep(i);
76 78
				setNote(i + " " + log);
79
				logger.debug("Position: " + (i - 1));
77 80
				normalization.fillRow(i - 1);
78 81
			} else {
79 82
				return;
branches/v10/extensions/extNormalization/src/org/gvsig/normalization/gui/NormPanelModel.java
92 92
public class NormPanelModel implements INormPanelModel {
93 93

  
94 94
	private static final Logger log = PluginServices.getLogger();
95
	
95

  
96 96
	private List listeners = new ArrayList();
97 97
	private String fieldToNormalize;
98 98
	private String[] samples;
99 99
	private Patternnormalization pattern;
100 100
	private Table tab;
101 101
	private boolean inNewTable;
102
	private int selectedFieldInList = 0;
103 102
	private int contador = 1;
104 103
	private String[] relateNames;
105 104
	private List fileChains;
......
130 129
	 */
131 130
	private NormPanelModel() {
132 131
		initPattern();
133
	}	
132
	}
134 133

  
135 134
	/**
136 135
	 * This method fills the GUI sample table with the samples
......
155 154
	}
156 155

  
157 156
	/**
158
	 * This method updates the model of the names FieldList
159
	 * 
160
	 * @return list model
161
	 */
162
	public DefaultListModel updateListModel() {
163

  
164
		DefaultListModel dlmodel = new DefaultListModel();
165
		Element[] adr = this.pattern.getArrayElements();
166
		String name = "";
167
		for (int i = 0; i < adr.length; i++) {
168
			name = adr[i].getFieldname();
169
			dlmodel.add(i, name);
170
		}
171
		return dlmodel;
172
	}
173

  
174
	/**
175 157
	 * Run the process of normalization
176 158
	 * 
177 159
	 * @return process ok
......
203 185
			int index = tab.getSelectedFieldIndices().nextSetBit(0);
204 186

  
205 187
			if (!this.inNewTable) {
206
				// ONE TABLEE
207
				log.debug("New fields in the original table");
188
				// ONE TABLE
208 189
				normAction = new TableNormalization(source, index, pattern);
209 190
			} else {
210 191
				// JOINED TABLE
......
289 270

  
290 271
		contador++;
291 272
		int tam = pattern.getElements().size();
292
		Element elem = new Element();
273
		Element eleme = new Element();
293 274

  
294 275
		Fieldseparator fsep = new Fieldseparator();
295 276
		fsep.setSemicolonsep(true);
......
318 299
		} while (!isOkName);
319 300

  
320 301
		// validate the new field name
321
		elem.setFieldname(validateFieldName(nam));
322
		elem.setFieldseparator(fsep);
323
		elem.setInfieldseparators(getDefaultInfieldseparators());
324
		elem.setFieldtype(getDefaultNewFieldType());
325
		elem.setFieldwidth(0);
326
		elem.setImportfield(true);
302
		String vname = validateFieldName(nam);
303
		eleme.setFieldname(vname);
304
		eleme.setFieldseparator(fsep);
305
		eleme.setInfieldseparators(getDefaultInfieldseparators());
306
		eleme.setFieldtype(getDefaultNewFieldType());
307
		eleme.setFieldwidth(0);
308
		eleme.setImportfield(true);
327 309

  
328
		pattern.getElements().add(tam, elem);
310
		List elems = pattern.getElements();
311
		elems.add(tam, eleme);
329 312
	}
330 313

  
331 314
	/**
......
369 352
						null, "save_norm_pattern"), JOptionPane.YES_NO_OPTION);
370 353
				if (n == JOptionPane.YES_OPTION) {
371 354
					writeSaveFile(thefile);
372
					log.debug("overwrite file");
373 355
				} else if (n == JOptionPane.NO_OPTION) {
374
					log.debug("Don't save the file");
375 356
					update("INFO.filenotoverwrite");
376 357
				} else {
377
					log.debug("Don't save the file");
378 358
					update("INFO.filenotsave");
379 359
				}
380 360
			} else {
......
409 389

  
410 390
		if (returnval == JFileChooser.APPROVE_OPTION) {
411 391
			thefile = jfc.getSelectedFile();
412
			log.debug("file to open: " + thefile);
413 392
		} else {
414 393
			update("INFO.noload");
415 394
			return null;
......
425 404
			update("INFO.loadsuccess");
426 405
		} catch (FileNotFoundException e) {
427 406
			pat = null;
428
			update("INFO.filenotfound");
407
			update("ERROR.filenotfound");
429 408
			log.error("File not found", e);
430 409
		} catch (Exception e) {
431 410
			pat = null;
432
			update("INFO.parsingpatternxml");
433

  
411
			update("ERROR.parsingpatternxml");
412
			update("INFO.noformatok");
413
			update("INFO.noload");
434 414
			log.error("ERROR Parsing xml", e);
435 415
		}
436 416

  
......
552 532
	}
553 533

  
554 534
	/**
555
	 * This method gets the position of the selected element in the List of
556
	 * names
557
	 * 
558
	 * @return position in the list
559
	 */
560
	public int getSelectedFieldInList() {
561
		return selectedFieldInList;
562
	}
563

  
564
	/**
565
	 * This method set the position of the selected element in the List
566
	 * 
567
	 * @param selectedFieldInList
568
	 */
569
	public void setSelectedFieldInList(int selectedFieldInList) {
570
		this.selectedFieldInList = selectedFieldInList;
571
	}
572

  
573
	/**
574 535
	 * This method returns the fields names of the original table
575 536
	 * 
576 537
	 * @return list model
......
960 921
	 * @param file
961 922
	 */
962 923
	private void writeSaveFile(File thefile) {
963
		
924

  
964 925
		pattern.setPatternname(thefile.getName());
965 926

  
966 927
		FileWriter writer;
......
968 929
		try {
969 930
			storage = new StorageXML();
970 931
			pattern.getstate(storage);
971
			writer = new FileWriter(thefile);			
932
			writer = new FileWriter(thefile);
972 933
			storage.dump(writer);
973 934
			update("INFO.savesuccess");
974 935
			writer.close();
......
1040 1001
		update(evt);
1041 1002
	}
1042 1003

  
1004
	/**
1005
	 * @return the pattern
1006
	 */
1007
	public Patternnormalization getPattern() {
1008
		return pattern;
1009
	}
1010

  
1043 1011
}

Also available in: Unified diff