java类javafx.collections.ListChangeListener的实例源码

ListTransformation.java 文件源码 项目:easyMvvmFx 阅读 26 收藏 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 文件源码 项目:easyMvvmFx 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Maps an add event of the model list to new elements of the {@link #viewModelList}.
 *
 * @param listEvent
 *            to analyze
 */
private void processAddEvent(
        ListChangeListener.Change<? extends SourceType> listEvent) {

    final List<TargetType> toAdd = new ArrayList<>();
    for (int index = listEvent.getFrom(); index < listEvent.getTo(); index++) {
        final SourceType item = listEvent.getList().get(index);
        toAdd.add(function.apply(item));
    }
    viewModelList.addAll(listEvent.getFrom(), toAdd);
}
ListTransformation.java 文件源码 项目:easyMvvmFx 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Maps an update event of the model list to new elements of the {@link #viewModelList}.
 *
 * @param listEvent
 *            to process
 */
private void processUpdateEvent(ListChangeListener.Change<? extends SourceType> listEvent) {
    for (int i = listEvent.getFrom(); i < listEvent.getTo(); i++) {
        SourceType item = listEvent.getList().get(i);
        viewModelList.set(i, ListTransformation.this.function.apply(item));
    }
}
ListTransformation.java 文件源码 项目:easyMvvmFx 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Maps an replace event of the model list to new elements of the {@link #viewModelList}.
 *
 * @param listEvent
 *            to process
 */
private void processReplaceEvent(
        ListChangeListener.Change<? extends SourceType> listEvent, List<TargetType> deletedStaging) {
    processRemoveEvent(listEvent, deletedStaging);
    processStagingLists(deletedStaging);
    processAddEvent(listEvent);
}
ValidationVisualizerBase.java 文件源码 项目:easyMvvmFx 阅读 21 收藏 0 点赞 0 评论 0
@Override
public void initVisualization(final ValidationStatus result, final Control control, boolean required) {
    if (required) {
        applyRequiredVisualization(control, required);
    }

    applyVisualization(control, result.getHighestMessage(), required);

    result.getMessages().addListener((ListChangeListener<ValidationMessage>) c -> {
        while (c.next()) {
            Platform.runLater(() -> applyVisualization(control, result.getHighestMessage(), required));
        }
    });
}
TimelineSceneSynchronizer.java 文件源码 项目:fx-animation-editor 阅读 26 收藏 0 点赞 0 评论 0
@Inject
public TimelineSceneSynchronizer(TimelineModel timelineModel, SceneModel sceneModel) {
    this.timelineModel = timelineModel;
    this.sceneModel = sceneModel;
    timelineModel.selectedKeyFrameProperty().addListener((v, o, n) -> updateBindings());
    timelineModel.getKeyFrames().addListener((ListChangeListener<? super KeyFrameModel>) change -> updateBindings());
}
DutyRosterController.java 文件源码 项目:Planchester 阅读 21 收藏 0 点赞 0 评论 0
@FXML
public void initialize() {
    staticAgenda = agenda;
    staticScrollPane = scrollPane;

    getGroupColorsFromCSS();
    initializeAppointmentGroupsForEventtypes(); //must be the first initialize-call
    initialzeCalendarSettings();
    initialzeCalendarView();

    agenda.setOnMouseClicked(event -> {
        if(event.getTarget().toString().contains("DayBodyPane")) {
            resetSideContent();
            removeSelection();
        }
    });

    agenda.selectedAppointments().addListener((ListChangeListener<Agenda.Appointment>) c -> {
        if(agenda.selectedAppointments().isEmpty()) {
            resetSideContent();
            return;
        }

        resetSideContent();
        selectedAppointment = agenda.selectedAppointments().get(0);
        showDutyDetailView();
    });


    Permission permission = AccountAdministrationManager.getInstance().getUserPermissions();
    if(AccountAdministrationManager.getInstance().getSectionType() != null) {
        dutyRosterLabel.setText("Duty Roster: " + AccountAdministrationManager.getInstance().getSectionType());
    }
    publishDutyRoster.setVisible(permission.isPublishDutyRoster());
}
OBVCanvas.java 文件源码 项目:TechnicalAnalysisTool 阅读 17 收藏 0 点赞 0 评论 0
@Override
public void onChanged(ListChangeListener.Change<? extends OHLC> c) {
    while(c.next()) {
        if (c.wasAdded()) {
            draw();
        }
    }
}
RSMCanvas.java 文件源码 项目:TechnicalAnalysisTool 阅读 17 收藏 0 点赞 0 评论 0
@Override
public void onChanged(ListChangeListener.Change<? extends OHLC> c) {
    while(c.next()) {
        if (c.wasAdded()) {
            draw();
        }
    }
}
ModelWrapper.java 文件源码 项目:javafx-qiniu-tinypng-client 阅读 16 收藏 0 点赞 0 评论 0
public FxListPropertyField(ListPropertyAccessor<M, E> accessor, Supplier<ListProperty<E>> propertySupplier, List<E> defaultValue) {
    this.accessor = accessor;
    this.defaultValue = defaultValue;

    this.targetProperty = propertySupplier.get();
    this.targetProperty.setValue(FXCollections.observableArrayList());

    this.targetProperty.addListener((ListChangeListener<E>) change -> ModelWrapper.this.propertyWasChanged());
}


问题


面经


文章

微信
公众号

扫码关注公众号