Revision 44 org.gvsig.legend.vectorfilterexpression.app.mainplugin/trunk/org.gvsig.legend.vectorfilterexpression.app.mainplugin/src/main/java/org/gvsig/symbology/gui/layerproperties/ExpressionSymbolPanel.java

View differences:

ExpressionSymbolPanel.java
216 216
        
217 217
        if (e.getActionCommand().compareToIgnoreCase("ok") == 0) {
218 218
            
219
            Class return_class = null;
219 220
            try {
220
                validateExpression();
221
                return_class = validateExpression();
221 222
            } catch (EvaluatorException epe) {
222 223
                
223 224
                if (epe.getCause() instanceof ArithmeticException) {
......
227 228
                        return;
228 229
                    } else {
229 230
                        // User said ok
230
                        // Do nothing, get out of catch block
231
                        okPressed = true;
232
                        closeThis();
233
                        return;
231 234
                    }
232 235
                    
233 236
                } else {
......
241 244
                    return;
242 245
                }
243 246
            }
247
            
248
            if (return_class != Boolean.class) {
249
                int usr_opt = JOptionPane.showConfirmDialog(
250
                    this,
251
                    Messages.getText("_Result_not_boolean_so_zero_empty_string_null_are_false_Continue_question"),
252
                    Messages.getText("confirmation_dialog"),
253
                    JOptionPane.YES_NO_OPTION);
254
                if (usr_opt == JOptionPane.NO_OPTION) {
255
                    okPressed = false;
256
                    return;
257
                }
258
            }
244 259
            okPressed = true;
245 260
            closeThis();
246 261
            
......
267 282
        int usr_opt = JOptionPane.showConfirmDialog(
268 283
            this,
269 284
            detail,
270
            Messages.getText("expression_creator"),
285
            Messages.getText("confirmation_dialog"),
271 286
            JOptionPane.YES_NO_OPTION);
272 287
        
273 288
        return usr_opt == JOptionPane.YES_OPTION;
274 289
    }
275 290

  
276 291
    /**
277
     * @return
292
     * @return class of the return value
278 293
     */
279
    private void validateExpression() throws EvaluatorException {
294
    private Class validateExpression() throws EvaluatorException {
280 295
        
281 296
        String expr = this.getExpression();
282 297
        EvaluatorWithDescriptions evde = EvaluatorCreator.getEvaluator(expr);
298
        Object resp_class = null;
283 299
        
284 300
        try {
285 301
            /*
286 302
             * Try evaluate feature with default values
287 303
             */
288
            evde.evaluate(dummyFeature.getEvaluatorData());
304
            resp_class = evde.evaluate(dummyFeature.getEvaluatorData());
289 305
        } catch (EvaluatorException e) {
290 306
            /*
291 307
             * Parse exception or field not found or
......
304 320
             */
305 321
            throw new EvaluatorException(e);
306 322
        }
323
        
324
        if (resp_class == null) {
325
            return null;
326
        } else {
327
            return resp_class.getClass();
328
        }
307 329
    }
308 330

  
309 331
    private void closeThis() {

Also available in: Unified diff