Revision 7011 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/ClearSelectionExtension.java

View differences:

ClearSelectionExtension.java
47 47
package com.iver.cit.gvsig;
48 48

  
49 49
import com.iver.andami.PluginServices;
50
import com.iver.andami.messages.NotificationListener;
51
import com.iver.andami.messages.NotificationManager;
50 52
import com.iver.andami.plugins.Extension;
51 53
import com.iver.cit.gvsig.fmap.DriverException;
52 54
import com.iver.cit.gvsig.fmap.MapContext;
......
163 165
			return false;
164 166
		}
165 167
		if (view instanceof View){
166
			FLayer[] selected = ((View)view).getModel().getMapContext().getLayers().getActives();
167
			if (selected.length == 1 && selected[0] instanceof FLyrVect){
168
				if (!selected[0].isAvailable()) return false;
169
				try {
170
					SelectableDataSource rs = ((FLyrVect)selected[0]).getRecordset();
171
					if (rs != null)
172
						return (rs.getSelection().cardinality()>0);
173
				} catch (DriverException e) {
174
					e.printStackTrace();
168
			MapContext mapa = ((View) view).getMapControl().getMapContext();
169
			for (int i = 0; i < mapa.getLayers().getLayersCount(); i++) {
170
				if (mapa.getLayers().getLayer(i) instanceof FLyrVect) {
171
					FLyrVect lyrVect = (FLyrVect) mapa.getLayers().getLayer(i); 
172
					if (lyrVect.isActive()) {
173
						if (lyrVect.isAvailable())
174
							try {
175
								if (lyrVect.getRecordset().getSelection().cardinality() > 0)
176
									return true;
177
							} catch (DriverException e) {
178
								e.printStackTrace();
179
								NotificationManager.addWarning("Capa " + lyrVect.getName() + " sin recordset correcto",e);
180
							}
181
					}
175 182
				}
176 183
			}
177 184
		}

Also available in: Unified diff