mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-05-03 11:20:34 +00:00
Various small fixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package io.xpipe.app.beacon.impl;
|
||||
|
||||
import io.xpipe.app.core.mode.OperationMode;
|
||||
import io.xpipe.app.core.window.AppMainWindow;
|
||||
import io.xpipe.beacon.api.DaemonFocusExchange;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
@@ -9,7 +10,11 @@ public class DaemonFocusExchangeImpl extends DaemonFocusExchange {
|
||||
|
||||
@Override
|
||||
public Object handle(HttpExchange exchange, Request msg) {
|
||||
OperationMode.switchUp(OperationMode.map(msg.getMode()));
|
||||
OperationMode.switchUp(OperationMode.GUI);
|
||||
var w = AppMainWindow.getInstance();
|
||||
if (w != null) {
|
||||
w.getStage().requestFocus();
|
||||
}
|
||||
return Response.builder().build();
|
||||
}
|
||||
|
||||
|
||||
@@ -183,6 +183,10 @@ public class StoreCreationComp extends DialogComp {
|
||||
}
|
||||
|
||||
public static void showEdit(DataStoreEntry e) {
|
||||
showEdit(e, dataStoreEntry -> {});
|
||||
}
|
||||
|
||||
public static void showEdit(DataStoreEntry e, Consumer<DataStoreEntry> consumer) {
|
||||
show(
|
||||
e.getName(),
|
||||
e.getProvider(),
|
||||
@@ -204,6 +208,7 @@ public class StoreCreationComp extends DialogComp {
|
||||
}
|
||||
}
|
||||
}
|
||||
consumer.accept(e);
|
||||
});
|
||||
},
|
||||
true,
|
||||
|
||||
@@ -125,8 +125,7 @@ public class StoreEntryWrapper {
|
||||
|
||||
public void delete() {
|
||||
ThreadHelper.runAsync(() -> {
|
||||
DataStorage.get().deleteChildren(this.entry);
|
||||
DataStorage.get().deleteStoreEntry(this.entry);
|
||||
DataStorage.get().deleteWithChildren(this.entry);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -56,10 +56,7 @@ public class AppInstance {
|
||||
try {
|
||||
var inputs = AppProperties.get().getArguments().getOpenArgs();
|
||||
// Assume that we want to open the GUI if we launched again
|
||||
client.get()
|
||||
.performRequest(DaemonFocusExchange.Request.builder()
|
||||
.mode(XPipeDaemonMode.GUI)
|
||||
.build());
|
||||
client.get().performRequest(DaemonFocusExchange.Request.builder().build());
|
||||
if (!inputs.isEmpty()) {
|
||||
client.get()
|
||||
.performRequest(DaemonOpenExchange.Request.builder()
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.github.weisj.jsvg.SVGDocument;
|
||||
import com.github.weisj.jsvg.SVGRenderingHints;
|
||||
import com.github.weisj.jsvg.attributes.ViewBox;
|
||||
import com.github.weisj.jsvg.parser.SVGLoader;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -106,6 +107,7 @@ public class SystemIconCache {
|
||||
}
|
||||
|
||||
private static ImageColorScheme rasterizeSizes(Path path, Path dir, String name, boolean dark) throws IOException {
|
||||
TrackEvent.trace("Rasterizing image " + path.getFileName().toString());
|
||||
try {
|
||||
ImageColorScheme c = null;
|
||||
for (var size : sizes) {
|
||||
|
||||
@@ -600,25 +600,6 @@ public abstract class DataStorage {
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteChildren(DataStoreEntry e) {
|
||||
var c = getDeepStoreChildren(e);
|
||||
if (c.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
c.forEach(entry -> entry.finalizeEntry());
|
||||
this.storeEntriesSet.removeAll(c);
|
||||
synchronized (identityStoreEntryMapCache) {
|
||||
identityStoreEntryMapCache.remove(e.getStore());
|
||||
}
|
||||
synchronized (storeEntryMapCache) {
|
||||
storeEntryMapCache.remove(e.getStore());
|
||||
}
|
||||
this.listeners.forEach(l -> l.onStoreRemove(c.toArray(DataStoreEntry[]::new)));
|
||||
refreshEntries();
|
||||
saveAsync();
|
||||
}
|
||||
|
||||
public void deleteWithChildren(DataStoreEntry... entries) {
|
||||
List<DataStoreEntry> toDelete = Arrays.stream(entries)
|
||||
.flatMap(entry -> {
|
||||
|
||||
@@ -8,6 +8,7 @@ import lombok.Value;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
@@ -15,12 +16,14 @@ import java.util.function.Function;
|
||||
@SuppressWarnings("InfiniteLoopStatement")
|
||||
public class BindingsHelper {
|
||||
|
||||
private static final Set<ReferenceEntry> REFERENCES = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
private static final Set<ReferenceEntry> REFERENCES = new HashSet<>();
|
||||
|
||||
static {
|
||||
ThreadHelper.createPlatformThread("referenceGC", true, () -> {
|
||||
while (true) {
|
||||
REFERENCES.removeIf(ReferenceEntry::canGc);
|
||||
synchronized (REFERENCES) {
|
||||
REFERENCES.removeIf(ReferenceEntry::canGc);
|
||||
}
|
||||
ThreadHelper.sleep(1000);
|
||||
|
||||
// Use for testing
|
||||
@@ -31,7 +34,9 @@ public class BindingsHelper {
|
||||
}
|
||||
|
||||
public static void preserve(Object source, Object target) {
|
||||
REFERENCES.add(new ReferenceEntry(new WeakReference<>(source), target));
|
||||
synchronized (REFERENCES) {
|
||||
REFERENCES.add(new ReferenceEntry(new WeakReference<>(source), target));
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, U> ObservableValue<U> map(
|
||||
|
||||
@@ -18,10 +18,7 @@ public class DaemonFocusExchange extends BeaconInterface<DaemonFocusExchange.Req
|
||||
@Jacksonized
|
||||
@Builder
|
||||
@Value
|
||||
public static class Request {
|
||||
@NonNull
|
||||
XPipeDaemonMode mode;
|
||||
}
|
||||
public static class Request {}
|
||||
|
||||
@Jacksonized
|
||||
@Builder
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
package io.xpipe.ext.base.action;
|
||||
|
||||
import io.xpipe.app.core.AppI18n;
|
||||
import io.xpipe.app.ext.ActionProvider;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||
import io.xpipe.app.util.FixedHierarchyStore;
|
||||
import io.xpipe.core.store.DataStore;
|
||||
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
public class DeleteChildrenStoreAction implements ActionProvider {
|
||||
|
||||
@Override
|
||||
public LeafDataStoreCallSite<?> getLeafDataStoreCallSite() {
|
||||
return new LeafDataStoreCallSite<>() {
|
||||
|
||||
@Override
|
||||
public boolean isSystemAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionProvider.Action createAction(DataStoreEntryRef<DataStore> store) {
|
||||
return new Action(store.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<DataStore> getApplicableClass() {
|
||||
return DataStore.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(DataStoreEntryRef<DataStore> o) {
|
||||
return !(o.getStore() instanceof FixedHierarchyStore)
|
||||
&& DataStorage.get().getStoreChildren(o.get()).size() > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObservableValue<String> getName(DataStoreEntryRef<DataStore> store) {
|
||||
return AppI18n.observable("base.deleteChildren");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIcon(DataStoreEntryRef<DataStore> store) {
|
||||
return "mdal-delete_outline";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Value
|
||||
static class Action implements ActionProvider.Action {
|
||||
|
||||
DataStoreEntry store;
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
DataStorage.get().deleteChildren(store);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user