Revision 38367 branches/v2_0_0_prep/libraries/org.gvsig.newlayer/org.gvsig.newlayer.lib/org.gvsig.newlayer.lib.impl/src/main/java/org/gvsig/newlayer/impl/FeatureTypePanel.java

View differences:

FeatureTypePanel.java
74 74
	private JButton jButtonAddField = null;
75 75
	private JButton jButtonDeleteField = null;
76 76
	protected int MAX_FIELD_LENGTH = 254;
77
	private List removedFields;
77
	
78
	// we dont need this list
79
	// we'll clear and rebuild featureType each time
80
	// the user clicks next
81
	// private List removedFields;
78 82

  
79 83
	private DataServerExplorer explorer = null;
80 84

  
81 85
	public FeatureTypePanel(NewLayerWizard wizard) {
82 86
		this.wizard = wizard;
83
		removedFields = new ArrayList<String>();
84 87
	}
85 88

  
86 89
	private void initializeComponents() {
......
652 655
									.getModel();
653 656

  
654 657
							for (int i = selecteds.length - 1; i >= 0; i--) {
658
							    /*
659
							     * 
655 660
								removedFields.add((String) tm.getValueAt(i, 0));
661
                                 */
656 662
								tm.removeRow(selecteds[i]);
657 663
							}
658 664
						}
......
679 685
		 */
680 686
		NewLayerService service = this.wizard.getService();
681 687
		EditableFeatureType featureType = service.getFeatureType();
688
		
689
		// Clean and rebuild featureType everytime we click next
690
		removeAllFields(featureType);
682 691

  
692
		/*
683 693
		for (Iterator iterator = removedFields.iterator(); iterator.hasNext();) {
684 694
			String name = (String) iterator.next();
685 695
			featureType.remove(name);
686 696
		}
687 697
		removedFields.clear();
698
		*/
688 699

  
689 700
		DefaultTableModel tm = (DefaultTableModel) jTable.getModel();
690 701
		for (int i = 0; i < tm.getRowCount(); i++) {
......
695 706
			if (dataType.getType() == DataTypes.DOUBLE) {
696 707
				fieldLength = 5;
697 708
			}
709
		
698 710
			// FIXME: Arreglar lo que pasa si en el siguiente panel volvemos
699 711
			// hacia atras, y en este volvemos a ir hacia adelante
712
			/*
700 713
			String fieldName = (String) tm.getValueAt(i, COLUMN_FIELD);
701 714
			EditableFeatureAttributeDescriptor attrDescriptor = (EditableFeatureAttributeDescriptor) featureType
702 715
					.getAttributeDescriptor(fieldName);
716

  
703 717
			if (attrDescriptor != null) {
704 718
				featureType.remove(attrDescriptor);
705 719
			}
720
			*/
721
			
706 722
			EditableFeatureAttributeDescriptor efad1 = featureType.add(
707 723
					(String) tm.getValueAt(i, COLUMN_FIELD), dataType.getType(),
708 724
					fieldLength);
......
723 739
		}
724 740
	}
725 741

  
726
	public void lastPanel() {
742
	/**
743
     * @param featureType
744
     */
745
    private void removeAllFields(EditableFeatureType ft) {
746
        
747
        FeatureAttributeDescriptor[] atts =  ft.getAttributeDescriptors();
748
        int len = atts.length;
749
        FeatureAttributeDescriptor item = null;
750
        for (int i=0; i<len; i++) {
751
            item = atts[i];
752
            ft.remove(item.getName());
753
        }
754
    }
755

  
756
    public void lastPanel() {
727 757
		// TODO Auto-generated method stub
728 758
		logger.info("FeatureTypePanel: lastPanel");
729 759
	}

Also available in: Unified diff