Révision 7

projets/BCCCC/src/org/ccc/bcccc/server/GreetingServiceImpl.java (revision 7)
26 26
import java.util.regex.Pattern;
27 27

  
28 28
import org.ccc.bcccc.client.GreetingService;
29
import org.ccc.bcccc.shared.ITerrainField;
29 30
import org.ccc.bcccc.shared.K;
30 31
import org.ccc.bcccc.shared.TerrainRecord;
31 32
import org.ccc.bcccc.shared.TerrainRecordAndRights;
......
173 174
		if (user != null) {
174 175
			if (user.equals(ConfigDB.getAdmin())) {
175 176
				r.deletable = true;
176
				r.editable = true;
177
				r.editable = false;
177 178
				r.validable = r.record.mustBeValidated;
178 179
			} else if (user.equals(r.record.user)) {
179 180
				r.deletable = true;
......
225 226
		log.info("getRecordWithComplexCritera: "+critera);
226 227
		ArrayList<TerrainRecord> searched_records = new ArrayList<TerrainRecord>();
227 228

  
228
		String words = addBackSlash(critera.get(K.WORDS)).replace(" ", "|");
229
		boolean matchOne = critera.get(K.MATCHINGSTRATEGY).equals("ONE");
230
		int NUMBEROFCRITERA = 0;
231
		
232
		String words = addBackSlash(critera.get(K.WORDS)).toLowerCase().replace(" ", "|");
229 233
		Pattern p = null;
230 234
		if (words.length() > 0) {
231 235
			try {
232 236
				p = Pattern.compile(words);
237
				NUMBEROFCRITERA++;
233 238
			} catch(Exception e) {
234 239
				log.warning("Error while compiling search pattern with "+words+": "+e);
235 240
				p = null;
236 241
			}
237 242
		}
243
		
238 244
		List<String> types = new ArrayList<String>();
239
		if (critera.get(K.TYPES).length() > 0)
245
		if (critera.get(K.TYPES).length() > 0) {
240 246
			types= Arrays.asList(critera.get(K.TYPES).split(","));
241

  
247
			NUMBEROFCRITERA++;
248
		}
249
		
242 250
		List<String> dispositifs = new ArrayList<String>();
243
		if (critera.get(K.DISPOSITIFS).length() > 0)
251
		if (critera.get(K.DISPOSITIFS).length() > 0) {
244 252
			dispositifs = Arrays.asList(critera.get(K.DISPOSITIFS).split(","));
245

  
253
			NUMBEROFCRITERA++;
254
		}
255
		
246 256
		List<String> supports = new ArrayList<String>();
247
		if (critera.get(K.SUPPORTS).length() > 0)
257
		if (critera.get(K.SUPPORTS).length() > 0) {
248 258
			supports = Arrays.asList(critera.get(K.SUPPORTS).split(","));
249

  
259
			NUMBEROFCRITERA++;
260
		}
261
		
250 262
		List<String> projets = new ArrayList<String>();
251
		if (critera.get(K.PROJECTS).length() > 0)
263
		if (critera.get(K.PROJECTS).length() > 0) {
252 264
			projets = Arrays.asList(critera.get(K.PROJECTS).split(","));
265
			NUMBEROFCRITERA++;
266
		}
267
		
268
		int numberOfParticipants = Integer.parseInt(critera.get(K.NUMBEROFPARTICIPANTS));
269
		NUMBEROFCRITERA++;
270
		
271
		log.info("getRecordWithComplexCritera: NUMBEROFCRITERA="+NUMBEROFCRITERA+" WORDS="+words+", TYPES="+types+" DISPOSITIFS="+dispositifs+" SUPPORTS="+supports+" PROJECTS="+projets+" NUMBEROFPARTICIPANTS="+numberOfParticipants);
253 272

  
254
		int persons = Integer.parseInt(critera.get(K.NUMBEROFPARTICIPANTS));
255

  
256
		log.info("getRecordWithComplexCritera: WORDS="+words+", TYPES="+types+" DISPOSITIFS="+dispositifs+" SUPPORTS="+supports+" PROJECTS="+projets+" NUMBEROFPARTICIPANTS="+persons);
257

  
273
		int match_counter = 0;
274
		
258 275
		for (TerrainRecord record : records.values()) {
259
			if (p != null && p.matcher(record.short_description).find()) {
276
			match_counter = 0;
277
			if (p != null && p.matcher(record.short_description.toLowerCase()).find()) {
278
				log.info(" "+record.uniq_id+" matches with words critera "+words);
279
				match_counter++;
280
			} 
281
			if (record.numberOfParticipants >= numberOfParticipants) {
282
				log.info(" "+record.uniq_id+" matches with numberOfParticipants critera "+numberOfParticipants);
283
				match_counter++;
284
			} 
285
			if (types.size() > 0 && interString(record.types, types)) {
286
				log.info(" "+record.uniq_id+" matches with types critera "+types);
287
				match_counter++;
288
			} 
289
			if (dispositifs.size() > 0 && inter(record.dispositifs, dispositifs)) {
290
				log.info(" "+record.uniq_id+" matches with dispositifs critera "+dispositifs);
291
				match_counter++;
292
			} 
293
			if (projets.size() > 0) {
294
				log.info(" "+record.uniq_id+" with projets critera "+projets);
295
				match_counter++;
296
			} 
297
			if (supports.size() > 0 && inter(record.supports, supports)) {
298
				log.info(" "+record.uniq_id+" matches with supports critera "+supports);
299
				match_counter++;
300
			}
301
			
302
			if (matchOne && match_counter >= 1) { 
260 303
				searched_records.add(record);
261
				log.info("Found "+record+" with words critera "+words);
262
			} else if (persons > 0 && record.numberOfParticipants >= persons) {
304
				log.info(" "+record.uniq_id+" found.");
305
			} else if (!matchOne && match_counter == NUMBEROFCRITERA) {
263 306
				searched_records.add(record);
264
				log.info("Found "+record+" with persons critera "+persons);
265
			} else if (types.size() > 0 && inter(record.types, types)) {
266
				searched_records.add(record);
267
				log.info("Found "+record+" with types critera "+types);
268
			} else if (dispositifs.size() > 0 && inter(record.dispositifs, dispositifs)) {
269
				searched_records.add(record);
270
				log.info("Found "+record+" with dispositifs critera "+dispositifs);
271
			} else if (projets.size() > 0) {
272
				searched_records.add(record);
273
				log.info("Found "+record+" with projets critera "+projets);
274
			} else if (supports.size() > 0 && inter(record.supports, supports)) {
275
				searched_records.add(record);
276
				log.info("Found "+record+" with supports critera "+supports);
307
				log.info(" "+record.uniq_id+" found.");
277 308
			}
278 309
		}
279 310

  
......
309 340
	 * @param little the little
310 341
	 * @return true, if successful
311 342
	 */
312
	public static boolean inter(List big, List little) {
343
	public static boolean interString(List big, List little) {
313 344
		for (Object o : little) {
314 345
			for(Object o2 : big)
315 346
				if (o2.toString().equals(o)) return true;
316 347
		}
317 348
		return false;
318 349
	}
350
	
351
	/**
352
	 * Inter.
353
	 *
354
	 * @param big the big
355
	 * @param little the little
356
	 * @return true, if successful
357
	 */
358
	public static boolean inter(List<? extends ITerrainField> big, List little) {
359
		for (Object o : little) {
360
			for(ITerrainField o2 : big)
361
				if (o2.toCompareString().equals(o)) return true;
362
		}
363
		return false;
364
	}
319 365

  
320 366
	/* (non-Javadoc)
321 367
	 * @see org.ccc.bcccc.client.GreetingService#getRecordsWithSimpleCritera(java.util.HashMap)
......
426 472

  
427 473
			log.info("updateRecord: user="+user);
428 474

  
429
			if (records.containsKey(ID)) {
475
			if (!records.containsKey(ID)) {
430 476
				log.warning("updateRecord: record does not exists: "+ID);
431 477
				return false;
432 478
			} else {
433 479
				if (records.isRecordSetToUser(user, ID)) {
434
					log.info("updateRecord: updating record: "+ID);
480
					log.info("updateRecord: updating record: "+ID+" with "+content);
435 481
					TerrainRecord record = records.get(ID);
436

  
437
					if (record.mustBeValidated) {
438
						log.warning("updateRecord: record needs to be validatd before: "+ID);
482
					if (record == null) {
483
						log.severe("updateRecord: record not found: "+ID);
439 484
						return false;
440 485
					}
486
//					if (record.mustBeValidated) {
487
//						log.warning("updateRecord: record needs to be validatd before: "+ID);
488
//						return false;
489
//					}
441 490
					record.setDetailFields(content.numberOfParticipants, content.place, content.types, content.keywords, content.persons, content.dispositifs, content.documentations, content.supports, content.reports, content.publications);
442
					record.setInfoFields(content.name, content.project, content.date, content.short_description, content.user);
491
					record.setInfoFields(content.name, content.project, content.date, content.short_description, user);
443 492
					return records.save(record);
444 493

  
445 494
				} else {
projets/BCCCC/src/org/ccc/bcccc/server/RecordsDB.java (revision 7)
27 27

  
28 28
import javax.xml.parsers.DocumentBuilder;
29 29
import javax.xml.parsers.DocumentBuilderFactory;
30
import javax.xml.transform.OutputKeys;
30 31
import javax.xml.transform.Transformer;
31 32
import javax.xml.transform.TransformerFactory;
32 33
import javax.xml.transform.dom.DOMSource;
......
36 37
import org.ccc.bcccc.shared.Dispositif;
37 38
import org.ccc.bcccc.shared.DocumentUnit;
38 39
import org.ccc.bcccc.shared.K;
40
import org.ccc.bcccc.shared.Report;
39 41
import org.ccc.bcccc.shared.TerrainRecord;
40 42
import org.w3c.dom.Document;
41 43
import org.w3c.dom.Element;
......
141 143
	 * @return true, if is record set to user
142 144
	 */
143 145
	public boolean isRecordSetToUser(String user, Long recordID) {
146
		if (allUsersRecordIDS.get(user) == null) return false;
144 147
		return allUsersRecordIDS.get(user).contains(recordID);
145 148
	}
146 149

  
......
238 241
						String url = node.getAttribute(K.URL);
239 242
						record.documentations.add(new DocumentUnit(type, url, dname));
240 243
					}
244
					
241 245

  
246
					// get documentations
247
					NodeList reports = rootElement.getElementsByTagName(K.REPORT);
248
					for (int i=0; i<reports.getLength(); i++){
249
						Element node = (Element)(reports.item(i));
250
						String userID = node.getAttribute(K.USER);
251
						String note = node.getAttribute(K.NOTE);
252
						int inote = 0;
253
						if (note.length() > 0) inote = Integer.parseInt(note);
254
						String comment = node.getTextContent();
255
						record.reports.add(new Report(userID, comment, inote));
256
					}
257

  
242 258
					this.put(record.uniq_id, record);
243 259
					if (!this.containsUser(record.user)) this.registerUser(record.user);
244 260
					this.setRecordToUser(record.user, record.uniq_id);
......
325 341
				rootElement.appendChild(e);
326 342
			}
327 343
			
344
			for (Report v : record.reports) {
345
				Element e = doc.createElement(K.REPORT);
346
				e.setAttribute(K.USER, v.user);
347
				e.setTextContent(v.comment);
348
				e.setAttribute(K.NOTE, ""+v.note);
349
				rootElement.appendChild(e);
350
			}
351
			
328 352
			// write the content into xml file
329 353
			TransformerFactory transformerFactory = TransformerFactory.newInstance();
330 354
			Transformer transformer = transformerFactory.newTransformer();
355
			transformer.setOutputProperty(OutputKeys.INDENT, "yes");
331 356
			DOMSource source = new DOMSource(doc);
332 357
			StreamResult result = new StreamResult(recordDB);
333 358
	 		// StreamResult result = new StreamResult(System.out);
projets/BCCCC/src/org/ccc/bcccc/shared/TerrainRecordAndRights.java (revision 7)
74 74
	 * @see java.lang.Object#toString()
75 75
	 */
76 76
	public String toString() {
77
		return "("+editable+", "+deletable+", "+validable+") "+record.toString();
77
		return record.toString()+ "\n(editable="+editable+", deleteable="+deletable+", validable="+validable+")";
78 78
	}
79 79
}
projets/BCCCC/src/org/ccc/bcccc/shared/Data.java (revision 7)
24 24
/**
25 25
 * The Class Data.
26 26
 */
27
public class Data implements Serializable {
27
public class Data implements Serializable, IHTMLprintable, ITerrainField {
28 28

  
29 29
	/** The Constant serialVersionUID. */
30 30
	private static final long serialVersionUID = 1047843881275904261L;
......
36 36
	public String url = null;
37 37
	
38 38
	/** The Constant values. */
39
	public static final String[] values = {"primary", "secondary", "illustrative"};
39
	public static final String[] values = {"Primaire", "Secondaire", "Illustratif"};
40 40
	
41
	protected Data() {
42
		
43
	}
44
	
41 45
	/**
42 46
	 * Instantiates a new data.
43 47
	 *
......
55 59
	public String toString() {
56 60
		return type +" "+url;
57 61
	}
62
	
63
	/* (non-Javadoc)
64
	 * @see java.lang.Object#toString()
65
	 */
66
	public String toHTML() {
67
		return "<p>"+type +" Télécharger à l'adresse <a href=\""+url+"\">"+url+"</a></p>";
68
	}
69
	
70
	public String toCompareString() {
71
		return type;
72
	}
58 73
}
projets/BCCCC/src/org/ccc/bcccc/shared/Publication.java (revision 7)
18 18
 */
19 19
package org.ccc.bcccc.shared;
20 20

  
21
import java.io.Serializable;
22

  
21 23
// TODO: Auto-generated Javadoc
22 24
/**
23 25
 * The Class Publication.
24 26
 */
25
public class Publication {
27
public class Publication implements Serializable, IHTMLprintable, ITerrainField {
26 28
	
29
	/**
30
	 * 
31
	 */
32
	private static final long serialVersionUID = 3080989627286156128L;
33

  
27 34
	/** The user. */
28 35
	public String user;
29 36
	
......
34 41
	public String type;
35 42
	
36 43
	/** The Constant types. */
37
	public static final String[] types = {"Atelier CCC", "article", "séminaire"};
44
	public static final String[] types = {"Atelier CCC", "Article", "Séminaire"};
38 45
	
46
	protected Publication() {
47
		
48
	}
49
	
39 50
	/**
40 51
	 * Instantiates a new publication.
41 52
	 *
......
55 66
	public String toString() {
56 67
		return user+":"+type+":"+url;
57 68
	}
69
	
70
	/* (non-Javadoc)
71
	 * @see java.lang.Object#toString()
72
	 */
73
	public String toHTML() {
74
		return "<p>"+type+" par "+user+" à télécharger à l'adresse suivante <a href=\""+url+"\">"+url+"</a></p>";
75
	}
76
	
77
	public String toCompareString() {
78
		return type;
79
	}
58 80
}
projets/BCCCC/src/org/ccc/bcccc/shared/K.java (revision 7)
106 106
	
107 107
	/** The Constant DOCUMENTATION. */
108 108
	public static final String DOCUMENTATION = "documentation";
109

  
110
	public static final String REPORT = "report";
109 111
	
110 112
	/** The Constant NAME. */
111 113
	public static final String NAME = "name";
......
124 126
	
125 127
	/** The Constant WORDS. */
126 128
	public static final String WORDS = "words";
129

  
130
	public static final String NOTE = "note";
131
	public static final String COMMENT = "comment";
132

  
133
	public static final String MATCHINGSTRATEGY = "matching";
134

  
127 135
}
projets/BCCCC/src/org/ccc/bcccc/shared/Report.java (revision 7)
24 24
/**
25 25
 * The Class Report.
26 26
 */
27
public class Report implements Serializable {
27
public class Report implements Serializable, IHTMLprintable, ITerrainField {
28 28

  
29 29
	/** The Constant serialVersionUID. */
30 30
	private static final long serialVersionUID = 5810467466405146857L;
......
38 38
	/** The note. */
39 39
	public int note;
40 40
	
41
	public Report() {
42
		
43
	}
44
	
41 45
	/**
42 46
	 * Instantiates a new report.
43 47
	 *
......
57 61
	public String toString() {
58 62
		return user+":"+note+":"+comment;
59 63
	}
64
	
65
	/* (non-Javadoc)
66
	 * @see java.lang.Object#toString()
67
	 */
68
	public String toHTML() {
69
		return "<p>"+user+" : "+note+"/5 </p><p>"+comment+"</p>";
70
	}
71

  
72
	@Override
73
	public String toCompareString() {
74
		return user;
75
	}
60 76
}
projets/BCCCC/src/org/ccc/bcccc/shared/Dispositif.java (revision 7)
20 20

  
21 21
import java.io.Serializable;
22 22

  
23
// TODO: Auto-generated Javadoc
24 23
/**
25 24
 * The Class Dispositif.
26 25
 */
27
public class Dispositif implements Serializable {
26
public class Dispositif implements Serializable, IHTMLprintable, ITerrainField {
28 27
	
28
	protected Dispositif() {
29
		
30
	}
31

  
29 32
	/**
30 33
	 * 
31 34
	 */
......
38 41
	public String url = null;
39 42
	
40 43
	/** The mobile. */
41
	public boolean mobile = false;
44
	public Boolean mobile = false;
42 45
	
43 46
	/** The Constant types. */
44 47
	public static final String[] types = {"camera", "micro", "scanner",
......
51 54
	 * @param url the url
52 55
	 * @param mobile the mobile
53 56
	 */
54
	public Dispositif(String type, String url, boolean mobile) {
57
	public Dispositif(String type, String url, Boolean mobile) {
55 58
		this.type = type;
56 59
		this.url = url;
57 60
		this.mobile = mobile;
......
63 66
	public String toString() {
64 67
		return type +" "+mobile+" "+url;
65 68
	}
69
	
70
	/* (non-Javadoc)
71
	 * @see java.lang.Object#toString()
72
	 */
73
	public String toHTML() {
74
		return "<p>Type : "+type +" "+(mobile?"mobile":"non mobile")+" plus d'information sur le matériel à l'adresse <a href=\""+url+"\">"+url+"</a></p>";
75
	}
76
	
77
	public String toCompareString() {
78
		return type;
79
	}
66 80
}
projets/BCCCC/src/org/ccc/bcccc/shared/DocumentUnit.java (revision 7)
24 24
/**
25 25
 * The Class DocumentUnit.
26 26
 */
27
public class DocumentUnit implements Serializable {
27
public class DocumentUnit implements Serializable, IHTMLprintable, ITerrainField {
28 28

  
29

  
30

  
31

  
29 32
	/** The Constant serialVersionUID. */
30 33
	private static final long serialVersionUID = 7528287443409293099L;
31
	
34

  
32 35
	/** The type. */
33 36
	public String type = "";
34
	
37

  
35 38
	/** The url. */
36 39
	public String url = "";
37
	
40

  
38 41
	/** The name. */
39 42
	public String name = "";
40
	
43

  
41 44
	/** The Constant values. */
42
	public static final String[] values = {"plan", "description", "makingof", "photo dispositif", "photo terrain"};
43
	
44
	
45
	public static final String[] values = {"Plan", "Description", "Makingof", "Dispositif photo", "Photo du terrain"};
46

  
47

  
48
	protected DocumentUnit() {
49

  
50
	}
51

  
45 52
	/**
46 53
	 * Instantiates a new document unit.
47 54
	 *
......
54 61
		this.url = url;
55 62
		this.name = name;
56 63
	}
57
	
64

  
58 65
	/* (non-Javadoc)
59 66
	 * @see java.lang.Object#toString()
60 67
	 */
61 68
	public String toString() {
62 69
		return name +" "+type+" "+url;
63 70
	}
71
	
72
	/* (non-Javadoc)
73
	 * @see java.lang.Object#toString()
74
	 */
75
	public String toHTML() {
76
		return "<p>"+type+" : "+name +" à télécharger à l'adresse <a href=\""+url+"\">"+url+"</a></p>";
77
	}
78
	
79
	public String toCompareString() {
80
		return type;
81
	}
64 82
}
projets/BCCCC/src/org/ccc/bcccc/shared/IHTMLprintable.java (revision 7)
1
package org.ccc.bcccc.shared;
2

  
3
public interface IHTMLprintable {
4
	public String toHTML();
5
}
0 6

  
projets/BCCCC/src/org/ccc/bcccc/shared/ITerrainField.java (revision 7)
1
package org.ccc.bcccc.shared;
2

  
3
public interface ITerrainField {
4
	public String toCompareString();
5
}
0 6

  
projets/BCCCC/src/org/ccc/bcccc/shared/TerrainRecord.java (revision 7)
23 23
import java.util.Date;
24 24
import java.util.List;
25 25

  
26
import com.google.gwt.i18n.client.DateTimeFormat;
27
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
28

  
26 29
// TODO: Auto-generated Javadoc
27 30
/**
28 31
 * The Class TerrainRecord.
......
152 155
	 * @see java.lang.Object#toString()
153 156
	 */
154 157
	public String toString() {
155
		return uniq_id+"="+name+" "+project+" "+user+" "+mustBeValidated+" "+date+" "+year+" "+place+" "+numberOfParticipants+" "+types+" "+keywords+" "+" "+persons+" "+dispositifs+" "+supports+" "+documentations+" "+short_description;
158
		return ""+uniq_id+"\n"
159
				+ "\tName="+name+" \n"
160
				+ "\tProject="+project+"\n"
161
				+ "\tOwner= "+user+"\n"
162
				+ "\tDesc="+short_description+"\n"
163
				+ "\tWaitingForValidation="+mustBeValidated+"\n"
164
				+ "\tDate="+date+" "+year+"\n"
165
				+ "\tPlace="+place+"\n"
166
				+ "\tNumberOfParticipants="+numberOfParticipants+"\n"
167
				+ "\tTypes"+types+"\n"
168
				+" \tMakers="+persons+"\n"
169
				+ "\tDispositifs="+dispositifs+"\n"
170
				+ "\tSupports "+supports+"\n"
171
				+ "\tDocs= "+documentations;
156 172
	}
157 173

  
158 174
	/* (non-Javadoc)
159 175
	 * @see java.lang.Object#toString()
160 176
	 */
161 177
	public String toHTML() {
162
		return "<h3>"+name+"</h3>\n" +
178
		return "<h2>"+name+"</h2>\n" +
179
				"<p>"+short_description+"</p>" +
163 180
				"<h3>Informations</h3>\n" +
164 181
				"<ul>"+
165
				"<li>Project: "+project+"</li>\n" +
166
				"<li>Owner: "+user+"</li>\n" +
167
				"<li>Year: "+year+"</li>\n" +
168
				"<li>Place: "+place+"</li>\n" +
169
				"<li>Number of participants: "+numberOfParticipants+"</li>" +
182
				"<li>Nom du projet ayant produit le terrain : "+project+"</li>\n" +
183
				"<li>Créateur de la fiche : "+user+"</li>\n" +
184
				"<li>Date de prise : "+DateTimeFormat.getFormat(PredefinedFormat.DATE_LONG).format(date)+"</li>\n" +
185
				"<li>Lieu de prise : "+place+"</li>\n" +
186
				"<li>Nombre de participants: "+numberOfParticipants+"</li>" +
187
				"<p>Persones impliquées dans la réalisation du terrain : "+toPrettyHTMLList(persons)+"</p>\n" +
170 188
				"</ul>" +
171
				"<h3>Details</h3>\n" +
172
				"<p>Types: "+types+"</p>\n" +
173
				"<p>Persons: "+persons+"</p>\n" +
174
				"<p>Dispositifs: "+dispositifs+"</p>\n" +
175
				"<p>Equipments: "+supports+"</p>\n" +
176
				"<p>Documentation: "+documentations+"<p>\n" +
177
				"<h3>Description</h3>\n" +
178
				"<p>"+short_description;
189
				"<h3>Détails</h3>\n" +
190
				"<p>Type : "+toPrettyHTMLList(types)+"</p>\n" +
191
				"<p>Equipments employés : "+toPrettyHTMLIHTMLprintableList(dispositifs)+"</p>\n" +
192
				"<p>Médias produits : "+toPrettyHTMLIHTMLprintableList(supports)+"</p>\n" +
193
				"<p>Évaluations : "+toPrettyHTMLIHTMLprintableList(reports)+"<p>\n" +
194
				"<p>Documentation : "+toPrettyHTMLIHTMLprintableList(documentations)+"<p>\n";
179 195
	}
196
	
197
	public String toPrettyHTMLIHTMLprintableList(List<? extends IHTMLprintable> list) {
198
		if (list.size() == 0) return "aucun";
199
		StringBuffer buf = new StringBuffer();
200
		buf.append("<ul>\n");
201
		for (IHTMLprintable o : list) {
202
			buf.append("<li class=\""+o.getClass().getSimpleName()+"\">"+o.toHTML()+"</li>");
203
		}
204
		buf.append("</ul>\n");
205
		return buf.toString();
206
	}
207
	
208
	public String toPrettyHTMLList(List<String> list) {
209
		if (list.size() == 0) return "NA";
210
		StringBuffer buf = new StringBuffer();
211
		buf.append("<ul>\n");
212
		for (Object o : list) {
213
			buf.append("<li class=\""+o.getClass().getSimpleName()+"\">"+o+"</li>");
214
		}
215
		buf.append("</ul>\n");
216
		return buf.toString();
217
	}
180 218
}
projets/BCCCC/src/org/ccc/bcccc/client/panels/BrowsePanel.java (revision 7)
27 27

  
28 28
import com.google.gwt.user.client.History;
29 29
import com.google.gwt.user.client.rpc.AsyncCallback;
30
import com.smartgwt.client.types.Alignment;
30 31
import com.smartgwt.client.types.ListGridFieldType;
32
import com.smartgwt.client.types.SortDirection;
31 33
import com.smartgwt.client.util.SC;
34
import com.smartgwt.client.widgets.Canvas;
35
import com.smartgwt.client.widgets.ImgButton;
36
import com.smartgwt.client.widgets.events.ClickEvent;
37
import com.smartgwt.client.widgets.events.ClickHandler;
32 38
import com.smartgwt.client.widgets.grid.ListGrid;
33 39
import com.smartgwt.client.widgets.grid.ListGridField;
34 40
import com.smartgwt.client.widgets.grid.ListGridRecord;
......
36 42
import com.smartgwt.client.widgets.grid.events.ChangedHandler;
37 43
import com.smartgwt.client.widgets.grid.events.RecordDoubleClickEvent;
38 44
import com.smartgwt.client.widgets.grid.events.RecordDoubleClickHandler;
45
import com.smartgwt.client.widgets.layout.HLayout;
39 46
import com.smartgwt.client.widgets.layout.VLayout;
40 47

  
41 48
// TODO: Auto-generated Javadoc
......
76 83

  
77 84
	private boolean isAdmin = false;
78 85
	
86
	private HLayout rollOverCanvas;
87
	private ListGridRecord rollOverRecord;
88
	
89
	String UNIQID_str;
90
	
79 91
	/**
80 92
	 * Inits the.
81 93
	 */
......
84 96
			System.out.println("Initializing 'browse'...");
85 97
			initBrowseDone = true;
86 98

  
87
			valuesGrid = new ListGrid();
99
			valuesGrid = new ListGrid(){
100
				@Override  
101
	            protected Canvas getRollOverCanvas(Integer rowNum, Integer colNum) {  
102
	                rollOverRecord = this.getRecord(rowNum);  
103
	                UNIQID_str = rollOverRecord.getAttribute(K.UNIQID);
104
	                
105
	                if(rollOverCanvas == null && UNIQID_str!=null) {  
106
	                    rollOverCanvas = new HLayout(3);  
107
	                    rollOverCanvas.setSnapTo("TR");  
108
	                    rollOverCanvas.setWidth(50);  
109
	                    rollOverCanvas.setHeight(22);  
110
	  
111
	                    ImgButton editImg = new ImgButton();  
112
	                    editImg.setShowDown(false);  
113
	                    editImg.setShowRollOver(false);  
114
	                    editImg.setLayoutAlign(Alignment.CENTER);  
115
	                    editImg.setSrc("pencil.png");  
116
	                    editImg.setPrompt("Editer la fiche");  
117
	                    editImg.setHeight(16);  
118
	                    editImg.setWidth(16);  
119
	                    editImg.addClickHandler(new ClickHandler() {  
120
	                        public void onClick(ClickEvent event) {  
121
	                        	
122
	                        	if (UNIQID_str == null) {
123
	                        		return;
124
	                        	}
125
	        					Long UNIQID = Long.parseLong(UNIQID_str);
126
	        					System.out.println("User double click the edit icon with UNIQID="+UNIQID);
127
	        					BCCCC.doubleClickedRecord = null;
128
	        					for (int i = 0 ; i < BCCCC.records.size() ; i++) {
129
	        						if (BCCCC.records.get(i).uniq_id == UNIQID) {
130
	        							BCCCC.doubleClickedRecord = BCCCC.records.get(i);
131
	        							continue;
132
	        						}
133
	        					}
134
	                        		                        	
135
	                        	History.newItem(K.EDITRECORD);
136
	                        }  
137
	                    });  
138
	  
139
	                    ImgButton viewImg = new ImgButton();  
140
	                    viewImg.setShowDown(false);  
141
	                    viewImg.setShowRollOver(false);  
142
	                    viewImg.setLayoutAlign(Alignment.CENTER);  
143
	                    viewImg.setSrc("report.png");  
144
	                    viewImg.setPrompt("Voir la fiche");  
145
	                    viewImg.setHeight(16);  
146
	                    viewImg.setWidth(16);  
147
	                    viewImg.addClickHandler(new ClickHandler() {  
148
	                        public void onClick(ClickEvent event) {  
149
	                        	if (UNIQID_str == null) {
150
	                        		return;
151
	                        	}
152
	        					Long UNIQID = Long.parseLong(UNIQID_str);
153
	        					System.out.println("User click the view icon with UNIQID="+UNIQID);
154
	        					BCCCC.doubleClickedRecord = null;
155
	        					for (int i = 0 ; i < BCCCC.records.size() ; i++) {
156
	        						if (BCCCC.records.get(i).uniq_id == UNIQID) {
157
	        							BCCCC.doubleClickedRecord = BCCCC.records.get(i);
158
	        							continue;
159
	        						}
160
	        					}
161
	                        		                        	
162
	                        	History.newItem(K.VIEWRECORD);  
163
	                        }  
164
	                    });  
165
	  
166
	                    rollOverCanvas.addMember(editImg);  
167
	                    rollOverCanvas.addMember(viewImg);  
168
	                }  
169
	                return rollOverCanvas;  
170
	  
171
	            }  
172
			};
88 173
			valuesGrid.setWidth100();
89 174
			valuesGrid.setWidth100();
90 175
			valuesGrid.setShowResizeBar(false);
176
			valuesGrid.setShowRowNumbers(true);
177
			valuesGrid.setWrapCells(true);
178
			valuesGrid.setEmptyMessage("<br>Pas de fiches publiées.");  
179
			valuesGrid.setFixedRecordHeights(false);  
180
			valuesGrid.setShowRollOverCanvas(true);
91 181
			valuesGrid.addRecordDoubleClickHandler(new RecordDoubleClickHandler() {
92 182
				@Override
93 183
				public void onRecordDoubleClick(RecordDoubleClickEvent event) {
94 184
					String UNIQID_str = event.getRecord().getAttribute(K.UNIQID);
95 185
					Long UNIQID = Long.parseLong(UNIQID_str);
186
					System.out.println("User double click on record with UNIQID="+UNIQID);
96 187
					BCCCC.doubleClickedRecord = null;
97 188
					for (int i = 0 ; i < BCCCC.records.size() ; i++) {
98 189
						if (BCCCC.records.get(i).uniq_id == UNIQID) {
......
126 217
			System.out.println(" init fields...");
127 218
			ArrayList<ListGridField> fields = new ArrayList<ListGridField>();
128 219

  
129
			idField = new ListGridField(K.ID, "Name");
220
			idField = new ListGridField(K.ID, "Nom");
130 221
			idField.setPrompt("identifiant");
131
			idField.setType(ListGridFieldType.INTEGER);
222
			idField.setType(ListGridFieldType.TEXT);
223
			idField.setWidth(100);
132 224
			fields.add(idField);
133 225

  
134
			yearField = new ListGridField(K.YEAR, "Year");
226
			yearField = new ListGridField(K.YEAR, "Année");
135 227
			yearField.setPrompt("Year");
136 228
			yearField.setWidth(150);
137 229
			yearField.setType(ListGridFieldType.INTEGER);
......
139 231

  
140 232
			descField = new ListGridField(K.DESC, "Description");
141 233
			descField.setPrompt("Short description");
142
			descField.setWidth(150);
234
			descField.setWidth("*");
143 235
			descField.setType(ListGridFieldType.TEXT);
144 236
			descField.setWrap(true);
145 237
			fields.add(descField);
146 238

  
147
			projectField = new ListGridField(K.PROJECT, "Project");
239
			projectField = new ListGridField(K.PROJECT, "Projet");
148 240
			projectField.setPrompt("Project name");
149 241
			projectField.setWidth(150);
150 242
			projectField.setType(ListGridFieldType.TEXT);
151
			projectField.setWrap(true);
152 243
			fields.add(projectField);
153 244
			
154
			validateField = new ListGridField(K.VALIDATE, "Waiting for publication");
245
			validateField = new ListGridField(K.VALIDATE, "En attente de publication");
155 246
			validateField.setPrompt("is visible or not to public users");
156 247
			validateField.setType(ListGridFieldType.BOOLEAN);
157
			validateField.setWrap(true);
248
			validateField.setWidth(100);
158 249
			validateField.setHidden(true);
159 250
			
160 251
			validateField.addChangedHandler(new ChangedHandler(){
......
187 278
			valuesGrid.setFields(yearField, idField, projectField, validateField, descField);
188 279
			valuesGrid.setGroupByField(K.YEAR);
189 280
			valuesGrid.setGroupStartOpen("all");
190

  
281
			 
191 282
			this.addMember(valuesGrid);
283
						
192 284
			System.out.println("End of 'browse' init");
193 285
		}
194 286
		
......
212 304
		ListGridRecord[] listGridRecords = new ListGridRecord[BCCCC.records.size()];
213 305

  
214 306
		int i = 0;
215
		System.out.println("Records: "+BCCCC.records.size());
307
		System.out.println("Number of records shown: "+BCCCC.records.size());
216 308
		for (TerrainRecord record : BCCCC.records) {
217 309
			//System.out.println(record);
218 310
			listGridRecords[i] = new ListGridRecord();
......
227 319
		}
228 320

  
229 321
		valuesGrid.setRecords(listGridRecords);
322
		valuesGrid.setSortField(0);  
323
		valuesGrid.setSortDirection(SortDirection.DESCENDING); 
230 324
	}
231 325
}
projets/BCCCC/src/org/ccc/bcccc/client/panels/EditPanel.java (revision 7)
23 23
import org.ccc.bcccc.client.BCCCC;
24 24
import org.ccc.bcccc.client.Services;
25 25
import org.ccc.bcccc.client.areas.DataRecordArea;
26
import org.ccc.bcccc.client.areas.DateRecordArea;
26
import org.ccc.bcccc.client.areas.DateRecordField;
27 27
import org.ccc.bcccc.client.areas.DispositifsRecordArea;
28 28
import org.ccc.bcccc.client.areas.DocumentsRecordArea;
29
import org.ccc.bcccc.client.areas.IntegerRecordArea;
30
import org.ccc.bcccc.client.areas.LongStringRecordArea;
31 29
import org.ccc.bcccc.client.areas.PublicationsRecordArea;
30
import org.ccc.bcccc.client.areas.RecordDescriptionField;
31
import org.ccc.bcccc.client.areas.RecordNOfParticipantsField;
32
import org.ccc.bcccc.client.areas.RecordNameField;
33
import org.ccc.bcccc.client.areas.RecordPersonsArea;
34
import org.ccc.bcccc.client.areas.RecordProjectField;
35
import org.ccc.bcccc.client.areas.RecordTypesArea;
32 36
import org.ccc.bcccc.client.areas.ReportsRecordArea;
33
import org.ccc.bcccc.client.areas.StringRecordField;
34 37
import org.ccc.bcccc.shared.K;
35 38
import org.ccc.bcccc.shared.TerrainRecordAndRights;
36 39

  
37 40
import com.google.gwt.user.client.History;
38 41
import com.google.gwt.user.client.rpc.AsyncCallback;
39 42
import com.smartgwt.client.types.TitleOrientation;
43
import com.smartgwt.client.util.BooleanCallback;
40 44
import com.smartgwt.client.util.SC;
41 45
import com.smartgwt.client.widgets.form.DynamicForm;
42 46
import com.smartgwt.client.widgets.form.fields.ButtonItem;
43 47
import com.smartgwt.client.widgets.layout.VLayout;
44 48

  
45
// TODO: Auto-generated Javadoc
46 49
/**
47 50
 * The Class ViewAndEditTerrainRecordPanel.
48 51
 */
......
61 64

  
62 65
	/** The init view and edit done. */
63 66
	boolean initViewAndEditDone;
64
	
67

  
65 68
	/** The view and edit form. */
66 69
	private DynamicForm viewAndEditForm;
67 70

  
68 71
	/** The save vae button. */
69 72
	private ButtonItem saveVAEButton;
70
	
73

  
71 74
	/** The delete vae button. */
72 75
	private ButtonItem deleteVAEButton;
73
	
76

  
74 77
	/** The validate vae button. */
75 78
	private ButtonItem validateVAEButton;
76 79

  
77 80
	/** The name field. */
78
	private StringRecordField nameField;
79
	
81
	private RecordNameField nameField;
82

  
80 83
	/** The project field. */
81
	private StringRecordField projectField;
82
	
84
	private RecordProjectField projectField;
85

  
83 86
	/** The description field. */
84
	private LongStringRecordArea descriptionField;
85
	
87
	private RecordDescriptionField descriptionField;
88

  
86 89
	/** The date field. */
87
	private DateRecordArea dateField;
90
	private DateRecordField dateField;
88 91

  
89 92
	/** The number of participants field. */
90
	private IntegerRecordArea numberOfParticipantsField;
91
	
93
	private RecordNOfParticipantsField numberOfParticipantsField;
94

  
92 95
	/** The participants field. */
93
	private StringRecordField personsField;
94
	
96
	private RecordPersonsArea personsField;
97

  
95 98
	/** The types field. */
96
	private StringRecordField typesField;
97
	
99
	private RecordTypesArea typesField;
100

  
98 101
	/** The dispositifs field. */
99 102
	private DispositifsRecordArea dispositifsField;
100
	
103

  
101 104
	/** The data field. */
102 105
	private DataRecordArea dataField;
103
	
106

  
104 107
	/** The documentation field. */
105 108
	private DocumentsRecordArea documentationField;
106
	
109

  
107 110
	/** The report field. */
108 111
	private ReportsRecordArea reportField;
109
	
112

  
110 113
	/** The publication field. */
111 114
	private PublicationsRecordArea publicationField;
112 115

  
116
	private ButtonItem viewVAEButton;
117

  
113 118
	/**
114 119
	 * Inits the.
115 120
	 */
116 121
	public void init() {
117 122
		this.hide();
123
		this.setMargin(10);
118 124
		if (!initViewAndEditDone) {
119 125
			initViewAndEditDone = true;
120 126

  
121 127
			viewAndEditForm = new DynamicForm();
122 128

  
123 129
			saveVAEButton = new ButtonItem("save_record");
124
			saveVAEButton.setTitle("Save changes");
130
			saveVAEButton.setTitle("Sauver les modifications");
125 131
			saveVAEButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
126 132
				@Override
127 133
				public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
128
//					final String ID = viewAndEditForm.getValueAsString(K.ID);
129
//					if (ID == null || ID.trim().length() == 0) return;
134
					//					final String ID = viewAndEditForm.getValueAsString(K.ID);
135
					//					if (ID == null || ID.trim().length() == 0) return;
130 136

  
131 137
					record.record.setInfoFields(nameField.getValue(), 
132 138
							projectField.getValue(), 
133 139
							dateField.getDate(), 
134 140
							descriptionField.getValue(),
135 141
							"???");
136
					
142

  
137 143
					record.record.setDetailFields(Integer.parseInt(numberOfParticipantsField.getValue()), 
138 144
							viewAndEditForm.getValueAsString(K.PLACE), 
139 145
							typesField.getValuesAsStringArray(), 
......
146 152
							publicationField.getValues());
147 153

  
148 154
					System.out.println("Call updateRecord: "+record.record.uniq_id+", "+record.record);
149
					Services.getMain().updateRecord(record.record.uniq_id, null, new AsyncCallback<Boolean>() {
155
					Services.getMain().updateRecord(record.record.uniq_id, record.record, new AsyncCallback<Boolean>() {
150 156

  
151 157
						@Override
152 158
						public void onFailure(Throwable caught) {
......
157 163
						@Override
158 164
						public void onSuccess(Boolean result) {
159 165
							if (result) {
160
								SC.warn("Record '"+record.record.uniq_id+"' saved: "+record.record);
166
								SC.say("Record '"+record.record.uniq_id+"' saved: "+record.record);
161 167
							} else {
162
								SC.warn("Record '"+record.record.uniq_id+"' NOT created.");
168
								SC.warn("Error: Record '"+record.record.uniq_id+"' NOT saved.");
163 169
							}
164 170
						}
165 171
					});
......
167 173
			});
168 174

  
169 175
			deleteVAEButton = new ButtonItem("delete_record");
170
			deleteVAEButton.setTitle("Delete record");
176
			deleteVAEButton.setTitle("Supprimer la fiche");
171 177
			deleteVAEButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
172 178
				@Override
173 179
				public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
174
					Services.getMain().deleteRecord(record.record.uniq_id, new AsyncCallback<Boolean>() {
180

  
181
					SC.ask("Etes-vous sur de vouloir supprimer la fiche ?", new BooleanCallback() {
182

  
175 183
						@Override
176
						public void onFailure(Throwable caught) {
177
							SC.warn("Error: "+caught);
178
						}
184
						public void execute(Boolean value) {
185
							if (value) {
186
								Services.getMain().deleteRecord(record.record.uniq_id, new AsyncCallback<Boolean>() {
187
									@Override
188
									public void onFailure(Throwable caught) {
189
										SC.warn("Error: "+caught);
190
									}
179 191

  
180
						@Override
181
						public void onSuccess(Boolean result) {
182
							if (result) {
183
								SC.say("Deleted.");
184
								History.newItem(K.BROWSE+"_my");
185
							} else {
186
								SC.say("NOT Deleted.");
192
									@Override
193
									public void onSuccess(Boolean result) {
194
										if (result) {
195
											SC.say("Deleted.");
196
											History.newItem(K.BROWSE+"_my");
197
										} else {
198
											SC.warn("Error: NOT Deleted.");
199
										}
200
									}
201
								});
187 202
							}
188 203
						}
189 204
					});
......
191 206
			});
192 207

  
193 208
			validateVAEButton = new ButtonItem("validate_record");
194
			validateVAEButton.setTitle("Validate record");
209
			validateVAEButton.setTitle("Validater la fiche pour publication");
195 210
			validateVAEButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
196 211
				@Override
197 212
				public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
......
209 224
				}
210 225
			});
211 226

  
212
			viewAndEditForm.setNumCols(3);
227
			viewVAEButton = new ButtonItem("view_record");
228
			viewVAEButton.setTitle("Voir la fiche");
229
			viewVAEButton.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
230
				@Override
231
				public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
232
					History.newItem(K.VIEWRECORD);  
233
				}
234
			});
235
			viewAndEditForm.setNumCols(4);
213 236
			viewAndEditForm.setAutoWidth();
214
			viewAndEditForm.setItems(deleteVAEButton, validateVAEButton, saveVAEButton);
237
			viewAndEditForm.setItems(deleteVAEButton, validateVAEButton, saveVAEButton, viewVAEButton);
215 238
			viewAndEditForm.setTitleOrientation(TitleOrientation.LEFT);
239
			viewAndEditForm.setMargin(10);
216 240

  
217
			nameField = new StringRecordField(this, "Name", false, true, null);	
218
			projectField = new StringRecordField(this, "Project", false, true, null);	
219
			descriptionField = new LongStringRecordArea(this, "Description", false, true);
220
			dateField = new DateRecordArea(this, "Date", false, true, null);
221
			numberOfParticipantsField = new IntegerRecordArea(this, "Number of participants");
222
			personsField = new StringRecordField(this, "Participants", true, true, null);
223
			String[] typesValues = {"privé", "commerce", "école", "etc."};
224
			typesField = new StringRecordField(this, "Types", true, false, typesValues);
225
			dispositifsField = new DispositifsRecordArea(this, "Dispositifs");
226
			dataField = new DataRecordArea(this,  "Données");
241
			nameField = new RecordNameField(this);
242
			projectField = new RecordProjectField(this);	
243
			descriptionField = new RecordDescriptionField(this);
244
			dateField = new DateRecordField(this, "Date", false, true, null);
245
			numberOfParticipantsField = new RecordNOfParticipantsField(this, "Nombre de participants");
246

  
247
			personsField = new RecordPersonsArea(this);
248
			typesField = new RecordTypesArea(this);
249

  
250
			dispositifsField = new DispositifsRecordArea(this, "Dispositifs utilisés");
251
			dataField = new DataRecordArea(this,  "Données produites");
227 252
			documentationField = new DocumentsRecordArea(this, "Documentation");
228 253
			reportField = new ReportsRecordArea(this,  "Rapports");
229
			publicationField = new PublicationsRecordArea(this, "Publications");
254
			publicationField = new PublicationsRecordArea(this, "Publications produites");
230 255
		}
231 256

  
232 257
		if (BCCCC.doubleClickedRecord != null) { // load record informations
233
			System.out.println("Reloading viewAndEdit record... "+BCCCC.doubleClickedRecord);
258
			System.out.println("Reloading viewAndEdit record... "+BCCCC.doubleClickedRecord.uniq_id);
234 259
			Services.getMain().getRecord(BCCCC.doubleClickedRecord.uniq_id, new AsyncCallback<TerrainRecordAndRights>() {
235 260
				@Override
236 261
				public void onFailure(Throwable caught) {
......
245 270
						return;
246 271
					}
247 272
					record = result;
248
					//record.record.uniq_id = BCCCC.doubleClickedRecord.uniq_id;
249
					
250
					viewAndEditForm.setCanEdit(result.editable);
273

  
251 274
					validateVAEButton.setDisabled(!result.validable);
252 275
					validateVAEButton.setStartRow(false);
253 276
					validateVAEButton.setEndRow(false);
......
257 280
					saveVAEButton.setDisabled(!result.editable);
258 281
					saveVAEButton.setStartRow(false);
259 282
					saveVAEButton.setEndRow(false);
260
					
283
					viewVAEButton.setStartRow(false);
284
					viewVAEButton.setEndRow(false);
261 285
					addMember(viewAndEditForm);
262
					viewAndEditForm.setVisible(result.editable);
263 286

  
264
					nameField.setCanEdit(record.editable);
265 287
					nameField.setValue(record.record.name);
266
					projectField.setCanEdit(record.editable);
267 288
					projectField.setValue(record.record.project);
268
					descriptionField.setCanEdit(record.editable);
269 289
					descriptionField.setValue(record.record.short_description);
270
					typesField.setCanEdit(record.editable);
271
					typesField.setValues(record.record.types);
272
					dateField.setCanEdit(record.editable);
290

  
273 291
					dateField.setValue(record.record.date);
274
					numberOfParticipantsField.setCanEdit(record.editable);
275 292
					numberOfParticipantsField.setValue(record.record.numberOfParticipants);
276
					personsField.setCanEdit(record.editable);
277
					dispositifsField.setCanEdit(record.editable);
293

  
294
					typesField.setValues(record.record.types);
278 295
					dispositifsField.setValues(record.record.dispositifs);
279
					dataField.setCanEdit(record.editable);
280
					dataField.setDataValues(record.record.supports);
281
					documentationField.setCanEdit(record.editable);
296
					dataField.setValues(record.record.supports);
282 297
					documentationField.setValues(record.record.documentations);
283
					reportField.setCanEdit(record.editable);
284 298
					reportField.setValues(record.record.reports);
285
					publicationField.setCanEdit(record.editable);
286 299
					publicationField.setValues(record.record.publications);
287
					
300

  
288 301
					addMember(viewAndEditForm);
289 302
					addMember(nameField);
290 303
					addMember(projectField);
291 304
					addMember(descriptionField);
292 305
					addMember(dateField);
293 306
					addMember(numberOfParticipantsField);
307

  
294 308
					addMember(typesField);
295 309
					addMember(personsField);
296 310
					addMember(dispositifsField);
projets/BCCCC/src/org/ccc/bcccc/client/panels/SearchPanel.java (revision 7)
34 34
import com.smartgwt.client.util.SC;
35 35
import com.smartgwt.client.widgets.form.DynamicForm;
36 36
import com.smartgwt.client.widgets.form.fields.ButtonItem;
37
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
38
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
37 39
import com.smartgwt.client.widgets.form.fields.SelectItem;
38 40
import com.smartgwt.client.widgets.form.fields.SliderItem;
39 41
import com.smartgwt.client.widgets.form.fields.TextItem;
......
55 57
	
56 58
	/** The init search complex done. */
57 59
	boolean initSearchComplexDone = false;
60
	private CheckboxItem checkboxItem;
58 61
	
59 62
	/**
60 63
	 * Inits the.
......
68 71
		form.setHeight100();
69 72
		this.addMember(form);
70 73
		
74
		checkboxItem = new CheckboxItem(K.MATCHINGSTRATEGY);  
75
        checkboxItem.setTitle("Doit matcher tous les critères renseignés");  
76
        checkboxItem.setHeight(20); 
77
        
71 78
		TextItem wordsField = new TextItem(K.WORDS, "Recherche par mot");
72 79
		
73

  
74 80
		SelectItem types = new SelectItem(K.TYPES);
75 81
		types.setTitle("Terrain types");
76 82
		types.setMultiple(true);  
......
109 115
			@Override
110 116
			public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
111 117

  
118
				String matching_strategy = "ONE";
119
				if (checkboxItem.getValueAsBoolean()) matching_strategy = "ALL";
120
				
112 121
				String words_value = form.getValueAsString(K.WORDS);
113 122
				if (words_value == null) words_value = "";
114 123
				else words_value = words_value.trim();
......
142 151
				System.out.println("Updating records...");
143 152

  
144 153
				HashMap<String, String> critera = new HashMap<String, String>();
154
				critera.put(K.MATCHINGSTRATEGY, matching_strategy);
145 155
				critera.put(K.WORDS, words_value);
146 156
				critera.put(K.TYPES, types_value);
147 157
				critera.put(K.PROJECTS, projects_value);
......
168 178
			}
169 179
		});
170 180

  
171
		form.setItems(wordsField, types, projets, participants, dispositifs, supports, validate);
181
		form.setItems(checkboxItem, wordsField, types, projets, participants, dispositifs, supports, validate);
172 182
	}
173 183
}
projets/BCCCC/src/org/ccc/bcccc/client/panels/ViewPanel.java (revision 7)
20 20

  
21 21
import org.ccc.bcccc.client.BCCCC;
22 22
import org.ccc.bcccc.client.Services;
23
import org.ccc.bcccc.shared.K;
23 24
import org.ccc.bcccc.shared.TerrainRecordAndRights;
24 25

  
26
import com.google.gwt.user.client.History;
25 27
import com.google.gwt.user.client.rpc.AsyncCallback;
28
import com.smartgwt.client.types.Alignment;
26 29
import com.smartgwt.client.util.SC;
30
import com.smartgwt.client.widgets.ImgButton;
27 31
import com.smartgwt.client.widgets.Label;
32
import com.smartgwt.client.widgets.events.ClickEvent;
33
import com.smartgwt.client.widgets.events.ClickHandler;
28 34
import com.smartgwt.client.widgets.layout.VLayout;
29 35

  
30 36
// TODO: Auto-generated Javadoc
......
47 53
	/** The init view and edit done. */
48 54
	boolean initViewAndEditDone = false;
49 55
	Label l;
56
	ImgButton editImg;
57
	
50 58
	/**
51 59
	 * Inits the.
52 60
	 */
......
55 63
		if (!initViewAndEditDone) {
56 64
			l = new Label();
57 65
			l.setWidth100();
58
			l.setHeight100();
66
			l.setMargin(10);
67
			//l.setHeight100();
59 68
			l.setContents("Nothing to show...");
69
			
70
			
71
			editImg = new ImgButton();  
72
			editImg.setShowDown(false);  
73
			editImg.setShowRollOver(false);  
74
			editImg.setLayoutAlign(Alignment.CENTER);  
75
			editImg.setSrc("pencil.png");  
76
			editImg.setPrompt("Editer la fiche");  
77
			editImg.setHeight(16);  
78
			editImg.setWidth(16);  
79
			editImg.setVisible(false);
80
			editImg.addClickHandler(new ClickHandler() {  
81
				public void onClick(ClickEvent event) {
82
					History.newItem(K.EDITRECORD);
83
				}
84
			}); 
85
			this.addMember(editImg);
60 86
			this.addMember(l);
61
			
62 87
			initViewAndEditDone = true;
63 88
		}
64
		
89

  
65 90
		if (BCCCC.doubleClickedRecord != null) { // load record informations
66 91
			Services.getMain().getRecord(BCCCC.doubleClickedRecord.uniq_id, new AsyncCallback<TerrainRecordAndRights>() {
67 92
				@Override
......
73 98
				public void onSuccess(TerrainRecordAndRights result) {
74 99
					record = result;
75 100
					l.setContents(record.record.toHTML());
101
					editImg.setVisible(result.editable);
76 102
					System.out.println(record.record.toHTML());
77 103
				}
78 104
			});
projets/BCCCC/src/org/ccc/bcccc/client/areas/DateRecordArea.java (revision 7)
1
/*
2
 * Authors: Matthieu Decorde
3
 * 
4
 * COPYRIGHT 2015 ICAR - CCC
5
 * 
6
 * This software is free software: you can redistribute it 
7
 * and/or modify it under the terms of the GNU General Public
8
 * License as published by the Free Software Foundation,
9
 * either version 2 of the License, or (at your option) any
10
 * later version.
11
 * 
12
 * This software is distributed in the hope that it will be
13
 * useful, but WITHOUT ANY WARRANTY; without even the implied
14
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
 * PURPOSE. See the GNU General Public License for more
16
 * details.
17
 * 
18
 */
19
package org.ccc.bcccc.client.areas;
20

  
21
import java.util.Date;
22

  
23
import org.ccc.bcccc.client.panels.EditPanel;
24

  
25
import com.smartgwt.client.widgets.form.fields.DateItem;
26
import com.smartgwt.client.widgets.form.fields.FormItem;
27
import com.smartgwt.client.widgets.form.fields.PickerIcon;
28

  
29
// TODO: Auto-generated Javadoc
30
/**
31
 * The Class DateRecordArea.
32
 */
33
public class DateRecordArea extends StringRecordField {
34

  
35
	/** The field. */
36
	FormItem field;
37
	
38
	/**
39
	 * Instantiates a new date record area.
40
	 *
41
	 * @param panel the panel
42
	 * @param name the name
43
	 * @param multiple the multiple
44
	 * @param freeField the free field
45
	 * @param values the values
46
	 */
47
	public DateRecordArea(EditPanel panel, String name, boolean multiple, boolean freeField,
48
			String[] values) {
49
		super(panel, name, multiple, freeField, values);
50
	}
51
	
52
	/* (non-Javadoc)
53
	 * @see org.ccc.bcccc.client.areas.StringRecordField#createField()
54
	 */
55
	@Override
56
	protected FormItem createField() {
57
		String lname = name.toLowerCase().replace(" ", "");
58
		field = new DateItem(lname+""+no++);
59
		return field;
60
	}
61
	
62
	/* (non-Javadoc)
63
	 * @see org.ccc.bcccc.client.areas.StringRecordField#addDefaultPickers(com.smartgwt.client.widgets.form.fields.FormItem, com.smartgwt.client.widgets.form.fields.PickerIcon)
64
	 */
65
	protected void addDefaultPickers(FormItem field, PickerIcon editPicker) {
66
		
67
	}
68

  
69
	/**
70
	 * Sets the value.
71
	 *
72
	 * @param date the new value
73
	 */
74
	public void setValue(Date date) {
75
		if (items.size() > 0 ) {
76
			FormItem field = items.get(0);
77
			((DateItem)field).setValue(date);
78
		}
79
	}
80

  
81
	/**
82
	 * Gets the date.
83
	 *
84
	 * @return the date
85
	 */
86
	public Date getDate() {
87
		return ((DateItem)field).getValueAsDate();
88
	}
89
}
projets/BCCCC/src/org/ccc/bcccc/client/areas/IntegerRecordArea.java (revision 7)
1
/*
2
 * Authors: Matthieu Decorde
3
 * 
4
 * COPYRIGHT 2015 ICAR - CCC
5
 * 
6
 * This software is free software: you can redistribute it 
7
 * and/or modify it under the terms of the GNU General Public
8
 * License as published by the Free Software Foundation,
9
 * either version 2 of the License, or (at your option) any
10
 * later version.
11
 * 
12
 * This software is distributed in the hope that it will be
13
 * useful, but WITHOUT ANY WARRANTY; without even the implied
14
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
 * PURPOSE. See the GNU General Public License for more
16
 * details.
17
 * 
18
 */
19
package org.ccc.bcccc.client.areas;
20

  
21
import org.ccc.bcccc.client.panels.EditPanel;
22

  
23
import com.smartgwt.client.types.TitleOrientation;
24
import com.smartgwt.client.widgets.form.DynamicForm;
25
import com.smartgwt.client.widgets.form.fields.SpinnerItem;
26
import com.smartgwt.client.widgets.layout.HLayout;
27

  
28
// TODO: Auto-generated Javadoc
29
/**
30
 * The Class DoubleStringRecordArea.
31
 */
32
public class IntegerRecordArea extends HLayout {
33

  
34
	/** The name. */
35
	String name;
36

  
37
	/** The panel. */
38
	protected EditPanel panel;
39

  
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff