Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions connector/src/main/java/devtoolsfx/connector/LocalElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
import devtoolsfx.scenegraph.*;
import devtoolsfx.util.ClassInfoCache;
import devtoolsfx.util.SceneUtils;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import javafx.scene.Node;
import javafx.stage.Window;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* The {@link Element} implementation that directly wraps a link to the scene graph
* node and must not leak the JVM process (e.g. by transferring it via the network).
Expand All @@ -25,6 +26,7 @@ public final class LocalElement implements Element {
private final Vertex vertex;
private final @Nullable NodeProperties nodeProperties;
private final @Nullable WindowProperties windowProperties;
private final Map<Object, Object> properties = new ConcurrentHashMap<>();
private final @Nullable Node node;

private LocalElement(int uid,
Expand Down Expand Up @@ -89,6 +91,11 @@ public boolean hasChildren() {
return windowProperties;
}

@Override
public Map<Object, Object> getProperties() {
return this.properties;
}

@Override
public boolean isWindowElement() {
return windowProperties != null;
Expand Down
13 changes: 12 additions & 1 deletion connector/src/main/java/devtoolsfx/scenegraph/Element.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package devtoolsfx.scenegraph;

import java.util.List;

import java.util.Map;
import javafx.scene.Node;
import javafx.stage.Window;
import org.jspecify.annotations.NullMarked;
Expand Down Expand Up @@ -58,6 +58,17 @@ public interface Element {
@Nullable
WindowProperties getWindowProperties();

/**
* Returns the map of properties associated with this element.
* <p>
* This map can be used to store user-defined data or metadata related to
* the element. The returned map is mutable, and callers may add, modify,
* or remove entries as needed.
*
* @return a mutable map of user-defined properties
*/
Map<Object, Object> getProperties();

/**
* Checks whether the element is a wrapper around {@link Node}.
*/
Expand Down
12 changes: 10 additions & 2 deletions gui/src/main/java/devtoolsfx/gui/util/DummyElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import devtoolsfx.scenegraph.Element;
import devtoolsfx.scenegraph.NodeProperties;
import devtoolsfx.scenegraph.WindowProperties;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

import java.util.List;

/**
* Dummy class to represent the root of a scene graph element tree.
*/
Expand All @@ -17,6 +18,8 @@ public final class DummyElement implements Element {

private final String name;

private final Map<Object, Object> properties = new ConcurrentHashMap<>();

public DummyElement(String name) {
this.name = name;
}
Expand Down Expand Up @@ -61,6 +64,11 @@ public boolean hasChildren() {
return null;
}

@Override
public Map<Object, Object> getProperties() {
return this.properties;
}

@Override
public boolean isWindowElement() {
return false;
Expand Down