当前位置: 首页>>代码示例>>Java>>正文


Java WeakChangeListener类代码示例

本文整理汇总了Java中javafx.beans.value.WeakChangeListener的典型用法代码示例。如果您正苦于以下问题:Java WeakChangeListener类的具体用法?Java WeakChangeListener怎么用?Java WeakChangeListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WeakChangeListener类属于javafx.beans.value包,在下文中一共展示了WeakChangeListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWriteblockListener

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
private ChangeListener<Boolean> getWriteblockListener() {
    writeBlockListener = (observable, oldValue, newValue) -> Platform.runLater(() -> {
        if (newValue) {
            writeblockStatus.setText("ENABLED");
            writeblockStatus.setTextFill(Color.LIME);
            readyLabel.setVisible(true);
            writeblockStatus.autosize();
        }
        else {
            writeblockStatus.setText("DISABLED");
            writeblockStatus.setTextFill(Color.RED);
            readyLabel.setVisible(false);
            writeblockStatus.autosize();
        }
    });
    return new WeakChangeListener<>(writeBlockListener);
}
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:18,代码来源:MainScreenController.java

示例2: getProgressUpdater

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
private ChangeListener<Number> getProgressUpdater() {
    ProgressStatus currentStatus = new ProgressStatus();
    progressListener = (arg0, oldVal, newVal) -> Platform.runLater(() -> {
        if (!progressBar.isDisabled()) {
            long newLong = newVal.longValue();
            if (newLong > 0) {
                currentStatus.onChange(newLong);
            }
            else if (newVal.intValue() == -1) {
                // failureLabel.setVisible(true);
                progressBar.setDisable(true);
                displayErrorPopup("Error: Failed to complete imaging.\n");
            }
        }
    });
    return new WeakChangeListener<>(progressListener);
}
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:18,代码来源:ImagingController.java

示例3: initUi

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
private void initUi() {
    timeLabel.setValue(model.getTime());

    // Use weak listener here so view can be garbage collected when key frame is deleted, because model instance will hang around in command stack.
    ChangeListener<Number> timeChangeListener = (v, o, n) -> timeLabel.setValue(n.doubleValue());
    timeLabel.getProperties().put(TIME_CHANGE_LISTENER_KEY, timeChangeListener);
    model.timeProperty().addListener(new WeakChangeListener<>(timeChangeListener));

    incrementButton.setGraphic(createArrowGraphic(NodeOrientation.LEFT_TO_RIGHT));
    decrementButton.setGraphic(createArrowGraphic(NodeOrientation.RIGHT_TO_LEFT));
    deleteButton.setGraphic(Svg.MINUS_TINY.node());

    leftButtonBox.visibleProperty().bind(model.timeProperty().greaterThan(0));
    rightButtonBox.visibleProperty().bind(model.timeProperty().greaterThan(0));
    plusLabel.visibleProperty().bind(model.timeProperty().greaterThan(0));
    plusLabel.managedProperty().bind(plusLabel.visibleProperty());

    highlight.visibleProperty().bind(model.selectedProperty());
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:20,代码来源:KeyFrameComponent.java

示例4: registerLeakDetection

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
/**
 * Check the scene property of a parent for getting null. If it gets null
 * and the Object retains in Memory (leakedObject List), it is likely a
 * leak.
 *
 * @param parent
 */
protected void registerLeakDetection(Node parent) {
    Optional<WeakRef<Node>> parentReference = map.keySet().stream()
            .filter(element -> element.get() == parent)
            .findFirst();
    
    WeakRef<Node> weakRef = new WeakRef<Node>(parent);
    ChangeListener<Scene> sceneListener = (observable, oldValue, newValue) -> {
        if (newValue == null) {
            if (!parentReference.isPresent()) {
                if(map.get(weakRef) == null) {
                    insertWeakRefIntoMap(weakRef);
                }
            }
        } else {
            if(parentReference.isPresent()) {
                map.remove(parentReference.get());
            }
        }
    };

    listeners.add(sceneListener);
    parent.sceneProperty().addListener(new WeakChangeListener<>(sceneListener));
}
 
开发者ID:sialcasa,项目名称:leakdetectorFX,代码行数:31,代码来源:LeakDetector.java

示例5: updateItem

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
@Override
public void updateItem(T item, boolean empty) {
    super.updateItem(item, empty);

    if (item != null) {
        if (dataSupplier.apply(item)!=null){
            if (displayText!=null){
                displayText.removeListener(changeListener);
            }

            displayText= dataSupplier.apply(item).internal().getDisplayTextObservable();
            changeListenerGarbageCollectionSave = (observable, oldValue, newValue) -> {
                setText(dataSupplier.apply(item).internal().getDisplayText());
            };
            changeListener = new WeakChangeListener<>(changeListenerGarbageCollectionSave);
            displayText.addListener(changeListener);
            changeListener.changed(displayText,null,displayText.get());
        } else {
            setText(alternativeDisplayText.apply(item));
        }

    }
    //CellUtils.updateItem(this, getConverter(), hbox, getTreeItemGraphic(), textField);
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:25,代码来源:DataTextFieldTreeCell.java

示例6: createVisualisation

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
@Override
public Node createVisualisation(SimpleObjectProperty<String> attributeValue, boolean readonly) {
    HTMLEditor htmlEditor = new HTMLEditor();

    changeListener = (observable, oldValue, newValue) -> htmlEditor.setHtmlText(newValue);
    attributeValue.addListener(new WeakChangeListener<>(changeListener));
    htmlEditor.setDisable(readonly);


    BorderPane borderPane = new BorderPane();
    borderPane.setCenter(htmlEditor);
    Button save = new Button("save");//strangely workaround HTMLEditor have no bind or change events
    save.setOnAction(event -> attributeValue.set(htmlEditor.getHtmlText()));
    htmlEditor.setHtmlText(attributeValue.get());
    BorderPane.setMargin(save,new Insets(3,0,3,0));
    borderPane.setTop(save);
    return borderPane;
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:19,代码来源:StringHtmlAttributeVisualisation.java

示例7: setListener

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
public void setListener() {
    dependentTypeChangeListener = (observable, oldValue, newValue) -> {
        this.getChildren().clear();
        if (dependenceType.getValue().equals(TaskDependencyType.FINISHSTART)) {
            this.getChildren().addAll(initFinishStartRelationLine(parentTaskBar, childTaskBar));
        }
        if (dependenceType.getValue().equals(TaskDependencyType.STARTFINISH)) {
            this.getChildren().addAll(iniStartFinishRelationLine(parentTaskBar, childTaskBar));
        }
        if (dependenceType.getValue().equals(TaskDependencyType.FINISHFINISH)) {
            this.getChildren().addAll(initFinishFinishRelationLine(parentTaskBar, childTaskBar));
        }
        if (dependenceType.getValue().equals(TaskDependencyType.STARTSTART)) {
            this.getChildren().addAll(initStartStartRelationLine(parentTaskBar, childTaskBar));
        }
    };
    dependenceType.addListener(new WeakChangeListener<>(dependentTypeChangeListener));
}
 
开发者ID:khasang,项目名称:Cachoeira,代码行数:19,代码来源:RelationLine.java

示例8: createTaskTable

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
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;
}
 
开发者ID:khasang,项目名称:Cachoeira,代码行数:18,代码来源:MainWindowController.java

示例9: createResourceTable

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
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;
}
 
开发者ID:khasang,项目名称:Cachoeira,代码行数:17,代码来源:MainWindowController.java

示例10: initModule

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
@Override
public void initModule() {
    module.disableProperty().bind(controller.selectedResourceProperty().isNull());

    module.getResourceTypeComboBox().setItems(FXCollections.observableArrayList(ResourceType.values()));

    resourceChangeListener = this::selectedResourceObserver;
    nameFieldInvalidationListener = this::nameFieldUnfocused;
    emailFieldInvalidationListener = this::emailFieldUnfocused;
    descriptionTextAreaInvalidationListener = this::descriptionTextAreaUnfocused;

    controller.selectedResourceProperty().addListener(new WeakChangeListener<>(resourceChangeListener));

    module.getNameField().setOnKeyPressed(this::nameFieldObserver);
    module.getResourceTypeComboBox().setOnAction(this::resourceTypeComboBoxObserver);
    module.getEmailField().setOnKeyPressed(this::emailFieldObserver);
    module.getDescriptionTextArea().setOnKeyPressed(this::descriptionTextAreaObserver);

    module.getNameField().focusedProperty().addListener(new WeakInvalidationListener(nameFieldInvalidationListener));
    module.getEmailField().focusedProperty().addListener(new WeakInvalidationListener(emailFieldInvalidationListener));
    module.getDescriptionTextArea().focusedProperty().addListener(new WeakInvalidationListener(descriptionTextAreaInvalidationListener));
}
 
开发者ID:khasang,项目名称:Cachoeira,代码行数:23,代码来源:ResourceInformationModuleController.java

示例11: handleStateChangeNotification

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
@Override
public void handleStateChangeNotification(StateChangeNotification evt) {
    if (evt.getType() == StateChangeNotification.Type.BEFORE_START) {
        //application is loaded => hide progress bar
        bar.setVisible(false);
        
        consumer = (MyWMS) evt.getApplication();
        consumer.loginServiceProperty().addListener(new WeakChangeListener<>(hideStageListener));

        checkLogin();
    }
}
 
开发者ID:salimvanak,项目名称:myWMS,代码行数:13,代码来源:LoginPreloader.java

示例12: registerListenerOnSceneRoot

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
protected void registerListenerOnSceneRoot(Scene scene) {
    scene.rootProperty().addListener(new WeakChangeListener<>((observable, oldValue, newValue) -> {
        safeRegisterTracking(newValue);
    }));

    Parent root = scene.getRoot();
    safeRegisterTracking(root);
}
 
开发者ID:sialcasa,项目名称:leakdetectorFX,代码行数:9,代码来源:LeakDetectorBase.java

示例13: RootTreeItem

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
RootTreeItem(final Collection<? extends TMAEntry> entries, final ObservableValue<Predicate<TMAEntry>> combinedPredicate) {
	super(null);
	for (TMAEntry entry : entries) {
		if (entry instanceof TMASummaryEntry)
			this.entries.add(new SummaryTreeItem((TMASummaryEntry)entry));
		else
			this.entries.add(new TreeItem<>(entry));					
	}
	this.combinedPredicate = combinedPredicate;
	this.combinedPredicate.addListener(new WeakChangeListener<>(this));
	updateChildren();
}
 
开发者ID:qupath,项目名称:qupath,代码行数:13,代码来源:TMASummaryViewer.java

示例14: initModule

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
@Override
public void initModule() {
    // set disable if selected task is null
    module.disableProperty().bind(controller.selectedTaskProperty().isNull());
    // init listeners
    taskChangeListener = this::selectedTaskObserver;
    nameFieldInvalidationListener = this::nameFieldUnfocused;
    costFieldInvalidationListener = this::costFieldUnfocused;
    descriptionTextAreaInvalidationListener = this::descriptionTextAreaUnfocused;
    // set listener on selected task
    controller.selectedTaskProperty().addListener(new WeakChangeListener<>(taskChangeListener));
    // set handlers on fields events
    module.getNameField().setOnKeyPressed(this::nameFieldHandler);
    module.getStartDatePicker().setOnAction(this::startDatePickerHandler);
    module.getFinishDatePicker().setOnAction(this::finishDatePickerHandler);
    module.getDonePercentSlider().setOnMouseReleased(this::donePercentSliderHandler);
    module.getCostField().setOnKeyPressed(this::costFieldHandler);
    module.getDescriptionTextArea().setOnKeyPressed(this::descriptionTextAreaHandler);
    // set listeners to discard changes when field is unfocused
    module.getNameField().focusedProperty().addListener(new WeakInvalidationListener(nameFieldInvalidationListener));
    module.getCostField().focusedProperty().addListener(new WeakInvalidationListener(costFieldInvalidationListener));
    module.getDescriptionTextArea().focusedProperty().addListener(new WeakInvalidationListener(descriptionTextAreaInvalidationListener));
    // set day cells disabled outer valid range
    module.getStartDatePicker().setDayCellFactory(this::makeStartDatePickerCellsDisabled);
    module.getFinishDatePicker().setDayCellFactory(this::makeFinishDatePickerCellsDisabled);
    // set date enabled only by mouse
    module.getStartDatePicker().setEditable(false);
    module.getFinishDatePicker().setEditable(false);
}
 
开发者ID:khasang,项目名称:Cachoeira,代码行数:30,代码来源:TaskInformationModuleController.java

示例15: requestShow

import javafx.beans.value.WeakChangeListener; //导入依赖的package包/类
@EventListener
void requestShow(ShowPdfDescriptorRequest event) {
    if (current != event.getDescriptor()) {
        current = event.getDescriptor();
        current.loadingStatus().addListener(new WeakChangeListener<>(this));
    }
    setFileProperties(current.getFile());
    setPdfProperties();
}
 
开发者ID:torakiki,项目名称:pdfsam,代码行数:10,代码来源:SummaryTab.java


注:本文中的javafx.beans.value.WeakChangeListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。