Subversion Repositories eFlore/Applications.cel

Rev

Rev 2553 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2553 Rev 2558
Line 1... Line 1...
1
package org.tela_botanica.client.util;
1
package org.tela_botanica.client.util;
Line -... Line 2...
-
 
2
 
-
 
3
import java.text.NumberFormat;
2
 
4
import java.text.ParsePosition;
3
import java.util.ArrayList;
5
import java.util.ArrayList;
4
import java.util.Collections;
6
import java.util.Collections;
5
import java.util.Comparator;
7
import java.util.Comparator;
6
import java.util.HashMap;
8
import java.util.HashMap;
Line 124... Line 126...
124
		lieuModele = lieuModele.replaceAll(",^$",", ");
126
		lieuModele = lieuModele.replaceAll(",^$",", ");
Line 125... Line 127...
125
		
127
		
126
		return lieuModele;
128
		return lieuModele;
Line 127... Line 129...
127
	}
129
	}
Line 128... Line 130...
128
	
130
	
129
	public static String obtenirDepartementAPartirChaineCommune(String departement, String commune) {
-
 
130
		
-
 
131
		String dep = "";
-
 
132
		
-
 
133
		if(departement == null) {
-
 
134
			departement = "";
-
 
135
		}
-
 
136
		
131
	public static String obtenirIdLocAPartirChaineCommune(String commune) {
137
		if(departement.equals("000null") || departement.equals("")) {
132
		
138
					
133
		String idLoc = "";	
139
			String[] depCom = commune.split(" ");
-
 
140
			if(depCom.length > 1) {
-
 
141
				dep = depCom[1].replace('(', ' ');
-
 
142
			} else {
134
		String[] depCom = commune.split(" ");
143
				dep = "";
135
		if(depCom.length > 1) {
144
			}
136
			idLoc = depCom[1].replace('(', ' ');
Line 145... Line 137...
145
		} else {
137
		} else {
146
			dep = departement;
138
			idLoc = "";
147
		}
139
		}
148
		
140
		
Line -... Line 141...
-
 
141
		idLoc = idLoc.replace(')', ' ');
-
 
142
		idLoc = idLoc.trim();
-
 
143
		idLoc = idLoc.replace('\\',' ');
-
 
144
		idLoc = idLoc.trim();
-
 
145
		
149
		dep = dep.replace(')', ' ');
146
		return idLoc;
150
		dep = dep.trim();
147
	}
151
		dep = dep.replace('\\',' ');
148
	
152
		dep = dep.trim();
149
	public static String formaterDepartement(String depAFormater) {	
153
		
150
		String dep = "";
154
		try
151
		try
Line 155... Line 152...
155
		{
152
		{
156
			int nDep = Integer.parseInt(dep);
153
			int nDep = Integer.parseInt(depAFormater);
157
			if(nDep > 0 && nDep < 110) {
154
			if(nDep > 0 && nDep < 110) {
Line 158... Line 155...
158
				departement = dep ;
155
				dep = depAFormater ;
159
			}
156
			}
160
			
157
			
161
			if(departement.length() == 4) {
158
			if(depAFormater.length() == 4) {
162
				departement = "0"+departement;
159
				dep = "0"+depAFormater;
163
			}
160
			}
Line 164... Line 161...
164
			
161
			
165
			departement = departement.substring(0,2);
162
			dep = depAFormater.substring(0,2);
Line 166... Line 163...
166
		}
163
		}
167
		catch(NumberFormatException e)
164
		catch(NumberFormatException e)
168
		{
165
		{
Line 169... Line 166...
169
			departement = "" ;
166
			// rien à faire
170
		}
167
		}
171
		
168
		
Line 301... Line 298...
301
 
298
 
302
	    }
299
	    }
303
	    return estZero;
300
	    return estZero;
Line -... Line 301...
-
 
301
	}
-
 
302
	
-
 
303
	public static boolean estUnNombre(String s) {
-
 
304
		//http://stackoverflow.com/questions/1102891/how-to-check-if-a-string-is-a-numeric-type-in-java
-
 
305
		try {  
-
 
306
			double d = Double.parseDouble(s);  
-
 
307
		} catch(NumberFormatException nfe) {  
-
 
308
			return false;  
-
 
309
		}  
-
 
310
		return true;  
304
	}
311
	}
305
	
312
	
306
	public static String formaterNombre(String s) {
313
	public static String formaterNombre(String s) {
307
		s = s.indexOf(".") < 0 ? s : s.replaceAll("0*$", "").replaceAll("\\.$", "");
314
		s = s.indexOf(".") < 0 ? s : s.replaceAll("0*$", "").replaceAll("\\.$", "");
Line 429... Line 436...
429
	}
436
	}
Line 430... Line 437...
430
 
437
 
431
	public static void curseurParDefaut() {
438
	public static void curseurParDefaut() {
432
		RootPanel.getBodyElement().getStyle().setProperty("cursor", "default");
439
		RootPanel.getBodyElement().getStyle().setProperty("cursor", "default");
433
	}
-
 
434
 
440
	}