Skip to content

Commit

Permalink
Made ObservableEntity version property public. Made context use UUID …
Browse files Browse the repository at this point in the history
…rather than string for identifier.
  • Loading branch information
kec committed Feb 14, 2025
1 parent 18d9fef commit 67f63af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import java.util.concurrent.atomic.AtomicReference;

/**
* TODO: should be a way of listening for changes to the versions of the entity?
* TODO: should be a way of listening for changes to the versions of the entity? Yes, use the versionProperty()...
*
* @param <O>
* @param <V>
Expand Down Expand Up @@ -126,7 +126,7 @@ protected Entity<V> entity() {
return entityReference.get();
}

ObservableList<O> versionProperty() {
public ObservableList<O> versionProperty() {
return versionProperty;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javafx.scene.Node;

import java.util.Optional;
import java.util.UUID;

/**
* The abstract class `ContextBlueprint` serves as a foundational blueprint for implementing specific context
Expand Down Expand Up @@ -68,7 +69,7 @@ public abstract class ContextBlueprint implements KlContext, KlStateCommands {
* It is primarily used for serialization, storage, and referencing purposes
* where the context's unique UUID is required in string format.
*/
private final PreferencePropertyString contextUuidStringProperty;
private final PreferencePropertyObject contextUuidProperty;

final ObservableViewNoOverride observableView;
final PublicIdStringKey publicIdStringKey;
Expand All @@ -79,8 +80,8 @@ protected ContextBlueprint(KlContextProvider contextProvider, ViewCoordinateReco
this.klObject = contextProvider.klObject();
this.viewCoordinateProperty =
PreferencePropertyObject.objectProp(this.klObject, KlContext.PreferenceKeys.VIEW_COORDINATE);
this.contextUuidStringProperty =
PreferencePropertyObject.stringProp(this.klObject, KlContext.PreferenceKeys.CONTEXT_UUID);
this.contextUuidProperty =
PreferencePropertyObject.objectProp(this.klObject, KlContext.PreferenceKeys.CONTEXT_UUID);
this.contextNameProperty =
PreferencePropertyObject.stringProp(this.klObject, KlContext.PreferenceKeys.CONTEXT_NAME);

Expand All @@ -96,11 +97,11 @@ protected ContextBlueprint(KometPreferences preferences, KlContextProvider conte
this.viewCoordinateProperty =
PreferencePropertyObject.objectProp(this.klObject, KlContext.PreferenceKeys.VIEW_COORDINATE);
this.contextNameProperty = PreferencePropertyObject.stringProp(this.klObject, KlContext.PreferenceKeys.CONTEXT_NAME);
this.contextUuidStringProperty = PreferencePropertyObject.stringProp(this.klObject, KlContext.PreferenceKeys.CONTEXT_UUID);
this.contextUuidProperty = PreferencePropertyObject.objectProp(this.klObject, KlContext.PreferenceKeys.CONTEXT_UUID);

String contextName = preferences.get(PreferenceKeys.CONTEXT_NAME, (String) PreferenceKeys.CONTEXT_NAME.defaultValue());
String contextUuidStr = preferences.get(PreferenceKeys.CONTEXT_UUID, (String) PreferenceKeys.CONTEXT_UUID.defaultValue());
this.publicIdStringKey = new PublicIdStringKey(PublicIds.of(contextUuidStr), contextName);
UUID contextUuid = preferences.getUuid(PreferenceKeys.CONTEXT_UUID, (UUID) PreferenceKeys.CONTEXT_UUID.defaultValue());
this.publicIdStringKey = new PublicIdStringKey(PublicIds.of(contextUuid), contextName);
ViewCoordinateRecord viewCoordinateRecord = preferences.getObject(PreferenceKeys.VIEW_COORDINATE, (ViewCoordinateRecord) PreferenceKeys.VIEW_COORDINATE.defaultValue());
this.observableView = new ObservableViewNoOverride(viewCoordinateRecord, contextName);

Expand All @@ -116,8 +117,8 @@ public PreferencePropertyString contextNameProperty() {
return contextNameProperty;
}

public PreferencePropertyString contextUuidStringProperty() {
return contextUuidStringProperty;
public PreferencePropertyObject contextUuidStringProperty() {
return contextUuidProperty;
}

@Override
Expand All @@ -140,7 +141,7 @@ public void save() {
for (KlContext.PreferenceKeys key : KlContext.PreferenceKeys.values()) {
switch (key) {
case CONTEXT_NAME -> klObject.preferences().put(key, this.contextNameProperty.getValue());
case CONTEXT_UUID -> klObject.preferences().put(key, this.contextUuidStringProperty.getValue());
case CONTEXT_UUID -> klObject.preferences().putUuid(key, (UUID) this.contextUuidProperty.getValue());
case VIEW_COORDINATE -> klObject.preferences().putObject(key, viewCoordinateProperty.getValue());
}
}
Expand All @@ -151,7 +152,7 @@ public void revert() {
for (KlContext.PreferenceKeys key : KlContext.PreferenceKeys.values()) {
switch (key) {
case CONTEXT_NAME -> this.contextNameProperty.setValue(klObject.preferences().get(key, (String) key.defaultValue()));
case CONTEXT_UUID -> this.contextUuidStringProperty.setValue(klObject.preferences().get(key, (String) key.defaultValue()));
case CONTEXT_UUID -> this.contextUuidProperty.setValue(klObject.preferences().getUuid(key, (UUID) key.defaultValue()));
case VIEW_COORDINATE -> this.viewCoordinateProperty.setValue(klObject.preferences().getObject(key, (ViewCoordinateRecord) key.defaultValue()));
}
}
Expand Down

0 comments on commit 67f63af

Please sign in to comment.