comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java @ 613:471ca61b83b5

#165 Set the max length of project names to 50 characters. flys-client/trunk@2228 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 24 Jun 2011 11:19:35 +0000
parents ee40f86dd009
children e14dc5fed6bb
comparison
equal deleted inserted replaced
612:e59f2569558e 613:471ca61b83b5
74 public static final int MIN_UPDATE_INTERVAL = 5000; 74 public static final int MIN_UPDATE_INTERVAL = 5000;
75 75
76 /** The initial width of this panel.*/ 76 /** The initial width of this panel.*/
77 public static final int MIN_WIDTH = 300; 77 public static final int MIN_WIDTH = 300;
78 78
79 /** The max length for new project names.*/
80 public static final int MAX_NAME_LENGTH = 50;
81
79 public static final String COLUMN_DATE_WIDTH = "100px"; 82 public static final String COLUMN_DATE_WIDTH = "100px";
80 83
81 public static final String COLUMN_TITLE_WIDTH = "*"; 84 public static final String COLUMN_TITLE_WIDTH = "*";
82 85
83 public static final String COLUMN_FAVORITE_WIDTH = "75px"; 86 public static final String COLUMN_FAVORITE_WIDTH = "75px";
319 Collection c = r.getCollection(); 322 Collection c = r.getCollection();
320 323
321 Map newValues = event.getNewValues(); 324 Map newValues = event.getNewValues();
322 String name = (String) newValues.get("name"); 325 String name = (String) newValues.get("name");
323 326
327 int maxLength = getMaxNameLength();
328 int length = name != null ? name.length() : 0;
329
330 if (length <= 0 || length > maxLength) {
331 String msg = messages.project_name_too_long();
332 msg = msg.replace("$LEN", String.valueOf(maxLength));
333 SC.warn(msg);
334
335 ListGridRecord[] rs = grid.getRecords();
336 rs[row] = (ListGridRecord) event.getOldRecord();
337 grid.setRecords(rs);
338
339 return;
340 }
341
324 c.setName(name); 342 c.setName(name);
325 updateCollectionName(c); 343 updateCollectionName(c);
326 } 344 }
327 345
328 346
476 } 494 }
477 495
478 for (Collection c: collections) { 496 for (Collection c: collections) {
479 grid.addData(new CollectionRecord(c)); 497 grid.addData(new CollectionRecord(c));
480 } 498 }
499 }
500
501
502 public int getMaxNameLength() {
503 return MAX_NAME_LENGTH;
481 } 504 }
482 505
483 506
484 /** 507 /**
485 * Builds the field in the grid that displays the creation time of a 508 * Builds the field in the grid that displays the creation time of a

http://dive4elements.wald.intevation.org