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();
|
||||
information.setGraphic(state.createRegion());
|
||||
|
||||
var summary = wrapper.summary();
|
||||
var summary = wrapper.getSummary();
|
||||
var info = wrapper.getEntry().getProvider().informationString(wrapper);
|
||||
SimpleChangeListener.apply(grid.hoverProperty(), val -> {
|
||||
if (val && summary.getValue() != null && wrapper.getEntry().getProvider().alwaysShowSummary()) {
|
||||
|
|
|
@ -120,7 +120,7 @@ public abstract class StoreEntryComp extends SimpleComp {
|
|||
|
||||
protected Label createSummary() {
|
||||
var summary = new Label();
|
||||
summary.textProperty().bind(wrapper.summary());
|
||||
summary.textProperty().bind(wrapper.getSummary());
|
||||
summary.getStyleClass().add("summary");
|
||||
AppFont.small(summary);
|
||||
return summary;
|
||||
|
|
|
@ -9,9 +9,7 @@ import io.xpipe.app.storage.DataStoreCategory;
|
|||
import io.xpipe.app.storage.DataStoreColor;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.app.util.ThreadHelper;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import lombok.Getter;
|
||||
|
||||
|
@ -39,6 +37,7 @@ public class StoreEntryWrapper {
|
|||
private final MapProperty<String, Object> cache = new SimpleMapProperty<>(FXCollections.observableHashMap());
|
||||
private final Property<DataStoreColor> color = new SimpleObjectProperty<>();
|
||||
private final Property<StoreCategoryWrapper> category = new SimpleObjectProperty<>();
|
||||
private final Property<String> summary = new SimpleObjectProperty<>();
|
||||
|
||||
public StoreEntryWrapper(DataStoreEntry 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() {
|
||||
name.addListener((c, o, n) -> {
|
||||
entry.setName(n);
|
||||
|
@ -137,6 +118,17 @@ public class StoreEntryWrapper {
|
|||
|
||||
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 -> {
|
||||
if (!isInStorage()) {
|
||||
actionProviders.get(dataStoreActionProvider).set(false);
|
||||
|
|
Loading…
Reference in a new issue