Revision 41747 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/SelectByAttributesExtension.java
SelectByAttributesExtension.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.app.extension; |
25 | 25 |
|
26 |
import java.awt.Component;
|
|
26 |
import java.util.Iterator;
|
|
27 | 27 |
|
28 | 28 |
import javax.swing.JOptionPane; |
29 | 29 |
|
... | ... | |
39 | 39 |
import org.gvsig.fmap.dal.DALLocator; |
40 | 40 |
import org.gvsig.fmap.dal.DataManager; |
41 | 41 |
import org.gvsig.fmap.dal.exception.DataException; |
42 |
import org.gvsig.fmap.dal.feature.Feature; |
|
42 | 43 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
44 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
43 | 45 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
44 | 46 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
45 | 47 |
import org.gvsig.i18n.Messages; |
... | ... | |
102 | 104 |
return (v instanceof FeatureTableDocumentPanel); |
103 | 105 |
} |
104 | 106 |
|
105 |
// By Pablo: if no filter expression -> no element selected
|
|
107 |
// if no filter expression -> no element selected |
|
106 | 108 |
public void newSet(String expression) throws DataException { |
107 | 109 |
if (!this.filterExpressionFromWhereIsEmpty(expression)) { |
108 | 110 |
FeatureSet set = null; |
... | ... | |
129 | 131 |
} |
130 | 132 |
} |
131 | 133 |
} else { |
132 |
// By Pablo: if no expression -> no element selected
|
|
134 |
// if no expression -> no element selected |
|
133 | 135 |
featureStore.getFeatureSelection().deselectAll(); |
134 | 136 |
} |
135 | 137 |
} |
... | ... | |
142 | 144 |
} |
143 | 145 |
|
144 | 146 |
public void addToSet(String expression) throws DataException { |
145 |
// By Pablo: if no filter expression -> don't add more elements to set
|
|
147 |
// if no filter expression -> don't add more elements to set |
|
146 | 148 |
if (!this.filterExpressionFromWhereIsEmpty(expression)) { |
147 | 149 |
FeatureSet set = null; |
148 | 150 |
try { |
... | ... | |
161 | 163 |
} |
162 | 164 |
|
163 | 165 |
public void fromSet(String expression) throws DataException { |
164 |
// By Pablo: if no filter expression -> no element selected |
|
165 |
try { |
|
166 |
if (!this.filterExpressionFromWhereIsEmpty(expression)) { |
|
167 |
NotificationManager.showMessageInfo("Falta por implementar", |
|
168 |
null); |
|
169 |
} else { |
|
170 |
// By Pablo: if no expression -> no element selected |
|
171 |
featureStore.getFeatureSelection().deselectAll(); |
|
166 |
if ( !this.filterExpressionFromWhereIsEmpty(expression) ) { |
|
167 |
FeatureSet set = null; |
|
168 |
try { |
|
169 |
set = doSet(expression); |
|
170 |
if ( set == null ) { |
|
171 |
return; |
|
172 |
} |
|
173 |
FeatureSelection oldSelection = featureStore.getFeatureSelection(); |
|
174 |
FeatureSelection newSelection = featureStore.createFeatureSelection(); |
|
175 |
Iterator iterator = set.iterator(); |
|
176 |
while ( iterator.hasNext() ) { |
|
177 |
Feature feature = (Feature) iterator.next(); |
|
178 |
if ( oldSelection.isSelected(feature) ) { |
|
179 |
newSelection.select(feature); |
|
180 |
} |
|
181 |
} |
|
182 |
featureStore.setSelection(newSelection); |
|
183 |
} finally { |
|
184 |
if ( set != null ) { |
|
185 |
set.dispose(); |
|
186 |
} |
|
172 | 187 |
} |
173 |
} catch (DataException e) {
|
|
174 |
NotificationManager.addError(e);
|
|
188 |
} else {
|
|
189 |
featureStore.getFeatureSelection().deselectAll();
|
|
175 | 190 |
} |
176 |
|
|
177 | 191 |
} |
178 |
|
|
192 |
|
|
179 | 193 |
/** |
180 | 194 |
* Returns true if the WHERE subconsultation of the filterExpression is |
181 | 195 |
* empty ("") |
... | ... | |
211 | 225 |
} |
212 | 226 |
|
213 | 227 |
// If there is no subexpression in the WHERE clause -> true |
214 |
subExpression = |
|
215 |
subExpression.substring(pos + 5, subExpression.length()).trim(); // + |
|
216 |
// 5 |
|
217 |
// is |
|
218 |
// the |
|
219 |
// length |
|
220 |
// of |
|
221 |
// 'where' |
|
228 |
// ( + 5 is the length of the 'where') |
|
229 |
subExpression =subExpression.substring(pos + 5, subExpression.length()).trim(); |
|
230 |
|
|
222 | 231 |
if (subExpression.length() == 0) { |
223 | 232 |
return true; |
224 | 233 |
} else { |
Also available in: Unified diff