mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-10-01 09:40:35 +13:00
Fix connection summary generation for #146
This commit is contained in:
parent
24c5b31a04
commit
e3b451b600
3 changed files with 14 additions and 22 deletions
|
@ -32,7 +32,7 @@ public class DenseStoreEntryComp extends StoreEntryComp {
|
||||||
: Comp.empty();
|
: Comp.empty();
|
||||||
information.setGraphic(state.createRegion());
|
information.setGraphic(state.createRegion());
|
||||||
|
|
||||||
var summary = wrapper.summary();
|
var summary = wrapper.getSummary();
|
||||||
var info = wrapper.getEntry().getProvider().informationString(wrapper);
|
var info = wrapper.getEntry().getProvider().informationString(wrapper);
|
||||||
SimpleChangeListener.apply(grid.hoverProperty(), val -> {
|
SimpleChangeListener.apply(grid.hoverProperty(), val -> {
|
||||||
if (val && summary.getValue() != null && wrapper.getEntry().getProvider().alwaysShowSummary()) {
|
if (val && summary.getValue() != null && wrapper.getEntry().getProvider().alwaysShowSummary()) {
|
||||||
|
|
|
@ -120,7 +120,7 @@ public abstract class StoreEntryComp extends SimpleComp {
|
||||||
|
|
||||||
protected Label createSummary() {
|
protected Label createSummary() {
|
||||||
var summary = new Label();
|
var summary = new Label();
|
||||||
summary.textProperty().bind(wrapper.summary());
|
summary.textProperty().bind(wrapper.getSummary());
|
||||||
summary.getStyleClass().add("summary");
|
summary.getStyleClass().add("summary");
|
||||||
AppFont.small(summary);
|
AppFont.small(summary);
|
||||||
return summary;
|
return summary;
|
||||||
|
|
|
@ -9,9 +9,7 @@ import io.xpipe.app.storage.DataStoreCategory;
|
||||||
import io.xpipe.app.storage.DataStoreColor;
|
import io.xpipe.app.storage.DataStoreColor;
|
||||||
import io.xpipe.app.storage.DataStoreEntry;
|
import io.xpipe.app.storage.DataStoreEntry;
|
||||||
import io.xpipe.app.util.ThreadHelper;
|
import io.xpipe.app.util.ThreadHelper;
|
||||||
import javafx.beans.binding.Bindings;
|
|
||||||
import javafx.beans.property.*;
|
import javafx.beans.property.*;
|
||||||
import javafx.beans.value.ObservableValue;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@ -39,6 +37,7 @@ public class StoreEntryWrapper {
|
||||||
private final MapProperty<String, Object> cache = new SimpleMapProperty<>(FXCollections.observableHashMap());
|
private final MapProperty<String, Object> cache = new SimpleMapProperty<>(FXCollections.observableHashMap());
|
||||||
private final Property<DataStoreColor> color = new SimpleObjectProperty<>();
|
private final Property<DataStoreColor> color = new SimpleObjectProperty<>();
|
||||||
private final Property<StoreCategoryWrapper> category = new SimpleObjectProperty<>();
|
private final Property<StoreCategoryWrapper> category = new SimpleObjectProperty<>();
|
||||||
|
private final Property<String> summary = new SimpleObjectProperty<>();
|
||||||
|
|
||||||
public StoreEntryWrapper(DataStoreEntry entry) {
|
public StoreEntryWrapper(DataStoreEntry entry) {
|
||||||
this.entry = entry;
|
this.entry = entry;
|
||||||
|
@ -84,24 +83,6 @@ public class StoreEntryWrapper {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableValue<String> summary() {
|
|
||||||
return PlatformThread.sync(Bindings.createStringBinding(
|
|
||||||
() -> {
|
|
||||||
if (!validity.getValue().isUsable()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return entry.getProvider().summaryString(this);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ErrorEvent.fromThrowable(ex).handle();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
validity,
|
|
||||||
persistentState));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupListeners() {
|
private void setupListeners() {
|
||||||
name.addListener((c, o, n) -> {
|
name.addListener((c, o, n) -> {
|
||||||
entry.setName(n);
|
entry.setName(n);
|
||||||
|
@ -137,6 +118,17 @@ public class StoreEntryWrapper {
|
||||||
|
|
||||||
category.setValue(StoreViewState.get().getCategoryWrapper(DataStorage.get().getStoreCategoryIfPresent(entry.getCategoryUuid()).orElseThrow()));
|
category.setValue(StoreViewState.get().getCategoryWrapper(DataStorage.get().getStoreCategoryIfPresent(entry.getCategoryUuid()).orElseThrow()));
|
||||||
|
|
||||||
|
if (!entry.getValidity().isUsable()) {
|
||||||
|
summary.setValue(null);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
summary.setValue(entry.getProvider().summaryString(this));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// Summary creation might fail or have a bug
|
||||||
|
ErrorEvent.fromThrowable(ex).handle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
actionProviders.keySet().forEach(dataStoreActionProvider -> {
|
actionProviders.keySet().forEach(dataStoreActionProvider -> {
|
||||||
if (!isInStorage()) {
|
if (!isInStorage()) {
|
||||||
actionProviders.get(dataStoreActionProvider).set(false);
|
actionProviders.get(dataStoreActionProvider).set(false);
|
||||||
|
|
Loading…
Reference in a new issue