Revision 42807 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/featuretable/table/DefaultFeatureTableModel.java

View differences:

DefaultFeatureTableModel.java
30 30
import java.text.SimpleDateFormat;
31 31
import java.util.ArrayList;
32 32
import java.util.HashMap;
33
import java.util.HashSet;
33 34
import java.util.Iterator;
34 35
import java.util.List;
35 36
import java.util.Locale;
36 37
import java.util.Map;
38
import java.util.Set;
37 39

  
38 40
import javax.swing.SwingUtilities;
39 41
import javax.swing.Timer;
42
import javax.swing.event.ChangeEvent;
43
import javax.swing.event.ChangeListener;
40 44
import javax.swing.event.TableModelEvent;
41 45
import javax.swing.table.AbstractTableModel;
42 46

  
......
92 96

  
93 97
    private final DelayAction delayAction = new DelayAction();
94 98

  
99
    private FeatureSelection selection = null;
95 100

  
101
    private Set<ActionListener> changeListeners = null;
102
    
96 103
    public DefaultFeatureTableModel(FeaturePagingHelper featurePager) {
97 104
        this.featurePager = featurePager;
98 105
        this.localeOfData = Locale.getDefault();
......
848 855
            }
849 856
        }
850 857
    }
851

  
858
    
852 859
    @Override
860
    public FeatureSelection getFeatureSelection() {
861
        if (selection == null) {
862
            try {
863
                return getFeatureStore().getFeatureSelection();
864
            } catch (Exception e) {
865
                logger.warn("Error getting the selection", e);
866
            }
867
        }
868
        return selection;
869
    }
870
    
871
    @Override
872
    public void setFeatureSelection(FeatureSelection selection) {
873
        this.selection = selection;
874
        this.featurePager.setSelection(selection);
875
        this.fireChangeListeners(new ActionEvent(this, 0,CHANGE_SELECTION));
876
    }
877
    
878
    public void addChangeListener(ActionListener listener) {
879
        if( this.changeListeners==null) {
880
            this.changeListeners = new HashSet<>();
881
        }
882
        this.changeListeners.add(listener);
883
    }
884
    
885
    public void fireChangeListeners(ActionEvent event) {
886
        if( this.changeListeners == null ) {
887
            return;
888
        }
889
        for( ActionListener listener : this.changeListeners ) {
890
            try {
891
                listener.actionPerformed(event);
892
            } catch(Exception ex) {
893
                // Ignore
894
            }
895
        }
896
    }
897
    
898
    @Override
853 899
    public int getSelectionCount() {
854 900
        try {
855
            FeatureSelection selection = this.getFeatureStore().getFeatureSelection();
901
            FeatureSelection selection = this.getFeatureSelection();
856 902
            return (int) selection.getSize();
857 903
        } catch (DataException ex) {
858 904
            throw new RuntimeException("Can't get selection of the FeatureTableModel",ex);

Also available in: Unified diff