コード例 #1
0
 private synchronized void reload() {
   if (!initialized) {
     executorService.submit(
         () -> {
           if (!super.getChildren().isEmpty()) {
             Platform.runLater(super.getChildren()::clear);
           }
           List<ShareNotificationMessage> removedShares = new LinkedList<>();
           for (ShareNotificationMessage message : notifications.getNotifications()) {
             try {
               final TreeItem<BoxObject> item = itemFromNotification(message);
               Platform.runLater(() -> super.getChildren().add(item));
             } catch (QblStorageNotFound e) {
               removedShares.add(message);
             } catch (Exception e) {
               logger.error("failed to load FM", e);
             }
           }
           for (ShareNotificationMessage message : removedShares) {
             notifications.remove(message);
           }
         });
     initialized = true;
   }
 }
コード例 #2
0
  public VirtualShareTreeItem(
      SharingService sharingService,
      AuthenticatedDownloader readBackend,
      ShareNotifications notifications,
      BoxObject value,
      Node graphic) {
    super(value, graphic);
    this.notifications = notifications;
    this.readBackend = readBackend;
    this.sharingService = sharingService;

    notifications.addObserver(
        (o, arg) ->
            executorService.submit(
                () -> {
                  initialized = false;
                  this.reload();
                }));
  }