List of usage examples for javafx.beans Observable removeListener
void removeListener(InvalidationListener listener);
From source file:acmi.l2.clientmod.xdat.Controller.java
private PropertySheet createPropertySheet(TreeView<Object> elements) { PropertySheet properties = new PropertySheet(); properties.setSkin(new PropertySheetSkin(properties)); elements.getSelectionModel().selectedItemProperty().addListener((selected, oldValue, newSelection) -> { properties.getItems().clear();//w ww. j av a2 s .c o m if (newSelection == null) return; Object obj = newSelection.getValue(); if (obj instanceof ListHolder) return; if (!map.containsKey(obj.getClass())) { map.put(obj.getClass(), loadProperties(obj)); } List<PropertySheetItem> props = map.get(obj.getClass()); props.forEach(property -> { property.setObject(obj); ChangeListener<Object> addToHistory = (observable1, oldValue1, newValue) -> editor.getHistory() .valueChanged(treeItemToScriptString(newSelection), property.getName(), newValue); property.addListener(addToHistory); selected.addListener(new InvalidationListener() { @Override public void invalidated(Observable observable) { property.removeListener(addToHistory); observable.removeListener(this); } }); }); properties.getItems().setAll(props); }); return properties; }