private ListChangeListener<String> getOutputToScreenLogger() {
outputListener = new ListChangeListener<String>() {
boolean first = true;
@Override
public void onChanged(ListChangeListener.Change<? extends String> change) {
change.next();
Platform.runLater(() -> {
List<? extends String> changedList = change.getList();
for (int index = first ? 0 : change.getFrom(); index < change.getTo(); index++) {
String added = changedList.get(index);
if (added != null) {
outputTextArea.appendText(added);
}
}
first = false;
});
}
};
return new WeakListChangeListener<>(outputListener);
}
java类javafx.collections.WeakListChangeListener的实例源码
ImagingController.java 文件源码
项目:IO
阅读 22
收藏 0
点赞 0
评论 0
MainWindowController.java 文件源码
项目:Cachoeira
阅读 21
收藏 0
点赞 0
评论 0
private AbstractTableView<ITask> createTaskTable(DoubleProperty horizontalScrollValue,
DoubleProperty verticalScrollValue) {
taskTableView = new TaskTableView<>(horizontalScrollValue, verticalScrollValue);
taskTableView.setRoot(new TreeItem<>(new Task()));
taskTableView.setRowFactory(new TaskTreeTableViewRowFactory(this, new TaskTableDragAndDrop(this)));
taskTableView.setRowFactory(new TaskTreeTableViewRowFactory(this, new TaskTableDragAndDrop(this)));
taskListChangeListener = this::taskChangeListenerHandler;
project.getTaskList().addListener(new WeakListChangeListener<>(taskListChangeListener));
taskChangeListener = this::refreshSelectedTask;
taskTableView.getSelectionModel().selectedItemProperty().addListener(new WeakChangeListener<>(taskChangeListener));
taskTreeItemsChangeListener = this::setSelectedTaskNull;
taskTableView.getRoot().getChildren().addListener(new WeakListChangeListener<>(taskTreeItemsChangeListener));
return taskTableView;
}
MainWindowController.java 文件源码
项目:Cachoeira
阅读 29
收藏 0
点赞 0
评论 0
private AbstractTableView<IResource> createResourceTable(DoubleProperty horizontalScrollValue,
DoubleProperty verticalScrollValue) {
resourceTableView = new ResourceTableView<>(horizontalScrollValue, verticalScrollValue);
resourceTableView.setRoot(new TreeItem<>(new Resource()));
resourceTableView.setRowFactory(new ResourceTreeTableViewRowFactory(this, new ResourceTableDragAndDrop(this)));
resourceListChangeListener = this::resourceChangeListenerHandler;
project.getResourceList().addListener(new WeakListChangeListener<>(resourceListChangeListener));
resourceChangeListener = this::refreshSelectedResource;
resourceTableView.getSelectionModel().selectedItemProperty().addListener(new WeakChangeListener<>(resourceChangeListener));
resourceTreeItemsChangeListener = this::setSelectedResourceNull;
resourceTableView.getRoot().getChildren().addListener(new WeakListChangeListener<>(resourceTreeItemsChangeListener));
return resourceTableView;
}
AutoTreeItem.java 文件源码
项目:StreamSis
阅读 25
收藏 0
点赞 0
评论 0
/**
* Instantiates a new AutoTreeItem, sets it's Value to passed value and it's Graphic to passed node.
*
* @param value
* the Value
* @param node
* the Graphic
*/
@SuppressWarnings("unchecked")
public AutoTreeItem(T value, Node node) {
super(value, node);
if (value != null) {
ObservableList<T> valueChildren = value.getChildren();
if (valueChildren != null) {
for (T valueChild : valueChildren) {
AutoTreeItem<T> treeItemChild = new AutoTreeItem<T>(valueChild);
treeItemChild.setExpanded(true);
getChildren().add(treeItemChild);
}
value.getChildren().addListener(new WeakListChangeListener<>(childrenListener));
}
}
}
ListTransformation.java 文件源码
项目:easyMvvmFx
阅读 20
收藏 0
点赞 0
评论 0
private void initListEvents() {
this.listChangeListener = new ListChangeListener<SourceType>() {
@Override
public void onChanged(
Change<? extends SourceType> listEvent) {
// We have to stage delete events, because if we process them
// separately, there will be unwanted ChangeEvents on the
// targetList
List<TargetType> deleteStaging = new ArrayList<>();
while (listEvent.next()) {
if (listEvent.wasUpdated()) {
processUpdateEvent(listEvent);
} else if (listEvent.wasReplaced()) {
processReplaceEvent(listEvent, deleteStaging);
} else if (listEvent.wasAdded()) {
processAddEvent(listEvent);
} else if (listEvent.wasRemoved()) {
processRemoveEvent(listEvent, deleteStaging);
}
}
// Process the staged elements
processStagingLists(deleteStaging);
}
};
modelListProperty().addListener(
new WeakListChangeListener<>(listChangeListener));
}
ListTransformation.java 文件源码
项目:javafx-qiniu-tinypng-client
阅读 22
收藏 0
点赞 0
评论 0
private void initListEvents() {
this.listChangeListener = new ListChangeListener<SourceType>() {
@Override
public void onChanged(
Change<? extends SourceType> listEvent) {
// We have to stage delete events, because if we process them
// separately, there will be unwanted ChangeEvents on the
// targetList
List<TargetType> deleteStaging = new ArrayList<>();
while (listEvent.next()) {
if (listEvent.wasUpdated()) {
processUpdateEvent(listEvent);
} else if (listEvent.wasReplaced()) {
processReplaceEvent(listEvent, deleteStaging);
} else if (listEvent.wasAdded()) {
processAddEvent(listEvent);
} else if (listEvent.wasRemoved()) {
processRemoveEvent(listEvent, deleteStaging);
}
}
// Process the staged elements
processStagingLists(deleteStaging);
}
};
modelListProperty().addListener(
new WeakListChangeListener<>(listChangeListener));
}
BarChartTileSkin.java 文件源码
项目:tilesfx
阅读 19
收藏 0
点赞 0
评论 0
@Override protected void registerListeners() {
super.registerListeners();
tile.getBarChartItems().addListener(new WeakListChangeListener<>(change -> {
while (change.next()) {
if (change.wasAdded()) {
change.getAddedSubList().forEach(addedItem -> {
barChartPane.getChildren().add(addedItem);
addedItem.addChartDataEventListener(updateHandler);
EventHandler<MouseEvent> clickHandler = e -> tile.fireTileEvent(new TileEvent(EventType.SELECTED_CHART_DATA, addedItem.getChartData()));
handlerMap.put(addedItem, clickHandler);
addedItem.setOnMousePressed(clickHandler);
});
updateChart();
} else if (change.wasRemoved()) {
change.getRemoved().forEach(removedItem -> {
removedItem.removeChartDataEventListener(updateHandler);
removedItem.removeEventHandler(MouseEvent.MOUSE_PRESSED, handlerMap.get(removedItem));
barChartPane.getChildren().remove(removedItem);
});
updateChart();
}
}
}));
pane.widthProperty().addListener(paneSizeListener);
pane.heightProperty().addListener(paneSizeListener);
}
TaskBarLabel.java 文件源码
项目:Cachoeira
阅读 16
收藏 0
点赞 0
评论 0
public void setListeners() {
resourceListChangeListener = change -> {
while (change.next()) {
if (change.wasAdded()) {
change.getAddedSubList().forEach(this::addResourceLabel);
}
if (change.wasRemoved()) {
change.getRemoved().forEach(this::removeResourceLabel);
}
}
};
taskBar.getTask().getResourceList().addListener(new WeakListChangeListener<>(resourceListChangeListener));
}
RelationsLayer.java 文件源码
项目:Cachoeira
阅读 23
收藏 0
点赞 0
评论 0
/**
* Метод инициализирующий листенеры.
*
*/
public void setListeners(MainWindowController controller) {
// Листенер который следит за добавлением новых задач.
// Нужен для обновления связей при изменении положения задачи в таблице задач (при драг'н'дропе).
// Если после драг'н'дропа не обновить связь, то она работает не корректно.
// TODO: 04.03.2016 По хорошему необходимо обновлять связь только у тех задач которые добавились, а не перерисовывать все связи.
taskListChangeListener = change -> {
while (change.next()) {
if (change.wasAdded()) {
Platform.runLater(() -> refreshRelationsDiagram(controller));
}
}
};
controller.getProject().getTaskList().addListener(new WeakListChangeListener<>(taskListChangeListener));
}
ObservableListBuffering.java 文件源码
项目:reta
阅读 20
收藏 0
点赞 0
评论 0
/**
* @param newBeanType
* bean type
* @param newPropertyName
* bean property name
* @param newSubject
* property value
*/
public ObservableListBuffering(final Class<?> newBeanType, final String newPropertyName,
final ObservableList<E> newSubject)
{
super(FXCollections.observableArrayList());
if (newBeanType != null || !(newSubject instanceof ReadOnlyProperty<?>))
{
beanType = newBeanType;
}
else
{
final Object bean = ((ReadOnlyProperty<?>) newSubject).getBean();
beanType = (bean != null ? bean.getClass() : null);
}
if (newPropertyName != null || !(newSubject instanceof ReadOnlyProperty<?>))
{
propertyName = newPropertyName;
}
else
{
propertyName = ((ReadOnlyProperty<?>) newSubject).getName();
}
subject = Objects.requireNonNull(newSubject);
addAll(subject);
thisListener = c -> {
if (equalsBuffering)
{
buffering.setValue(!equalsSubject());
}
else
{
buffering.setValue(true);
}
validate();
};
subjectListener = c -> {
if (!buffering.getValue())
{
revert();
}
};
addListener(thisListener);
weakSubjectListener = new WeakListChangeListener<E>(subjectListener);
subject.addListener(weakSubjectListener);
validate();
}