Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java @ 3501:0de0ef04bcdc
Delete empty project after closing CollectionView (#785).
flys-client/trunk@5234 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Wed, 22 Aug 2012 12:29:33 +0000 |
parents | 60bf22a14ed8 |
children | 718e5c6c992e |
comparison
equal
deleted
inserted
replaced
3500:def13f23bb27 | 3501:0de0ef04bcdc |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | 2 |
3 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
4 | |
5 import com.google.gwt.i18n.client.DateTimeFormat; | 4 import com.google.gwt.i18n.client.DateTimeFormat; |
6 | |
7 import com.google.gwt.user.client.Timer; | 5 import com.google.gwt.user.client.Timer; |
8 | |
9 import com.google.gwt.user.client.rpc.AsyncCallback; | 6 import com.google.gwt.user.client.rpc.AsyncCallback; |
10 | |
11 import com.smartgwt.client.types.Alignment; | 7 import com.smartgwt.client.types.Alignment; |
12 import com.smartgwt.client.types.ListGridEditEvent; | 8 import com.smartgwt.client.types.ListGridEditEvent; |
13 import com.smartgwt.client.types.ListGridFieldType; | 9 import com.smartgwt.client.types.ListGridFieldType; |
14 import com.smartgwt.client.types.SelectionStyle; | 10 import com.smartgwt.client.types.SelectionStyle; |
15 import com.smartgwt.client.types.SortArrow; | 11 import com.smartgwt.client.types.SortArrow; |
16 import com.smartgwt.client.types.SortDirection; | 12 import com.smartgwt.client.types.SortDirection; |
17 import com.smartgwt.client.types.VerticalAlignment; | 13 import com.smartgwt.client.types.VerticalAlignment; |
18 | |
19 import com.smartgwt.client.util.BooleanCallback; | 14 import com.smartgwt.client.util.BooleanCallback; |
20 import com.smartgwt.client.util.SC; | 15 import com.smartgwt.client.util.SC; |
21 | |
22 import com.smartgwt.client.widgets.Canvas; | 16 import com.smartgwt.client.widgets.Canvas; |
23 import com.smartgwt.client.widgets.Label; | 17 import com.smartgwt.client.widgets.Label; |
24 | |
25 import com.smartgwt.client.widgets.grid.CellFormatter; | 18 import com.smartgwt.client.widgets.grid.CellFormatter; |
26 import com.smartgwt.client.widgets.grid.HoverCustomizer; | 19 import com.smartgwt.client.widgets.grid.HoverCustomizer; |
27 import com.smartgwt.client.widgets.grid.ListGrid; | 20 import com.smartgwt.client.widgets.grid.ListGrid; |
28 import com.smartgwt.client.widgets.grid.ListGridField; | 21 import com.smartgwt.client.widgets.grid.ListGridField; |
29 import com.smartgwt.client.widgets.grid.ListGridRecord; | 22 import com.smartgwt.client.widgets.grid.ListGridRecord; |
30 | |
31 import com.smartgwt.client.widgets.grid.events.CellClickEvent; | 23 import com.smartgwt.client.widgets.grid.events.CellClickEvent; |
32 import com.smartgwt.client.widgets.grid.events.CellClickHandler; | 24 import com.smartgwt.client.widgets.grid.events.CellClickHandler; |
33 import com.smartgwt.client.widgets.grid.events.CellDoubleClickEvent; | 25 import com.smartgwt.client.widgets.grid.events.CellDoubleClickEvent; |
34 import com.smartgwt.client.widgets.grid.events.CellDoubleClickHandler; | 26 import com.smartgwt.client.widgets.grid.events.CellDoubleClickHandler; |
35 import com.smartgwt.client.widgets.grid.events.EditCompleteEvent; | 27 import com.smartgwt.client.widgets.grid.events.EditCompleteEvent; |
36 import com.smartgwt.client.widgets.grid.events.EditCompleteHandler; | 28 import com.smartgwt.client.widgets.grid.events.EditCompleteHandler; |
37 import com.smartgwt.client.widgets.grid.events.HeaderDoubleClickEvent; | 29 import com.smartgwt.client.widgets.grid.events.HeaderDoubleClickEvent; |
38 import com.smartgwt.client.widgets.grid.events.HeaderDoubleClickHandler; | 30 import com.smartgwt.client.widgets.grid.events.HeaderDoubleClickHandler; |
39 import com.smartgwt.client.widgets.grid.events.RowContextClickEvent; | 31 import com.smartgwt.client.widgets.grid.events.RowContextClickEvent; |
40 import com.smartgwt.client.widgets.grid.events.RowContextClickHandler; | 32 import com.smartgwt.client.widgets.grid.events.RowContextClickHandler; |
41 | |
42 import com.smartgwt.client.widgets.layout.VLayout; | 33 import com.smartgwt.client.widgets.layout.VLayout; |
43 | |
44 import com.smartgwt.client.widgets.menu.Menu; | 34 import com.smartgwt.client.widgets.menu.Menu; |
45 import com.smartgwt.client.widgets.menu.MenuItem; | 35 import com.smartgwt.client.widgets.menu.MenuItem; |
46 import com.smartgwt.client.widgets.menu.MenuItemSeparator; | 36 import com.smartgwt.client.widgets.menu.MenuItemSeparator; |
47 | |
48 import com.smartgwt.client.widgets.menu.events.ClickHandler; | 37 import com.smartgwt.client.widgets.menu.events.ClickHandler; |
49 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; | 38 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; |
50 | 39 |
51 import de.intevation.flys.client.client.Config; | 40 import de.intevation.flys.client.client.Config; |
52 import de.intevation.flys.client.client.FLYS; | 41 import de.intevation.flys.client.client.FLYS; |
53 import de.intevation.flys.client.client.FLYSConstants; | 42 import de.intevation.flys.client.client.FLYSConstants; |
54 | |
55 import de.intevation.flys.client.client.event.CollectionChangeEvent; | 43 import de.intevation.flys.client.client.event.CollectionChangeEvent; |
56 import de.intevation.flys.client.client.event.CollectionChangeHandler; | 44 import de.intevation.flys.client.client.event.CollectionChangeHandler; |
57 import de.intevation.flys.client.client.event.FilterHandler; | 45 import de.intevation.flys.client.client.event.FilterHandler; |
58 import de.intevation.flys.client.client.event.RangeFilterEvent; | 46 import de.intevation.flys.client.client.event.RangeFilterEvent; |
59 import de.intevation.flys.client.client.event.StringFilterEvent; | 47 import de.intevation.flys.client.client.event.StringFilterEvent; |
60 | |
61 import de.intevation.flys.client.client.services.AddArtifactService; | 48 import de.intevation.flys.client.client.services.AddArtifactService; |
62 import de.intevation.flys.client.client.services.AddArtifactServiceAsync; | 49 import de.intevation.flys.client.client.services.AddArtifactServiceAsync; |
63 import de.intevation.flys.client.client.services.ArtifactService; | 50 import de.intevation.flys.client.client.services.ArtifactService; |
64 import de.intevation.flys.client.client.services.ArtifactServiceAsync; | 51 import de.intevation.flys.client.client.services.ArtifactServiceAsync; |
65 import de.intevation.flys.client.client.services.CreateCollectionService; | 52 import de.intevation.flys.client.client.services.CreateCollectionService; |
74 import de.intevation.flys.client.client.services.SetCollectionNameServiceAsync; | 61 import de.intevation.flys.client.client.services.SetCollectionNameServiceAsync; |
75 import de.intevation.flys.client.client.services.SetCollectionTTLService; | 62 import de.intevation.flys.client.client.services.SetCollectionTTLService; |
76 import de.intevation.flys.client.client.services.SetCollectionTTLServiceAsync; | 63 import de.intevation.flys.client.client.services.SetCollectionTTLServiceAsync; |
77 import de.intevation.flys.client.client.services.UserCollectionsService; | 64 import de.intevation.flys.client.client.services.UserCollectionsService; |
78 import de.intevation.flys.client.client.services.UserCollectionsServiceAsync; | 65 import de.intevation.flys.client.client.services.UserCollectionsServiceAsync; |
79 | |
80 import de.intevation.flys.client.shared.model.Artifact; | 66 import de.intevation.flys.client.shared.model.Artifact; |
81 import de.intevation.flys.client.shared.model.Collection; | 67 import de.intevation.flys.client.shared.model.Collection; |
82 import de.intevation.flys.client.shared.model.CollectionItem; | 68 import de.intevation.flys.client.shared.model.CollectionItem; |
83 import de.intevation.flys.client.shared.model.CollectionRecord; | 69 import de.intevation.flys.client.shared.model.CollectionRecord; |
84 import de.intevation.flys.client.shared.model.Recommendation; | 70 import de.intevation.flys.client.shared.model.Recommendation; |
117 public static final String COLUMN_TITLE_WIDTH = "*"; | 103 public static final String COLUMN_TITLE_WIDTH = "*"; |
118 | 104 |
119 public static final String COLUMN_FAVORITE_WIDTH = "75px"; | 105 public static final String COLUMN_FAVORITE_WIDTH = "75px"; |
120 | 106 |
121 /** The interface that provides i18n messages. */ | 107 /** The interface that provides i18n messages. */ |
122 private FLYSConstants messages = GWT.create(FLYSConstants.class); | 108 private final FLYSConstants messages = GWT.create(FLYSConstants.class); |
123 | 109 |
124 /** The UserService used to retrieve information about the current user. */ | 110 /** The UserService used to retrieve information about the current user. */ |
125 protected UserCollectionsServiceAsync userCollectionsService = | 111 protected UserCollectionsServiceAsync userCollectionsService = |
126 GWT.create(UserCollectionsService.class); | 112 GWT.create(UserCollectionsService.class); |
127 | 113 |
187 */ | 173 */ |
188 public ProjectList(FLYS flys, User user) { | 174 public ProjectList(FLYS flys, User user) { |
189 this.flys = flys; | 175 this.flys = flys; |
190 this.user = user; | 176 this.user = user; |
191 | 177 |
192 filteredCollections = new ArrayList(); | 178 filteredCollections = new ArrayList<Collection>(); |
193 collections = new ArrayList(); | 179 collections = new ArrayList<Collection>(); |
194 grid = new ListGrid(); | 180 grid = new ListGrid(); |
195 initGrid(); | 181 initGrid(); |
196 init(); | 182 init(); |
197 initTimer(); | 183 initTimer(); |
198 | 184 |
223 ListGridField fav = buildFavoriteField(); | 209 ListGridField fav = buildFavoriteField(); |
224 | 210 |
225 grid.setFields(date, name, fav); | 211 grid.setFields(date, name, fav); |
226 | 212 |
227 grid.addHeaderDoubleClickHandler(new HeaderDoubleClickHandler() { | 213 grid.addHeaderDoubleClickHandler(new HeaderDoubleClickHandler() { |
214 @Override | |
228 public void onHeaderDoubleClick(HeaderDoubleClickEvent event) { | 215 public void onHeaderDoubleClick(HeaderDoubleClickEvent event) { |
229 // Cancel the event. | 216 // Cancel the event. |
230 return; | 217 return; |
231 } | 218 } |
232 }); | 219 }); |
233 | 220 |
234 // Add a handler to set / unset the favorite state of a project. | 221 // Add a handler to set / unset the favorite state of a project. |
235 grid.addCellClickHandler(new CellClickHandler() { | 222 grid.addCellClickHandler(new CellClickHandler() { |
223 @Override | |
236 public void onCellClick(CellClickEvent event) { | 224 public void onCellClick(CellClickEvent event) { |
237 if (event.getColNum() != 2) { | 225 if (event.getColNum() != 2) { |
238 return; | 226 return; |
239 } | 227 } |
240 | 228 |
246 } | 234 } |
247 }); | 235 }); |
248 | 236 |
249 // Add a handler to open a project. | 237 // Add a handler to open a project. |
250 grid.addCellDoubleClickHandler(new CellDoubleClickHandler() { | 238 grid.addCellDoubleClickHandler(new CellDoubleClickHandler() { |
239 @Override | |
251 public void onCellDoubleClick(CellDoubleClickEvent e) { | 240 public void onCellDoubleClick(CellDoubleClickEvent e) { |
252 CollectionRecord record = (CollectionRecord) e.getRecord(); | 241 CollectionRecord record = (CollectionRecord) e.getRecord(); |
253 String uuid = record != null | 242 String uuid = record != null |
254 ? record.getCollection().identifier() | 243 ? record.getCollection().identifier() |
255 : ""; | 244 : ""; |
257 } | 246 } |
258 }); | 247 }); |
259 | 248 |
260 // Add a handler to open a context menu. | 249 // Add a handler to open a context menu. |
261 grid.addRowContextClickHandler(new RowContextClickHandler() { | 250 grid.addRowContextClickHandler(new RowContextClickHandler() { |
251 @Override | |
262 public void onRowContextClick(RowContextClickEvent event) { | 252 public void onRowContextClick(RowContextClickEvent event) { |
263 CollectionRecord record = (CollectionRecord) event.getRecord(); | 253 CollectionRecord record = (CollectionRecord) event.getRecord(); |
264 | 254 |
265 Menu menu = createContextMenu(record); | 255 Menu menu = createContextMenu(record); |
266 grid.setContextMenu(menu); | 256 grid.setContextMenu(menu); |
311 protected Menu createContextMenu(final CollectionRecord record) { | 301 protected Menu createContextMenu(final CollectionRecord record) { |
312 Menu menu = new Menu(); | 302 Menu menu = new Menu(); |
313 | 303 |
314 MenuItem open = new MenuItem(messages.open_project()); | 304 MenuItem open = new MenuItem(messages.open_project()); |
315 open.addClickHandler(new ClickHandler() { | 305 open.addClickHandler(new ClickHandler() { |
306 @Override | |
316 public void onClick(MenuItemClickEvent evt) { | 307 public void onClick(MenuItemClickEvent evt) { |
317 getFlys().openProject(record.getCollection().identifier()); | 308 getFlys().openProject(record.getCollection().identifier()); |
318 } | 309 } |
319 }); | 310 }); |
320 | 311 |
321 MenuItem del = new MenuItem(messages.delete_project()); | 312 MenuItem del = new MenuItem(messages.delete_project()); |
322 del.addClickHandler(new ClickHandler() { | 313 del.addClickHandler(new ClickHandler() { |
314 @Override | |
323 public void onClick(MenuItemClickEvent evt) { | 315 public void onClick(MenuItemClickEvent evt) { |
324 SC.ask(messages.really_delete(), new BooleanCallback() { | 316 SC.ask(messages.really_delete(), new BooleanCallback() { |
317 @Override | |
325 public void execute(Boolean value) { | 318 public void execute(Boolean value) { |
326 if (value) { | 319 if (value) { |
327 deleteCollection(record.getCollection()); | 320 deleteCollection(record.getCollection()); |
328 } | 321 } |
329 } | 322 } |
331 } | 324 } |
332 }); | 325 }); |
333 | 326 |
334 MenuItem rename = new MenuItem(messages.rename_project()); | 327 MenuItem rename = new MenuItem(messages.rename_project()); |
335 rename.addClickHandler(new ClickHandler() { | 328 rename.addClickHandler(new ClickHandler() { |
329 @Override | |
336 public void onClick(MenuItemClickEvent evt) { | 330 public void onClick(MenuItemClickEvent evt) { |
337 int row = grid.getRecordIndex(record); | 331 int row = grid.getRecordIndex(record); |
338 grid.startEditing(row, 1, false); | 332 grid.startEditing(row, 1, false); |
339 } | 333 } |
340 }); | 334 }); |
341 | 335 |
342 MenuItem clone = new MenuItem(messages.clone_project()); | 336 MenuItem clone = new MenuItem(messages.clone_project()); |
343 clone.addClickHandler(new ClickHandler() { | 337 clone.addClickHandler(new ClickHandler() { |
338 @Override | |
344 public void onClick(MenuItemClickEvent evt) { | 339 public void onClick(MenuItemClickEvent evt) { |
345 cloneProject(record.getCollection()); | 340 cloneProject(record.getCollection()); |
346 } | 341 } |
347 }); | 342 }); |
348 | 343 |
393 addMember(gridWrapper); | 388 addMember(gridWrapper); |
394 addMember(filter); | 389 addMember(filter); |
395 } | 390 } |
396 | 391 |
397 | 392 |
393 @Override | |
398 public void onFilterCriteriaChanged(StringFilterEvent event) { | 394 public void onFilterCriteriaChanged(StringFilterEvent event) { |
399 String search = event.getFilter(); | 395 String search = event.getFilter(); |
400 if (search != null && search.length() > 0) { | 396 if (search != null && search.length() > 0) { |
401 // Filter the records. | 397 // Filter the records. |
402 filterCollections(search); | 398 filterCollections(search); |
409 updateGrid(); | 405 updateGrid(); |
410 } | 406 } |
411 } | 407 } |
412 | 408 |
413 | 409 |
410 @Override | |
414 public void onFilterCriteriaChanged(RangeFilterEvent event) { | 411 public void onFilterCriteriaChanged(RangeFilterEvent event) { |
415 //Empty. No Ranges to filter. | 412 //Empty. No Ranges to filter. |
416 } | 413 } |
417 | 414 |
418 | 415 |
416 @Override | |
419 public void onCollectionChange(CollectionChangeEvent event) { | 417 public void onCollectionChange(CollectionChangeEvent event) { |
420 if (event.getOldValue() == null) { | 418 if (event.getOldValue() == null) { |
421 updateUserCollections(); | 419 updateUserCollections(); |
422 } | 420 } |
423 } | 421 } |
424 | 422 |
425 | 423 |
424 @Override | |
426 public void onEditComplete(EditCompleteEvent event) { | 425 public void onEditComplete(EditCompleteEvent event) { |
427 if (event.getColNum() != 1) { | 426 if (event.getColNum() != 1) { |
428 return; | 427 return; |
429 } | 428 } |
430 | 429 |
431 int row = event.getRowNum(); | 430 int row = event.getRowNum(); |
432 | 431 |
433 CollectionRecord r = (CollectionRecord) grid.getRecord(row); | 432 CollectionRecord r = (CollectionRecord) grid.getRecord(row); |
434 Collection c = r.getCollection(); | 433 Collection c = r.getCollection(); |
435 | 434 |
436 Map newValues = event.getNewValues(); | 435 Map<?, ?> newValues = event.getNewValues(); |
437 String name = (String) newValues.get("name"); | 436 String name = (String) newValues.get("name"); |
438 | 437 |
439 int maxLength = getMaxNameLength(); | 438 int maxLength = getMaxNameLength(); |
440 int length = name != null ? name.length() : 0; | 439 int length = name != null ? name.length() : 0; |
441 | 440 |
469 | 468 |
470 GWT.log("Update Collection name: " + c.identifier()); | 469 GWT.log("Update Collection name: " + c.identifier()); |
471 GWT.log("=> New name = " + c.getName()); | 470 GWT.log("=> New name = " + c.getName()); |
472 | 471 |
473 nameService.setName(c, new AsyncCallback<Void>(){ | 472 nameService.setName(c, new AsyncCallback<Void>(){ |
473 @Override | |
474 public void onFailure(Throwable caught) { | 474 public void onFailure(Throwable caught) { |
475 String msg = caught.getMessage(); | 475 String msg = caught.getMessage(); |
476 | 476 |
477 try { | 477 try { |
478 SC.warn(messages.getString(msg)); | 478 SC.warn(messages.getString(msg)); |
480 catch (MissingResourceException mre) { | 480 catch (MissingResourceException mre) { |
481 SC.warn(msg); | 481 SC.warn(msg); |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 @Override | |
485 public void onSuccess(Void v) { | 486 public void onSuccess(Void v) { |
486 updateUserCollections(); | 487 updateUserCollections(); |
487 if(flys.getWorkspace().hasView(c.identifier())) { | 488 if(flys.getWorkspace().hasView(c.identifier())) { |
488 flys.getWorkspace().updateTitle(c.identifier(), c.getName()); | 489 flys.getWorkspace().updateTitle(c.identifier(), c.getName()); |
489 } | 490 } |
505 | 506 |
506 GWT.log("Update Collection TTL: " + c.identifier()); | 507 GWT.log("Update Collection TTL: " + c.identifier()); |
507 GWT.log("=> New ttl = " + c.getTTL()); | 508 GWT.log("=> New ttl = " + c.getTTL()); |
508 | 509 |
509 ttlService.setTTL(c, new AsyncCallback<Void>() { | 510 ttlService.setTTL(c, new AsyncCallback<Void>() { |
511 @Override | |
510 public void onFailure(Throwable caught) { | 512 public void onFailure(Throwable caught) { |
511 String msg = caught.getMessage(); | 513 String msg = caught.getMessage(); |
512 | 514 |
513 try { | 515 try { |
514 SC.warn(messages.getString(msg)); | 516 SC.warn(messages.getString(msg)); |
516 catch (MissingResourceException mre) { | 518 catch (MissingResourceException mre) { |
517 SC.warn(msg); | 519 SC.warn(msg); |
518 } | 520 } |
519 } | 521 } |
520 | 522 |
523 @Override | |
521 public void onSuccess(Void v) { | 524 public void onSuccess(Void v) { |
522 updateUserCollections(); | 525 updateUserCollections(); |
523 } | 526 } |
524 }); | 527 }); |
525 } | 528 } |
528 /** | 531 /** |
529 * Delete the collection <i>c</i>. | 532 * Delete the collection <i>c</i>. |
530 * | 533 * |
531 * @param c The Collection that should be deleted. | 534 * @param c The Collection that should be deleted. |
532 */ | 535 */ |
533 protected void deleteCollection(final Collection c) { | 536 public void deleteCollection(final Collection c) { |
534 if (c == null) { | 537 if (c == null) { |
535 return; | 538 return; |
536 } | 539 } |
537 | 540 |
538 GWT.log("Delete Collection: " + c.identifier()); | 541 GWT.log("Delete Collection: " + c.identifier()); |
539 | 542 |
540 deleteService.delete(c, new AsyncCallback<Void>(){ | 543 deleteService.delete(c, new AsyncCallback<Void>(){ |
544 @Override | |
541 public void onFailure(Throwable caught) { | 545 public void onFailure(Throwable caught) { |
542 String msg = caught.getMessage(); | 546 String msg = caught.getMessage(); |
543 | 547 |
544 try { | 548 try { |
545 SC.warn(messages.getString(msg)); | 549 SC.warn(messages.getString(msg)); |
547 catch (MissingResourceException mre) { | 551 catch (MissingResourceException mre) { |
548 SC.warn(msg); | 552 SC.warn(msg); |
549 } | 553 } |
550 } | 554 } |
551 | 555 |
556 @Override | |
552 public void onSuccess(Void v) { | 557 public void onSuccess(Void v) { |
553 flys.getWorkspace().destroyProject(c.identifier()); | 558 flys.getWorkspace().destroyProject(c.identifier()); |
554 updateUserCollections(); | 559 updateUserCollections(); |
555 } | 560 } |
556 }); | 561 }); |
563 Config config = Config.getInstance(); | 568 Config config = Config.getInstance(); |
564 String locale = config.getLocale(); | 569 String locale = config.getLocale(); |
565 | 570 |
566 userCollectionsService.getUserCollections(locale, user.identifier(), | 571 userCollectionsService.getUserCollections(locale, user.identifier(), |
567 new AsyncCallback<Collection[]>() { | 572 new AsyncCallback<Collection[]>() { |
573 @Override | |
568 public void onFailure(Throwable caught) { | 574 public void onFailure(Throwable caught) { |
569 String msg = caught.getMessage(); | 575 String msg = caught.getMessage(); |
570 | 576 |
571 try { | 577 try { |
572 SC.warn(messages.getString(msg)); | 578 SC.warn(messages.getString(msg)); |
574 catch (MissingResourceException mre) { | 580 catch (MissingResourceException mre) { |
575 SC.warn(msg); | 581 SC.warn(msg); |
576 } | 582 } |
577 } | 583 } |
578 | 584 |
585 @Override | |
579 public void onSuccess(Collection[] collections) { | 586 public void onSuccess(Collection[] collections) { |
580 int num = collections != null ? collections.length : 0; | 587 int num = collections != null ? collections.length : 0; |
581 | 588 |
582 GWT.log("Received " + num + " user collections."); | 589 GWT.log("Received " + num + " user collections."); |
583 | 590 |
690 | 697 |
691 date.setType(ListGridFieldType.DATE); | 698 date.setType(ListGridFieldType.DATE); |
692 date.setCanEdit(false); | 699 date.setCanEdit(false); |
693 | 700 |
694 date.setCellFormatter(new CellFormatter() { | 701 date.setCellFormatter(new CellFormatter() { |
702 @Override | |
695 public String format(Object value, ListGridRecord rec, int r, int c) { | 703 public String format(Object value, ListGridRecord rec, int r, int c) { |
696 if (value == null) { | 704 if (value == null) { |
697 return null; | 705 return null; |
698 } | 706 } |
699 | 707 |
721 "name", messages.projectlist_title()); | 729 "name", messages.projectlist_title()); |
722 | 730 |
723 name.setType(ListGridFieldType.TEXT); | 731 name.setType(ListGridFieldType.TEXT); |
724 name.setShowHover(true); | 732 name.setShowHover(true); |
725 name.setHoverCustomizer(new HoverCustomizer() { | 733 name.setHoverCustomizer(new HoverCustomizer() { |
734 @Override | |
726 public String hoverHTML( | 735 public String hoverHTML( |
727 Object value, | 736 Object value, |
728 ListGridRecord record, | 737 ListGridRecord record, |
729 int row, | 738 int row, |
730 int col) | 739 int col) |
769 | 778 |
770 cloneCollection = c; | 779 cloneCollection = c; |
771 | 780 |
772 describeCollectionService.describe(c.identifier(), locale, | 781 describeCollectionService.describe(c.identifier(), locale, |
773 new AsyncCallback<Collection>() { | 782 new AsyncCallback<Collection>() { |
783 @Override | |
774 public void onFailure(Throwable caught) { | 784 public void onFailure(Throwable caught) { |
775 GWT.log("Could not DESCRIBE collection."); | 785 GWT.log("Could not DESCRIBE collection."); |
776 SC.warn(messages.getString(caught.getMessage())); | 786 SC.warn(messages.getString(caught.getMessage())); |
777 } | 787 } |
778 | 788 |
779 | 789 |
790 @Override | |
780 public void onSuccess(Collection newCollection) { | 791 public void onSuccess(Collection newCollection) { |
781 GWT.log("Successfully DESCRIBED collection."); | 792 GWT.log("Successfully DESCRIBED collection."); |
782 String uuid = getMasterArtifact(newCollection); | 793 String uuid = getMasterArtifact(newCollection); |
783 cloneArtifact(uuid, newCollection); | 794 cloneArtifact(uuid, newCollection); |
784 } | 795 } |
806 | 817 |
807 String factory = recommendation.getFactory(); | 818 String factory = recommendation.getFactory(); |
808 createArtifactService.create( | 819 createArtifactService.create( |
809 locale, factory, recommendation, | 820 locale, factory, recommendation, |
810 new AsyncCallback<Artifact>() { | 821 new AsyncCallback<Artifact>() { |
822 @Override | |
811 public void onFailure(Throwable caught) { | 823 public void onFailure(Throwable caught) { |
812 GWT.log("Error loading recommendations: " + | 824 GWT.log("Error loading recommendations: " + |
813 caught.getMessage()); | 825 caught.getMessage()); |
814 } | 826 } |
815 | 827 |
828 @Override | |
816 public void onSuccess(Artifact artifact) { | 829 public void onSuccess(Artifact artifact) { |
817 GWT.log("Created new artifact: " + artifact.getUuid()); | 830 GWT.log("Created new artifact: " + artifact.getUuid()); |
818 createCollection(artifact); | 831 createCollection(artifact); |
819 } | 832 } |
820 } | 833 } |
834 getArtifactService.getArtifact( | 847 getArtifactService.getArtifact( |
835 locale, | 848 locale, |
836 master.identifier(), | 849 master.identifier(), |
837 master.hash(), | 850 master.hash(), |
838 new AsyncCallback<Artifact>() { | 851 new AsyncCallback<Artifact>() { |
852 @Override | |
839 public void onFailure(Throwable caught) { | 853 public void onFailure(Throwable caught) { |
840 SC.warn(MSG.getString(caught.getMessage())); | 854 SC.warn(MSG.getString(caught.getMessage())); |
841 } | 855 } |
842 | 856 |
857 @Override | |
843 public void onSuccess(Artifact artifact) { | 858 public void onSuccess(Artifact artifact) { |
844 cloneArtifact(uuid, artifact, locale); | 859 cloneArtifact(uuid, artifact, locale); |
845 } | 860 } |
846 }); | 861 }); |
847 } | 862 } |
854 | 869 |
855 createCollectionService.create( | 870 createCollectionService.create( |
856 locale, | 871 locale, |
857 ownerid, | 872 ownerid, |
858 new AsyncCallback<Collection>() { | 873 new AsyncCallback<Collection>() { |
874 @Override | |
859 public void onFailure(Throwable caught) { | 875 public void onFailure(Throwable caught) { |
860 GWT.log("Could not create the new collection."); | 876 GWT.log("Could not create the new collection."); |
861 SC.warn(messages.getString(caught.getMessage())); | 877 SC.warn(messages.getString(caught.getMessage())); |
862 } | 878 } |
863 | 879 |
880 @Override | |
864 public void onSuccess(Collection collection) { | 881 public void onSuccess(Collection collection) { |
865 GWT.log("Successfully created a new collection."); | 882 GWT.log("Successfully created a new collection."); |
866 addArtifactToCollection(artifact, collection); | 883 addArtifactToCollection(artifact, collection); |
867 } | 884 } |
868 } | 885 } |
875 final String locale = config.getLocale(); | 892 final String locale = config.getLocale(); |
876 | 893 |
877 addArtifactService.add( | 894 addArtifactService.add( |
878 c, a, locale, | 895 c, a, locale, |
879 new AsyncCallback<Collection>() { | 896 new AsyncCallback<Collection>() { |
897 @Override | |
880 public void onFailure(Throwable caught) { | 898 public void onFailure(Throwable caught) { |
881 GWT.log("An error occured while adding artifact."); | 899 GWT.log("An error occured while adding artifact."); |
882 SC.warn(messages.getString(caught.getMessage())); | 900 SC.warn(messages.getString(caught.getMessage())); |
883 } | 901 } |
884 | 902 |
903 @Override | |
885 public void onSuccess(Collection newColl) { | 904 public void onSuccess(Collection newColl) { |
886 String name = cloneCollection.getName(); | 905 String name = cloneCollection.getName(); |
887 if(name == null || name.equals("")) { | 906 if(name == null || name.equals("")) { |
888 name = cloneCollection.identifier(); | 907 name = cloneCollection.identifier(); |
889 } | 908 } |