Revision 17478

View differences:

trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/swing/ValidatingTextField.java
147 147
     */
148 148
    public static Cleaner NUMBER_CLEANER = new Cleaner() {
149 149
            public String clean(String text) {
150
                try {
151
                    Double.parseDouble(text.trim());
150
            	if (text!=null) {
151
            		try {
152
            			Double.parseDouble(text.trim());
152 153

  
153
                    return text;
154
                } catch (NumberFormatException e) {
155
                    return "0";
156
                }
154
            		} catch (NumberFormatException e) {
155
            			return "0";
156
            		}
157
            	}
158
            	return text;
159

  
157 160
            }
158 161
        };
162
        
163
        
164
    /**
165
     * The validators allow the user to simply enter "+", "-", or ".". If the user
166
     * doesn't go any farther, this cleaner will set the text to 0, which is reasonable.
167
     */
168
    public static Cleaner NUMBER_CLEANER_2_DECIMALS = new Cleaner() {
169
            public String clean(String text) {
170
            	if (text!=null) {
171
            		try {
172
            			System.out.println("text before "+text);
173
            			double d = Double.parseDouble(text.trim());
174
            			int integerPart = (int) d;
175
            			double decimalPart = d - integerPart;
176
           				text = integerPart + "." + (int) Math.round(decimalPart*100);
177
           				System.out.println("text after "+text);
178
            		} catch (NumberFormatException e) {
179
            			return "0";
180
            		}
181
            	}
182
            	
183
            	return text;
184
            }
185
        };
186
//        public static class NumberWithDefinedDecimalNumberCuntCleaner extends NumberCleaner {
187
//        	private int decimalCount = 2;
188
//        	public NumberWithDefinedDecimalNumberCuntCleaner(String textToAppend) {
189
//    			this(textToAppend, 2);
190
//    		}
191
//    		public NumberWithDefinedDecimalNumberCuntCleaner(String textToAppend, int decimalCount) {
192
//        		super(textToAppend);
193
//        		this.decimalCount = decimalCount;
194
//    		}
195
//    		
196
//    		@Override
197
//    		public String clean(String text) {
198
//    			String s = super.clean(text);
199
//    			if (s.indexOf(ch)
200
//    			
201
//    			return s;
202
//    		}
203
//        }
159 204

  
160 205
    /**
161 206
     * Validator that does nothing.
......
357 402
            }
358 403
        }
359 404
    }
405
    
406
   
360 407

  
361 408
    public static class MinIntCleaner implements Cleaner {
362 409
        private int minimum;
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/swing/JFileChooser.java
79 79
	 */
80 80
	public JFileChooser(String fileChooserID, File defaultDirectory) {
81 81
		super();
82
		setDragEnabled(true);
82 83
		if (fileChooserID == null) 
83 84
			throw new IllegalArgumentException("JFileChooser's ID cannot be null");
84 85
		
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/swing/JIncrementalNumberField.java
200 200
	}
201 201

  
202 202
	public JIncrementalNumberField(String text, int columns) {
203
		this(text, columns, ValidatingTextField.DOUBLE_VALIDATOR, ValidatingTextField.NUMBER_CLEANER, -Double.MAX_VALUE, Double.MAX_VALUE, 1);
203
		this(text, columns, ValidatingTextField.DOUBLE_VALIDATOR, ValidatingTextField.NUMBER_CLEANER_2_DECIMALS, -Double.MAX_VALUE, Double.MAX_VALUE, 1);
204 204
	}
205 205

  
206 206
	public JIncrementalNumberField(String text, int columns, double minValue, double maxValue, double step) {
207
		this(text, columns, ValidatingTextField.DOUBLE_VALIDATOR, ValidatingTextField.NUMBER_CLEANER, minValue, maxValue, step);
207
		this(text, columns, ValidatingTextField.DOUBLE_VALIDATOR, ValidatingTextField.NUMBER_CLEANER_2_DECIMALS, minValue, maxValue, step);
208 208
	}
209 209

  
210 210
	public JIncrementalNumberField(String text, int columns, Validator validator, Cleaner cleaner, double minValue, double maxValue, double step) {

Also available in: Unified diff