Project

General

Profile

Revision df566daf

IDdf566dafc6d25450bec8cabdd34ddb2fed099130
Parent 486205ef
Child c2c33ccd

Added by Andreas Müller over 3 years ago

fix #6454 Allow null for numbers

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/NumberWithLabelElement.java
62 62
	    if(super.getText()!=null){
63 63
	        String text = super.getText().trim();
64 64
	        try {
65
	            return StringUtils.isBlank(text) ? 0 : new Integer(text);
65
	            return StringUtils.isBlank(text) ? null : new Integer(text);
66 66
	        } catch (NumberFormatException e) {
67 67
	            exception = e;
68 68
	        }
......
77 77
	public Float getFloat(){
78 78
	    String text = super.getText();
79 79
	    try {
80
	    	return StringUtils.isBlank(text) ? 0 : new Float(text);
80
	    	return StringUtils.isBlank(text) ? null : new Float(text);
81 81
	    } catch (NumberFormatException e) {
82 82
	        exception = e;
83 83
	    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/PartialElement.java
118 118
	}
119 119

  
120 120
	private void handleEvent(Object eventSource){
121
	    if(eventSource == number_month && number_month.getException()==null){
122
	        if (number_month.getInteger() == null || number_month.getInteger() == 0){
123
	            partial = TimePeriod.setPartialField(partial, null, TimePeriod.MONTH_TYPE);
124
	        } else{
125
	            partial = TimePeriod.setPartialField(partial, number_month.getInteger(), TimePeriod.MONTH_TYPE);
126
	        }
127

  
128
	    }else if(eventSource == number_day && number_day.getException()==null){
129
	        try{
130
	            if (number_day.getInteger() == null || number_day.getInteger() == 0){
131
	                partial = TimePeriod.setPartialField(partial, null, TimePeriod.DAY_TYPE);
132
	            } else{
121
	    if (eventSource instanceof NumberWithLabelElement){
122
			try{
123
		    	if(eventSource == number_month && number_month.getException()==null){
124
			        partial = TimePeriod.setPartialField(partial, number_month.getInteger(), TimePeriod.MONTH_TYPE);
125
			    }else if(eventSource == number_day && number_day.getException()==null){
133 126
	                partial = TimePeriod.setPartialField(partial, number_day.getInteger(), TimePeriod.DAY_TYPE);
134
	            }
135
	        }
136
	        catch (IndexOutOfBoundsException | IllegalFieldValueException e) {
137
	            number_day.text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
138
	        }
139

  
140
	    }else if(eventSource == number_year && number_year.getException()==null){
141
	        if (number_year.getInteger() == null || number_year.getInteger() == 0){
142
	            partial = TimePeriod.setPartialField(partial, null, TimePeriod.YEAR_TYPE);
143
	        } else{
144
	            partial = TimePeriod.setPartialField(partial, number_year.getInteger(), TimePeriod.YEAR_TYPE);
145
	        }
146

  
127
			    }else if(eventSource == number_year && number_year.getException()==null){
128
			        partial = TimePeriod.setPartialField(partial, number_year.getInteger(), TimePeriod.YEAR_TYPE);
129
			    }
130
			} catch (IndexOutOfBoundsException | IllegalFieldValueException e) {
131
				((NumberWithLabelElement)eventSource).text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
132
			}
147 133
	    }
148 134
	    firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
149 135
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/key/PolytomousKeyDetailElement.java
63 63
		    getEntity().setTitleCache(textLabel.getText(), true);
64 64
		}
65 65
		else if(eventSource==numberStartNumber){
66
		    getEntity().setStartNumber(numberStartNumber.getInteger());
66
			int startNumber = numberStartNumber.getInteger() == null? 0 : numberStartNumber.getInteger();
67
		    getEntity().setStartNumber(startNumber);
67 68
		}
68 69
		firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
69 70
	}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)