Java 类javafx.collections.MapChangeListener 实例源码

项目:worldheatmap    文件:World.java   
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
项目:charts    文件:World.java   
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
项目:Paradinc-FX    文件:World.java   
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
项目:worldfx    文件:World.java   
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
项目:leakdetectorFX    文件:LeakDetector.java   
public LeakDetector(Scene... scenes) {
    registerListenerOnSceneRoot(scenes[0]);

    map.addListener(((MapChangeListener<WeakRef<Node>, TreeItem<WeakRef<Node>>>) c -> {
      if (c.wasAdded()) {
          // add TreeItem to root if the node has no parent (else append to TreeItem of parent) 
          if(getParent(c.getKey()) == null) {
              appendTreeItemToRoot(c.getValueAdded());
          } else {
              addParentOfNode(c.getKey(), c.getValueAdded());
          }
      }

      if(c.wasRemoved()) {
          // remove also TreeItem if node was removed from map
          Platform.runLater(() -> {
              rootItem.getChildren().remove(c.getValueRemoved());
          }); 
      }
    }));
}
项目:JttDesktop    文件:MapChangeListenerRegistrationImplTest.java   
@Before public void initialiseSystemUnderTest(){
   addedResultsList = new ArrayList<>();
   removedResultsList = new ArrayList<>();
   observableMap = FXCollections.observableHashMap();

   systemUnderTest = new MapChangeListenerRegistrationImpl<>(
            observableMap, 
            ( MapChangeListener.Change< ? extends String, ? extends Object > change ) -> {
               if ( !observableMap.containsKey( change.getKey() ) ) {
                  removedResultsList.add( new Pair<>( change.getKey(), change.getValueRemoved() ) );
               } else {
                  addedResultsList.add( new Pair<>( change.getKey(), change.getValueAdded() ) );
               }
            }
   );
}
项目:jutility-javafx    文件:ValidationSupport.java   
/**
 * Creates validation support instance
 */
public ValidationSupport() {

    this.validationResultProperty()
            .addListener((o, oldValue, validationResult) -> {
                this.invalidProperty.set(!validationResult.getErrors()
                        .isEmpty());
                this.redecorate();
            });

    // notify validation result observers
    this.validationResults.addListener(
            (final MapChangeListener.Change<? extends Control, ? extends
                    ValidationResult> change) -> this
                    .validationResultProperty.set(
                    ValidationResult.fromResults(
                            this.validationResults.values())));


}
项目:SynchronizeFX    文件:Listeners.java   
@Override
public void onChanged(final MapChangeListener.Change<? extends Object, ? extends Object> change) {
    final ObservableMap<?, ?> map = change.getMap();
    if (disabledFor.containsKey(map)) {
        return;
    }
    try {
        final UUID mapId = objectRegistry.getIdOrFail(map);
        final Object key = change.getKey();
        if (change.wasAdded()) {
            final Object value = change.getValueAdded();
            final List<Command> commands = creator.putToMap(mapId, key, value);
            registerListenersOnEverything(key);
            if (value != null) {
                registerListenersOnEverything(value);
            }
            distributeCommands(commands);
        } else {
            distributeCommands(creator.removeFromMap(mapId, key));
        }
    } catch (final SynchronizeFXException e) {
        topology.onError(e);
    }
}
项目:hygene    文件:GraphVisualizer.java   
/**
 * Create a new {@link GraphVisualizer} instance.
 * <p>
 * The passed {@link GraphStore} is observed by this class. If the {@link GraphStore}
 * {@link org.dnacronym.hygene.parser.GfaFile} is updated, it will prompt a redraw. Changing the properties of this
 * class will also prompt a redraw if the {@link org.dnacronym.hygene.parser.GfaFile} in {@link GraphStore} is not
 * {@code null}.
 *
 * @param graphDimensionsCalculator {@link GraphDimensionsCalculator} used to calculate node positions
 * @param query                     the {@link Query} used to get the currently queried nodes
 * @param bookmarkStore             the {@link BookmarkStore} used to draw bookmark indications
 * @param graphAnnotation           the {@link GraphAnnotation} used to draw annotations
 */
@Inject
public GraphVisualizer(final GraphDimensionsCalculator graphDimensionsCalculator, final Query query,
                       final BookmarkStore bookmarkStore, final GraphAnnotation graphAnnotation,
                       final GraphStore graphStore) {
    HygeneEventBus.getInstance().register(this);
    this.graphDimensionsCalculator = graphDimensionsCalculator;
    this.query = query;
    this.bookmarkStore = bookmarkStore;
    this.colorRoulette = new ColorRoulette();
    this.graphAnnotation = graphAnnotation;
    this.graphStore = graphStore;

    selectedSegmentProperty = new SimpleObjectProperty<>();
    selectedSegmentProperty.addListener((observable, oldValue, newValue) -> draw());

    hoveredSegmentProperty = new SimpleObjectProperty<>();
    hoveredSegmentProperty.addListener((observable, oldValue, newValue) -> draw());

    genomePaths = FXCollections.observableArrayList(new HashSet<>());
    selectedGenomePaths = FXCollections.observableHashMap();
    selectedGenomePaths.addListener((MapChangeListener<String, Color>) change -> draw());

    edgeColorProperty = new SimpleObjectProperty<>(DEFAULT_EDGE_COLOR);
    nodeHeightProperty = new SimpleDoubleProperty(DEFAULT_NODE_HEIGHT);
    graphDimensionsCalculator.getNodeHeightProperty().bind(nodeHeightProperty);

    edgeColorProperty.addListener((observable, oldValue, newValue) -> draw());
    nodeHeightProperty.addListener((observable, oldValue, newValue) -> draw());
    Node.setColorScheme(BasicSettingsViewController.NODE_COLOR_SCHEMES.get(0).getValue());

    displayLaneBordersProperty = new SimpleBooleanProperty();
    displayLaneBordersProperty.addListener((observable, oldValue, newValue) -> draw());

    graphDimensionsCalculator.getGraphProperty()
            .addListener((observable, oldValue, newValue) -> setGraph(newValue));

    graphDimensionsCalculator.getObservableQueryNodes()
            .addListener((ListChangeListener<Node>) change -> draw());

    query.getQueriedNodes().addListener((ListChangeListener<Integer>) observable -> draw());

    segmentDrawingToolkit = new SegmentDrawingToolkit();
    snpDrawingToolkit = new SnpDrawingToolkit();
    edgeDrawingToolkit = new EdgeDrawingToolkit();
    graphAnnotationVisualizer = new GraphAnnotationVisualizer(graphDimensionsCalculator);
    graphAnnotation.indexBuiltProperty().addListener((observable, oldValue, newValue) -> draw());

    nodeHeightProperty.addListener((observable, oldValue, newValue) -> {
        segmentDrawingToolkit.setNodeHeight(nodeHeightProperty.get());
        snpDrawingToolkit.setNodeHeight(nodeHeightProperty.get());
        draw();
    });

    segmentDrawingToolkit.setNodeHeight(nodeHeightProperty.get());
    snpDrawingToolkit.setNodeHeight(nodeHeightProperty.get());
}
项目:kafka-visualizer    文件:KafkaBrokersTracker.java   
public void start() {
    if (!started.compareAndSet(false, true)) {
        throw new DefectException("Can only be started once!");
    }

    brokersById.addListener((MapChangeListener<String, KafkaBroker>) change -> version.incrementAndGet());
    zkClient.waitUntilExists("/brokers", TimeUnit.SECONDS, 10);

    executor.submit(() -> {
        zkClient.subscribeChildChanges("/brokers/ids", (parentPath, currentChilds) ->
                updateBrokers(ImmutableSet.copyOf(currentChilds)));
        updateBrokers(ImmutableSet.copyOf(zkClient.getChildren("/brokers/ids")));
    });
}
项目:kafka-visualizer    文件:KafkaTopicsTracker.java   
public void start() {
    if (!started.compareAndSet(false, true)) {
        throw new DefectException("Can only be started once!");
    }

    topicsByName.addListener((MapChangeListener<String, KafkaTopic>) change -> version.incrementAndGet());
    zkClient.waitUntilExists("/brokers", TimeUnit.SECONDS, 10);

    executor.submit(() -> {
        zkClient.subscribeChildChanges("/brokers/topics", (parentPath, currentChilds) ->
                updateTopics(ImmutableSet.copyOf(currentChilds)));
        updateTopics(ImmutableSet.copyOf(zkClient.getChildren("/brokers/topics")));
    });
}
项目:shuffleboard    文件:PropertyUtils.java   
/**
 * Binds a property to a specific key in a map. If there is no entry for that key, the property's
 * value will be set to null.
 *
 * @param property the property to bind
 * @param map      the map to bind to
 * @param key      the key for the entry to bind to
 * @param v2t      a conversion function for converting objects of type <i>V</i> to type <i>T</i>
 * @param <K>      the types of the keys in the map
 * @param <V>      the types of the values in the map
 * @param <T>      the type of data in the property
 */
public static <K, V, T extends V> void bindToMapBidirectionally(Property<T> property,
                                                                ObservableMap<K, V> map,
                                                                K key,
                                                                Function<V, T> v2t) {
  property.addListener((__, oldValue, newValue) -> map.put(key, newValue));
  map.addListener((MapChangeListener<K, V>) change -> {
    if (change.getKey().equals(key)) {
      if (change.wasRemoved() && !map.containsKey(key)) {
        property.setValue(null);
      } else if (change.wasAdded()) {
        property.setValue(v2t.apply(change.getValueAdded()));
      }
    }
  });
}
项目:shuffleboard    文件:RobotPreferencesWidget.java   
@FXML
private void initialize() {
  dataOrDefault.addListener((__, prevData, curData) -> {
    Map<String, Object> updated = curData.changesFrom(prevData);
    if (prevData != null) {
      // Remove items for any deleted robot preferences
      prevData.asMap().entrySet().stream()
          .map(Map.Entry::getKey)
          .filter(k -> !curData.containsKey(k))
          .forEach(wrapperProperties::remove);
    }
    updated.forEach((key, value) -> {
      if (NetworkTableUtils.isMetadata(key)) {
        return;
      }
      wrapperProperties.computeIfAbsent(key, k -> generateWrapper(k, value)).setValue(value);
    });
  });

  wrapperProperties.addListener((MapChangeListener<String, ObjectProperty<? super Object>>) change -> {
    if (change.wasAdded()) {
      propertySheet.getItems().add(new ExtendedPropertySheet.PropertyItem<>(change.getValueAdded(), change.getKey()));
    } else if (change.wasRemoved()) {
      propertySheet.getItems().removeIf(i -> i.getName().equals(change.getKey()));
    }
    propertySheet.getItems().sort(itemSorter);
  });

  exportProperties(propertySheet.searchBoxVisibleProperty());
}
项目:CalendarFX    文件:WeekTimeScaleView.java   
/**
 * Constructs a new scale view.
 */
public WeekTimeScaleView() {
    MapChangeListener<? super Object, ? super Object> propertiesListener = change -> {
        if (change.wasAdded()) {
            if (change.getKey().equals("week.view")) { //$NON-NLS-1$
                detailedWeekView.set((DetailedWeekView) change.getValueAdded());
            }
        }
    };

    getProperties().addListener(propertiesListener);
}
项目:CalendarFX    文件:WeekDayView.java   
/**
 * Constructs a new day view.
 */
public WeekDayView() {
    getStyleClass().add(WEEKDAY_VIEW);

    MapChangeListener<? super Object, ? super Object> propertiesListener = change -> {
        if (change.wasAdded()) {
            if (change.getKey().equals("week.view")) { //$NON-NLS-1$
                WeekView view = (WeekView) change.getValueAdded();
                weekView.set(view);
            }
        }
    };

    getProperties().addListener(propertiesListener);
}
项目:CalendarFX    文件:SearchResultView.java   
/**
 * Constructs a new view.
 */
public SearchResultView() {
    getStyleClass().add(DEFAULT_STYLE_CLASS);

    searchService = new SearchService();
    searchService.setOnSucceeded(evt -> updateSearchResults());

    searchTextProperty().addListener(it -> {
        if (SEARCH.isLoggable(FINE)) {
            SEARCH.fine("restarting search service"); //$NON-NLS-1$
        }

        searchService.restart();
    });

    /*
     * Listens to changes to the properties map. Each control has a
     * properties map associated with it. We are using the map to pass
     * values from the skin to the control. This allows the skin to update
     * read-only properties.
     */
    MapChangeListener<? super Object, ? super Object> listener = change -> {
        if (change.wasAdded()) {
            if (change.getKey().equals(SELECTED_ENTRY)) {
                Entry<?> entry = (Entry<?>) change.getValueAdded();
                selectedEntry.set(entry);
                getProperties().remove(SELECTED_ENTRY);
            }
        }
    };

    getProperties().addListener(listener);
}
项目:CalendarFX    文件:Entry.java   
/**
 * Returns an observable map of properties on this entry for use primarily
 * by application developers.
 *
 * @return an observable map of properties on this entry for use primarily
 * by application developers
 */
public final ObservableMap<Object, Object> getProperties() {
    if (properties == null) {
        properties = FXCollections.observableMap(new HashMap<>());

        MapChangeListener<? super Object, ? super Object> changeListener = change -> {
            if (change.getKey().equals("com.calendarfx.recurrence.source")) { //$NON-NLS-1$
                if (change.getValueAdded() != null) {
                    @SuppressWarnings("unchecked")
                    Entry<T> source = (Entry<T>) change.getValueAdded();

                    // lookup of property first to instantiate
                    recurrenceSourceProperty();
                    recurrenceSource.set(source);
                }
            } else if (change.getKey().equals("com.calendarfx.recurrence.id")) { //$NON-NLS-1$
                if (change.getValueAdded() != null) {
                    setRecurrenceId((String) change.getValueAdded());
                }
            }
        };

        properties.addListener(changeListener);
    }

    return properties;
}
项目:drd    文件:ObservableMergers.java   
@SafeVarargs
public static <K, V> void mergeMap(ObservableMap<K, V> into,
    ObservableMap<K, V>... maps) {
    final ObservableMap<K, V> map = into;
    for (ObservableMap<K, V> m : maps) {
        map.putAll(m);
        m.addListener((MapChangeListener<K, V>) c -> {
            if (c.wasAdded()) {
                map.put(c.getKey(), c.getValueAdded());
            }
            if (c.wasRemoved()) {
                map.remove(c.getKey());
            }
        });
    }
}
项目:drd    文件:ObservableMergers.java   
@SafeVarargs
public static <K, V, W> void mergeMap(Function<? super W, ? extends V> mapper,
    ObservableMap<K, V> into, ObservableMap<K, W>... maps) {
    final ObservableMap<K, V> map = into;
    for (ObservableMap<K, W> m : maps) {
        for (Entry<K, W> entry : m.entrySet()) {
            map.put(entry.getKey(), mapper.apply(entry.getValue()));
        }
        m.addListener((MapChangeListener<K, W>) c -> {
            if (c.wasAdded()) {
                map.put(c.getKey(), mapper.apply(c.getValueAdded()));
            }
            if (c.wasRemoved()) {
                map.remove(c.getKey());
            }
        });
    }
}
项目:voogasalad-ltub    文件:GeneralGameDataBar.java   
public GeneralGameDataBar(ObservableMap<String, String> data) {
    this.setSpacing(SPACING);
    data.addListener(new MapChangeListener<String, String>() {
        @Override
        public void onChanged(@SuppressWarnings("rawtypes") MapChangeListener.Change change) {
            redraw(data);
        }
    });
    redraw(data);
}
项目:stvs    文件:HybridRow.java   
private void onSourceCellsChange(
    MapChangeListener.Change<? extends String, ? extends ConstraintCell> change) {
  if (change.wasAdded()) {
    getCells().put(change.getKey(), new HybridCell<>(change.getValueAdded()));
  }
  if (change.wasRemoved()) {
    getCells().put(change.getKey(), new HybridCell<>(change.getValueRemoved()));
  }
}
项目:stvs    文件:SpecificationRow.java   
/**
 * Called when cells were added or removed to this row.
 *
 * @param change The change event
 */
private void cellsMapChanged(MapChangeListener.Change<? extends String, ? extends C> change) {
  if (change.wasAdded()) {
    subscribeToCell(change.getValueAdded());
  }
  if (change.wasRemoved()) {
    unsubscribeFromCell(change.getValueRemoved());
  }
}
项目:waterrower-workout    文件:ActivityDiagramSkin.java   
/**
 * The visual representation of the ActivityDiagram.
 *
 * @param control The control, must not be null.
 */
public ActivityDiagramSkin(ActivityDiagram control) {
    super(control);

    getSkinnable().getStyleClass().add("week-activity");
    getSkinnable().getActivityMap().addListener((MapChangeListener<LocalDate, Activity>) change -> updateActivities());
    getSkinnable().addEventFilter(ANY, mouseEventHandler);

    updateActivities();
}
项目:arma-dialog-creator    文件:LanguageSelectionPane.java   
public void setToKey(@Nullable StringTableKey key) {
    getChildren().clear();
    links.clear();
    setDisable(key == null);

    //force an update to null so that if the Language is the same as the previous in this observer, the listeners will get notified below at comment marked with: ****
    chosenLanguageObserver.updateValue(null);

    if (key == null) {
        return;
    }

    key.getLanguageTokenMap().addListener(new MapChangeListener<Language, String>() {
        @Override
        public void onChanged(Change<? extends Language, ? extends String> change) {
            if (change.wasAdded()) {
                addLanguage(change.getKey());
                if (links.size() == 1) {
                    chosenLanguageObserver.updateValue(null);
                    chosenLanguageObserver.updateValue(change.getKey());
                }
            } else if (change.wasRemoved()) {
                removeLanguage(change.getKey());
            } else {
                throw new IllegalStateException("unexpected change type:" + change);
            }
        }
    });
    for (Map.Entry<Language, String> token : key.getLanguageTokenMap().entrySet()) {
        addLanguage(token.getKey());
    }

    chosenLanguageObserver.updateValue(defaultLanguage); //**** (see above comment with valueObserver.updateValue(null))
}
项目:photometric-data-retriever    文件:SearchOverviewController.java   
private void initializeStarSurveySearchService() {
    starSurveySearchService.setOnError(this::showErrorMessage);
    starSurveySearchService.setOnDone(() -> disableElements(false));
    starSurveySearchService.getStarSurveysMap().addListener((MapChangeListener<StarSurveyModel, Boolean>) change -> {
        if (change.wasAdded())
            Platform.runLater(() -> progressLabel.setText(change.getKey().getName() + "->" + change.getValueAdded()));
    });
}
项目:factoryfx    文件:ValueMapAttribute.java   
public ValueMapAttribute(Class<K> keyType, Class<V> valueType) {
    super(null);
    this.keyType=keyType;
    this.valueType=valueType;
    set(FXCollections.observableMap(new TreeMap<>()));

    get().addListener((MapChangeListener<K, V>) change -> {
        updateListeners(get());
    });
}
项目:JttDesktop    文件:MapChangeListenerRegistrationImpl.java   
/**
 * Constructs a new {@link MapChangeListenerRegistrationImpl}.
 * @param observableMap the {@link ObservableMap} associated.
 * @param action the {@link MapChangeListener} associated with the {@link ObservableMap}.
 */
public MapChangeListenerRegistrationImpl( 
         ObservableMap< KeyTypeT, ValueTypeT > observableMap, 
         MapChangeListener< KeyTypeT, ValueTypeT > action 
) {
   this.map = observableMap;
   this.listener = action;
}
项目:Tuntuni    文件:MainController.java   
@Override
    public void initialize(URL url, ResourceBundle rb) {
        // set main controller to core
        Core.instance().main(this);
//        userListPrefWidth = userList.getPrefWidth();

        // capture status
        Logs.addHandler(new StatusHandler(statusLabel));

        // change of user name
        profileButton.setText(Core.instance().user().getName());
        Core.instance().user().userNameProperty().addListener((ov, o, n) -> {
            Platform.runLater(() -> profileButton.setText(n));
        });

        // change of setAvatar image
        final ImageView profileImage = (ImageView) profileButton.getGraphic();
        ChangeListener updateAvatar = (ov, o, n) -> {
            Image avatar = Core.instance().user().getAvatarImage(32, 32);
            profileImage.setImage(avatar);
        };
        updateAvatar.changed(null, null, null);
        Core.instance().user().avatarProperty().addListener(updateAvatar);

        // add existing users
        userList.getItems().clear();
        updateUserList(null, null);
        Core.instance().scanner().userListProperty().values().forEach((client) -> {
            Platform.runLater(() -> updateUserList(client, null));
        });
        // monitor user list
        Core.instance().scanner().userListProperty().addListener((MapChangeListener.Change<? extends Integer, ? extends Client> change) -> {
            Platform.runLater(() -> updateUserList(change.getValueAdded(), change.getValueRemoved()));
        });

        showUser(null);
    }
项目:mars-sim    文件:Spinner.java   
/***************************************************************************
 *                                                                         *
 * Constructors                                                            *
 *                                                                         *
 **************************************************************************/

public Spinner() {
    getStyleClass().add(DEFAULT_STYLE_CLASS);

    getEditor().setOnAction(action -> {
        String text = getEditor().getText();
        SpinnerValueFactory<T> valueFactory = getValueFactory();
        if (valueFactory != null) {
            T value = valueFactory.fromString(text);
            valueFactory.setValue(value);
        }
    });

    getEditor().editableProperty().bind(editableProperty());

    value.addListener((o, oldValue, newValue) -> setText(newValue));

    // Fix for RT-29885
    getProperties().addListener((MapChangeListener<Object, Object>) change -> {
        if (change.wasAdded()) {
            if (change.getKey() == "FOCUSED") {
                setFocused((Boolean)change.getValueAdded());
                getProperties().remove("FOCUSED");
            }
        }
    });
    // End of fix for RT-29885
}
项目:SmartModInserter    文件:ObservableMapValues.java   
public ObservableMapValues(ObservableList<T> internalStore, ObservableMap<?, T> referencedMap) {
    this.internalStore = internalStore;
    this.referencedMap = referencedMap;

    referencedMap.addListener((MapChangeListener<Object, T>) change -> {
        if (change.wasAdded()) {
            internalStore.add(change.getValueAdded());
        }
        if (change.wasRemoved()) {
            internalStore.remove(change.getValueRemoved());
        }
    });
}
项目:dnainator    文件:LeafNode.java   
private void onColorServerChanged(
        MapChangeListener.Change<? extends String, ? extends String> change) {
    if (change.wasAdded()) {
        highlighted = true;
        addStyle(change.getValueAdded());
    } else {
        highlighted = false;
        removeStyle(change.getValueRemoved());
    }
}
项目:dnainator    文件:ClusterDrawable.java   
private void onColorServerChanged(
        MapChangeListener.Change<? extends String, ? extends String> change) {
    if (!sources.contains(change.getKey())) {
        return;
    }

    if (change.wasAdded()) {
        addStyle(change.getValueAdded());
    } else if (change.wasRemoved()) {
        removeStyle(change.getValueRemoved());
    }
}
项目:iText-GUI    文件:Controller.java   
@Override
public void onChanged(MapChangeListener.Change<? extends String, ? extends List<Parameterizable>> change) {
   if (change.wasAdded()) {
      if (!styleClasses.contains(change.getKey())) {
         styleClasses.add(change.getKey());
         Collections.sort(styleClasses);
      }
   } else if (change.wasRemoved()) {
      styleClasses.remove(change.getKey());
   }
}
项目:LightningPlayer    文件:PlaylistElement.java   
/**
 * Az aktuális lejátszólista elemet újjáépíti úgy, hogy annak fontosabb
 * mezői egy null értéket se tartalmazzanak, illetve beállítja a
 * {@link Media}-t, hogy a Player számára feldolgozható legyen.
 * <p>
 * Lejátszólista beolvasása során használt metódus.
 */
public void rebuildPlaylistElement() {
    this.media = new Media(this.location);
    this.artist = ifnullToEmpty(this.artist);
    this.album = ifnullToEmpty(this.album);

    media.getMetadata().addListener((MapChangeListener<String, Object>) change -> {

            switch (change.getKey().toString()) {
                case "year":
                    year = ifnullToEmpty(change.getValueAdded().toString());
                    break;
                case "genre":
                    this.genre = ifnullToEmpty(change.getValueAdded().toString());
                    break;
                default:
                    break;
            }
        }
    );

    try {
        Mp3File mp3File = new Mp3File(new File(new URI(this.location).getPath()));
        this.bitrate = mp3File.getBitrate();
    } catch (IOException | UnsupportedTagException | InvalidDataException | URISyntaxException e) {
        log.error("MP3 fiel is not rebuildable.", e);
    }

    this.trackNum = ifnullToEmpty(this.trackNum);
}
项目:exchange    文件:ArbitratorRegistrationViewModel.java   
@Inject
public ArbitratorRegistrationViewModel(ArbitratorManager arbitratorManager,
                                       User user,
                                       P2PService p2PService,
                                       BtcWalletService walletService,
                                       KeyRing keyRing) {
    this.arbitratorManager = arbitratorManager;
    this.user = user;
    this.p2PService = p2PService;
    this.walletService = walletService;
    this.keyRing = keyRing;

    arbitratorMapChangeListener = new MapChangeListener<NodeAddress, Arbitrator>() {
        @Override
        public void onChanged(Change<? extends NodeAddress, ? extends Arbitrator> change) {
            Arbitrator myRegisteredArbitrator = user.getRegisteredArbitrator();
            myArbitratorProperty.set(myRegisteredArbitrator);

            // We don't reset the languages in case of revocation, as its likely that the arbitrator will use the same again when he re-activate
            // registration later
            if (myRegisteredArbitrator != null)
                languageCodes.setAll(myRegisteredArbitrator.getLanguageCodes());

            updateDisableStates();
        }
    };
}
项目:dwoss    文件:CategoryProductEditorController.java   
/**
     * Create a CategoryProductFx based on the values from cp. Bind the
     * CategoryProductFx with the ui components.
     *
     * @param cp received categoryProduct.
     */
    public void setCategoryProduct(CategoryProduct cp) {

        // Bind in initialze and update via mapper would be much better.
        // CategoryProductFxMapper.INSTANCE.update(categoryProductFx, cp);
        categoryProductFx = CategoryProductFxMapper.INSTANCE.from(cp);

// Old show lucas, jens and jacob
//        categoryProductFx = new CategoryProductFx(cp.getId(), cp.getName(),
//                cp.getDescription(),
//                cp.getSalesChannel(),
//                cp.getProducts()
//                        .stream()
//                        .map(p -> new PicoProduct(p.getId(), p.getName()))
//                        .collect(Collectors.toList()),
//                cp.getPrices());
        name.textProperty().bindBidirectional(categoryProductFx.getNameProperty());
        description.textProperty().bindBidirectional(categoryProductFx.getDescriptionProperty());
        salesChannel.valueProperty().bindBidirectional(categoryProductFx.getSalesChannelProperty());

// TODO: Looks wrong. must be binded ? - ask lucas.
        // listViewProducts.itemsProperty().bind(categoryProductFx.getProductsProperty());
        // listViewPrices.itemsProperty().bind(categoryProductFx.getPricesProperty().entrySet());
        listViewProducts.setItems(categoryProductFx.getProductsProperty());

        listViewPrices.setItems(FXCollections.observableArrayList(categoryProductFx.getPricesProperty().entrySet()));

        categoryProductFx.getPricesProperty().addListener((MapChangeListener<PriceType, Double>)change -> {
            listViewPrices.getItems().clear();
            listViewPrices.getItems().addAll(categoryProductFx.getPricesProperty().entrySet());
        });
    }
项目:ISAAC    文件:DynamicRefexView.java   
@Override
public void onChanged(
        javafx.collections.MapChangeListener.Change<? extends ColumnId, ? extends Filter<?>> c) {
    if (c.wasAdded() || c.wasRemoved()) {
        refresh();
    }
}
项目:PiOnWheels    文件:Radar.java   
private void registerListeners() {
    widthProperty().addListener(observable -> resize());
    heightProperty().addListener(observable -> resize());
    beamVisible.addListener(observable -> handleControlPropertyChanged("BEAM_VISIBLE"));
    radarColor.addListener(observable -> handleControlPropertyChanged("RADAR_COLOR"));
    pois.addListener((MapChangeListener<String, Poi>) change -> handleControlPropertyChanged("POIS"));
}
项目:WellBehavedFX    文件:Nodes.java   
/**
 *
 * @param node
 */
private static void init(Node node) {
    if(node.getProperties().get(P_INPUTMAP) == null) {

        node.getProperties().put(P_INPUTMAP, InputMap.empty());
        node.getProperties().put(P_HANDLERS, new ArrayList<Map.Entry<?, ?>>());

        MapChangeListener<Object, Object> listener = ch -> {
            if(!P_INPUTMAP.equals(ch.getKey())) {
                return;
            }

            getHandlers(node).forEach(entry -> {
                node.removeEventHandler((EventType<Event>) entry.getKey(), (EventHandler<Event>) entry.getValue());
            });

            getHandlers(node).clear();

            InputMap<?> inputMap = (InputMap<?>) ch.getValueAdded();
            inputMap.forEachEventType(new HandlerConsumer<Event>() {

                @Override
                public <E extends Event> void accept(
                        EventType<? extends E> t, InputHandler<? super E> h) {
                    node.addEventHandler(t, h);
                    getHandlers(node).add(new SimpleEntry<>(t, h));
                }});
        };
        node.getProperties().addListener(listener);
    }
}
项目:reta    文件:MapTableView.java   
@Override
public void onChanged(final javafx.collections.MapChangeListener.Change<? extends K, ? extends V> change)
{
    // TODO: Workaround for https://bugs.openjdk.java.net/browse/JDK-8136465
    if (!changingSubject)
    {
        if (change.getKey().equals(entry.getKey()) && change.wasAdded())
        {
            value.removeListener(changeListener);
            value.setValue(change.getValueAdded());
            value.addListener(changeListener);
        }
    }
}