javafx.beans.value.WeakChangeListener Java Examples

The following examples show how to use javafx.beans.value.WeakChangeListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MarkdownPreviewPane.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public MarkdownPreviewPane() {
	pane.getStyleClass().add("preview-pane");

	previewContext = new PreviewContext() {
		@Override public Renderer getRenderer() { return activeRenderer; }
		@Override public String getMarkdownText() { return markdownText.get(); }
		@Override public Node getMarkdownAST() { return markdownAST.get(); }
		@Override public Path getPath() { return path.get(); }
		@Override public IndexRange getEditorSelection() { return editorSelection.get(); }
	};

	path.addListener((observable, oldValue, newValue) -> update() );
	markdownText.addListener((observable, oldValue, newValue) -> update() );
	markdownAST.addListener((observable, oldValue, newValue) -> update() );
	scrollY.addListener((observable, oldValue, newValue) -> scrollY());
	editorSelection.addListener((observable, oldValue, newValue) -> editorSelectionChanged());

	Options.additionalCSSProperty().addListener(new WeakChangeListener<String>(
		(observable, oldValue, newValue) -> update()));
}
 
Example #2
Source File: PinDecoration.java    From BlockMap with MIT License 5 votes vote down vote up
public PinDecoration(DisplayViewport viewport) {
	this.viewport = Objects.requireNonNull(viewport);
	this.viewport.scaleProperty.addListener(new WeakChangeListener<>(this));

	world = new AnchorPane();
	world.getStylesheets().add("/de/piegames/blockmap/gui/decoration/pins.css");
	{
		Scale s = new Scale();
		s.xProperty().bind(viewport.scaleProperty);
		s.yProperty().bind(viewport.scaleProperty);
		Translate t = new Translate();
		t.xProperty().bind(Bindings.createDoubleBinding(() -> viewport.translationProperty.get().x(), viewport.translationProperty));
		t.yProperty().bind(Bindings.createDoubleBinding(() -> viewport.translationProperty.get().y(), viewport.translationProperty));
		world.getTransforms().add(s);
		world.getTransforms().add(t);
	}
	world.setPickOnBounds(false);
	getChildren().add(world);

	setMinSize(0, 0);
	setPrefSize(0, 0);
	setPickOnBounds(false);

	{
		final Rectangle outputClip = new Rectangle();
		this.setClip(outputClip);

		this.layoutBoundsProperty().addListener((ov, oldValue, newValue) -> {
			outputClip.setWidth(newValue.getWidth());
			outputClip.setHeight(newValue.getHeight());
		});
	}

	visiblePins.addListener((InvalidationListener) e -> executeUpdate.requestExecution());
}
 
Example #3
Source File: TableItemProxy.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
public TableItemProxy(final PVTableItem item)
{
    this.item = new WeakReference<>(item);
    update(item);

    selected.addListener(new WeakChangeListener<>((prop, old, current) ->  item.setSelected(current)));
    use_completion.addListener(new WeakChangeListener<>((prop, old, current) ->  item.setUseCompletion(current)));
}
 
Example #4
Source File: SummaryTab.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventListener
void requestShow(ShowPdfDescriptorRequest event) {
    if (current != event.getDescriptor()) {
        current = event.getDescriptor();
        current.loadingStatus().addListener(new WeakChangeListener<>(this));
    }
    setFileProperties(current.getFile());
    setPdfProperties();
}
 
Example #5
Source File: KeywordsTab.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventListener
void requestShow(ShowPdfDescriptorRequest event) {
    if (current != event.getDescriptor()) {
        current = event.getDescriptor();
        current.loadingStatus().addListener(new WeakChangeListener<>(this));
    }
    keywords.setText(event.getDescriptor().getInformation(PdfMetadataFields.KEYWORDS));
}
 
Example #6
Source File: SingleSelectionPane.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initializeFor(PdfDocumentDescriptor docDescriptor) {
    invalidateDescriptor();
    PdfLoadRequestEvent loadEvent = new PdfLoadRequestEvent(getOwnerModule());
    descriptor = docDescriptor;
    descriptor.loadingStatus().addListener(new WeakChangeListener<>(onLoadingStatusChange));
    setContextMenuDisable(false);
    loadEvent.add(descriptor);
    eventStudio().broadcast(loadEvent);
}