mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-23 01:36:33 +00:00
Rework [stage]
This commit is contained in:
@@ -366,8 +366,8 @@ public class AppMainWindow {
|
||||
|
||||
var screens = Screen.getScreens();
|
||||
if (screens.size() > 1) {
|
||||
stage.setWidth(1280);
|
||||
stage.setHeight(780);
|
||||
stage.setWidth(1520);
|
||||
stage.setHeight(860);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class StoreEntryComp extends SimpleRegionBuilder {
|
||||
public static final ObservableDoubleValue INFO_WIDTH = Bindings.createDoubleBinding(
|
||||
() -> {
|
||||
var w = App.getApp().getStage().getWidth();
|
||||
if (w > 1800) {
|
||||
if (w > 1500) {
|
||||
return (w / 1.8) - 100;
|
||||
} else if (w >= 1000) {
|
||||
return (w / 2.0) - 100;
|
||||
|
||||
@@ -89,9 +89,7 @@ public class StoreEntryWrapper {
|
||||
var newCat = StoreViewState.get().getCategoryWrapper(category);
|
||||
|
||||
ThreadHelper.runAsync(() -> {
|
||||
synchronized (this) {
|
||||
DataStorage.get().moveEntryToCategory(entry, category);
|
||||
}
|
||||
DataStorage.get().moveEntryToCategory(entry, category);
|
||||
Platform.runLater(() -> {
|
||||
oldCat.update();
|
||||
newCat.update();
|
||||
@@ -113,9 +111,7 @@ public class StoreEntryWrapper {
|
||||
|
||||
public void delete() {
|
||||
ThreadHelper.runAsync(() -> {
|
||||
synchronized (this) {
|
||||
DataStorage.get().deleteWithChildren(this.entry);
|
||||
}
|
||||
DataStorage.get().deleteWithChildren(this.entry);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -555,18 +555,6 @@ public class StoreViewState {
|
||||
.filter(storeEntryWrapper -> a.contains(storeEntryWrapper.getEntry()))
|
||||
.toList();
|
||||
}
|
||||
List<StoreCategoryWrapper> cats;
|
||||
synchronized (this) {
|
||||
cats = categories.getList().stream()
|
||||
.filter(storeCategoryWrapper -> allEntries.getList().stream()
|
||||
.anyMatch(storeEntryWrapper -> storeEntryWrapper
|
||||
.getEntry()
|
||||
.getCategoryUuid()
|
||||
.equals(storeCategoryWrapper
|
||||
.getCategory()
|
||||
.getUuid())))
|
||||
.toList();
|
||||
}
|
||||
Platform.runLater(() -> {
|
||||
// Don't update anything if we have already reset
|
||||
if (INSTANCE == null) {
|
||||
@@ -576,7 +564,7 @@ public class StoreViewState {
|
||||
synchronized (this) {
|
||||
allEntries.getList().removeAll(l);
|
||||
}
|
||||
cats.forEach(storeCategoryWrapper -> storeCategoryWrapper.update());
|
||||
categories.getList().forEach(storeCategoryWrapper -> storeCategoryWrapper.update());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ public class StoreSectionConfig {
|
||||
StoreCategoryWrapper category;
|
||||
Set<StoreEntryWrapper> selected;
|
||||
StoreSectionDrag dragOperation;
|
||||
Set<StoreEntryWrapper> added;
|
||||
|
||||
public boolean isTop(StoreEntryWrapper wrapper) {
|
||||
if (wrapper.getEntry().getValidity() == DataStoreEntry.Validity.LOAD_FAILED) {
|
||||
@@ -74,11 +75,12 @@ public class StoreSectionConfig {
|
||||
}
|
||||
|
||||
var isBatchSelected = selected.contains(section.getWrapper());
|
||||
var wasAddedAfterFilter = added.contains(section.getWrapper());
|
||||
|
||||
var matchesFilterThis = filter != null && matchesFilter(section, filter);
|
||||
var matchesFilterParents = filter != null && parents.stream().anyMatch(p -> p.matchesFilter(filter));
|
||||
var matchesFilter = filter == null || matchesFilterThis || matchesFilterParents;
|
||||
if (!isBatchSelected && !matchesFilter) {
|
||||
if (!isBatchSelected && !matchesFilter && !wasAddedAfterFilter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -164,6 +166,6 @@ public class StoreSectionConfig {
|
||||
if (parent != null) {
|
||||
l.add(parent);
|
||||
}
|
||||
return new StoreSectionConfig(l, selector, filter, category, selected, dragOperation);
|
||||
return new StoreSectionConfig(l, selector, filter, category, selected, dragOperation, added);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.value.ObservableBooleanValue;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -32,6 +33,7 @@ public class StoreSectionState {
|
||||
private final ObservableList<StoreEntryWrapper> selected;
|
||||
private final ObservableValue<StoreSectionSortMode> sortMode;
|
||||
private final ObservableValue<StoreSectionDrag> dragOperation;
|
||||
private final ObservableList<StoreEntryWrapper> added = FXCollections.observableArrayList();
|
||||
private final IntegerProperty orderUpdateIndex = new SimpleIntegerProperty();
|
||||
private final ObservableBooleanValue enabled;
|
||||
|
||||
@@ -92,7 +94,8 @@ public class StoreSectionState {
|
||||
filter.getValue(),
|
||||
category.getValue(),
|
||||
new HashSet<>(selected),
|
||||
dragOperation.getValue());
|
||||
dragOperation.getValue(),
|
||||
new HashSet<>(added));
|
||||
rootSection.refreshAll(all, config, 0, orderUpdateIndex.get());
|
||||
rootSection.refreshShown(config);
|
||||
rootSection.apply(true);
|
||||
@@ -106,7 +109,8 @@ public class StoreSectionState {
|
||||
filter.getValue(),
|
||||
category.getValue(),
|
||||
new HashSet<>(selected),
|
||||
dragOperation.getValue());
|
||||
dragOperation.getValue(),
|
||||
new HashSet<>(added));
|
||||
rootSection.refreshShown(config);
|
||||
rootSection.apply(alwaysUpdateAll);
|
||||
}
|
||||
@@ -121,6 +125,16 @@ public class StoreSectionState {
|
||||
});
|
||||
|
||||
Listeners.attach(enabled, filter, () -> {
|
||||
added.clear();
|
||||
updateShown(false);
|
||||
});
|
||||
|
||||
Listeners.listen(enabled, StoreViewState.get().getAllEntries().getList(), change -> {
|
||||
while (change.next()) {
|
||||
if (change.wasAdded()) {
|
||||
added.addAll(change.getAddedSubList());
|
||||
}
|
||||
}
|
||||
updateShown(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -98,4 +98,20 @@ public class Listeners {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static <T> void listen(ObservableValue<Boolean> enabled, ObservableList<T> value, Consumer<ListChangeListener.Change<? extends T>> consumer) {
|
||||
var listener = new ListChangeListener<T>() {
|
||||
@Override
|
||||
public void onChanged(Change<? extends T> c) {
|
||||
consumer.accept(c);
|
||||
}
|
||||
};
|
||||
enabled.subscribe(v -> {
|
||||
if (v) {
|
||||
value.addListener(listener);
|
||||
} else {
|
||||
value.removeListener(listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,12 +47,7 @@ public class DevolutionsRdpClient implements ExternalApplicationType.WindowsType
|
||||
@Override
|
||||
public void launch(RdpLaunchConfig configuration) throws Exception {
|
||||
var config = writeRdpConfigFile(configuration.getTitle(), configuration.getConfig());
|
||||
launch(CommandBuilder.of().addFile(config));
|
||||
ThreadHelper.runFailableAsync(() -> {
|
||||
// Startup is slow
|
||||
ThreadHelper.sleep(10000);
|
||||
FileUtils.deleteQuietly(config.toFile());
|
||||
});
|
||||
launch(CommandBuilder.of().addQuoted(config.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -107,7 +107,7 @@ public interface ExternalRdpClient extends PrefsValue {
|
||||
String getWebsite();
|
||||
|
||||
default Path writeRdpConfigFile(String title, RdpConfig input) throws Exception {
|
||||
var name = OsFileSystem.ofLocal().makeFileSystemCompatible(title);
|
||||
var name = OsFileSystem.ofLocal().makeFileSystemCompatible(title).replaceAll("\\s+", "_");
|
||||
var file = AppLocalTemp.getLocalTempDataDirectory("rdp").resolve(name + ".rdp");
|
||||
var string = input.toString() + "\n";
|
||||
Files.createDirectories(file.getParent());
|
||||
|
||||
@@ -917,6 +917,8 @@ public abstract class DataStorage {
|
||||
if (toDelete.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.listeners.forEach(l -> l.onStoreRemove(toDelete.toArray(DataStoreEntry[]::new)));
|
||||
|
||||
for (var td : toDelete) {
|
||||
td.finalizeEntry();
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.process.ShellScript;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.terminal.ExternalTerminalType;
|
||||
import io.xpipe.app.terminal.TerminalLaunch;
|
||||
import io.xpipe.app.update.AppDistributionType;
|
||||
import io.xpipe.app.util.GlobalTimer;
|
||||
@@ -230,10 +231,15 @@ public class WebtopAppListManager {
|
||||
var exec = AppInstallation.ofCurrent().getCliExecutablePath();
|
||||
var endCommand =
|
||||
requiresRestart ? " && " + exec + " daemon stop --wait && " + exec + " open" : ";" + exec + " open";
|
||||
|
||||
var termPref = AppPrefs.get().terminalType().getValue();
|
||||
var term = termPref == null || !termPref.isAvailable() ? ExternalTerminalType.determineFallbackTerminalToOpen(termPref) : null;
|
||||
|
||||
TerminalLaunch.builder()
|
||||
.title("Install packages")
|
||||
.localScript(ShellScript.lines(command, endCommand))
|
||||
.pauseOnExit(true)
|
||||
.terminal(term)
|
||||
.launch();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user