mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-05-04 11:50:44 +00:00
Rework
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package io.xpipe.app.action;
|
||||
|
||||
import io.xpipe.app.ext.DataStore;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
@@ -21,6 +23,8 @@ public interface QuickConnectProvider extends ActionProvider {
|
||||
|
||||
String getName();
|
||||
|
||||
Optional<DataStoreEntry> findExisting(DataStore store);
|
||||
|
||||
DataStore createStore(String arguments, DataStore existing);
|
||||
|
||||
String getPlaceholder();
|
||||
|
||||
@@ -127,6 +127,8 @@ public class StoreFilterFieldComp extends SimpleRegionBuilder {
|
||||
var fieldComp = RegionBuilder.of(() -> field);
|
||||
var inputGroup = new InputGroupComp(List.of(fieldComp, menuButton));
|
||||
inputGroup.setMainReference(fieldComp);
|
||||
inputGroup.prefHeight(47);
|
||||
inputGroup.minHeight(47);
|
||||
return inputGroup.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +43,6 @@ public class StoreFilterState {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!v.contains(" ")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return QuickConnectProvider.find(v).isPresent();
|
||||
}, rawText);
|
||||
|
||||
@@ -57,10 +53,6 @@ public class StoreFilterState {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!v.contains(" ")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return LauncherUrlProvider.find(v).isPresent();
|
||||
}, rawText);
|
||||
|
||||
@@ -84,10 +76,19 @@ public class StoreFilterState {
|
||||
var type = TypeFactory.defaultInstance().constructType(new TypeReference<List<String>>() {});
|
||||
List<String> recentSearches = AppCache.getNonNull("recentSearches", type, () -> List.of());
|
||||
List<String> recentQuickConnections = AppCache.getNonNull("recentQuickConnections", type, () -> List.of());
|
||||
List<String> recentUrls = AppCache.getNonNull("recentUrls", type, () -> List.of());
|
||||
|
||||
INSTANCE = new StoreFilterState();
|
||||
INSTANCE.recentSearches.setContent(recentSearches);
|
||||
INSTANCE.recentQuickConnections.setContent(recentQuickConnections);
|
||||
INSTANCE.recentUrls.setContent(recentUrls);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
AppCache.update("recentSearches", recentSearches);
|
||||
AppCache.update("recentQuickConnections", recentQuickConnections);
|
||||
AppCache.update("recentUrls", recentUrls);
|
||||
INSTANCE = null;
|
||||
}
|
||||
|
||||
public void set(String s) {
|
||||
@@ -162,7 +163,11 @@ public class StoreFilterState {
|
||||
return false;
|
||||
}
|
||||
|
||||
return StoreQuickConnect.launchQuickConnect(rawText.getValue());
|
||||
var r = StoreQuickConnect.launchQuickConnect(rawText.getValue());
|
||||
if (r) {
|
||||
putQuickConnect(rawText.getValue());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -68,8 +68,20 @@ public class StoreQuickConnect {
|
||||
return false;
|
||||
}
|
||||
|
||||
DataStorage.get().updateEntryStore(quickConnectEntry, newStore);
|
||||
if (newStore.isComplete()) {
|
||||
var existing = provider.get().findExisting(newStore);
|
||||
if (existing.isPresent()) {
|
||||
try {
|
||||
existing.get().getProvider().launch(existing.get()).run();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
ErrorEventFactory.fromThrowable(e).handle();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DataStorage.get().updateEntryStore(quickConnectEntry, newStore);
|
||||
var model = StoreCreationDialog.showEdit(quickConnectEntry, newStore, false, finished -> {
|
||||
update(finished.getStore());
|
||||
ThreadHelper.runAsync(() -> {
|
||||
@@ -85,7 +97,7 @@ public class StoreQuickConnect {
|
||||
});
|
||||
|
||||
var wasCached = AppCache.getNonNull("quickConnect", DataStore.class, () -> null) != null;
|
||||
if (wasCached) {
|
||||
if (newStore.isComplete() && wasCached) {
|
||||
GlobalTimer.delay(() -> {
|
||||
Platform.runLater(() -> {
|
||||
model.finish();
|
||||
|
||||
@@ -256,7 +256,7 @@
|
||||
}
|
||||
|
||||
.store-filter-state-comp .button:disabled {
|
||||
-fx-opacity: 1.0;
|
||||
-fx-opacity: 0.9;
|
||||
}
|
||||
|
||||
.store-filter-state-comp .label {
|
||||
|
||||
Generated
+1
-1
@@ -103,7 +103,7 @@ null=$VALUE$ must be not null
|
||||
roots=Roots
|
||||
scripts=Scripts
|
||||
searchFilter=Search ...
|
||||
storeFilterPrompt=Find a host, tag, or ssh user@host
|
||||
storeFilterPrompt=Search or run ...
|
||||
#context: last used
|
||||
recent=Recent
|
||||
shortcut=Shortcut
|
||||
|
||||
Reference in New Issue
Block a user