Revision 29238

View differences:

branches/v2_0_0_prep/extensions/extNormalization/src/org/gvsig/normalization/gui/NormalizationPanel.java
383 383
		jScrollPaneSource.setPreferredSize(new java.awt.Dimension(100, 90));
384 384

  
385 385
		jTableSource.setFont(new java.awt.Font("Courier New", 0, 11));
386
		jTableSource.setModel(getSourceData());
386
		jTableSource.setModel(new DefaultTableModel());
387 387
		jTableSource.getTableHeader().setReorderingAllowed(false);
388 388
		jScrollPaneSource.setViewportView(jTableSource);
389 389

  
......
1041 1041
			controller
1042 1042
					.setFirstRows(Integer.parseInt(jTextNumberRows.getText()));
1043 1043
			this.jTextNumberRows.requestFocus();
1044
			controller.getSamplesFromFile(controller.getFirstRows());
1045
			jTableSource.setModel(getSourceData());
1044
			DefaultTableModel model = controller.getSamplesDataStore(controller.getFirstRows());
1045
			jTableSource.setModel(model);
1046 1046
		}
1047 1047
		/* Normalize the first rows */
1048 1048
		else {
1049 1049
			jTextNumberRows.setText("0");
1050 1050
			jTextNumberRows.setEditable(false);
1051 1051
			controller.setFirstRows(0);
1052
			controller.getSamplesFromFile(controller.getFirstRows());
1053
			jTableSource.setModel(getSourceData());
1052
			DefaultTableModel model = controller.getSamplesDataStore(controller.getFirstRows());
1053
			jTableSource.setModel(model);
1054 1054
		}
1055 1055
	}
1056 1056

  
branches/v2_0_0_prep/extensions/extNormalization/src/org/gvsig/normalization/gui/NormalizationPanelController.java
43 43
import javax.swing.JOptionPane;
44 44
import javax.swing.table.DefaultTableModel;
45 45

  
46
import org.gvsig.fmap.dal.exception.DataException;
46 47
import org.gvsig.fmap.dal.feature.Feature;
47 48
import org.gvsig.fmap.dal.feature.FeatureSet;
48 49
import org.gvsig.fmap.dal.feature.FeatureStore;
......
546 547
				.getStringProperty("Normalization_pattern_folder"));
547 548
		return pathFolder;
548 549
	}
549
	
550

  
550 551
	/**
551 552
	 * Gets the strings sample for the table of samples
552 553
	 * 
553 554
	 * @return table model
555
	 * @throws DataException 
554 556
	 */
555
	protected DefaultTableModel getSamplesDataStore() {
556
		
557
	protected DefaultTableModel getSamplesDataStore(int noRows) throws DataException {
558

  
557 559
		FeatureSet features = (FeatureSet) store.getDataSet();
558
		Iterator<Feature> it = features.iterator();
559
		int contador = 0;		
560
		Iterator<Feature> it = features.iterator(noRows);
561
		int contador = 0;
560 562
		while (it.hasNext()) {
561 563
			Feature feature = (Feature) it.next();
562
			if(contador<SAMPLES){
564
			if (contador < SAMPLES) {
563 565
				String sample = feature.get(selectedField).toString();
564 566
				samples[contador] = sample;
565
			}			
567
			}
566 568
		}
567
		
569
		// String samples
568 570
		Object[][] data = new Object[samples.length][1];
569 571
		for (int i = 0; i < samples.length; i++) {
570 572
			data[i][0] = samples[i];
571 573
		}
572
		DefaultTableModel tablemodel = new DefaultTableModel(data, new String[] { this.controller
573
					.getFieldToNormalize() }) {
574
		// table field name
575
		String fieldname = store.getDefaultFeatureType().getAttributeDescriptor(selectedField).getName();
576
		String[] names = { fieldname };
577
		DefaultTableModel tablemodel = new DefaultTableModel(data, names) {
574 578

  
575
				private static final long serialVersionUID = -7429493540158414622L;
579
			private static final long serialVersionUID = -7429493540158414622L;
576 580

  
577
				public boolean isCellEditable(int rowIndex, int columnIndex) {
578
					return false;
579
				}
580
			};
581
		} else {
582
			Object[] names = { controller.getFileName() };
583
			dtm1 = new DefaultTableModel(data, names);
584
		}
581
			public boolean isCellEditable(int rowIndex, int columnIndex) {
582
				return false;
583
			}
584
		};
585 585

  
586 586
		return tablemodel;
587

  
587 588
	}
588 589

  
590
	
591

  
589 592
}

Also available in: Unified diff