Revision 23303 branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/gui/tablemodel/DataSourceDataModel.java

View differences:

DataSourceDataModel.java
1 1
package com.iver.cit.gvsig.project.documents.table.gui.tablemodel;
2 2

  
3
import java.awt.Component;
3
import java.util.ConcurrentModificationException;
4 4
import java.util.Date;
5 5

  
6
import javax.swing.JOptionPane;
7 6
import javax.swing.table.AbstractTableModel;
8 7

  
9 8
import org.apache.log4j.Logger;
......
13 12
import org.gvsig.fmap.data.feature.FeatureCollection;
14 13
import org.gvsig.fmap.data.feature.FeatureStore;
15 14

  
16
import com.iver.andami.PluginServices;
17 15
import com.iver.cit.gvsig.project.documents.table.ProjectTable;
18 16

  
19 17
/**
......
30 28
	private int lastNumRow=-1;
31 29
	private String order;
32 30
	private FeatureCollection featureCollection = null;
31
	private long rowcount = -1;
32

  
33 33
    /**
34 34
     * Crea un nuevo DataSourceDataModel.
35 35
     *
......
40 40
        if (pt.getAssociatedTable()!=null) {
41 41
        	hasAssociatedLayer=true;
42 42
        }
43
        try {
44
			featureCollection=(FeatureCollection)pt.getModel().getDataCollection(pt.getModel().getDefaultFeatureType(),null,order);
45
		} catch (ReadException e) {
46
			// TODO Auto-generated catch block
47
			e.printStackTrace();
48
		}
43
        this.refreshCollection();
49 44
        //try {
50 45
        //dataSource = pt.getModelo().getRecordset();
51 46
        //} catch (DriverLoadException e) {
......
54 49
        //}
55 50
    }
56 51

  
52
    private void refreshCollection() {
53
		try {
54
			featureCollection = (FeatureCollection) pt.getModel()
55
					.getDataCollection(pt.getModel().getDefaultFeatureType(),
56
							null, order);
57
		} catch (ReadException e) {
58
			// TODO Auto-generated catch block
59
			e.printStackTrace();
60
		}
61

  
62
	}
63

  
64

  
65

  
57 66
    /**
58 67
     * Returns the name of the field.
59 68
     *
......
87 96
     * @return number of rows.
88 97
     */
89 98
    public int getRowCount() {
90
        try {
91
        	FeatureStore fs = pt.getModel();
92
            return ((FeatureCollection)fs.getDataCollection()).size();
93
        } catch (ReadException e) {
94
            return 0;
95
        }
99
    	int count = 0;
100
    	try {
101
			count = this.featureCollection.size();
102
		} catch (ConcurrentModificationException e) {
103
			this.refreshCollection();
104
			count = this.featureCollection.size();
105
		}
106
		return count;
96 107
    }
97 108

  
98 109
    /**
......
210 221
         }else {
211 222
      	   numFeature=rowIndex;
212 223
         }
213
    	if (getValueAt(rowIndex,columnIndex)==null || getValueAt(rowIndex,columnIndex).toString().equals(aValue))
214
        	return;
224
    	if (getValueAt(rowIndex,columnIndex)==null || getValueAt(rowIndex,columnIndex).toString().equals(aValue)) {
225
			return;
226
		}
215 227
        try {
216 228
        	FeatureStore fs = pt.getModel();
217 229
//        	try{

Also available in: Unified diff